Merge lp:~nskaggs/ubuntu-clock-app/convert-aptests-to-sdk into lp:ubuntu-clock-app/saucy

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 172
Merged at revision: 166
Proposed branch: lp:~nskaggs/ubuntu-clock-app/convert-aptests-to-sdk
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 600 lines (+159/-250)
8 files modified
debian/control (+2/-1)
tests/autopilot/ubuntu_clock_app/emulators.py (+100/-0)
tests/autopilot/ubuntu_clock_app/emulators/__init__.py (+0/-17)
tests/autopilot/ubuntu_clock_app/emulators/main_window.py (+0/-112)
tests/autopilot/ubuntu_clock_app/tests/__init__.py (+11/-58)
tests/autopilot/ubuntu_clock_app/tests/test_clock.py (+2/-2)
tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py (+14/-14)
tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+30/-46)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-clock-app/convert-aptests-to-sdk
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nekhelesh Ramananthan Approve
Leo Arias (community) code review Approve
Review via email: mp+179062@code.launchpad.net

Commit message

This converts the clock testcase to the sdk emulator, and cleans up the functions. It should be much more robust now.

Atm, depends on https://code.launchpad.net/~elopio/ubuntu-ui-toolkit/fix1209405-header_object_name/+merge/179060.

Description of the change

This converts the clock testcase to the sdk emulator, and cleans up the functions. It should be much more robust now.

Atm, depends on https://code.launchpad.net/~elopio/ubuntu-ui-toolkit/fix1209405-header_object_name/+merge/179060.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) :
review: Approve (code review)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

After adding the ubuntu-ui-toolkit-autopilot package as dependency, the test pass successfully for me. Triggering a jenkins rebuild to see if it can merge it.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
172. By Nicholas Skaggs

d'oh! fix the init launch to launch clock not dropping letters ;-(

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-05-27 07:43:41 +0000
3+++ debian/control 2013-08-12 17:47:04 +0000
4@@ -16,7 +16,7 @@
5 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
6 qtdeclarative5-localstorage-plugin,
7 qtdeclarative5-qtquick2-plugin,
8- qtdeclarative5-xmllistmodel-plugin,
9+ qtdeclarative5-xmllistmodel-plugin,
10 Description: Clock application
11 Ubuntu Core Clock application which provides Stopwatch, Timer, Alarm and Clock functionalities.
12
13@@ -24,6 +24,7 @@
14 Architecture: all
15 Depends: libautopilot-qt,
16 libqt5test5,
17+ ubuntu-ui-toolkit-autopilot,
18 ubuntu-clock-app (= ${source:Version}),
19 Description: Autopilot tests for Ubuntu Clock Application
20 This package contains autopilot tests for the Ubuntu Clock application.
21
22=== removed directory 'tests/autopilot/ubuntu_clock_app/emulators'
23=== added file 'tests/autopilot/ubuntu_clock_app/emulators.py'
24--- tests/autopilot/ubuntu_clock_app/emulators.py 1970-01-01 00:00:00 +0000
25+++ tests/autopilot/ubuntu_clock_app/emulators.py 2013-08-12 17:47:04 +0000
26@@ -0,0 +1,100 @@
27+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
28+#
29+# Copyright (C) 2013 Canonical Ltd.
30+#
31+# This program is free software; you can redistribute it and/or modify
32+# it under the terms of the GNU Lesser General Public License as published by
33+# the Free Software Foundation; version 3.
34+#
35+# This program is distributed in the hope that it will be useful,
36+# but WITHOUT ANY WARRANTY; without even the implied warranty of
37+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38+# GNU Lesser General Public License for more details.
39+#
40+# You should have received a copy of the GNU Lesser General Public License
41+# along with this program. If not, see <http://www.gnu.org/licenses/>.
42+
43+from ubuntuuitoolkit import emulators as toolkit_emulators
44+
45+
46+class MainView(toolkit_emulators.MainView):
47+ def get_stopwatch_tab_button(self):
48+ """Returns the stopwatch tab."""
49+ return self.select_single("AbstractButton", buttonIndex=3)
50+
51+ def get_stopwatch_label(self):
52+ """Returns the select for the stopwatch label"""
53+ return self.select_single("Label", objectName="labelStopwatch")
54+
55+ def get_stopwatch_button(self):
56+ """Returns the select for the stopwatch button"""
57+ return self.select_single("AnalogStopwatch", objectName="buttonStopwatch")
58+
59+ def get_lap_button(self):
60+ """Returns the select for the lap button"""
61+ return self.select_single("Button", objectName="lapButton")
62+
63+ def get_reset_button(self):
64+ """Returns the select for the reset button"""
65+ return self.select_single("ImageButton", objectName="resetButton")
66+
67+ def get_laps(self):
68+ """Returns the select for the lap count"""
69+ return self.select_single("ListModel", objectName="laps")
70+
71+ def get_timer_tab_button(self):
72+ """Returns the timer tab."""
73+ return self.select_single("AbstractButton", buttonIndex=2)
74+
75+ def get_toolbar_timer(self):
76+ """Returns the toolbar of timer tab"""
77+ return self.select_single("ToolbarItems")
78+
79+ def get_toolbar_timer_button(self, button_idx):
80+ """Returns a button of toolbar of timer tab"""
81+ toolbar = self.select_single("ToolbarItems")
82+ button = toolbar.get_children()
83+ return button[button_idx]
84+
85+ def get_toolbar_timer_add_preset_button(self):
86+ """Returns the button for add preset of toolbar of timer tab"""
87+ return self.get_toolbar_timer_button(1)
88+
89+ def get_timer_name_preset(self):
90+ """Returns the TextField where insert the name of the preset"""
91+ return self.select_single("TextField", objectName="namePreset")
92+
93+ def get_timer_hour_hand(self):
94+ """Returns the hour hand of clock in timer tab"""
95+ return self.select_single("AnalogTouchHand", objectName="hourHand")
96+
97+ def get_timer_clock_center_label(self):
98+ """Returns the label in the center of clock"""
99+ return self.select_single("Label", objectName="addPresetTextDone")
100+
101+ def get_preset_label_text(self):
102+ """Returns the label with the preset text"""
103+ preset = self.select_many("Label", objectName="presetTextLabel")
104+ return preset[0] #last preset, the one created by autopilot
105+
106+ def get_preset_label_timer(self):
107+ """Returns the label with the preset timer"""
108+ preset = self.select_many("Label", objectName="presetTimerLabel")
109+ return preset[0] #last preset, the one created by autopilot
110+
111+ def get_label_timer(self):
112+ """Return the label with the timer countdown"""
113+ return self.select_single("Label", objectName="labelTimer")
114+
115+ def get_num_of_presets(self):
116+ """Returns the number of presets in the timer page."""
117+ timer_page = self.select_single("TimerPage")
118+ return int(timer_page.select_single("QQuickListView").count)
119+
120+ def get_first_preset_list_item(self):
121+ """Returns the first preset list item in the timer page."""
122+ return self.select_single("Standard", objectName="preset0")
123+
124+ def get_time_label(self):
125+ """Return the label with the timer countdown"""
126+ return self.select_single("Label", objectName="currentTimeLabel")
127
128=== removed file 'tests/autopilot/ubuntu_clock_app/emulators/__init__.py'
129--- tests/autopilot/ubuntu_clock_app/emulators/__init__.py 2013-05-27 07:48:32 +0000
130+++ tests/autopilot/ubuntu_clock_app/emulators/__init__.py 1970-01-01 00:00:00 +0000
131@@ -1,17 +0,0 @@
132-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
133-#
134-# Copyright (C) 2013 Canonical Ltd
135-#
136-# This program is free software: you can redistribute it and/or modify
137-# it under the terms of the GNU General Public License version 3 as
138-# published by the Free Software Foundation.
139-#
140-# This program is distributed in the hope that it will be useful,
141-# but WITHOUT ANY WARRANTY; without even the implied warranty of
142-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
143-# GNU General Public License for more details.
144-#
145-# You should have received a copy of the GNU General Public License
146-# along with this program. If not, see <http://www.gnu.org/licenses/>.
147-#
148-# Authored by: Renato Araujo Oliveira Filho <renato@canonical.com>
149
150=== removed file 'tests/autopilot/ubuntu_clock_app/emulators/main_window.py'
151--- tests/autopilot/ubuntu_clock_app/emulators/main_window.py 2013-08-07 13:39:51 +0000
152+++ tests/autopilot/ubuntu_clock_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
153@@ -1,112 +0,0 @@
154-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
155-#
156-# Copyright (C) 2013 Canonical Ltd
157-#
158-# This program is free software: you can redistribute it and/or modify
159-# it under the terms of the GNU General Public License version 3 as
160-# published by the Free Software Foundation.
161-#
162-# This program is distributed in the hope that it will be useful,
163-# but WITHOUT ANY WARRANTY; without even the implied warranty of
164-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
165-# GNU General Public License for more details.
166-#
167-# You should have received a copy of the GNU General Public License
168-# along with this program. If not, see <http://www.gnu.org/licenses/>.
169-#
170-# Authored by: Renato Araujo Oliveira Filho <renato@canonical.com>
171-# Nekhelesh Ramananthan <krnekhelesh@gmail.com>
172-
173-
174-class MainWindow(object):
175- """An emulator class that makes it easy to interact with the clock-app."""
176-
177- def __init__(self, app):
178- self.app = app
179-
180- def get_qml_view(self):
181- """Get the main QML view"""
182- return self.app.select_single("QQuickView")
183-
184- def get_object(self, typeName, name):
185- return self.app.select_single(typeName, objectName=name)
186-
187- def get_object_by_id(self, typeName, objectId):
188- return self.app.select_single(typeName, id=objectId)
189-
190- def get_stopwatch_tab_button(self):
191- """Returns the stopwatch tab."""
192- return self.app.select_single("AbstractButton", buttonIndex=3)
193-
194- def get_stopwatch_label(self):
195- """Returns the select for the stopwatch label"""
196- return self.app.select_single("Label", objectName="labelStopwatch")
197-
198- def get_stopwatch_button(self):
199- """Returns the select for the stopwatch button"""
200- return self.app.select_single("AnalogStopwatch", objectName="buttonStopwatch")
201-
202- def get_lap_button(self):
203- """Returns the select for the lap button"""
204- return self.app.select_single("Button", objectName="lapButton")
205-
206- def get_reset_button(self):
207- """Returns the select for the reset button"""
208- return self.app.select_single("ImageButton", objectName="resetButton")
209-
210- def get_laps(self):
211- """Returns the select for the lap count"""
212- return self.app.select_single("ListModel", objectName="laps")
213-
214- def get_timer_tab_button(self):
215- """Returns the timer tab."""
216- return self.app.select_single("AbstractButton", buttonIndex=2)
217-
218- def get_toolbar_timer(self):
219- """Returns the toolbar of timer tab"""
220- return self.app.select_single("ToolbarItems")
221-
222- def get_toolbar_timer_button(self, button_idx):
223- """Returns a button of toolbar of timer tab"""
224- toolbar = self.app.select_single("ToolbarItems")
225- button = toolbar.get_children()
226- return button[button_idx]
227-
228- def get_toolbar_timer_add_preset_button(self):
229- """Returns the button for add preset of toolbar of timer tab"""
230- return self.get_toolbar_timer_button(1)
231-
232- def get_timer_name_preset(self):
233- """Returns the TextField where insert the name of the preset"""
234- return self.app.select_single("TextField", objectName="namePreset")
235-
236- def get_timer_hour_hand(self):
237- """Returns the hour hand of clock in timer tab"""
238- return self.app.select_single("AnalogTouchHand", objectName="hourHand")
239-
240- def get_timer_clock_center_label(self):
241- """Returns the label in the center of clock"""
242- return self.app.select_single("Label", objectName="addPresetTextDone")
243-
244- def get_preset_label_text(self):
245- """Returns the label with the preset text"""
246- preset = self.app.select_many("Label", objectName="presetTextLabel")
247- return preset[0] #last preset, the one created by autopilot
248-
249- def get_preset_label_timer(self):
250- """Returns the label with the preset timer"""
251- preset = self.app.select_many("Label", objectName="presetTimerLabel")
252- return preset[0] #last preset, the one created by autopilot
253-
254- def get_label_timer(self):
255- """Return the label with the timer countdown"""
256- return self.app.select_single("Label", objectName="labelTimer")
257-
258- def get_num_of_presets(self):
259- """Returns the number of presets in the timer page."""
260- timer_page = self.app.select_single("TimerPage")
261- return timer_page.select_single("QQuickListView").count
262-
263- def get_first_preset_list_item(self):
264- """Returns the first preset list item in the timer page."""
265- return self.app.select_single("Standard", objectName="preset0")
266
267=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
268--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-08-07 15:48:05 +0000
269+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-08-12 17:47:04 +0000
270@@ -28,13 +28,13 @@
271 from autopilot.matchers import Eventually
272 from testtools.matchers import GreaterThan
273
274-from ubuntu_clock_app.emulators.main_window import MainWindow
275-
276+from ubuntuuitoolkit import emulators as toolkit_emulators
277+from ubuntu_clock_app import emulators
278
279 class ClockAppTestCase(AutopilotTestCase):
280
281 """A common test case class that provides several useful methods for
282- clock-app tests.
283+ calendar-app tests.
284
285 """
286 if model() == 'Desktop':
287@@ -56,65 +56,18 @@
288 self.app = self.launch_test_application(
289 "qmlscene",
290 self.local_location,
291- app_type='qt')
292+ app_type='qt',
293+ emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
294
295 def launch_test_installed(self):
296 self.app = self.launch_test_application(
297 "qmlscene",
298 "/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml",
299- "--desktop_file_hint=/usr/share/applications/ubuntu-clock-app.desktop",
300- app_type='qt')
301-
302- def get_toolbar(self):
303- return self.app.select_single("Toolbar")
304-
305- #shamelessly pulled and adapted from the ubuntusdk emulator unmerged code, 6 Aug 13
306- #need to migrate to ubuntusdk emulator
307- def get_tabs(self):
308- return self.app.select_single("TabBar")
309-
310- def switch_to_next_tab(self):
311- """Open the next tab."""
312- self.pointing_device.click_object(self._get_current_tab_button())
313- self.pointing_device.click_object(self._get_next_tab_button())
314-
315- def _get_current_tab_button(self):
316- tabs = self.get_tabs()
317- #return tabs.tabs.select_many('AbstractButton', selected=True) <--- can't do this
318- #clock has 8 buttons, a duplicate of each tab for some reason.
319- #Sometimes 2 buttons are shown as selected. If this is the case, we want the second one.
320- #Looping through them in this horrible way accomplishes our goal
321- buttons = tabs.select_many('AbstractButton')
322- for button in buttons:
323- if button.selected == True:
324- selectedButton = button
325- return selectedButton
326-
327- def _get_next_tab_button(self):
328- current_index = self._get_current_tab_button().buttonIndex
329- next_index = (current_index + 1) % self._get_number_of_tab_buttons()
330- return self._get_tab_buttons()[next_index]
331-
332- def _get_number_of_tab_buttons(self):
333- return len(self._get_tab_buttons())
334-
335- def _get_tab_buttons(self):
336- tabs = self.get_tabs()
337- return tabs.select_many('AbstractButton')
338-
339- def move_to_stopwatch_tab(self):
340- #stopwatch is 3 tabs over from clock
341- #we really need better tab support to support moving to tab based on objectName
342- self.switch_to_next_tab()
343- self.switch_to_next_tab()
344- self.switch_to_next_tab()
345-
346- def move_to_timer_tab(self):
347- #timer is 2 tabs over from clock
348- #we really need better tab support to support moving to tab based on objectName
349- self.switch_to_next_tab()
350- self.switch_to_next_tab()
351+ "--desktop_file_hint=/usr/share/applications/"
352+ "ubuntu-clock-app.desktop",
353+ app_type='qt',
354+ emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
355
356 @property
357- def main_window(self):
358- return MainWindow(self.app)
359+ def main_view(self):
360+ return self.app.select_single(emulators.MainView)
361
362=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
363--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-05-27 07:48:32 +0000
364+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-08-12 17:47:04 +0000
365@@ -35,14 +35,14 @@
366 def setUp(self):
367 super(TestClock, self).setUp()
368 self.assertThat(
369- self.main_window.get_qml_view().visible, Eventually(Equals(True)))
370+ self.main_view.visible, Eventually(Equals(True)))
371
372 def tearDown(self):
373 super(TestClock, self).tearDown()
374
375 """ Test if the clock labels contains the correct time """
376 def test_label_value(self):
377- label = self.main_window.get_object("Label", "currentTimeLabel")
378+ label = self.main_view.get_time_label()
379
380 # TODO: investigate a way to get the system wide format for time
381 # and compare the values
382
383=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py'
384--- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-08-07 16:18:35 +0000
385+++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-08-12 17:47:04 +0000
386@@ -32,13 +32,12 @@
387 In the testfarm, the application may take some time to show up."""
388 def setUp(self):
389 super(TestStopwatch, self).setUp()
390- self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
391-
392- self.move_to_stopwatch_tab()
393-
394- # Test if the current Tab is the Stopwatch Tab
395- CurrentTab = self.main_window.get_object("Tab", "StopwatchTab")
396- self.assertThat(CurrentTab.title, Eventually(Equals("Stopwatch")))
397+ self.assertThat(
398+ self.main_view.visible, Eventually(Equals(True)))
399+
400+ #move to stopwatch tab
401+ #ignoring the emulator tab functions until fixed
402+ self.main_view.switch_to_tab("StopwatchTab")
403
404 def tearDown(self):
405 super(TestStopwatch, self).tearDown()
406@@ -46,23 +45,24 @@
407 def test_start_stop_reset_stopwatch(self):
408 """Test to check the proper functioning of the start/stop/reset of stopwatch"""
409
410- start_stop_button = self.main_window.get_stopwatch_button()
411+ start_stop_button = self.main_view.get_stopwatch_button()
412 self.assertThat(lambda: start_stop_button, Eventually(NotEquals(None)))
413- stopwatch_label = self.main_window.get_stopwatch_label()
414+ stopwatch_label = self.main_view.get_stopwatch_label()
415 self.assertThat(lambda: stopwatch_label, Eventually(NotEquals(None)))
416- reset_button = self.main_window.get_reset_button()
417+ reset_button = self.main_view.get_reset_button()
418 self.assertThat(lambda: reset_button, Eventually(NotEquals(None)))
419
420 # Press the start button to start the stopwatch
421+ stopwatch_label_before = self.main_view.get_stopwatch_label().text
422+ self.assertThat(lambda: stopwatch_label_before, Eventually(NotEquals(None)))
423 self.pointing_device.click_object(start_stop_button)
424 self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0")))
425
426 # Press stop and check if the stopwatch has indeed stopped
427- stopwatch_label_before = self.main_window.get_stopwatch_label().text
428 self.pointing_device.click_object(start_stop_button)
429- self.assertThat(stopwatch_label_before, NotEquals(self.main_window.get_stopwatch_label().text))
430- stopwatch_label_after = lambda: self.main_window.get_stopwatch_label().text
431- self.assertThat(stopwatch_label_after, Eventually(Equals(self.main_window.get_stopwatch_label().text)))
432+ self.assertThat(stopwatch_label_before, NotEquals(self.main_view.get_stopwatch_label().text))
433+ stopwatch_label_after = lambda: self.main_view.get_stopwatch_label().text
434+ self.assertThat(stopwatch_label_after, Eventually(Equals(self.main_view.get_stopwatch_label().text)))
435
436 # Press reset and check if the stopwatch has been resetted
437 self.pointing_device.click_object(reset_button)
438
439=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
440--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-08-07 16:18:35 +0000
441+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-08-12 17:47:04 +0000
442@@ -33,17 +33,17 @@
443 In the testfarm, the application may take some time to show up."""
444 def setUp(self):
445 super(TestTimer, self).setUp()
446- self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
447-
448- self.move_to_timer_tab()
449-
450- # Test if the current Tab is the Timer Tab
451- CurrentTab = self.main_window.get_object("Tab", "TimerTab")
452- self.assertThat(CurrentTab.title, Eventually(Equals("Timer")))
453+ self.assertThat(
454+ self.main_view.visible, Eventually(Equals(True)))
455+
456+ #move to timer tab
457+ #ignoring the emulator tab functions until fixed
458+ self.main_view.switch_to_tab("TimerTab")
459
460
461 def drag_page_up_to_show_input_box(self):
462- timer_page = self.app.select_single("TimerPage")
463+ timer_page = self.select_single("TimerPage")
464+ self.assertThat(timer_page, Eventually(NotEquals(None)))
465
466 x, y, w, h = timer_page.globalRect
467 tx = x + (w / 2)
468@@ -55,7 +55,8 @@
469 Eventually(Equals(False)))
470
471 def drag_page_down_to_previous_state(self):
472- timer_page = self.app.select_single("TimerPage")
473+ timer_page = self.select_single("TimerPage")
474+ self.assertThat(timer_page, Eventually(NotEquals(None)))
475
476 x, y, w, h = timer_page.globalRect
477 tx = x + (w / 2)
478@@ -66,46 +67,24 @@
479 timer_page.select_single("AnimationContainer").moving,
480 Eventually(Equals(False)))
481
482-
483- def open_toolbar(self):
484- toolbar = self.get_toolbar()
485-
486- x, y, w, h = toolbar.globalRect
487- tx = x + (w / 2)
488- ty = y + (h - (h / 8))
489-
490- self.pointing_device.drag(tx, ty, tx, ty - h)
491- self.assertThat(toolbar.animating, Eventually(Equals(False)))
492- #self.assertThat(toolbar.state, Eventually(Equals("spread")))
493-
494- def close_toolbar(self):
495- toolbar = self.get_toolbar()
496-
497- x, y, w, h = toolbar.globalRect
498- tx = x + (w / 2)
499- ty = y + (h - (h / 8))
500-
501- self.pointing_device.drag(tx, ty - h, tx, ty)
502- self.assertThat(toolbar.animating, Eventually(Equals(False)))
503- #self.assertThat(toolbar.state, Eventually(NotEquals("spread")))
504-
505 def test_add_preset(self):
506 """Test to check if button to add a preset working"""
507
508 # Show the toolbar
509- self.open_toolbar()
510+ self.main_view.open_toolbar()
511
512 # Click the add preset button
513- add_preset_button = self.main_window.get_toolbar_timer_add_preset_button()
514+ add_preset_button = self.main_view.get_toolbar_timer_add_preset_button()
515+ self.assertThat(lambda: add_preset_button, Eventually(NotEquals(None)))
516 self.pointing_device.click_object(add_preset_button)
517
518 #For now close the toolbar due to https://bugs.launchpad.net/ubuntu-clock-app/+bug/1209024
519- self.close_toolbar()
520+ self.main_view.close_toolbar()
521
522 # Write in the label
523 if model() != "Desktop":
524 self.drag_page_up_to_show_input_box()
525- label = self.main_window.get_timer_name_preset()
526+ label = self.main_view.get_timer_name_preset()
527 self.assertThat(lambda: label, Eventually(NotEquals(None)))
528 self.pointing_device.click_object(label)
529 self.assertThat(label.focus, Eventually(Equals(True)))
530@@ -116,20 +95,22 @@
531 self.drag_page_down_to_previous_state()
532
533 # Set hour
534- hour = self.main_window.get_timer_hour_hand()
535+ hour = self.main_view.get_timer_hour_hand()
536 self.assertThat(lambda: hour, Eventually(NotEquals(None)))
537 x, y, w, h = hour.globalRect
538 tx = x + (w / 2)
539 ty = y + (h / 2)
540 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
541
542- num_of_presets_old = int(self.main_window.get_num_of_presets())
543+ num_of_presets_old = self.main_view.get_num_of_presets()
544+ self.assertThat(lambda: num_of_presets_old, Eventually(NotEquals(None)))
545 # Press "Done" button
546- label = self.main_window.get_timer_clock_center_label()
547+ label = self.main_view.get_timer_clock_center_label()
548+ self.assertThat(lambda: label, Eventually(NotEquals(None)))
549 self.pointing_device.click_object(label)
550
551 # Check if the preset has been saved
552- self.assertThat(self.main_window.get_num_of_presets(),
553+ self.assertThat(self.main_view.get_num_of_presets,
554 Eventually(Equals(num_of_presets_old+1)))
555
556 def test_delete_preset(self):
557@@ -138,8 +119,9 @@
558 # Create a new preset
559 self.test_add_preset()
560
561- num_of_presets_old = int(self.main_window.get_num_of_presets())
562- first_preset = self.main_window.get_first_preset_list_item()
563+ num_of_presets_old = self.main_view.get_num_of_presets()
564+ self.assertThat(lambda: num_of_presets_old, Eventually(NotEquals(None)))
565+ first_preset = self.main_view.get_first_preset_list_item()
566 self.assertThat(lambda: first_preset, Eventually(NotEquals(None)))
567
568 if model() != "Desktop":
569@@ -151,7 +133,7 @@
570 self.pointing_device.drag(tx, ty, w - w / 8, ty)
571
572 # Check has been deleted
573- self.assertThat(self.main_window.get_num_of_presets(),
574+ self.assertThat(self.main_view.get_num_of_presets,
575 Eventually(Equals(num_of_presets_old-1)))
576
577 def test_run_preset(self):
578@@ -161,7 +143,7 @@
579 self.test_add_preset()
580
581 # Click to select the preset
582- first_preset = self.main_window.get_first_preset_list_item()
583+ first_preset = self.main_view.get_first_preset_list_item()
584 self.assertThat(lambda: first_preset, Eventually(NotEquals(None)))
585 if model() != "Desktop":
586 self.drag_page_up_to_show_input_box()
587@@ -171,9 +153,11 @@
588 self.drag_page_down_to_previous_state()
589
590 # Click to start the preset
591- label = self.main_window.get_timer_clock_center_label()
592+ label = self.main_view.get_timer_clock_center_label()
593+ self.assertThat(lambda: label, Eventually(NotEquals(None)))
594 self.pointing_device.click_object(label)
595
596 # Check if timer is started
597- label_timer = self.main_window.get_label_timer()
598+ label_timer = self.main_view.get_label_timer()
599+ self.assertThat(lambda: label_timer, Eventually(NotEquals(None)))
600 self.assertThat(label_timer.text, Eventually(NotEquals("23:00:00")))

Subscribers

People subscribed via source and target branches