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
=== modified file 'debian/control'
--- debian/control 2013-05-27 07:43:41 +0000
+++ debian/control 2013-08-12 17:47:04 +0000
@@ -16,7 +16,7 @@
16 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,16 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
17 qtdeclarative5-localstorage-plugin,17 qtdeclarative5-localstorage-plugin,
18 qtdeclarative5-qtquick2-plugin,18 qtdeclarative5-qtquick2-plugin,
19 qtdeclarative5-xmllistmodel-plugin,19 qtdeclarative5-xmllistmodel-plugin,
20Description: Clock application20Description: Clock application
21 Ubuntu Core Clock application which provides Stopwatch, Timer, Alarm and Clock functionalities.21 Ubuntu Core Clock application which provides Stopwatch, Timer, Alarm and Clock functionalities.
2222
@@ -24,6 +24,7 @@
24Architecture: all24Architecture: all
25Depends: libautopilot-qt,25Depends: libautopilot-qt,
26 libqt5test5,26 libqt5test5,
27 ubuntu-ui-toolkit-autopilot,
27 ubuntu-clock-app (= ${source:Version}),28 ubuntu-clock-app (= ${source:Version}),
28Description: Autopilot tests for Ubuntu Clock Application29Description: Autopilot tests for Ubuntu Clock Application
29 This package contains autopilot tests for the Ubuntu Clock application.30 This package contains autopilot tests for the Ubuntu Clock application.
3031
=== removed directory 'tests/autopilot/ubuntu_clock_app/emulators'
=== added file 'tests/autopilot/ubuntu_clock_app/emulators.py'
--- tests/autopilot/ubuntu_clock_app/emulators.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators.py 2013-08-12 17:47:04 +0000
@@ -0,0 +1,100 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 Canonical Ltd.
4#
5# 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 by
7# the Free Software Foundation; version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from ubuntuuitoolkit import emulators as toolkit_emulators
18
19
20class MainView(toolkit_emulators.MainView):
21 def get_stopwatch_tab_button(self):
22 """Returns the stopwatch tab."""
23 return self.select_single("AbstractButton", buttonIndex=3)
24
25 def get_stopwatch_label(self):
26 """Returns the select for the stopwatch label"""
27 return self.select_single("Label", objectName="labelStopwatch")
28
29 def get_stopwatch_button(self):
30 """Returns the select for the stopwatch button"""
31 return self.select_single("AnalogStopwatch", objectName="buttonStopwatch")
32
33 def get_lap_button(self):
34 """Returns the select for the lap button"""
35 return self.select_single("Button", objectName="lapButton")
36
37 def get_reset_button(self):
38 """Returns the select for the reset button"""
39 return self.select_single("ImageButton", objectName="resetButton")
40
41 def get_laps(self):
42 """Returns the select for the lap count"""
43 return self.select_single("ListModel", objectName="laps")
44
45 def get_timer_tab_button(self):
46 """Returns the timer tab."""
47 return self.select_single("AbstractButton", buttonIndex=2)
48
49 def get_toolbar_timer(self):
50 """Returns the toolbar of timer tab"""
51 return self.select_single("ToolbarItems")
52
53 def get_toolbar_timer_button(self, button_idx):
54 """Returns a button of toolbar of timer tab"""
55 toolbar = self.select_single("ToolbarItems")
56 button = toolbar.get_children()
57 return button[button_idx]
58
59 def get_toolbar_timer_add_preset_button(self):
60 """Returns the button for add preset of toolbar of timer tab"""
61 return self.get_toolbar_timer_button(1)
62
63 def get_timer_name_preset(self):
64 """Returns the TextField where insert the name of the preset"""
65 return self.select_single("TextField", objectName="namePreset")
66
67 def get_timer_hour_hand(self):
68 """Returns the hour hand of clock in timer tab"""
69 return self.select_single("AnalogTouchHand", objectName="hourHand")
70
71 def get_timer_clock_center_label(self):
72 """Returns the label in the center of clock"""
73 return self.select_single("Label", objectName="addPresetTextDone")
74
75 def get_preset_label_text(self):
76 """Returns the label with the preset text"""
77 preset = self.select_many("Label", objectName="presetTextLabel")
78 return preset[0] #last preset, the one created by autopilot
79
80 def get_preset_label_timer(self):
81 """Returns the label with the preset timer"""
82 preset = self.select_many("Label", objectName="presetTimerLabel")
83 return preset[0] #last preset, the one created by autopilot
84
85 def get_label_timer(self):
86 """Return the label with the timer countdown"""
87 return self.select_single("Label", objectName="labelTimer")
88
89 def get_num_of_presets(self):
90 """Returns the number of presets in the timer page."""
91 timer_page = self.select_single("TimerPage")
92 return int(timer_page.select_single("QQuickListView").count)
93
94 def get_first_preset_list_item(self):
95 """Returns the first preset list item in the timer page."""
96 return self.select_single("Standard", objectName="preset0")
97
98 def get_time_label(self):
99 """Return the label with the timer countdown"""
100 return self.select_single("Label", objectName="currentTimeLabel")
0101
=== removed file 'tests/autopilot/ubuntu_clock_app/emulators/__init__.py'
--- tests/autopilot/ubuntu_clock_app/emulators/__init__.py 2013-05-27 07:48:32 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Renato Araujo Oliveira Filho <renato@canonical.com>
180
=== removed file 'tests/autopilot/ubuntu_clock_app/emulators/main_window.py'
--- tests/autopilot/ubuntu_clock_app/emulators/main_window.py 2013-08-07 13:39:51 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Renato Araujo Oliveira Filho <renato@canonical.com>
18# Nekhelesh Ramananthan <krnekhelesh@gmail.com>
19
20
21class MainWindow(object):
22 """An emulator class that makes it easy to interact with the clock-app."""
23
24 def __init__(self, app):
25 self.app = app
26
27 def get_qml_view(self):
28 """Get the main QML view"""
29 return self.app.select_single("QQuickView")
30
31 def get_object(self, typeName, name):
32 return self.app.select_single(typeName, objectName=name)
33
34 def get_object_by_id(self, typeName, objectId):
35 return self.app.select_single(typeName, id=objectId)
36
37 def get_stopwatch_tab_button(self):
38 """Returns the stopwatch tab."""
39 return self.app.select_single("AbstractButton", buttonIndex=3)
40
41 def get_stopwatch_label(self):
42 """Returns the select for the stopwatch label"""
43 return self.app.select_single("Label", objectName="labelStopwatch")
44
45 def get_stopwatch_button(self):
46 """Returns the select for the stopwatch button"""
47 return self.app.select_single("AnalogStopwatch", objectName="buttonStopwatch")
48
49 def get_lap_button(self):
50 """Returns the select for the lap button"""
51 return self.app.select_single("Button", objectName="lapButton")
52
53 def get_reset_button(self):
54 """Returns the select for the reset button"""
55 return self.app.select_single("ImageButton", objectName="resetButton")
56
57 def get_laps(self):
58 """Returns the select for the lap count"""
59 return self.app.select_single("ListModel", objectName="laps")
60
61 def get_timer_tab_button(self):
62 """Returns the timer tab."""
63 return self.app.select_single("AbstractButton", buttonIndex=2)
64
65 def get_toolbar_timer(self):
66 """Returns the toolbar of timer tab"""
67 return self.app.select_single("ToolbarItems")
68
69 def get_toolbar_timer_button(self, button_idx):
70 """Returns a button of toolbar of timer tab"""
71 toolbar = self.app.select_single("ToolbarItems")
72 button = toolbar.get_children()
73 return button[button_idx]
74
75 def get_toolbar_timer_add_preset_button(self):
76 """Returns the button for add preset of toolbar of timer tab"""
77 return self.get_toolbar_timer_button(1)
78
79 def get_timer_name_preset(self):
80 """Returns the TextField where insert the name of the preset"""
81 return self.app.select_single("TextField", objectName="namePreset")
82
83 def get_timer_hour_hand(self):
84 """Returns the hour hand of clock in timer tab"""
85 return self.app.select_single("AnalogTouchHand", objectName="hourHand")
86
87 def get_timer_clock_center_label(self):
88 """Returns the label in the center of clock"""
89 return self.app.select_single("Label", objectName="addPresetTextDone")
90
91 def get_preset_label_text(self):
92 """Returns the label with the preset text"""
93 preset = self.app.select_many("Label", objectName="presetTextLabel")
94 return preset[0] #last preset, the one created by autopilot
95
96 def get_preset_label_timer(self):
97 """Returns the label with the preset timer"""
98 preset = self.app.select_many("Label", objectName="presetTimerLabel")
99 return preset[0] #last preset, the one created by autopilot
100
101 def get_label_timer(self):
102 """Return the label with the timer countdown"""
103 return self.app.select_single("Label", objectName="labelTimer")
104
105 def get_num_of_presets(self):
106 """Returns the number of presets in the timer page."""
107 timer_page = self.app.select_single("TimerPage")
108 return timer_page.select_single("QQuickListView").count
109
110 def get_first_preset_list_item(self):
111 """Returns the first preset list item in the timer page."""
112 return self.app.select_single("Standard", objectName="preset0")
1130
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-08-07 15:48:05 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-08-12 17:47:04 +0000
@@ -28,13 +28,13 @@
28from autopilot.matchers import Eventually28from autopilot.matchers import Eventually
29from testtools.matchers import GreaterThan29from testtools.matchers import GreaterThan
3030
31from ubuntu_clock_app.emulators.main_window import MainWindow31from ubuntuuitoolkit import emulators as toolkit_emulators
3232from ubuntu_clock_app import emulators
3333
34class ClockAppTestCase(AutopilotTestCase):34class ClockAppTestCase(AutopilotTestCase):
3535
36 """A common test case class that provides several useful methods for36 """A common test case class that provides several useful methods for
37 clock-app tests.37 calendar-app tests.
3838
39 """39 """
40 if model() == 'Desktop':40 if model() == 'Desktop':
@@ -56,65 +56,18 @@
56 self.app = self.launch_test_application(56 self.app = self.launch_test_application(
57 "qmlscene",57 "qmlscene",
58 self.local_location,58 self.local_location,
59 app_type='qt')59 app_type='qt',
60 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
6061
61 def launch_test_installed(self):62 def launch_test_installed(self):
62 self.app = self.launch_test_application(63 self.app = self.launch_test_application(
63 "qmlscene",64 "qmlscene",
64 "/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml",65 "/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml",
65 "--desktop_file_hint=/usr/share/applications/ubuntu-clock-app.desktop",66 "--desktop_file_hint=/usr/share/applications/"
66 app_type='qt')67 "ubuntu-clock-app.desktop",
6768 app_type='qt',
68 def get_toolbar(self):69 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
69 return self.app.select_single("Toolbar")
70
71 #shamelessly pulled and adapted from the ubuntusdk emulator unmerged code, 6 Aug 13
72 #need to migrate to ubuntusdk emulator
73 def get_tabs(self):
74 return self.app.select_single("TabBar")
75
76 def switch_to_next_tab(self):
77 """Open the next tab."""
78 self.pointing_device.click_object(self._get_current_tab_button())
79 self.pointing_device.click_object(self._get_next_tab_button())
80
81 def _get_current_tab_button(self):
82 tabs = self.get_tabs()
83 #return tabs.tabs.select_many('AbstractButton', selected=True) <--- can't do this
84 #clock has 8 buttons, a duplicate of each tab for some reason.
85 #Sometimes 2 buttons are shown as selected. If this is the case, we want the second one.
86 #Looping through them in this horrible way accomplishes our goal
87 buttons = tabs.select_many('AbstractButton')
88 for button in buttons:
89 if button.selected == True:
90 selectedButton = button
91 return selectedButton
92
93 def _get_next_tab_button(self):
94 current_index = self._get_current_tab_button().buttonIndex
95 next_index = (current_index + 1) % self._get_number_of_tab_buttons()
96 return self._get_tab_buttons()[next_index]
97
98 def _get_number_of_tab_buttons(self):
99 return len(self._get_tab_buttons())
100
101 def _get_tab_buttons(self):
102 tabs = self.get_tabs()
103 return tabs.select_many('AbstractButton')
104
105 def move_to_stopwatch_tab(self):
106 #stopwatch is 3 tabs over from clock
107 #we really need better tab support to support moving to tab based on objectName
108 self.switch_to_next_tab()
109 self.switch_to_next_tab()
110 self.switch_to_next_tab()
111
112 def move_to_timer_tab(self):
113 #timer is 2 tabs over from clock
114 #we really need better tab support to support moving to tab based on objectName
115 self.switch_to_next_tab()
116 self.switch_to_next_tab()
11770
118 @property71 @property
119 def main_window(self):72 def main_view(self):
120 return MainWindow(self.app)73 return self.app.select_single(emulators.MainView)
12174
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-05-27 07:48:32 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-08-12 17:47:04 +0000
@@ -35,14 +35,14 @@
35 def setUp(self):35 def setUp(self):
36 super(TestClock, self).setUp()36 super(TestClock, self).setUp()
37 self.assertThat(37 self.assertThat(
38 self.main_window.get_qml_view().visible, Eventually(Equals(True)))38 self.main_view.visible, Eventually(Equals(True)))
3939
40 def tearDown(self):40 def tearDown(self):
41 super(TestClock, self).tearDown()41 super(TestClock, self).tearDown()
4242
43 """ Test if the clock labels contains the correct time """43 """ Test if the clock labels contains the correct time """
44 def test_label_value(self):44 def test_label_value(self):
45 label = self.main_window.get_object("Label", "currentTimeLabel")45 label = self.main_view.get_time_label()
4646
47 # TODO: investigate a way to get the system wide format for time47 # TODO: investigate a way to get the system wide format for time
48 # and compare the values48 # and compare the values
4949
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-08-07 16:18:35 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-08-12 17:47:04 +0000
@@ -32,13 +32,12 @@
32 In the testfarm, the application may take some time to show up."""32 In the testfarm, the application may take some time to show up."""
33 def setUp(self):33 def setUp(self):
34 super(TestStopwatch, self).setUp()34 super(TestStopwatch, self).setUp()
35 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))35 self.assertThat(
3636 self.main_view.visible, Eventually(Equals(True)))
37 self.move_to_stopwatch_tab()37
3838 #move to stopwatch tab
39 # Test if the current Tab is the Stopwatch Tab39 #ignoring the emulator tab functions until fixed
40 CurrentTab = self.main_window.get_object("Tab", "StopwatchTab")40 self.main_view.switch_to_tab("StopwatchTab")
41 self.assertThat(CurrentTab.title, Eventually(Equals("Stopwatch")))
4241
43 def tearDown(self):42 def tearDown(self):
44 super(TestStopwatch, self).tearDown()43 super(TestStopwatch, self).tearDown()
@@ -46,23 +45,24 @@
46 def test_start_stop_reset_stopwatch(self):45 def test_start_stop_reset_stopwatch(self):
47 """Test to check the proper functioning of the start/stop/reset of stopwatch"""46 """Test to check the proper functioning of the start/stop/reset of stopwatch"""
4847
49 start_stop_button = self.main_window.get_stopwatch_button()48 start_stop_button = self.main_view.get_stopwatch_button()
50 self.assertThat(lambda: start_stop_button, Eventually(NotEquals(None)))49 self.assertThat(lambda: start_stop_button, Eventually(NotEquals(None)))
51 stopwatch_label = self.main_window.get_stopwatch_label()50 stopwatch_label = self.main_view.get_stopwatch_label()
52 self.assertThat(lambda: stopwatch_label, Eventually(NotEquals(None)))51 self.assertThat(lambda: stopwatch_label, Eventually(NotEquals(None)))
53 reset_button = self.main_window.get_reset_button()52 reset_button = self.main_view.get_reset_button()
54 self.assertThat(lambda: reset_button, Eventually(NotEquals(None)))53 self.assertThat(lambda: reset_button, Eventually(NotEquals(None)))
5554
56 # Press the start button to start the stopwatch55 # Press the start button to start the stopwatch
56 stopwatch_label_before = self.main_view.get_stopwatch_label().text
57 self.assertThat(lambda: stopwatch_label_before, Eventually(NotEquals(None)))
57 self.pointing_device.click_object(start_stop_button)58 self.pointing_device.click_object(start_stop_button)
58 self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0")))59 self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0")))
5960
60 # Press stop and check if the stopwatch has indeed stopped61 # Press stop and check if the stopwatch has indeed stopped
61 stopwatch_label_before = self.main_window.get_stopwatch_label().text
62 self.pointing_device.click_object(start_stop_button)62 self.pointing_device.click_object(start_stop_button)
63 self.assertThat(stopwatch_label_before, NotEquals(self.main_window.get_stopwatch_label().text))63 self.assertThat(stopwatch_label_before, NotEquals(self.main_view.get_stopwatch_label().text))
64 stopwatch_label_after = lambda: self.main_window.get_stopwatch_label().text64 stopwatch_label_after = lambda: self.main_view.get_stopwatch_label().text
65 self.assertThat(stopwatch_label_after, Eventually(Equals(self.main_window.get_stopwatch_label().text)))65 self.assertThat(stopwatch_label_after, Eventually(Equals(self.main_view.get_stopwatch_label().text)))
6666
67 # Press reset and check if the stopwatch has been resetted67 # Press reset and check if the stopwatch has been resetted
68 self.pointing_device.click_object(reset_button)68 self.pointing_device.click_object(reset_button)
6969
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-08-07 16:18:35 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-08-12 17:47:04 +0000
@@ -33,17 +33,17 @@
33 In the testfarm, the application may take some time to show up."""33 In the testfarm, the application may take some time to show up."""
34 def setUp(self):34 def setUp(self):
35 super(TestTimer, self).setUp()35 super(TestTimer, self).setUp()
36 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))36 self.assertThat(
3737 self.main_view.visible, Eventually(Equals(True)))
38 self.move_to_timer_tab()38
3939 #move to timer tab
40 # Test if the current Tab is the Timer Tab40 #ignoring the emulator tab functions until fixed
41 CurrentTab = self.main_window.get_object("Tab", "TimerTab")41 self.main_view.switch_to_tab("TimerTab")
42 self.assertThat(CurrentTab.title, Eventually(Equals("Timer")))
4342
4443
45 def drag_page_up_to_show_input_box(self):44 def drag_page_up_to_show_input_box(self):
46 timer_page = self.app.select_single("TimerPage")45 timer_page = self.select_single("TimerPage")
46 self.assertThat(timer_page, Eventually(NotEquals(None)))
4747
48 x, y, w, h = timer_page.globalRect48 x, y, w, h = timer_page.globalRect
49 tx = x + (w / 2)49 tx = x + (w / 2)
@@ -55,7 +55,8 @@
55 Eventually(Equals(False)))55 Eventually(Equals(False)))
5656
57 def drag_page_down_to_previous_state(self):57 def drag_page_down_to_previous_state(self):
58 timer_page = self.app.select_single("TimerPage")58 timer_page = self.select_single("TimerPage")
59 self.assertThat(timer_page, Eventually(NotEquals(None)))
5960
60 x, y, w, h = timer_page.globalRect61 x, y, w, h = timer_page.globalRect
61 tx = x + (w / 2)62 tx = x + (w / 2)
@@ -66,46 +67,24 @@
66 timer_page.select_single("AnimationContainer").moving,67 timer_page.select_single("AnimationContainer").moving,
67 Eventually(Equals(False)))68 Eventually(Equals(False)))
6869
69
70 def open_toolbar(self):
71 toolbar = self.get_toolbar()
72
73 x, y, w, h = toolbar.globalRect
74 tx = x + (w / 2)
75 ty = y + (h - (h / 8))
76
77 self.pointing_device.drag(tx, ty, tx, ty - h)
78 self.assertThat(toolbar.animating, Eventually(Equals(False)))
79 #self.assertThat(toolbar.state, Eventually(Equals("spread")))
80
81 def close_toolbar(self):
82 toolbar = self.get_toolbar()
83
84 x, y, w, h = toolbar.globalRect
85 tx = x + (w / 2)
86 ty = y + (h - (h / 8))
87
88 self.pointing_device.drag(tx, ty - h, tx, ty)
89 self.assertThat(toolbar.animating, Eventually(Equals(False)))
90 #self.assertThat(toolbar.state, Eventually(NotEquals("spread")))
91
92 def test_add_preset(self):70 def test_add_preset(self):
93 """Test to check if button to add a preset working"""71 """Test to check if button to add a preset working"""
9472
95 # Show the toolbar73 # Show the toolbar
96 self.open_toolbar()74 self.main_view.open_toolbar()
9775
98 # Click the add preset button76 # Click the add preset button
99 add_preset_button = self.main_window.get_toolbar_timer_add_preset_button()77 add_preset_button = self.main_view.get_toolbar_timer_add_preset_button()
78 self.assertThat(lambda: add_preset_button, Eventually(NotEquals(None)))
100 self.pointing_device.click_object(add_preset_button)79 self.pointing_device.click_object(add_preset_button)
10180
102 #For now close the toolbar due to https://bugs.launchpad.net/ubuntu-clock-app/+bug/120902481 #For now close the toolbar due to https://bugs.launchpad.net/ubuntu-clock-app/+bug/1209024
103 self.close_toolbar()82 self.main_view.close_toolbar()
10483
105 # Write in the label84 # Write in the label
106 if model() != "Desktop":85 if model() != "Desktop":
107 self.drag_page_up_to_show_input_box()86 self.drag_page_up_to_show_input_box()
108 label = self.main_window.get_timer_name_preset()87 label = self.main_view.get_timer_name_preset()
109 self.assertThat(lambda: label, Eventually(NotEquals(None)))88 self.assertThat(lambda: label, Eventually(NotEquals(None)))
110 self.pointing_device.click_object(label)89 self.pointing_device.click_object(label)
111 self.assertThat(label.focus, Eventually(Equals(True)))90 self.assertThat(label.focus, Eventually(Equals(True)))
@@ -116,20 +95,22 @@
116 self.drag_page_down_to_previous_state()95 self.drag_page_down_to_previous_state()
11796
118 # Set hour97 # Set hour
119 hour = self.main_window.get_timer_hour_hand()98 hour = self.main_view.get_timer_hour_hand()
120 self.assertThat(lambda: hour, Eventually(NotEquals(None)))99 self.assertThat(lambda: hour, Eventually(NotEquals(None)))
121 x, y, w, h = hour.globalRect100 x, y, w, h = hour.globalRect
122 tx = x + (w / 2)101 tx = x + (w / 2)
123 ty = y + (h / 2)102 ty = y + (h / 2)
124 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))103 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
125104
126 num_of_presets_old = int(self.main_window.get_num_of_presets())105 num_of_presets_old = self.main_view.get_num_of_presets()
106 self.assertThat(lambda: num_of_presets_old, Eventually(NotEquals(None)))
127 # Press "Done" button107 # Press "Done" button
128 label = self.main_window.get_timer_clock_center_label()108 label = self.main_view.get_timer_clock_center_label()
109 self.assertThat(lambda: label, Eventually(NotEquals(None)))
129 self.pointing_device.click_object(label)110 self.pointing_device.click_object(label)
130111
131 # Check if the preset has been saved112 # Check if the preset has been saved
132 self.assertThat(self.main_window.get_num_of_presets(),113 self.assertThat(self.main_view.get_num_of_presets,
133 Eventually(Equals(num_of_presets_old+1)))114 Eventually(Equals(num_of_presets_old+1)))
134115
135 def test_delete_preset(self):116 def test_delete_preset(self):
@@ -138,8 +119,9 @@
138 # Create a new preset119 # Create a new preset
139 self.test_add_preset()120 self.test_add_preset()
140121
141 num_of_presets_old = int(self.main_window.get_num_of_presets())122 num_of_presets_old = self.main_view.get_num_of_presets()
142 first_preset = self.main_window.get_first_preset_list_item()123 self.assertThat(lambda: num_of_presets_old, Eventually(NotEquals(None)))
124 first_preset = self.main_view.get_first_preset_list_item()
143 self.assertThat(lambda: first_preset, Eventually(NotEquals(None)))125 self.assertThat(lambda: first_preset, Eventually(NotEquals(None)))
144126
145 if model() != "Desktop":127 if model() != "Desktop":
@@ -151,7 +133,7 @@
151 self.pointing_device.drag(tx, ty, w - w / 8, ty)133 self.pointing_device.drag(tx, ty, w - w / 8, ty)
152134
153 # Check has been deleted135 # Check has been deleted
154 self.assertThat(self.main_window.get_num_of_presets(),136 self.assertThat(self.main_view.get_num_of_presets,
155 Eventually(Equals(num_of_presets_old-1)))137 Eventually(Equals(num_of_presets_old-1)))
156138
157 def test_run_preset(self):139 def test_run_preset(self):
@@ -161,7 +143,7 @@
161 self.test_add_preset()143 self.test_add_preset()
162144
163 # Click to select the preset145 # Click to select the preset
164 first_preset = self.main_window.get_first_preset_list_item()146 first_preset = self.main_view.get_first_preset_list_item()
165 self.assertThat(lambda: first_preset, Eventually(NotEquals(None)))147 self.assertThat(lambda: first_preset, Eventually(NotEquals(None)))
166 if model() != "Desktop":148 if model() != "Desktop":
167 self.drag_page_up_to_show_input_box()149 self.drag_page_up_to_show_input_box()
@@ -171,9 +153,11 @@
171 self.drag_page_down_to_previous_state()153 self.drag_page_down_to_previous_state()
172154
173 # Click to start the preset155 # Click to start the preset
174 label = self.main_window.get_timer_clock_center_label()156 label = self.main_view.get_timer_clock_center_label()
157 self.assertThat(lambda: label, Eventually(NotEquals(None)))
175 self.pointing_device.click_object(label)158 self.pointing_device.click_object(label)
176159
177 # Check if timer is started160 # Check if timer is started
178 label_timer = self.main_window.get_label_timer()161 label_timer = self.main_view.get_label_timer()
162 self.assertThat(lambda: label_timer, Eventually(NotEquals(None)))
179 self.assertThat(label_timer.text, Eventually(NotEquals("23:00:00")))163 self.assertThat(label_timer.text, Eventually(NotEquals("23:00:00")))

Subscribers

People subscribed via source and target branches