Merge lp:~nik90/ubuntu-clock-app/add-stopwatch-ap-tests into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Superseded
Proposed branch: lp:~nik90/ubuntu-clock-app/add-stopwatch-ap-tests
Merge into: lp:ubuntu-clock-app
Diff against target: 363 lines (+200/-11)
9 files modified
app/MainPage.qml (+29/-4)
app/components/HeaderNavigation.qml (+8/-2)
app/stopwatch/StopwatchFace.qml (+2/-0)
app/stopwatch/StopwatchPage.qml (+3/-1)
debian/changelog (+1/-0)
tests/autopilot/ubuntu_clock_app/__init__.py (+104/-1)
tests/autopilot/ubuntu_clock_app/tests/test_alarm.py (+3/-2)
tests/autopilot/ubuntu_clock_app/tests/test_clock.py (+0/-1)
tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py (+50/-0)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/add-stopwatch-ap-tests
Reviewer Review Type Date Requested Status
Ubuntu Clock Developers Pending
Review via email: mp+287917@code.launchpad.net

Commit message

Added stopwatch tests

Description of the change

Added stopwatch tests

To post a comment you must log in.
465. By Nekhelesh Ramananthan

Added add lap and delete lap stopwatch tests

466. By Nekhelesh Ramananthan

Updated debian changelog

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/MainPage.qml'
2--- app/MainPage.qml 2016-03-03 00:28:40 +0000
3+++ app/MainPage.qml 2016-03-03 12:06:41 +0000
4@@ -107,13 +107,41 @@
5 }
6 }
7
8+
9+
10 ListView {
11 id: listview
12+ objectName: "pageListView"
13+
14+ property alias isMoving: moveAnimation.running
15+
16+ function moveToStopwatchPage() {
17+ moveAnimation.moveTo(listview.originX + listview.width)
18+ listview.currentIndex = 1
19+ }
20+
21+ function moveToClockPage() {
22+ moveAnimation.moveTo(listview.originX)
23+ listview.currentIndex = 0
24+ }
25+
26+ UbuntuNumberAnimation {
27+ id: moveAnimation
28+ objectName: "pageListViewAnimation"
29+
30+ target: listview
31+ property: "contentX"
32+ function moveTo(contentX) {
33+ from = listview.contentX
34+ to = contentX
35+ start()
36+ }
37+ }
38
39 // Show the stopwatch page on app startup if it is running
40 Component.onCompleted: {
41 if (stopwatchPage.isRunning) {
42- positionViewAtIndex(1, ListView.SnapPosition)
43+ moveToStopwatchPage()
44 }
45 }
46
47@@ -126,9 +154,6 @@
48
49 model: navigationModel
50 orientation: ListView.Horizontal
51- snapMode: ListView.SnapOneItem
52 interactive: false
53- highlightMoveDuration: UbuntuAnimation.BriskDuration
54- highlightRangeMode: ListView.StrictlyEnforceRange
55 }
56 }
57
58=== modified file 'app/components/HeaderNavigation.qml'
59--- app/components/HeaderNavigation.qml 2016-02-29 12:42:02 +0000
60+++ app/components/HeaderNavigation.qml 2016-03-03 12:06:41 +0000
61@@ -31,15 +31,21 @@
62 spacing: units.gu(2)
63
64 ActionIcon {
65+ id: clockNavigationButton
66+ objectName: "clockNavigationButton"
67+
68 icon.name: "clock"
69 icon.color: listview.currentIndex === 0 ? "#19b6ee" : "#5d5d5d" // #TODO: Replace with UbuntuColors.Blue and UbuntuColors.Slate after OTA-10
70- onClicked: listview.currentIndex = 0
71+ onClicked: listview.moveToClockPage()
72 }
73
74 ActionIcon {
75+ id: stopwatchNavigationButton
76+ objectName: "stopwatchNavigationButton"
77+
78 icon.name: "stopwatch"
79 icon.color: listview.currentIndex === 1 ? "#19b6ee" : "#5d5d5d" // #TODO: Replace with UbuntuColors.Blue and UbuntuColors.Slate after OTA-10
80- onClicked: listview.currentIndex = 1
81+ onClicked: listview.moveToStopwatchPage()
82 }
83 }
84
85
86=== modified file 'app/stopwatch/StopwatchFace.qml'
87--- app/stopwatch/StopwatchFace.qml 2016-03-02 12:04:48 +0000
88+++ app/stopwatch/StopwatchFace.qml 2016-03-03 12:06:41 +0000
89@@ -35,6 +35,7 @@
90
91 Label {
92 id: time
93+ objectName: "stopwatchTime"
94
95 text: stopwatchFormatTime.millisToTimeString(milliseconds, true)
96 font.pixelSize: units.dp(36)
97@@ -44,6 +45,7 @@
98
99 Label {
100 id: miliseconds
101+ objectName: "stopwatchMilliseconds"
102
103 text: stopwatchFormatTime.millisToString(milliseconds)
104 textSize: Label.Large
105
106=== modified file 'app/stopwatch/StopwatchPage.qml'
107--- app/stopwatch/StopwatchPage.qml 2016-02-25 22:16:54 +0000
108+++ app/stopwatch/StopwatchPage.qml 2016-03-03 12:06:41 +0000
109@@ -71,7 +71,8 @@
110 }
111
112 Button {
113- id: stopButton
114+ id: startStopButton
115+ objectName: "startAndStopButton"
116
117 width: parent.width / 2 - units.gu(1)
118 height: units.gu(4)
119@@ -94,6 +95,7 @@
120
121 Button {
122 id: lapButton
123+ objectName: "lapAndClearButton"
124
125 text: stopwatchEngine.running ? i18n.tr("Lap") : i18n.tr("Clear")
126 width: parent.width / 2 - units.gu(1)
127
128=== modified file 'debian/changelog'
129--- debian/changelog 2016-03-03 11:58:53 +0000
130+++ debian/changelog 2016-03-03 12:06:41 +0000
131@@ -4,6 +4,7 @@
132 * Dynamic loading of ListView in ExpandableListItem
133 * Removed all vertical positioning overrides of trailing icon in ListItem.
134 * Fixed failing autopilot tests in trunk (LP: #1552489)
135+ * Added Stopwatch autopilot tests (LP: #1490206)
136
137 -- Nekhelesh <krnekhelesh@nik90-laptop> Wed, 02 Mar 2016 19:30:48 +0100
138
139
140=== modified file 'tests/autopilot/ubuntu_clock_app/__init__.py'
141--- tests/autopilot/ubuntu_clock_app/__init__.py 2016-03-03 07:02:42 +0000
142+++ tests/autopilot/ubuntu_clock_app/__init__.py 2016-03-03 12:06:41 +0000
143@@ -20,7 +20,7 @@
144
145 from autopilot import logging as autopilot_logging
146 from autopilot.introspection import dbus
147-from testtools.matchers import GreaterThan
148+from testtools.matchers import (NotEquals, Equals, GreaterThan)
149
150 from ubuntuuitoolkit import (
151 MainView, UbuntuUIToolkitCustomProxyObjectBase, pickers, UCListItem)
152@@ -83,6 +83,18 @@
153 return self.wait_select_single("WorldCityList",
154 objectName="worldCityList")
155
156+ @autopilot_logging.log_action(logger.info)
157+ def open_stopwatch(self):
158+ """Open the Stopwatch Page.
159+
160+ :return: the Stopwatch Page.
161+
162+ """
163+ mainPage = self.get_main_page()
164+ mainPage.press_header_navigation_button(
165+ 'stopwatchNavigationButton')
166+ return self.wait_select_single(StopwatchPage)
167+
168
169 class Page(UbuntuUIToolkitCustomProxyObjectBase):
170 """Autopilot helper for Pages."""
171@@ -120,6 +132,97 @@
172 logger.error('BottomEdge element not found.')
173 raise
174
175+ def press_header_navigation_button(self, button_object_name):
176+ """Press the passed custom navigation button
177+
178+ :param button_object_name: Object name of navigation button
179+
180+ """
181+ navigation_button = self.wait_select_single(
182+ 'ActionIcon', objectName=button_object_name)
183+ self.pointing_device.click_object(navigation_button)
184+ page_list_view = self.wait_select_single(
185+ 'QQuickListView', objectName="pageListView")
186+ page_list_view.isMoving.wait_for(False)
187+
188+
189+class StopwatchPage(Page):
190+ """Autopilot helper for the Stopwatch page."""
191+
192+ @autopilot_logging.log_action(logger.info)
193+ def start_stopwatch(self):
194+ self._click_start_stop_button()
195+
196+ try:
197+ self._get_start_stop_button().text.wait_for("Stop")
198+ self._get_lap_clear_button().text.wait_for("Lap")
199+ self._get_stopwatch_time().text.wait_for(
200+ NotEquals("00:00:00"))
201+ self._get_stopwatch_milliseconds().text.wait_for(
202+ NotEquals("000"))
203+ except AssertionError:
204+ raise ClockEmulatorException(
205+ 'Incorrect stopwatch run state')
206+
207+ @autopilot_logging.log_action(logger.info)
208+ def stop_stopwatch(self):
209+ self._click_start_stop_button()
210+
211+ try:
212+ self._get_start_stop_button().text.wait_for("Resume")
213+ self._get_lap_clear_button().text.wait_for("Clear")
214+ except AssertionError:
215+ raise ClockEmulatorException(
216+ 'Incorrect stopwatch pause state')
217+
218+ @autopilot_logging.log_action(logger.info)
219+ def clear_stopwatch(self):
220+ self._click_lap_clear_button()
221+
222+ try:
223+ self._get_start_stop_button().text.wait_for("Start")
224+ self._get_stopwatch_time().text.wait_for(
225+ Equals("00:00:00"))
226+ self._get_stopwatch_milliseconds().text.wait_for(
227+ Equals("000"))
228+ except AssertionError:
229+ raise ClockEmulatorException(
230+ 'Invalid stopwatch clear state')
231+
232+ def _get_stopwatch_time(self):
233+ """Return the stopwatch time object"""
234+ stopwatch_time = self.wait_select_single(
235+ "UCLabel", objectName="stopwatchTime")
236+ return stopwatch_time
237+
238+ def _get_stopwatch_milliseconds(self):
239+ """Return the stopwatch milliseconds object"""
240+ stopwatch_milliseconds = self.wait_select_single(
241+ "UCLabel", objectName="stopwatchMilliseconds")
242+ return stopwatch_milliseconds
243+
244+ def _get_start_stop_button(self):
245+ """Return the start/stop button"""
246+ start_stop_button = self.wait_select_single(
247+ "Button", objectName="startAndStopButton")
248+ return start_stop_button
249+
250+ def _get_lap_clear_button(self):
251+ """Return the lap/clear button"""
252+ lap_clear_button = self.wait_select_single(
253+ "Button", objectName="lapAndClearButton")
254+ return lap_clear_button
255+
256+ def _click_start_stop_button(self):
257+ """Press the start/stop button"""
258+ start_stop_button = self._get_start_stop_button()
259+ self.pointing_device.click_object(start_stop_button)
260+
261+ def _click_lap_clear_button(self):
262+ """Press the lap/clear button"""
263+ lap_clear_button = self._get_lap_clear_button()
264+ self.pointing_device.click_object(lap_clear_button)
265+
266
267 class ClockPage(Page):
268 """Autopilot helper for the Clock page."""
269
270=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_alarm.py'
271--- tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2016-03-03 07:02:42 +0000
272+++ tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2016-03-03 12:06:41 +0000
273@@ -22,12 +22,13 @@
274
275 from autopilot.matchers import Eventually
276 from testtools.matchers import Equals
277+
278 from ubuntu_clock_app.tests import ClockAppTestCase
279
280
281 class TestAlarm(ClockAppTestCase):
282-
283 """Tests the alarm page features"""
284+
285 scenarios = [
286 ('random',
287 {'alarm_name': 'Random days Alarm Test',
288@@ -55,7 +56,7 @@
289 ]
290
291 def setUp(self):
292- """ This is needed to wait for the application to start.
293+ """This is needed to wait for the application to start.
294
295 In the testfarm, the application may take some time to show up.
296
297
298=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
299--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2016-03-03 00:28:40 +0000
300+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2016-03-03 12:06:41 +0000
301@@ -27,7 +27,6 @@
302
303
304 class TestClock(ClockAppTestCase):
305-
306 """Test the clock page features."""
307
308 def setUp(self):
309
310=== added file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py'
311--- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 1970-01-01 00:00:00 +0000
312+++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2016-03-03 12:06:41 +0000
313@@ -0,0 +1,50 @@
314+# Copyright (C) 2016 Canonical Ltd
315+#
316+# This file is part of Ubuntu Clock App
317+#
318+# Ubuntu Clock App is free software: you can redistribute it and/or modify
319+# it under the terms of the GNU General Public License version 3 as
320+# published by the Free Software Foundation.
321+#
322+# Ubuntu Clock App is distributed in the hope that it will be useful,
323+# but WITHOUT ANY WARRANTY; without even the implied warranty of
324+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
325+# GNU General Public License for more details.
326+#
327+# You should have received a copy of the GNU General Public License
328+# along with this program. If not, see <http://www.gnu.org/licenses/>.
329+
330+"""
331+Tests for the Clock App, stopwatch page.
332+"""
333+
334+from __future__ import absolute_import
335+
336+from autopilot.matchers import Eventually
337+from testtools.matchers import Equals
338+
339+from ubuntu_clock_app.tests import ClockAppTestCase
340+
341+
342+class TestStopwatch(ClockAppTestCase):
343+ """Tests the stopwatch feature"""
344+
345+ def setUp(self):
346+ """This is needed to wait for the application to start.
347+
348+ In the testfarm, the application may take some time to show up.
349+
350+ """
351+ super(TestStopwatch, self).setUp()
352+ self.assertThat(
353+ self.app.main_view.visible, Eventually(Equals(True)))
354+
355+ self.page = self.app.main_view.open_stopwatch()
356+
357+ def test_pressing_start_stop_button_starts_stops_stopwatch(self):
358+ """Test to check if stopwatch can be started and stopped using
359+ the UI buttons"""
360+
361+ self.page.start_stopwatch()
362+ self.page.stop_stopwatch()
363+ self.page.clear_stopwatch()

Subscribers

People subscribed via source and target branches