Merge lp:~rpadovani/ubuntu-clock-app/start_preset_autopilot into lp:ubuntu-clock-app/saucy

Proposed by Riccardo Padovani
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 141
Merged at revision: 143
Proposed branch: lp:~rpadovani/ubuntu-clock-app/start_preset_autopilot
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 271 lines (+189/-2)
5 files modified
tests/autopilot/ubuntu_clock_app/emulators/main_window.py (+47/-0)
tests/autopilot/ubuntu_clock_app/tests/__init__.py (+15/-1)
tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+121/-0)
timer/AnalogTimer.qml (+1/-0)
timer/TimerPage.qml (+5/-1)
To merge this branch: bzr merge lp:~rpadovani/ubuntu-clock-app/start_preset_autopilot
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Ubuntu Clock Developers Pending
Review via email: mp+174592@code.launchpad.net

Commit message

Added autopilot to create a new preset. (#1188800)
Added autopilot to delete a new preset. (#1188801)
Added autopilot to run a preset. (#1188807)

Description of the change

Added autopilot to create a new preset. (#1188800)
Added autopilot to delete a new preset. (#1188801)
Added autopilot to run a preset. (#1188807)

To post a comment you must log in.
141. By Riccardo Padovani

Some improvments to delete_preset test

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This looks good to me. Thank you again Riccardo. At some point we'll convert this to the sdk emulator, but this works for now. I'd want to make sure the things like moving to a specific tab are more maintainable -- and the sdk emulator should fix that.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/ubuntu_clock_app/emulators/main_window.py'
--- tests/autopilot/ubuntu_clock_app/emulators/main_window.py 2013-07-10 19:38:56 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators/main_window.py 2013-07-14 22:20:33 +0000
@@ -30,6 +30,9 @@
3030
31 def get_object(self, typeName, name):31 def get_object(self, typeName, name):
32 return self.app.select_single(typeName, objectName=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)
33 36
34 def get_stopwatch_tab_button(self):37 def get_stopwatch_tab_button(self):
35 """Returns the stopwatch tab."""38 """Returns the stopwatch tab."""
@@ -54,3 +57,47 @@
54 def get_laps(self):57 def get_laps(self):
55 """Returns the select for the lap count"""58 """Returns the select for the lap count"""
56 return self.app.select_single("ListModel", objectName="laps") 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")
57104
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-06-27 17:18:33 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-07-14 22:20:33 +0000
@@ -79,7 +79,21 @@
79 stopwatch_tab_button = self.main_window.get_stopwatch_tab_button()79 stopwatch_tab_button = self.main_window.get_stopwatch_tab_button()
8080
81 self.assertThat(stopwatch_tab_button.opacity, Eventually(GreaterThan(0.35)))81 self.assertThat(stopwatch_tab_button.opacity, Eventually(GreaterThan(0.35)))
82 self.pointing_device.click_object(stopwatch_tab_button) 82 self.pointing_device.click_object(stopwatch_tab_button)
83
84 def move_to_timer_tab(self):
85 tabs_bar = self.get_tabs()
86
87 x, y, w, h = tabs_bar.globalRect
88 tx = x + w / 10
89 ty = y + h / 2
90 self.pointing_device.drag(tx, ty, w - 9, ty)
91
92 timer_tab_button = self.main_window.get_timer_tab_button()
93
94 self.assertThat(timer_tab_button.opacity, Eventually(GreaterThan(0.35)))
95 self.pointing_device.click_object(timer_tab_button)
96
8397
84 @property98 @property
85 def main_window(self):99 def main_window(self):
86100
=== added file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-07-14 22:20:33 +0000
@@ -0,0 +1,121 @@
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: Riccardo Padovani <rpadovani@ubuntu-it.org>
18
19"""Tests for the Clock App - Timer"""
20
21from __future__ import absolute_import
22
23from testtools.matchers import Equals, NotEquals
24from autopilot.matchers import Eventually
25
26from ubuntu_clock_app.tests import ClockAppTestCase
27
28class TestTimer(ClockAppTestCase):
29 """Tests the timer page features"""
30
31 """ This is needed to wait for the application to start.
32 In the testfarm, the application may take some time to show up."""
33 def setUp(self):
34 super(TestTimer, self).setUp()
35 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
36
37 self.move_to_timer_tab()
38
39 # Test if the current Tab is the Timer Tab
40 CurrentTab = self.main_window.get_object("Tab", "TimerTab")
41 self.assertThat(CurrentTab.title, Eventually(Equals("Timer")))
42
43 def show_toolbar(self):
44 toolbar_timer = self.main_window.get_toolbar_timer()
45
46 x, y, w, h = toolbar_timer.globalRect
47 tx = x + (w / 2)
48 ty = y - (h / 2)
49
50 self.pointing_device.drag(tx, ty + (h / 3), tx, ty - h)
51
52 def test_add_preset(self):
53 """Test to check if button to add a preset working"""
54
55 # Show the toolbar
56 self.show_toolbar()
57
58 # Click the add preset button
59 add_preset_button = self.main_window.get_toolbar_timer_add_preset_button()
60 self.pointing_device.click_object(add_preset_button)
61
62 # Write in the label
63 label = self.main_window.get_timer_name_preset()
64 self.pointing_device.click_object(label)
65 self.keyboard.type("test")
66
67 # Set hour
68 hour = self.main_window.get_timer_hour_hand()
69 x, y, w, h = hour.globalRect
70 tx = x + (w / 2)
71 ty = y + (h / 2)
72 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
73
74 # Press "Done" button
75 label = self.main_window.get_timer_clock_center_label()
76 self.pointing_device.click_object(label)
77
78 # Check if the preset has been saved
79 preset_text_label = self.main_window.get_preset_label_text()
80 preset_timer_label = self.main_window.get_preset_label_timer()
81
82 self.assertThat(preset_text_label.text, Eventually(Equals("test")))
83 self.assertThat(preset_timer_label.text, Eventually(Equals("23:00:00")))
84
85 def test_delete_preset(self):
86 """Test if the swipe of a preset deletes it"""
87
88 # Create a new preset
89 self.test_add_preset()
90
91 # Get the label of test and its id
92 preset_text_label = self.main_window.get_preset_label_text()
93 preset_text_label_id = preset_text_label.id
94
95 # Delete the preset
96 x, y, w, h = preset_text_label.globalRect
97 tx = x + (w / 2)
98 ty = y + (h / 2)
99 self.pointing_device.drag(tx - w, ty, tx + 10 * w , ty)
100
101 # Check has been deleted
102 label = lambda: self.main_window.get_object_by_id('Label', preset_text_label_id)
103 self.assertThat(label, Eventually(Equals(None)))
104
105 def test_run_preset(self):
106 """Tests if a preset can runs"""
107
108 # Create a new preset
109 self.test_add_preset()
110
111 # Click to select the preset
112 preset_text_label = self.main_window.get_preset_label_text()
113 self.pointing_device.click_object(preset_text_label)
114
115 # Click to start the preset
116 label = self.main_window.get_timer_clock_center_label()
117 self.pointing_device.click_object(label)
118
119 # Check if timer is started
120 label_timer = self.main_window.get_label_timer()
121 self.assertThat(label_timer.text, Eventually(NotEquals("23:00:00")))
0\ No newline at end of file122\ No newline at end of file
1123
=== modified file 'timer/AnalogTimer.qml'
--- timer/AnalogTimer.qml 2013-07-12 17:07:55 +0000
+++ timer/AnalogTimer.qml 2013-07-14 22:20:33 +0000
@@ -86,6 +86,7 @@
86 // Hour hand with touch/mouse drag support86 // Hour hand with touch/mouse drag support
87 AnalogTouchHand {87 AnalogTouchHand {
88 id: hourHand88 id: hourHand
89 objectName: "hourHand"
8990
90 onTimerValueChanged: hours = timerValue;91 onTimerValueChanged: hours = timerValue;
9192
9293
=== modified file 'timer/TimerPage.qml'
--- timer/TimerPage.qml 2013-07-12 17:07:55 +0000
+++ timer/TimerPage.qml 2013-07-14 22:20:33 +0000
@@ -222,12 +222,15 @@
222222
223 delegate: ListItem.Standard {223 delegate: ListItem.Standard {
224 Label {224 Label {
225 id: presetTextLabel // Needs by autopilot
226 objectName: "presetTextLabel"
225 fontSize: "large";227 fontSize: "large";
226 text: label228 text: label
227 anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) }229 anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) }
228 }230 }
229231
230 Label {232 Label {
233 objectName: "presetTimerLabel"
231 fontSize: "large"234 fontSize: "large"
232 text: getstringTimer(seconds);235 text: getstringTimer(seconds);
233 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) }236 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) }
@@ -269,6 +272,7 @@
269272
270 Label {273 Label {
271 id: addPresetTextDone274 id: addPresetTextDone
275 objectName: "addPresetTextDone"
272276
273 //anchors.centerIn: parent277 //anchors.centerIn: parent
274 color: Constants.green278 color: Constants.green
@@ -292,6 +296,7 @@
292 // Element to set the name of a saved preset.296 // Element to set the name of a saved preset.
293 TextField {297 TextField {
294 id: namePreset298 id: namePreset
299 objectName: "namePreset"
295300
296 visible: false301 visible: false
297 hasClearButton: true302 hasClearButton: true
@@ -308,7 +313,6 @@
308 ToolbarButton {313 ToolbarButton {
309 action: Action {314 action: Action {
310 id: addPreset315 id: addPreset
311 objectName: "add-preset"
312316
313 iconSource: Qt.resolvedUrl("../images/add_icon.png")317 iconSource: Qt.resolvedUrl("../images/add_icon.png")
314 text: i18n.tr("Add Preset")318 text: i18n.tr("Add Preset")

Subscribers

People subscribed via source and target branches