Merge lp:~elopio/ubuntu-ui-toolkit/fix1274240-gallery-textfield_helper into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Merged
Approved by: Cris Dywan
Approved revision: 936
Merged at revision: 932
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/fix1274240-gallery-textfield_helper
Merge into: lp:ubuntu-ui-toolkit
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/dateUtilsTestFix
Diff against target: 179 lines (+81/-50)
3 files modified
tests/autopilot/ubuntuuitoolkit/emulators.py (+1/-0)
tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py (+50/-50)
tests/unit_x11/tst_components/tst_textfield.qml (+30/-0)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/fix1274240-gallery-textfield_helper
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Richard Huddie Pending
Javier Collado Pending
VĂ­ctor R. Ruiz Pending
Review via email: mp+203831@code.launchpad.net

This proposal supersedes a proposal from 2014-01-29.

Commit message

Use the autopilot text field helper in the gallery test cases

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :
Revision history for this message
Leo Arias (elopio) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

This fails on mako in ERROR: ubuntuuitoolkit.tests.test_emulators.TextFieldTestCase.test_write_without_clear

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

So why doesn't write work here? Is that a bug?

review: Needs Information
Revision history for this message
Leo Arias (elopio) wrote :

Because I added a focus.wait_for(True) on the write method, so it will only work on enabled textfields.
I thought that's ok, as we should never write on disabled textfields, and if we do it should fail anyway.

So, for this test on the disabled text field, we need to go one level lower than write, and call type so we avoid the focus.wait_for(True)

Let me know what you think about it.
Thanks for reviewing.

Revision history for this message
Cris Dywan (kalikiana) wrote :

It wasn't clear from the code, but the reasoning is sound.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Thanks for the review!
All tests failed again in jenkins, I wonder what's going on there. Still, not related to this branch.

Now, after this branch lands, please let me know if you see any text fields misbehaving. The logs should provide more useful information and clues to what we can try next.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
--- tests/autopilot/ubuntuuitoolkit/emulators.py 2014-01-13 23:38:20 +0000
+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2014-02-04 17:25:32 +0000
@@ -472,6 +472,7 @@
472472
473 """473 """
474 with self.keyboard.focused_type(self):474 with self.keyboard.focused_type(self):
475 self.focus.wait_for(True)
475 if clear:476 if clear:
476 self.clear()477 self.clear()
477 else:478 else:
478479
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py'
--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2013-12-12 09:56:16 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-02-04 17:25:32 +0000
@@ -1,6 +1,6 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#2#
3# Copyright (C) 2012, 2013 Canonical Ltd.3# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
4#4#
5# This program is free software; you can redistribute it and/or modify5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by6# it under the terms of the GNU Lesser General Public License as published by
@@ -16,59 +16,59 @@
1616
17"""Tests for the Ubuntu UI Toolkit Gallery - TextInput components"""17"""Tests for the Ubuntu UI Toolkit Gallery - TextInput components"""
1818
19from autopilot.matchers import Eventually19from ubuntuuitoolkit import emulators
20from testtools.matchers import Equals
21from ubuntuuitoolkit.tests.gallery import GalleryTestCase20from ubuntuuitoolkit.tests.gallery import GalleryTestCase
2221
2322
24class TextInputTests(GalleryTestCase):23class WriteAndClearTextInputTestCase(GalleryTestCase):
25 """Generic tests for the Gallery"""24
2625 scenarios = [
27 def test_textfield_standard(self):26 ('standard textfield', dict(
28 item = "Text Field"27 objectName='textfield_standard', text_to_write='Hello World',
29 self.loadItem(item)28 expected_text='Hello World')),
30 self.checkPageHeader(item)29 ('password textfield', dict(
31 textfield_standard = self.getObject('textfield_standard')30 objectName='textfield_password', text_to_write='Test password',
32 self.pointing_device.click_object(textfield_standard)31 expected_text='Test password')),
33 self.assertThat(textfield_standard.focus, Eventually(Equals(True)))32 ('only integers textfield', dict(
34 self.type_string('Hello World')33 objectName='textfield_numbers', text_to_write='-100.123',
35 self.assertThat(textfield_standard.text,34 expected_text='-100123'))
36 Eventually(Equals('Hello World')))35 ]
3736
38 def test_textfield_password(self):37 def setUp(self):
39 item = "Text Field"38 super(WriteAndClearTextInputTestCase, self).setUp()
40 self.loadItem(item)39 item = 'Text Field'
41 self.checkPageHeader(item)40 self.loadItem(item)
42 textfield_password = self.getObject('textfield_password')41 self.checkPageHeader(item)
43 self.pointing_device.click_object(textfield_password)42
44 self.assertThat(textfield_password.text, Equals('password'))43 def test_write_on_textfield_must_update_text(self):
4544 textfield = self.main_view.select_single(
46 self.tap_clearButton('textfield_password')45 emulators.TextField, objectName=self.objectName)
47 self.assertThat(textfield_password.text, Eventually(Equals('')))46
4847 textfield.write(self.text_to_write)
49 self.type_string('abcdefgh123')48 self.assertEqual(self.expected_text, textfield.text)
50 self.assertThat(textfield_password.text,49
51 Eventually(Equals('abcdefgh123')))50 def test_clear_textfield_must_remove_text(self):
5251 textfield = self.main_view.select_single(
53 def test_textfield_numbers(self):52 emulators.TextField, objectName=self.objectName)
54 item = "Text Field"53 textfield.write(self.text_to_write)
55 self.loadItem(item)54
56 self.checkPageHeader(item)55 textfield.clear()
57 textfield_numbers = self.getObject('textfield_numbers')56 self.assertEqual('', textfield.text)
58 self.assertThat(textfield_numbers.text, Eventually(Equals('123')))57
5958
60 self.tap_clearButton('textfield_numbers')59class DisabledTextInputTestCase(GalleryTestCase):
61 self.assertThat(textfield_numbers.text, Eventually(Equals('')))60
62 #try typing decimal value when text filed is int only.61 def setUp(self):
63 self.type_string('-100.123')62 super(DisabledTextInputTestCase, self).setUp()
64 self.assertThat(textfield_numbers.text, Eventually(Equals('-100123')))63 item = 'Text Field'
64 self.loadItem(item)
65 self.checkPageHeader(item)
6566
66 def test_textfield_disabled(self):67 def test_textfield_disabled(self):
67 item = "Text Field"68 textfield_disabled = self.main_view.select_single(
68 self.loadItem(item)69 emulators.TextField, objectName='textfield_disabled')
69 self.checkPageHeader(item)
70 textfield_disabled = self.getObject('textfield_disabled')
71 self.assertFalse(textfield_disabled.enabled)70 self.assertFalse(textfield_disabled.enabled)
72 #try tapping a disabled field and verify that focus is false.71
73 self.pointing_device.click_object(textfield_disabled)72 self.pointing_device.click_object(textfield_disabled)
74 self.assertFalse(textfield_disabled.focus)73 textfield_disabled.keyboard.type('This should not be writen')
74 self.assertEqual('', textfield_disabled.text)
7575
=== modified file 'tests/unit_x11/tst_components/tst_textfield.qml'
--- tests/unit_x11/tst_components/tst_textfield.qml 2013-10-22 17:15:24 +0000
+++ tests/unit_x11/tst_components/tst_textfield.qml 2014-02-04 17:25:32 +0000
@@ -64,6 +64,16 @@
64 }64 }
65 }65 }
6666
67 TextField {
68 id: enabledTextField
69 enabled: true
70 }
71
72 TextField {
73 id: disabledTextField
74 enabled: false
75 }
76
67 TestCase {77 TestCase {
68 name: "TextFieldAPI"78 name: "TextFieldAPI"
69 when: windowShown79 when: windowShown
@@ -451,5 +461,25 @@
451 id: regExpValidator461 id: regExpValidator
452 regExp: /[a-z]*/462 regExp: /[a-z]*/
453 }463 }
464
465 function test_click_enabled_textfield_must_give_focus() {
466 textField.forceActiveFocus();
467 compare(
468 enabledTextField.focus, false,
469 'enabledTextField is not focused');
470 mouseClick(
471 enabledTextField, enabledTextField.width/2,
472 enabledTextField.height/2)
473 compare(
474 enabledTextField.focus, true, 'enabledTextField is focused')
475 }
476
477 function test_click_disabled_textfield_must_not_give_focus() {
478 mouseClick(
479 disabledTextField, disabledTextField.width/2,
480 disabledTextField.height/2)
481 compare(
482 textField.focus, false, 'disabledTextField is not focused');
483 }
454 }484 }
455}485}

Subscribers

People subscribed via source and target branches

to status/vote changes: