Merge lp:~elopio/ubuntu-ui-toolkit/clean_toggles into lp:ubuntu-ui-toolkit
- clean_toggles
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tim Peeters |
Approved revision: | 817 |
Merged at revision: | 818 |
Proposed branch: | lp:~elopio/ubuntu-ui-toolkit/clean_toggles |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
254 lines (+148/-46) 4 files modified
tests/autopilot/ubuntuuitoolkit/emulators.py (+31/-9) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py (+0/-35) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py (+79/-0) tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+38/-2) |
To merge this branch: | bzr merge lp:~elopio/ubuntu-ui-toolkit/clean_toggles |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Chris Gagnon (community) | Approve | ||
Zoltan Balogh | Approve | ||
Review via email:
|
Commit message
Added the change_state method to the CheckBox autopilot emulator.
Cleaned up the autopilot gallery toggles tests.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:812
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Zoltan Balogh (bzoltan) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Gagnon (chris.gagnon) wrote : | # |
time_out needs to be tested, timeout is also one word.
for reference see
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:813
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:817
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
Approved revid is not set in launchpad. This is most likely a launchpad issue and re-approve should fix it. There is also a chance (although a very small one) this is a permission problem of the ps-jenkins bot.
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py' |
2 | --- tests/autopilot/ubuntuuitoolkit/emulators.py 2013-10-28 13:28:01 +0000 |
3 | +++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-11-01 15:20:48 +0000 |
4 | @@ -329,17 +329,39 @@ |
5 | class CheckBox(UbuntuUIToolkitEmulatorBase): |
6 | """CheckBox Autopilot emulator.""" |
7 | |
8 | - def check(self): |
9 | - """Check a CheckBox, if its not already checked.""" |
10 | + def check(self, timeout=10): |
11 | + """Check a CheckBox, if its not already checked. |
12 | + |
13 | + :parameter timeout: number of seconds to wait for the CheckBox to be |
14 | + checked. Default is 10. |
15 | + |
16 | + """ |
17 | if not self.checked: |
18 | - self.pointing_device.click_object(self) |
19 | - self.checked.wait_for(True) |
20 | - |
21 | - def uncheck(self): |
22 | - """Uncheck a CheckBox, if its not already unchecked.""" |
23 | + self.change_state(timeout) |
24 | + |
25 | + def uncheck(self, timeout=10): |
26 | + """Uncheck a CheckBox, if its not already unchecked. |
27 | + |
28 | + :parameter timeout: number of seconds to wait for the CheckBox to be |
29 | + unchecked. Default is 10. |
30 | + |
31 | + """ |
32 | if self.checked: |
33 | - self.pointing_device.click_object(self) |
34 | - self.checked.wait_for(False) |
35 | + self.change_state(timeout) |
36 | + |
37 | + def change_state(self, timeout=10): |
38 | + """Change the state of a CheckBox. |
39 | + |
40 | + If it is checked, it will be unchecked. If it is unchecked, it will be |
41 | + checked. |
42 | + |
43 | + :parameter time_out: number of seconds to wait for the CheckBox state |
44 | + to change. Default is 10. |
45 | + |
46 | + """ |
47 | + original_state = self.checked |
48 | + self.pointing_device.click_object(self) |
49 | + self.checked.wait_for(not original_state, timeout) |
50 | |
51 | |
52 | class Empty(UbuntuUIToolkitEmulatorBase): |
53 | |
54 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py' |
55 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2013-10-07 13:11:40 +0000 |
56 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2013-11-01 15:20:48 +0000 |
57 | @@ -37,41 +37,6 @@ |
58 | self.loadItem(item) |
59 | self.checkPageHeader(item) |
60 | |
61 | - def test_toggles(self): |
62 | - item = "Toggles" |
63 | - self.checkListItem(item) |
64 | - self.loadItem(item) |
65 | - self.checkPageHeader(item) |
66 | - |
67 | - # check default states |
68 | - item_data = [ |
69 | - ["checkbox_unchecked", False, True], |
70 | - ["checkbox_checked", True, True], |
71 | - ["checkbox_disabled_unchecked", False, False], |
72 | - ["checkbox_disabled_checked", True, False], |
73 | - ["switch_unchecked", False, True], |
74 | - ["switch_checked", True, True], |
75 | - ["switch_disabled_unchecked", False, False], |
76 | - ["switch_disabled_checked", True, False] |
77 | - ] |
78 | - |
79 | - for data in item_data: |
80 | - objName = data[0] |
81 | - objChecked = data[1] |
82 | - objEnabled = data[2] |
83 | - |
84 | - obj = self.getObject(objName) |
85 | - self.assertThat(obj.checked, Equals(objChecked)) |
86 | - self.assertThat(obj.enabled, Equals(objEnabled)) |
87 | - |
88 | - # try to interact with objects |
89 | - self.tap(objName) |
90 | - |
91 | - if (obj.enabled): |
92 | - self.assertThat(obj.checked, Not(Equals(objChecked))) |
93 | - else: |
94 | - self.assertThat(obj.checked, Equals(objChecked)) |
95 | - |
96 | def test_slider(self): |
97 | item = "Slider" |
98 | self.loadItem(item) |
99 | |
100 | === added file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py' |
101 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 1970-01-01 00:00:00 +0000 |
102 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2013-11-01 15:20:48 +0000 |
103 | @@ -0,0 +1,79 @@ |
104 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
105 | +# |
106 | +# Copyright (C) 2012, 2013 Canonical Ltd. |
107 | +# |
108 | +# This program is free software; you can redistribute it and/or modify |
109 | +# it under the terms of the GNU Lesser General Public License as published by |
110 | +# the Free Software Foundation; version 3. |
111 | +# |
112 | +# This program is distributed in the hope that it will be useful, |
113 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
114 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
115 | +# GNU Lesser General Public License for more details. |
116 | +# |
117 | +# You should have received a copy of the GNU Lesser General Public License |
118 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
119 | + |
120 | +from ubuntuuitoolkit import emulators |
121 | +from ubuntuuitoolkit.tests import gallery |
122 | + |
123 | +from testtools.matchers import Equals |
124 | + |
125 | + |
126 | +class EnabledTogglesTestCase(gallery.GalleryTestCase): |
127 | + |
128 | + scenarios = [ |
129 | + ('checkbox unchecked', dict( |
130 | + object_name='checkbox_unchecked', initial_state=False)), |
131 | + ('checkbox checked', dict( |
132 | + object_name='checkbox_checked', initial_state=True)), |
133 | + ('switch unchecked', dict( |
134 | + object_name='switch_unchecked', initial_state=False)), |
135 | + ('switch checked', dict( |
136 | + object_name='switch_checked', initial_state=True)) |
137 | + ] |
138 | + |
139 | + def setUp(self): |
140 | + super(EnabledTogglesTestCase, self).setUp() |
141 | + item = "Toggles" |
142 | + self.checkListItem(item) |
143 | + self.loadItem(item) |
144 | + self.checkPageHeader(item) |
145 | + |
146 | + def test_change_toggles_state(self): |
147 | + toggle = self.main_view.select_single( |
148 | + emulators.CheckBox, objectName=self.object_name) |
149 | + self.assertThat(toggle.enabled, Equals(True)) |
150 | + self.assertThat(toggle.checked, Equals(self.initial_state)) |
151 | + |
152 | + toggle.change_state(timeout=1) |
153 | + self.assertThat(toggle.checked, Equals(not self.initial_state)) |
154 | + |
155 | + |
156 | +class DisabledTogglesTestCase(gallery.GalleryTestCase): |
157 | + |
158 | + scenarios = [ |
159 | + ('checkbox disabled unchecked', dict( |
160 | + object_name='checkbox_disabled_unchecked', initial_state=False)), |
161 | + ('checkbox disabled checked', dict( |
162 | + object_name='checkbox_disabled_checked', initial_state=True)), |
163 | + ('switch disabled unchecked', dict( |
164 | + object_name='switch_disabled_unchecked', initial_state=False)), |
165 | + ('switch disabled checked', dict( |
166 | + object_name='switch_disabled_checked', initial_state=True)) |
167 | + ] |
168 | + |
169 | + def setUp(self): |
170 | + super(DisabledTogglesTestCase, self).setUp() |
171 | + item = "Toggles" |
172 | + self.checkListItem(item) |
173 | + self.loadItem(item) |
174 | + self.checkPageHeader(item) |
175 | + |
176 | + def test_change_toggles_state(self): |
177 | + toggle = self.main_view.select_single( |
178 | + emulators.CheckBox, objectName=self.object_name) |
179 | + self.assertThat(toggle.enabled, Equals(False)) |
180 | + self.assertThat(toggle.checked, Equals(self.initial_state)) |
181 | + |
182 | + self.assertRaises(AssertionError, toggle.change_state, timeout=1) |
183 | |
184 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py' |
185 | --- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-10-28 13:28:01 +0000 |
186 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-11-01 15:20:48 +0000 |
187 | @@ -14,10 +14,12 @@ |
188 | # You should have received a copy of the GNU Lesser General Public License |
189 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
190 | |
191 | +import mock |
192 | +import time |
193 | import unittest |
194 | |
195 | -import mock |
196 | from autopilot import input, platform |
197 | +from testtools.matchers import GreaterThan, LessThan |
198 | |
199 | from ubuntuuitoolkit import emulators, tests |
200 | |
201 | @@ -432,12 +434,12 @@ |
202 | super(ToggleTestCase, self).setUp() |
203 | self.toggle = self.main_view.select_single( |
204 | emulators.CheckBox, objectName=self.objectName) |
205 | + self.assertFalse(self.toggle.checked) |
206 | |
207 | def test_toggle_emulator(self): |
208 | self.assertIsInstance(self.toggle, emulators.CheckBox) |
209 | |
210 | def test_check_toggle(self): |
211 | - self.assertFalse(self.toggle.checked) |
212 | self.toggle.check() |
213 | self.assertTrue(self.toggle.checked) |
214 | |
215 | @@ -457,6 +459,40 @@ |
216 | self.toggle.uncheck() |
217 | self.assertFalse(mock_click.called) |
218 | |
219 | + def test_change_state_from_checked(self): |
220 | + self.toggle.check() |
221 | + self.toggle.change_state() |
222 | + self.assertFalse(self.toggle.checked) |
223 | + |
224 | + def test_change_state_from_unchecked(self): |
225 | + self.toggle.change_state() |
226 | + self.assertTrue(self.toggle.checked) |
227 | + |
228 | + def test_check_with_timeout(self): |
229 | + with mock.patch.object( |
230 | + emulators.CheckBox, 'change_state') as mock_change: |
231 | + self.toggle.check(timeout=1) |
232 | + |
233 | + mock_change.assert_called_once_with(1) |
234 | + |
235 | + def test_uncheck_with_timeout(self): |
236 | + self.toggle.check() |
237 | + with mock.patch.object( |
238 | + emulators.CheckBox, 'change_state') as mock_change: |
239 | + self.toggle.uncheck(timeout=1) |
240 | + |
241 | + mock_change.assert_called_once_with(1) |
242 | + |
243 | + def test_change_state_with_timeout(self): |
244 | + with mock.patch.object(self.toggle, 'pointing_device'): |
245 | + # mock the pointing device so the checkbox is not clicked. |
246 | + timestamp_before_call = time.time() |
247 | + self.assertRaises(AssertionError, self.toggle.change_state, 1) |
248 | + |
249 | + waiting_time = time.time() - timestamp_before_call |
250 | + self.assertThat(waiting_time, GreaterThan(1)) |
251 | + self.assertThat(waiting_time, LessThan(2)) |
252 | + |
253 | |
254 | class SwipeToDeleteTestCase(tests.QMLStringAppTestCase): |
255 |
FAILED: Continuous integration, rev:811 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/1133/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 240 jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/232/ console jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- amd64-ci/ 81 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 81 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 81/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-trusty/ 232 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/240 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/240/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/232 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/232/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- maguro/ 2855 jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/2906/ console 10.97.0. 26:8080/ job/touch- flash-device/ 757 10.97.0. 26:8080/ job/touch- flash-device/ 756
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/ubuntu- ui-toolkit- ci/1133/ rebuild
http://