Merge lp:~elopio/ubuntu-ui-toolkit/clean_toggles into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
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
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Chris Gagnon (community) Approve
Zoltan Balogh Approve
Review via email: mp+193374@code.launchpad.net

Commit message

Added the change_state method to the CheckBox autopilot emulator.
Cleaned up the autopilot gallery toggles tests.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:811
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1133/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/240
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/232/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/81
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/81
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/81/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/232
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/240
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/240/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/232
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/232/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2855
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2906/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/757
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/756

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1133/rebuild

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

FAILED: Continuous integration, rev:812
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1136/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/243
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/235/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/84
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/84
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/84/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/233
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/243
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/243/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/235
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/235/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2856
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2907/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/758
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/759

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1136/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) :
review: Approve
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

time_out needs to be tested, timeout is also one word.
for reference see
http://unity.ubuntu.com/autopilot/_modules/autopilot/matchers.html

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:813
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1146/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/288
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/278/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/94
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/94
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/94/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/272
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/288
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/288/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/278
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/278/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2896
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2947/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/838
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/839

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1146/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

LGTM

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

PASSED: Continuous integration, rev:817
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1147/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/292
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/282
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/95
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/95
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/95/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/276
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/292
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/292/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/282
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/282/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2899
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2950
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/844
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/845

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1147/rebuild

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

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-autolanding/416/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/295
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/285/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-autolanding/19
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-autolanding/19
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-autolanding/19/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/278
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/295
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/295/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/285
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/285/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2902/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2953
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/851
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/850

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

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-autolanding/417/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/304
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/293/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-autolanding/20
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-autolanding/20
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-autolanding/20/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/286
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/304
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/304/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/293
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/293/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2909
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2960/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/865
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/864

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
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://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-autolanding/418/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/308
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/297
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-autolanding/21
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-autolanding/21
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-autolanding/21/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/289
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/308
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/308/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/297
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/297/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2912
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2963
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/870
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/871

review: Needs Fixing (continuous-integration)
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 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

Subscribers

People subscribed via source and target branches

to status/vote changes: