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
1=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
2--- tests/autopilot/ubuntuuitoolkit/emulators.py 2014-01-13 23:38:20 +0000
3+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2014-02-04 17:25:32 +0000
4@@ -472,6 +472,7 @@
5
6 """
7 with self.keyboard.focused_type(self):
8+ self.focus.wait_for(True)
9 if clear:
10 self.clear()
11 else:
12
13=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py'
14--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2013-12-12 09:56:16 +0000
15+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-02-04 17:25:32 +0000
16@@ -1,6 +1,6 @@
17 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
18 #
19-# Copyright (C) 2012, 2013 Canonical Ltd.
20+# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
21 #
22 # This program is free software; you can redistribute it and/or modify
23 # it under the terms of the GNU Lesser General Public License as published by
24@@ -16,59 +16,59 @@
25
26 """Tests for the Ubuntu UI Toolkit Gallery - TextInput components"""
27
28-from autopilot.matchers import Eventually
29-from testtools.matchers import Equals
30+from ubuntuuitoolkit import emulators
31 from ubuntuuitoolkit.tests.gallery import GalleryTestCase
32
33
34-class TextInputTests(GalleryTestCase):
35- """Generic tests for the Gallery"""
36-
37- def test_textfield_standard(self):
38- item = "Text Field"
39- self.loadItem(item)
40- self.checkPageHeader(item)
41- textfield_standard = self.getObject('textfield_standard')
42- self.pointing_device.click_object(textfield_standard)
43- self.assertThat(textfield_standard.focus, Eventually(Equals(True)))
44- self.type_string('Hello World')
45- self.assertThat(textfield_standard.text,
46- Eventually(Equals('Hello World')))
47-
48- def test_textfield_password(self):
49- item = "Text Field"
50- self.loadItem(item)
51- self.checkPageHeader(item)
52- textfield_password = self.getObject('textfield_password')
53- self.pointing_device.click_object(textfield_password)
54- self.assertThat(textfield_password.text, Equals('password'))
55-
56- self.tap_clearButton('textfield_password')
57- self.assertThat(textfield_password.text, Eventually(Equals('')))
58-
59- self.type_string('abcdefgh123')
60- self.assertThat(textfield_password.text,
61- Eventually(Equals('abcdefgh123')))
62-
63- def test_textfield_numbers(self):
64- item = "Text Field"
65- self.loadItem(item)
66- self.checkPageHeader(item)
67- textfield_numbers = self.getObject('textfield_numbers')
68- self.assertThat(textfield_numbers.text, Eventually(Equals('123')))
69-
70- self.tap_clearButton('textfield_numbers')
71- self.assertThat(textfield_numbers.text, Eventually(Equals('')))
72- #try typing decimal value when text filed is int only.
73- self.type_string('-100.123')
74- self.assertThat(textfield_numbers.text, Eventually(Equals('-100123')))
75+class WriteAndClearTextInputTestCase(GalleryTestCase):
76+
77+ scenarios = [
78+ ('standard textfield', dict(
79+ objectName='textfield_standard', text_to_write='Hello World',
80+ expected_text='Hello World')),
81+ ('password textfield', dict(
82+ objectName='textfield_password', text_to_write='Test password',
83+ expected_text='Test password')),
84+ ('only integers textfield', dict(
85+ objectName='textfield_numbers', text_to_write='-100.123',
86+ expected_text='-100123'))
87+ ]
88+
89+ def setUp(self):
90+ super(WriteAndClearTextInputTestCase, self).setUp()
91+ item = 'Text Field'
92+ self.loadItem(item)
93+ self.checkPageHeader(item)
94+
95+ def test_write_on_textfield_must_update_text(self):
96+ textfield = self.main_view.select_single(
97+ emulators.TextField, objectName=self.objectName)
98+
99+ textfield.write(self.text_to_write)
100+ self.assertEqual(self.expected_text, textfield.text)
101+
102+ def test_clear_textfield_must_remove_text(self):
103+ textfield = self.main_view.select_single(
104+ emulators.TextField, objectName=self.objectName)
105+ textfield.write(self.text_to_write)
106+
107+ textfield.clear()
108+ self.assertEqual('', textfield.text)
109+
110+
111+class DisabledTextInputTestCase(GalleryTestCase):
112+
113+ def setUp(self):
114+ super(DisabledTextInputTestCase, self).setUp()
115+ item = 'Text Field'
116+ self.loadItem(item)
117+ self.checkPageHeader(item)
118
119 def test_textfield_disabled(self):
120- item = "Text Field"
121- self.loadItem(item)
122- self.checkPageHeader(item)
123- textfield_disabled = self.getObject('textfield_disabled')
124+ textfield_disabled = self.main_view.select_single(
125+ emulators.TextField, objectName='textfield_disabled')
126 self.assertFalse(textfield_disabled.enabled)
127- #try tapping a disabled field and verify that focus is false.
128+
129 self.pointing_device.click_object(textfield_disabled)
130- self.assertFalse(textfield_disabled.focus)
131+ textfield_disabled.keyboard.type('This should not be writen')
132+ self.assertEqual('', textfield_disabled.text)
133
134=== modified file 'tests/unit_x11/tst_components/tst_textfield.qml'
135--- tests/unit_x11/tst_components/tst_textfield.qml 2013-10-22 17:15:24 +0000
136+++ tests/unit_x11/tst_components/tst_textfield.qml 2014-02-04 17:25:32 +0000
137@@ -64,6 +64,16 @@
138 }
139 }
140
141+ TextField {
142+ id: enabledTextField
143+ enabled: true
144+ }
145+
146+ TextField {
147+ id: disabledTextField
148+ enabled: false
149+ }
150+
151 TestCase {
152 name: "TextFieldAPI"
153 when: windowShown
154@@ -451,5 +461,25 @@
155 id: regExpValidator
156 regExp: /[a-z]*/
157 }
158+
159+ function test_click_enabled_textfield_must_give_focus() {
160+ textField.forceActiveFocus();
161+ compare(
162+ enabledTextField.focus, false,
163+ 'enabledTextField is not focused');
164+ mouseClick(
165+ enabledTextField, enabledTextField.width/2,
166+ enabledTextField.height/2)
167+ compare(
168+ enabledTextField.focus, true, 'enabledTextField is focused')
169+ }
170+
171+ function test_click_disabled_textfield_must_not_give_focus() {
172+ mouseClick(
173+ disabledTextField, disabledTextField.width/2,
174+ disabledTextField.height/2)
175+ compare(
176+ textField.focus, false, 'disabledTextField is not focused');
177+ }
178 }
179 }

Subscribers

People subscribed via source and target branches

to status/vote changes: