Merge lp:~nik90/ubuntu-clock-app/add-stopwatch-ap-tests into lp:ubuntu-clock-app
- add-stopwatch-ap-tests
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Bartosz Kosiorek | ||||
Approved revision: | 466 | ||||
Merged at revision: | 456 | ||||
Proposed branch: | lp:~nik90/ubuntu-clock-app/add-stopwatch-ap-tests | ||||
Merge into: | lp:ubuntu-clock-app | ||||
Prerequisite: | lp:~nik90/ubuntu-clock-app/fix-failing-ap-tests | ||||
Diff against target: |
634 lines (+367/-61) 12 files modified
app/MainPage.qml (+30/-3) app/components/HeaderNavigation.qml (+8/-2) app/stopwatch/CMakeLists.txt (+1/-0) app/stopwatch/LapListView.qml (+12/-51) app/stopwatch/LapsListDelegate.qml (+81/-0) app/stopwatch/StopwatchFace.qml (+2/-0) app/stopwatch/StopwatchPage.qml (+4/-1) debian/changelog (+3/-0) tests/autopilot/ubuntu_clock_app/__init__.py (+160/-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 (+63/-0) |
||||
To merge this branch: | bzr merge lp:~nik90/ubuntu-clock-app/add-stopwatch-ap-tests | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Bartosz Kosiorek | Approve | ||
Michal Predotka | Approve | ||
Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+287919@code.launchpad.net |
Commit message
Added 3 stopwatch tests,
- Tests to checking adding/deleting laps
- Test to check if stopwatch state meets design during run, pause and stop state
- Moved laps list item delegate into its own file LapsListDelegat
- Changed page switch code to be compatible with autopilot (no visual change)
Description of the change
Added stopwatch tests
IMPORTANT NOTE: In order to detect that stopwatchPage has fully loaded in Autopilot, it was necessary to rewrite the page switch code in MainPage.qml. Rest assured it isn't too much of a code change. That said, test the UX and see if it is *exactly* the same as before.
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote : | # |
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:465
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 466. By Nekhelesh Ramananthan
-
Updated debian changelog
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:466
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:466
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Michal Predotka (mpredotka) wrote : | # |
It works the same from a user point of view. QML code looks good to me.
Bartosz Kosiorek (gang65) wrote : | # |
I tested that branch and it is working perfectly for me.
I didn't notice any regression.
Preview Diff
1 | === modified file 'app/MainPage.qml' | |||
2 | --- app/MainPage.qml 2016-03-03 00:28:40 +0000 | |||
3 | +++ app/MainPage.qml 2016-03-03 14:51:35 +0000 | |||
4 | @@ -107,13 +107,42 @@ | |||
5 | 107 | } | 107 | } |
6 | 108 | } | 108 | } |
7 | 109 | 109 | ||
8 | 110 | |||
9 | 111 | |||
10 | 110 | ListView { | 112 | ListView { |
11 | 111 | id: listview | 113 | id: listview |
12 | 114 | objectName: "pageListView" | ||
13 | 115 | |||
14 | 116 | // Property required only in autopilot to check if listitem has finished moving | ||
15 | 117 | property alias isMoving: moveAnimation.running | ||
16 | 118 | |||
17 | 119 | function moveToStopwatchPage() { | ||
18 | 120 | moveAnimation.moveTo(listview.originX + listview.width) | ||
19 | 121 | listview.currentIndex = 1 | ||
20 | 122 | } | ||
21 | 123 | |||
22 | 124 | function moveToClockPage() { | ||
23 | 125 | moveAnimation.moveTo(listview.originX) | ||
24 | 126 | listview.currentIndex = 0 | ||
25 | 127 | } | ||
26 | 128 | |||
27 | 129 | UbuntuNumberAnimation { | ||
28 | 130 | id: moveAnimation | ||
29 | 131 | objectName: "pageListViewAnimation" | ||
30 | 132 | |||
31 | 133 | target: listview | ||
32 | 134 | property: "contentX" | ||
33 | 135 | function moveTo(contentX) { | ||
34 | 136 | from = listview.contentX | ||
35 | 137 | to = contentX | ||
36 | 138 | start() | ||
37 | 139 | } | ||
38 | 140 | } | ||
39 | 112 | 141 | ||
40 | 113 | // Show the stopwatch page on app startup if it is running | 142 | // Show the stopwatch page on app startup if it is running |
41 | 114 | Component.onCompleted: { | 143 | Component.onCompleted: { |
42 | 115 | if (stopwatchPage.isRunning) { | 144 | if (stopwatchPage.isRunning) { |
44 | 116 | positionViewAtIndex(1, ListView.SnapPosition) | 145 | moveToStopwatchPage() |
45 | 117 | } | 146 | } |
46 | 118 | } | 147 | } |
47 | 119 | 148 | ||
48 | @@ -128,7 +157,5 @@ | |||
49 | 128 | orientation: ListView.Horizontal | 157 | orientation: ListView.Horizontal |
50 | 129 | snapMode: ListView.SnapOneItem | 158 | snapMode: ListView.SnapOneItem |
51 | 130 | interactive: false | 159 | interactive: false |
52 | 131 | highlightMoveDuration: UbuntuAnimation.BriskDuration | ||
53 | 132 | highlightRangeMode: ListView.StrictlyEnforceRange | ||
54 | 133 | } | 160 | } |
55 | 134 | } | 161 | } |
56 | 135 | 162 | ||
57 | === modified file 'app/components/HeaderNavigation.qml' | |||
58 | --- app/components/HeaderNavigation.qml 2016-02-29 12:42:02 +0000 | |||
59 | +++ app/components/HeaderNavigation.qml 2016-03-03 14:51:35 +0000 | |||
60 | @@ -31,15 +31,21 @@ | |||
61 | 31 | spacing: units.gu(2) | 31 | spacing: units.gu(2) |
62 | 32 | 32 | ||
63 | 33 | ActionIcon { | 33 | ActionIcon { |
64 | 34 | id: clockNavigationButton | ||
65 | 35 | objectName: "clockNavigationButton" | ||
66 | 36 | |||
67 | 34 | icon.name: "clock" | 37 | icon.name: "clock" |
68 | 35 | icon.color: listview.currentIndex === 0 ? "#19b6ee" : "#5d5d5d" // #TODO: Replace with UbuntuColors.Blue and UbuntuColors.Slate after OTA-10 | 38 | icon.color: listview.currentIndex === 0 ? "#19b6ee" : "#5d5d5d" // #TODO: Replace with UbuntuColors.Blue and UbuntuColors.Slate after OTA-10 |
70 | 36 | onClicked: listview.currentIndex = 0 | 39 | onClicked: listview.moveToClockPage() |
71 | 37 | } | 40 | } |
72 | 38 | 41 | ||
73 | 39 | ActionIcon { | 42 | ActionIcon { |
74 | 43 | id: stopwatchNavigationButton | ||
75 | 44 | objectName: "stopwatchNavigationButton" | ||
76 | 45 | |||
77 | 40 | icon.name: "stopwatch" | 46 | icon.name: "stopwatch" |
78 | 41 | icon.color: listview.currentIndex === 1 ? "#19b6ee" : "#5d5d5d" // #TODO: Replace with UbuntuColors.Blue and UbuntuColors.Slate after OTA-10 | 47 | icon.color: listview.currentIndex === 1 ? "#19b6ee" : "#5d5d5d" // #TODO: Replace with UbuntuColors.Blue and UbuntuColors.Slate after OTA-10 |
80 | 42 | onClicked: listview.currentIndex = 1 | 48 | onClicked: listview.moveToStopwatchPage() |
81 | 43 | } | 49 | } |
82 | 44 | } | 50 | } |
83 | 45 | 51 | ||
84 | 46 | 52 | ||
85 | === modified file 'app/stopwatch/CMakeLists.txt' | |||
86 | --- app/stopwatch/CMakeLists.txt 2015-08-25 01:02:54 +0000 | |||
87 | +++ app/stopwatch/CMakeLists.txt 2016-03-03 14:51:35 +0000 | |||
88 | @@ -1,5 +1,6 @@ | |||
89 | 1 | set(STOPWATCH_QML_JS_FILES | 1 | set(STOPWATCH_QML_JS_FILES |
90 | 2 | LapListView.qml | 2 | LapListView.qml |
91 | 3 | LapsListDelegate.qml | ||
92 | 3 | StopwatchFace.qml | 4 | StopwatchFace.qml |
93 | 4 | StopwatchPage.qml | 5 | StopwatchPage.qml |
94 | 5 | ) | 6 | ) |
95 | 6 | 7 | ||
96 | === modified file 'app/stopwatch/LapListView.qml' | |||
97 | --- app/stopwatch/LapListView.qml 2016-02-26 10:00:54 +0000 | |||
98 | +++ app/stopwatch/LapListView.qml 2016-03-03 14:51:35 +0000 | |||
99 | @@ -20,11 +20,10 @@ | |||
100 | 20 | import Ubuntu.Components 1.3 | 20 | import Ubuntu.Components 1.3 |
101 | 21 | import Stopwatch 1.0 | 21 | import Stopwatch 1.0 |
102 | 22 | 22 | ||
104 | 23 | UbuntuListView { | 23 | ListView { |
105 | 24 | id: lapListView | 24 | id: lapListView |
106 | 25 | 25 | ||
107 | 26 | clip: true | 26 | clip: true |
108 | 27 | currentIndex: -1 | ||
109 | 28 | 27 | ||
110 | 29 | StopwatchFormatTime { | 28 | StopwatchFormatTime { |
111 | 30 | id: stopwatchFormatTime | 29 | id: stopwatchFormatTime |
112 | @@ -75,18 +74,18 @@ | |||
113 | 75 | } | 74 | } |
114 | 76 | } | 75 | } |
115 | 77 | 76 | ||
118 | 78 | delegate: ListItem { | 77 | delegate: LapsListDelegate { |
119 | 79 | divider.visible: true | 78 | id: lapsListItem |
120 | 79 | objectName: "lapsListItem" + index | ||
121 | 80 | |||
122 | 80 | divider.anchors.leftMargin: units.gu(2) | 81 | divider.anchors.leftMargin: units.gu(2) |
123 | 81 | divider.anchors.right: parent.right | ||
124 | 82 | divider.anchors.rightMargin: units.gu(2) | 82 | divider.anchors.rightMargin: units.gu(2) |
125 | 83 | 83 | ||
126 | 84 | width: parent.width | ||
127 | 85 | anchors.horizontalCenter: parent.horizontalCenter | ||
128 | 86 | |||
129 | 87 | leadingActions: ListItemActions { | 84 | leadingActions: ListItemActions { |
130 | 88 | actions: [ | 85 | actions: [ |
131 | 89 | Action { | 86 | Action { |
132 | 87 | id: swipeDeleteAction | ||
133 | 88 | objectName: "swipeDeleteAction" | ||
134 | 90 | iconName: "delete" | 89 | iconName: "delete" |
135 | 91 | onTriggered: { | 90 | onTriggered: { |
136 | 92 | stopwatchEngine.removeLap(index) | 91 | stopwatchEngine.removeLap(index) |
137 | @@ -95,48 +94,10 @@ | |||
138 | 95 | ] | 94 | ] |
139 | 96 | } | 95 | } |
140 | 97 | 96 | ||
184 | 98 | Row { | 97 | indexLabel: "#%1".arg(Number(count - index).toLocaleString(Qt.locale(), "f", 0)) |
185 | 99 | anchors { | 98 | lapTimeLabel: stopwatchFormatTime.lapTimeToString(model.laptime) + "." |
186 | 100 | left: parent.left | 99 | lapMilliTimeLabel: stopwatchFormatTime.millisToString(model.laptime) |
187 | 101 | right: parent.right | 100 | totalTimeLabel: stopwatchFormatTime.lapTimeToString(model.totaltime) + "." |
188 | 102 | verticalCenter: parent.verticalCenter | 101 | totalMilliTimeLabel: stopwatchFormatTime.millisToString(model.totaltime) |
146 | 103 | leftMargin: units.gu(3) | ||
147 | 104 | rightMargin: units.gu(2) | ||
148 | 105 | } | ||
149 | 106 | |||
150 | 107 | Label { | ||
151 | 108 | text: "#%1".arg(Number(count - index).toLocaleString(Qt.locale(), "f", 0)) | ||
152 | 109 | width: parent.width / 5 | ||
153 | 110 | horizontalAlignment: Text.AlignLeft | ||
154 | 111 | } | ||
155 | 112 | |||
156 | 113 | Item { | ||
157 | 114 | width: 2* parent.width / 5 | ||
158 | 115 | height: childrenRect.height | ||
159 | 116 | Row { | ||
160 | 117 | anchors.horizontalCenter: parent.horizontalCenter | ||
161 | 118 | Label { | ||
162 | 119 | text: stopwatchFormatTime.lapTimeToString(model.laptime) + "." | ||
163 | 120 | } | ||
164 | 121 | Label { | ||
165 | 122 | text: stopwatchFormatTime.millisToString(model.laptime) | ||
166 | 123 | } | ||
167 | 124 | } | ||
168 | 125 | } | ||
169 | 126 | |||
170 | 127 | Item { | ||
171 | 128 | width: 2 * parent.width / 5 | ||
172 | 129 | height: childrenRect.height | ||
173 | 130 | Row { | ||
174 | 131 | anchors.right: parent.right | ||
175 | 132 | Label { | ||
176 | 133 | text: stopwatchFormatTime.lapTimeToString(model.totaltime) + "." | ||
177 | 134 | } | ||
178 | 135 | Label { | ||
179 | 136 | text: stopwatchFormatTime.millisToString(model.totaltime) | ||
180 | 137 | } | ||
181 | 138 | } | ||
182 | 139 | } | ||
183 | 140 | } | ||
189 | 141 | } | 102 | } |
190 | 142 | } | 103 | } |
191 | 143 | 104 | ||
192 | === added file 'app/stopwatch/LapsListDelegate.qml' | |||
193 | --- app/stopwatch/LapsListDelegate.qml 1970-01-01 00:00:00 +0000 | |||
194 | +++ app/stopwatch/LapsListDelegate.qml 2016-03-03 14:51:35 +0000 | |||
195 | @@ -0,0 +1,81 @@ | |||
196 | 1 | /* | ||
197 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
198 | 3 | * | ||
199 | 4 | * This file is part of Ubuntu Clock App | ||
200 | 5 | * | ||
201 | 6 | * Ubuntu Clock App is free software: you can redistribute it and/or modify | ||
202 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
203 | 8 | * published by the Free Software Foundation. | ||
204 | 9 | * | ||
205 | 10 | * Ubuntu Clock App is distributed in the hope that it will be useful, | ||
206 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
207 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
208 | 13 | * GNU General Public License for more details. | ||
209 | 14 | * | ||
210 | 15 | * You should have received a copy of the GNU General Public License | ||
211 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
212 | 17 | */ | ||
213 | 18 | |||
214 | 19 | |||
215 | 20 | import QtQuick 2.4 | ||
216 | 21 | import Ubuntu.Components 1.3 | ||
217 | 22 | |||
218 | 23 | ListItem { | ||
219 | 24 | id: lapsListItem | ||
220 | 25 | |||
221 | 26 | property string indexLabel | ||
222 | 27 | property string lapTimeLabel | ||
223 | 28 | property string lapMilliTimeLabel | ||
224 | 29 | property string totalTimeLabel | ||
225 | 30 | property string totalMilliTimeLabel | ||
226 | 31 | |||
227 | 32 | Row { | ||
228 | 33 | anchors { | ||
229 | 34 | left: parent.left | ||
230 | 35 | right: parent.right | ||
231 | 36 | verticalCenter: parent.verticalCenter | ||
232 | 37 | leftMargin: units.gu(3) | ||
233 | 38 | rightMargin: units.gu(2) | ||
234 | 39 | } | ||
235 | 40 | |||
236 | 41 | Label { | ||
237 | 42 | id: _indexLabel | ||
238 | 43 | text: indexLabel | ||
239 | 44 | width: parent.width / 5 | ||
240 | 45 | horizontalAlignment: Text.AlignLeft | ||
241 | 46 | } | ||
242 | 47 | |||
243 | 48 | Item { | ||
244 | 49 | id: lapTimeContainer | ||
245 | 50 | width: 2* parent.width / 5 | ||
246 | 51 | height: childrenRect.height | ||
247 | 52 | Row { | ||
248 | 53 | anchors.horizontalCenter: parent.horizontalCenter | ||
249 | 54 | Label { | ||
250 | 55 | id: _lapTimeLabel | ||
251 | 56 | text: lapTimeLabel | ||
252 | 57 | } | ||
253 | 58 | Label { | ||
254 | 59 | id: _lapMilliTimeLabel | ||
255 | 60 | text: lapMilliTimeLabel | ||
256 | 61 | } | ||
257 | 62 | } | ||
258 | 63 | } | ||
259 | 64 | |||
260 | 65 | Item { | ||
261 | 66 | width: 2 * parent.width / 5 | ||
262 | 67 | height: childrenRect.height | ||
263 | 68 | Row { | ||
264 | 69 | anchors.right: parent.right | ||
265 | 70 | Label { | ||
266 | 71 | id: _totalTimeLabel | ||
267 | 72 | text: totalTimeLabel | ||
268 | 73 | } | ||
269 | 74 | Label { | ||
270 | 75 | id: _totalMilliTimeLabel | ||
271 | 76 | text: totalMilliTimeLabel | ||
272 | 77 | } | ||
273 | 78 | } | ||
274 | 79 | } | ||
275 | 80 | } | ||
276 | 81 | } | ||
277 | 0 | 82 | ||
278 | === modified file 'app/stopwatch/StopwatchFace.qml' | |||
279 | --- app/stopwatch/StopwatchFace.qml 2016-03-02 12:04:48 +0000 | |||
280 | +++ app/stopwatch/StopwatchFace.qml 2016-03-03 14:51:35 +0000 | |||
281 | @@ -35,6 +35,7 @@ | |||
282 | 35 | 35 | ||
283 | 36 | Label { | 36 | Label { |
284 | 37 | id: time | 37 | id: time |
285 | 38 | objectName: "stopwatchTime" | ||
286 | 38 | 39 | ||
287 | 39 | text: stopwatchFormatTime.millisToTimeString(milliseconds, true) | 40 | text: stopwatchFormatTime.millisToTimeString(milliseconds, true) |
288 | 40 | font.pixelSize: units.dp(36) | 41 | font.pixelSize: units.dp(36) |
289 | @@ -44,6 +45,7 @@ | |||
290 | 44 | 45 | ||
291 | 45 | Label { | 46 | Label { |
292 | 46 | id: miliseconds | 47 | id: miliseconds |
293 | 48 | objectName: "stopwatchMilliseconds" | ||
294 | 47 | 49 | ||
295 | 48 | text: stopwatchFormatTime.millisToString(milliseconds) | 50 | text: stopwatchFormatTime.millisToString(milliseconds) |
296 | 49 | textSize: Label.Large | 51 | textSize: Label.Large |
297 | 50 | 52 | ||
298 | === modified file 'app/stopwatch/StopwatchPage.qml' | |||
299 | --- app/stopwatch/StopwatchPage.qml 2016-02-25 22:16:54 +0000 | |||
300 | +++ app/stopwatch/StopwatchPage.qml 2016-03-03 14:51:35 +0000 | |||
301 | @@ -71,7 +71,8 @@ | |||
302 | 71 | } | 71 | } |
303 | 72 | 72 | ||
304 | 73 | Button { | 73 | Button { |
306 | 74 | id: stopButton | 74 | id: startStopButton |
307 | 75 | objectName: "startAndStopButton" | ||
308 | 75 | 76 | ||
309 | 76 | width: parent.width / 2 - units.gu(1) | 77 | width: parent.width / 2 - units.gu(1) |
310 | 77 | height: units.gu(4) | 78 | height: units.gu(4) |
311 | @@ -94,6 +95,7 @@ | |||
312 | 94 | 95 | ||
313 | 95 | Button { | 96 | Button { |
314 | 96 | id: lapButton | 97 | id: lapButton |
315 | 98 | objectName: "lapAndClearButton" | ||
316 | 97 | 99 | ||
317 | 98 | text: stopwatchEngine.running ? i18n.tr("Lap") : i18n.tr("Clear") | 100 | text: stopwatchEngine.running ? i18n.tr("Lap") : i18n.tr("Clear") |
318 | 99 | width: parent.width / 2 - units.gu(1) | 101 | width: parent.width / 2 - units.gu(1) |
319 | @@ -138,6 +140,7 @@ | |||
320 | 138 | id: lapListViewComponent | 140 | id: lapListViewComponent |
321 | 139 | LapListView { | 141 | LapListView { |
322 | 140 | id: lapListView | 142 | id: lapListView |
323 | 143 | objectName: "lapsList" | ||
324 | 141 | model: stopwatchEngine | 144 | model: stopwatchEngine |
325 | 142 | } | 145 | } |
326 | 143 | } | 146 | } |
327 | 144 | 147 | ||
328 | === modified file 'debian/changelog' | |||
329 | --- debian/changelog 2016-03-03 11:58:53 +0000 | |||
330 | +++ debian/changelog 2016-03-03 14:51:35 +0000 | |||
331 | @@ -4,6 +4,9 @@ | |||
332 | 4 | * Dynamic loading of ListView in ExpandableListItem | 4 | * Dynamic loading of ListView in ExpandableListItem |
333 | 5 | * Removed all vertical positioning overrides of trailing icon in ListItem. | 5 | * Removed all vertical positioning overrides of trailing icon in ListItem. |
334 | 6 | * Fixed failing autopilot tests in trunk (LP: #1552489) | 6 | * Fixed failing autopilot tests in trunk (LP: #1552489) |
335 | 7 | * Added Stopwatch autopilot tests for adding/deleting laps, checking | ||
336 | 8 | start, pause and stop stopwatch states. (LP: #1490206) | ||
337 | 9 | * Moved laps list delegate into its own file | ||
338 | 7 | 10 | ||
339 | 8 | -- Nekhelesh <krnekhelesh@nik90-laptop> Wed, 02 Mar 2016 19:30:48 +0100 | 11 | -- Nekhelesh <krnekhelesh@nik90-laptop> Wed, 02 Mar 2016 19:30:48 +0100 |
340 | 9 | 12 | ||
341 | 10 | 13 | ||
342 | === modified file 'tests/autopilot/ubuntu_clock_app/__init__.py' | |||
343 | --- tests/autopilot/ubuntu_clock_app/__init__.py 2016-03-03 07:02:42 +0000 | |||
344 | +++ tests/autopilot/ubuntu_clock_app/__init__.py 2016-03-03 14:51:35 +0000 | |||
345 | @@ -20,7 +20,7 @@ | |||
346 | 20 | 20 | ||
347 | 21 | from autopilot import logging as autopilot_logging | 21 | from autopilot import logging as autopilot_logging |
348 | 22 | from autopilot.introspection import dbus | 22 | from autopilot.introspection import dbus |
350 | 23 | from testtools.matchers import GreaterThan | 23 | from testtools.matchers import (NotEquals, Equals, GreaterThan) |
351 | 24 | 24 | ||
352 | 25 | from ubuntuuitoolkit import ( | 25 | from ubuntuuitoolkit import ( |
353 | 26 | MainView, UbuntuUIToolkitCustomProxyObjectBase, pickers, UCListItem) | 26 | MainView, UbuntuUIToolkitCustomProxyObjectBase, pickers, UCListItem) |
354 | @@ -83,6 +83,18 @@ | |||
355 | 83 | return self.wait_select_single("WorldCityList", | 83 | return self.wait_select_single("WorldCityList", |
356 | 84 | objectName="worldCityList") | 84 | objectName="worldCityList") |
357 | 85 | 85 | ||
358 | 86 | @autopilot_logging.log_action(logger.info) | ||
359 | 87 | def open_stopwatch(self): | ||
360 | 88 | """Open the Stopwatch Page. | ||
361 | 89 | |||
362 | 90 | :return: the Stopwatch Page. | ||
363 | 91 | |||
364 | 92 | """ | ||
365 | 93 | mainPage = self.get_main_page() | ||
366 | 94 | mainPage.press_header_navigation_button( | ||
367 | 95 | 'stopwatchNavigationButton') | ||
368 | 96 | return self.wait_select_single(StopwatchPage) | ||
369 | 97 | |||
370 | 86 | 98 | ||
371 | 87 | class Page(UbuntuUIToolkitCustomProxyObjectBase): | 99 | class Page(UbuntuUIToolkitCustomProxyObjectBase): |
372 | 88 | """Autopilot helper for Pages.""" | 100 | """Autopilot helper for Pages.""" |
373 | @@ -120,6 +132,153 @@ | |||
374 | 120 | logger.error('BottomEdge element not found.') | 132 | logger.error('BottomEdge element not found.') |
375 | 121 | raise | 133 | raise |
376 | 122 | 134 | ||
377 | 135 | def press_header_navigation_button(self, button_object_name): | ||
378 | 136 | """Press the passed custom navigation button | ||
379 | 137 | |||
380 | 138 | :param button_object_name: Object name of navigation button | ||
381 | 139 | |||
382 | 140 | """ | ||
383 | 141 | navigation_button = self.wait_select_single( | ||
384 | 142 | 'ActionIcon', objectName=button_object_name) | ||
385 | 143 | self.pointing_device.click_object(navigation_button) | ||
386 | 144 | page_list_view = self.wait_select_single( | ||
387 | 145 | 'QQuickListView', objectName="pageListView") | ||
388 | 146 | page_list_view.isMoving.wait_for(False) | ||
389 | 147 | |||
390 | 148 | |||
391 | 149 | class StopwatchPage(Page): | ||
392 | 150 | """Autopilot helper for the Stopwatch page.""" | ||
393 | 151 | |||
394 | 152 | @autopilot_logging.log_action(logger.info) | ||
395 | 153 | def start_stopwatch(self): | ||
396 | 154 | self._click_start_stop_button() | ||
397 | 155 | |||
398 | 156 | try: | ||
399 | 157 | self._get_start_stop_button().text.wait_for("Stop") | ||
400 | 158 | self._get_lap_clear_button().text.wait_for("Lap") | ||
401 | 159 | self._get_stopwatch_time().text.wait_for( | ||
402 | 160 | NotEquals("00:00:00")) | ||
403 | 161 | self._get_stopwatch_milliseconds().text.wait_for( | ||
404 | 162 | NotEquals("000")) | ||
405 | 163 | except AssertionError: | ||
406 | 164 | raise ClockEmulatorException( | ||
407 | 165 | 'Incorrect stopwatch run state') | ||
408 | 166 | |||
409 | 167 | @autopilot_logging.log_action(logger.info) | ||
410 | 168 | def stop_stopwatch(self): | ||
411 | 169 | self._click_start_stop_button() | ||
412 | 170 | |||
413 | 171 | try: | ||
414 | 172 | self._get_start_stop_button().text.wait_for("Resume") | ||
415 | 173 | self._get_lap_clear_button().text.wait_for("Clear") | ||
416 | 174 | self._get_stopwatch_time().text.wait_for( | ||
417 | 175 | NotEquals("00:00:00")) | ||
418 | 176 | self._get_stopwatch_milliseconds().text.wait_for( | ||
419 | 177 | NotEquals("000")) | ||
420 | 178 | except AssertionError: | ||
421 | 179 | raise ClockEmulatorException( | ||
422 | 180 | 'Incorrect stopwatch pause state') | ||
423 | 181 | |||
424 | 182 | @autopilot_logging.log_action(logger.info) | ||
425 | 183 | def clear_stopwatch(self): | ||
426 | 184 | self._click_lap_clear_button() | ||
427 | 185 | |||
428 | 186 | try: | ||
429 | 187 | self._get_start_stop_button().text.wait_for("Start") | ||
430 | 188 | self._get_stopwatch_time().text.wait_for( | ||
431 | 189 | Equals("00:00:00")) | ||
432 | 190 | self._get_stopwatch_milliseconds().text.wait_for( | ||
433 | 191 | Equals("000")) | ||
434 | 192 | except AssertionError: | ||
435 | 193 | raise ClockEmulatorException( | ||
436 | 194 | 'Invalid stopwatch clear state') | ||
437 | 195 | |||
438 | 196 | @autopilot_logging.log_action(logger.info) | ||
439 | 197 | def add_lap(self): | ||
440 | 198 | old_count = self._get_laps_count() | ||
441 | 199 | self._click_lap_clear_button() | ||
442 | 200 | |||
443 | 201 | try: | ||
444 | 202 | self._get_laps_list_view().count.wait_for( | ||
445 | 203 | Equals(old_count + 1)) | ||
446 | 204 | except AssertionError: | ||
447 | 205 | raise ClockEmulatorException( | ||
448 | 206 | 'Laps count did not increase on pressing the add lap \ | ||
449 | 207 | button') | ||
450 | 208 | |||
451 | 209 | @autopilot_logging.log_action(logger.info) | ||
452 | 210 | def delete_lap(self, index): | ||
453 | 211 | old_count = self._get_laps_count() | ||
454 | 212 | laps_list = self._get_laps_list_view() | ||
455 | 213 | |||
456 | 214 | lap = laps_list.wait_select_single( | ||
457 | 215 | "LapsListDelegate", objectName="lapsListItem{}".format(index)) | ||
458 | 216 | lap.click_remove_action() | ||
459 | 217 | |||
460 | 218 | try: | ||
461 | 219 | self._get_laps_list_view().count.wait_for( | ||
462 | 220 | Equals(old_count - 1)) | ||
463 | 221 | except AssertionError: | ||
464 | 222 | raise ClockEmulatorException( | ||
465 | 223 | 'Laps count did not decrease on deleting the lap') | ||
466 | 224 | |||
467 | 225 | def _get_laps_count(self): | ||
468 | 226 | return int(self._get_laps_list_view().count) | ||
469 | 227 | |||
470 | 228 | def _get_laps_list_view(self): | ||
471 | 229 | return self.wait_select_single("QQuickListView", | ||
472 | 230 | objectName="lapsList") | ||
473 | 231 | |||
474 | 232 | @autopilot_logging.log_action(logger.info) | ||
475 | 233 | def clean_up_test(self): | ||
476 | 234 | if self._get_start_stop_button().text == "Stop": | ||
477 | 235 | self._click_start_stop_button() | ||
478 | 236 | |||
479 | 237 | if self._get_lap_clear_button().text == "Clear": | ||
480 | 238 | self._click_lap_clear_button() | ||
481 | 239 | |||
482 | 240 | def _get_stopwatch_time(self): | ||
483 | 241 | """Return the stopwatch time object""" | ||
484 | 242 | stopwatch_time = self.wait_select_single( | ||
485 | 243 | "UCLabel", objectName="stopwatchTime") | ||
486 | 244 | return stopwatch_time | ||
487 | 245 | |||
488 | 246 | def _get_stopwatch_milliseconds(self): | ||
489 | 247 | """Return the stopwatch milliseconds object""" | ||
490 | 248 | stopwatch_milliseconds = self.wait_select_single( | ||
491 | 249 | "UCLabel", objectName="stopwatchMilliseconds") | ||
492 | 250 | return stopwatch_milliseconds | ||
493 | 251 | |||
494 | 252 | def _get_start_stop_button(self): | ||
495 | 253 | """Return the start/stop button""" | ||
496 | 254 | start_stop_button = self.wait_select_single( | ||
497 | 255 | "Button", objectName="startAndStopButton") | ||
498 | 256 | return start_stop_button | ||
499 | 257 | |||
500 | 258 | def _get_lap_clear_button(self): | ||
501 | 259 | """Return the lap/clear button""" | ||
502 | 260 | lap_clear_button = self.wait_select_single( | ||
503 | 261 | "Button", objectName="lapAndClearButton") | ||
504 | 262 | return lap_clear_button | ||
505 | 263 | |||
506 | 264 | def _click_start_stop_button(self): | ||
507 | 265 | """Press the start/stop button""" | ||
508 | 266 | start_stop_button = self._get_start_stop_button() | ||
509 | 267 | self.pointing_device.click_object(start_stop_button) | ||
510 | 268 | |||
511 | 269 | def _click_lap_clear_button(self): | ||
512 | 270 | """Press the lap/clear button""" | ||
513 | 271 | lap_clear_button = self._get_lap_clear_button() | ||
514 | 272 | self.pointing_device.click_object(lap_clear_button) | ||
515 | 273 | |||
516 | 274 | |||
517 | 275 | class LapsListDelegate(UCListItem): | ||
518 | 276 | """Autopilot helper for laps list delegate""" | ||
519 | 277 | |||
520 | 278 | def click_remove_action(self): | ||
521 | 279 | return self.trigger_leading_action('swipeDeleteAction', | ||
522 | 280 | self.wait_until_destroyed) | ||
523 | 281 | |||
524 | 123 | 282 | ||
525 | 124 | class ClockPage(Page): | 283 | class ClockPage(Page): |
526 | 125 | """Autopilot helper for the Clock page.""" | 284 | """Autopilot helper for the Clock page.""" |
527 | 126 | 285 | ||
528 | === modified file 'tests/autopilot/ubuntu_clock_app/tests/test_alarm.py' | |||
529 | --- tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2016-03-03 07:02:42 +0000 | |||
530 | +++ tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2016-03-03 14:51:35 +0000 | |||
531 | @@ -22,12 +22,13 @@ | |||
532 | 22 | 22 | ||
533 | 23 | from autopilot.matchers import Eventually | 23 | from autopilot.matchers import Eventually |
534 | 24 | from testtools.matchers import Equals | 24 | from testtools.matchers import Equals |
535 | 25 | |||
536 | 25 | from ubuntu_clock_app.tests import ClockAppTestCase | 26 | from ubuntu_clock_app.tests import ClockAppTestCase |
537 | 26 | 27 | ||
538 | 27 | 28 | ||
539 | 28 | class TestAlarm(ClockAppTestCase): | 29 | class TestAlarm(ClockAppTestCase): |
540 | 29 | |||
541 | 30 | """Tests the alarm page features""" | 30 | """Tests the alarm page features""" |
542 | 31 | |||
543 | 31 | scenarios = [ | 32 | scenarios = [ |
544 | 32 | ('random', | 33 | ('random', |
545 | 33 | {'alarm_name': 'Random days Alarm Test', | 34 | {'alarm_name': 'Random days Alarm Test', |
546 | @@ -55,7 +56,7 @@ | |||
547 | 55 | ] | 56 | ] |
548 | 56 | 57 | ||
549 | 57 | def setUp(self): | 58 | def setUp(self): |
551 | 58 | """ This is needed to wait for the application to start. | 59 | """This is needed to wait for the application to start. |
552 | 59 | 60 | ||
553 | 60 | In the testfarm, the application may take some time to show up. | 61 | In the testfarm, the application may take some time to show up. |
554 | 61 | 62 | ||
555 | 62 | 63 | ||
556 | === modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py' | |||
557 | --- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2016-03-03 00:28:40 +0000 | |||
558 | +++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2016-03-03 14:51:35 +0000 | |||
559 | @@ -27,7 +27,6 @@ | |||
560 | 27 | 27 | ||
561 | 28 | 28 | ||
562 | 29 | class TestClock(ClockAppTestCase): | 29 | class TestClock(ClockAppTestCase): |
563 | 30 | |||
564 | 31 | """Test the clock page features.""" | 30 | """Test the clock page features.""" |
565 | 32 | 31 | ||
566 | 33 | def setUp(self): | 32 | def setUp(self): |
567 | 34 | 33 | ||
568 | === added file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py' | |||
569 | --- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 1970-01-01 00:00:00 +0000 | |||
570 | +++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2016-03-03 14:51:35 +0000 | |||
571 | @@ -0,0 +1,63 @@ | |||
572 | 1 | # Copyright (C) 2016 Canonical Ltd | ||
573 | 2 | # | ||
574 | 3 | # This file is part of Ubuntu Clock App | ||
575 | 4 | # | ||
576 | 5 | # Ubuntu Clock App is free software: you can redistribute it and/or modify | ||
577 | 6 | # it under the terms of the GNU General Public License version 3 as | ||
578 | 7 | # published by the Free Software Foundation. | ||
579 | 8 | # | ||
580 | 9 | # Ubuntu Clock App is distributed in the hope that it will be useful, | ||
581 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
582 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
583 | 12 | # GNU General Public License for more details. | ||
584 | 13 | # | ||
585 | 14 | # You should have received a copy of the GNU General Public License | ||
586 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
587 | 16 | |||
588 | 17 | """ | ||
589 | 18 | Tests for the Clock App, stopwatch page. | ||
590 | 19 | """ | ||
591 | 20 | |||
592 | 21 | from __future__ import absolute_import | ||
593 | 22 | |||
594 | 23 | from autopilot.matchers import Eventually | ||
595 | 24 | from testtools.matchers import Equals | ||
596 | 25 | |||
597 | 26 | from ubuntu_clock_app.tests import ClockAppTestCase | ||
598 | 27 | |||
599 | 28 | |||
600 | 29 | class TestStopwatch(ClockAppTestCase): | ||
601 | 30 | """Tests the stopwatch feature""" | ||
602 | 31 | |||
603 | 32 | def setUp(self): | ||
604 | 33 | """This is needed to wait for the application to start. | ||
605 | 34 | |||
606 | 35 | In the testfarm, the application may take some time to show up. | ||
607 | 36 | |||
608 | 37 | """ | ||
609 | 38 | super(TestStopwatch, self).setUp() | ||
610 | 39 | self.assertThat( | ||
611 | 40 | self.app.main_view.visible, Eventually(Equals(True))) | ||
612 | 41 | |||
613 | 42 | self.page = self.app.main_view.open_stopwatch() | ||
614 | 43 | |||
615 | 44 | def test_pressing_gui_button_starts_stops_clears_stopwatch(self): | ||
616 | 45 | """Test to check if stopwatch can be started, stopped and | ||
617 | 46 | cleared using the UI buttons""" | ||
618 | 47 | |||
619 | 48 | self.page.start_stopwatch() | ||
620 | 49 | self.page.stop_stopwatch() | ||
621 | 50 | self.page.clear_stopwatch() | ||
622 | 51 | |||
623 | 52 | def test_pressing_lap_button_adds_laps(self): | ||
624 | 53 | """Test to check if stopwatch laps can be created""" | ||
625 | 54 | self.page.start_stopwatch() | ||
626 | 55 | self.page.add_lap() | ||
627 | 56 | self.page.clean_up_test() | ||
628 | 57 | |||
629 | 58 | def test_swipe_delete_button_deletes_laps(self): | ||
630 | 59 | """Test to check if laps can be deleted by swiping right""" | ||
631 | 60 | self.page.start_stopwatch() | ||
632 | 61 | self.page.add_lap() | ||
633 | 62 | self.page.delete_lap(0) | ||
634 | 63 | self.page.clean_up_test() |
PASSED: Continuous integration, rev:464 /core-apps- jenkins. ubuntu. com/job/ clock-app- ci/88/ /core-apps- jenkins. ubuntu. com/job/ generic- update- mp/677/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /core-apps- jenkins. ubuntu. com/job/ clock-app- ci/88/rebuild
https:/