Merge lp:~nskaggs/dropping-letters/finish_elopio_branch into lp:dropping-letters
- finish_elopio_branch
- Merge into trunk
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Nicholas Skaggs | ||||||||||||
Approved revision: | 42 | ||||||||||||
Merged at revision: | 38 | ||||||||||||
Proposed branch: | lp:~nskaggs/dropping-letters/finish_elopio_branch | ||||||||||||
Merge into: | lp:dropping-letters | ||||||||||||
Diff against target: |
587 lines (+191/-228) 7 files modified
dropping-letters.qml (+17/-3) tests/autopilot/dropping_letters_app/emulators.py (+47/-0) tests/autopilot/dropping_letters_app/emulators/__init__.py (+0/-6) tests/autopilot/dropping_letters_app/emulators/main_window.py (+0/-33) tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py (+0/-155) tests/autopilot/dropping_letters_app/tests/__init__.py (+24/-17) tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py (+103/-14) |
||||||||||||
To merge this branch: | bzr merge lp:~nskaggs/dropping-letters/finish_elopio_branch | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Dropping Letters developers | Pending | ||
Review via email: mp+178147@code.launchpad.net |
Commit message
This closes all open bugs for autopilot tests. Implements new game test, intro screen test, and playing and selecting letters and words.
I have some concerns about not being able to truly test finishing a word and having it be correct -- there's no good way to do that that won't randomly fail; ie, waiting for letters you know will spell a word. The current version checks for the word being valid and asserts properly however.
Finally, grabbing the popover seemed impossible; thus a raw select is used as it's the only popover on the start screen. It works, but isn't ideal.
Description of the change
This closes all open bugs for autopilot tests. Implements new game test, intro screen test, and playing and selecting letters and words.
I have some concerns about not being able to truly test finishing a word and having it be correct -- there's no good way to do that that won't randomly fail; ie, waiting for letters you know will spell a word. The current version checks for the word being valid and asserts properly however.
Finally, grabbing the popover seemed impossible; thus a raw select is used as it's the only popover on the start screen. It works, but isn't ideal.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
- 41. By Nicholas Skaggs
-
tweak tile selection to account for indexing (3rd tiling attempting to be selected while still falling)
- 42. By Nicholas Skaggs
-
add timeouts to avoid infinite loops and nice asserts to go with it
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:41
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:42
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'dropping-letters.qml' |
2 | --- dropping-letters.qml 2013-07-31 18:33:19 +0000 |
3 | +++ dropping-letters.qml 2013-08-01 20:50:36 +0000 |
4 | @@ -27,8 +27,8 @@ |
5 | } |
6 | |
7 | Page { |
8 | - tools: ToolbarActions { |
9 | - Action { |
10 | + tools: ToolbarItems { |
11 | + ToolbarButton { |
12 | text: i18n.tr("Sound") |
13 | iconSource: (volume.audible ? "audio-volume-high-symbolic.svg" : "audio-volume-muted-symbolic.svg") |
14 | visible: volume.supportsMedia |
15 | @@ -36,7 +36,8 @@ |
16 | volume.audible = !volume.audible; |
17 | } |
18 | } |
19 | - Action { |
20 | + ToolbarButton { |
21 | + objectName: "new_game" |
22 | text: i18n.tr("New game") |
23 | iconSource: ("new.png") |
24 | onTriggered: { |
25 | @@ -133,6 +134,7 @@ |
26 | color: Qt.hsla(210/360, 0.84, 0.25 + ((4-parent.lineIndex) * 0.05) + ((4-index) * 0.05)); |
27 | //radius: "medium" |
28 | Label { |
29 | + objectName: "lettertile" |
30 | text: modelData |
31 | anchors.centerIn: parent |
32 | fontSize: "x-large" |
33 | @@ -179,6 +181,7 @@ |
34 | } |
35 | Label { |
36 | id: bestscore |
37 | + objectName: "bestscorelabel" |
38 | property int bestsofar: 0 |
39 | text: "..." |
40 | anchors.top: playbutton.bottom |
41 | @@ -196,10 +199,12 @@ |
42 | |
43 | Rectangle { |
44 | id: helpbutton |
45 | + objectName: "introhelpbutton" |
46 | width: units.gu(5) |
47 | height: units.gu(5) |
48 | radius: units.gu(1) |
49 | Label { |
50 | + objectName: "introhelplabel" |
51 | text: "?" |
52 | anchors.centerIn: parent |
53 | } |
54 | @@ -217,7 +222,9 @@ |
55 | id: helppop |
56 | Popover { |
57 | id: helpsheet |
58 | + objectName: "helpsheetpopover" |
59 | Rectangle { |
60 | + objectName: "helpsheetpopoverbox" |
61 | anchors.top: parent.top |
62 | anchors.left: parent.left |
63 | anchors.right: parent.right |
64 | @@ -225,6 +232,7 @@ |
65 | border.color: "#ddd" |
66 | radius: 2 |
67 | Label { |
68 | + objectName: "helpsheetpopoverlabel" |
69 | anchors.fill: parent |
70 | anchors.margins: units.gu(1) |
71 | text: "game by <a href='http://twitter.com/sil'>@sil</a><br>music: <a href='http://incompetech.com/music/royalty-free/index.html?isrc=USUAN1200076'>Easy Lemon</a> from Kevin McCloud (incompetech.com)<br>sounds: freesound from <a href='http://www.freesound.org/people/kantouth/sounds/106727/'>kantouth</a> / <a href='http://www.freesound.org/people/tictacshutup/sounds/407/'>tictacshutup</a> / <a href='http://www.freesound.org/people/dj-chronos/sounds/45137/'>dj-chronos</a> / <a href='http://www.freesound.org/people/justinbw/sounds/80921/'>justinbw</a>" |
72 | @@ -240,6 +248,7 @@ |
73 | |
74 | back: Rectangle { |
75 | id: main |
76 | + objectName: "lettersRectangles" |
77 | color: "#58585A" |
78 | width: flipable.width // 48 * 7 + 2 * 7 + 2 |
79 | height: flipable.height // 48 * 10 + 2 * 10 + 50 |
80 | @@ -330,6 +339,7 @@ |
81 | color: Qt.hsla(210/360, 0.84, 0.2) |
82 | |
83 | Item { |
84 | + objectName: "mainscore" |
85 | id: mainscore |
86 | anchors { |
87 | centerIn: bottombar |
88 | @@ -449,6 +459,7 @@ |
89 | |
90 | Label { |
91 | id: scoredisplay |
92 | + objectName: "scoredisplaylabel" |
93 | anchors.centerIn: parent |
94 | z: 3 |
95 | fontSize: "x-large" |
96 | @@ -519,6 +530,7 @@ |
97 | |
98 | Rectangle { |
99 | id: game |
100 | + objectName: "gametile" |
101 | property int squaresize: Math.min((flipable.width) / 7, (flipable.height - (flipable.minChromeHeight * 2)) / 10) |
102 | anchors.top: topbar.bottom |
103 | anchors.bottom: bottombar.top |
104 | @@ -548,6 +560,7 @@ |
105 | model: letters |
106 | Rectangle { |
107 | id: box |
108 | + objectName: "gametilebox" |
109 | property bool selected: false |
110 | property int idx: index |
111 | property string containedLetter: letter |
112 | @@ -569,6 +582,7 @@ |
113 | y: game.height + game.squaresize |
114 | z: 5 |
115 | Label { |
116 | + objectName: "gametilelabel" |
117 | anchors.centerIn: parent |
118 | text: letter |
119 | fontSize: "large" |
120 | |
121 | === removed directory 'tests/autopilot/dropping_letters_app/emulators' |
122 | === added file 'tests/autopilot/dropping_letters_app/emulators.py' |
123 | --- tests/autopilot/dropping_letters_app/emulators.py 1970-01-01 00:00:00 +0000 |
124 | +++ tests/autopilot/dropping_letters_app/emulators.py 2013-08-01 20:50:36 +0000 |
125 | @@ -0,0 +1,47 @@ |
126 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
127 | +# |
128 | +# Copyright (C) 2013 Canonical Ltd. |
129 | +# |
130 | +# This program is free software; you can redistribute it and/or modify |
131 | +# it under the terms of the GNU Lesser General Public License as published by |
132 | +# the Free Software Foundation; version 3. |
133 | +# |
134 | +# This program is distributed in the hope that it will be useful, |
135 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
136 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
137 | +# GNU Lesser General Public License for more details. |
138 | +# |
139 | +# You should have received a copy of the GNU Lesser General Public License |
140 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
141 | + |
142 | +from ubuntuuitoolkit import emulators as toolkit_emulators |
143 | + |
144 | + |
145 | +class MainView(toolkit_emulators.MainView): |
146 | + |
147 | + def get_main_score_label(self): |
148 | + item = self.select_single('QQuickItem', objectName='mainscore') |
149 | + return item.select_single('Label') |
150 | + |
151 | + def get_letter_tiles(self): |
152 | + item = self.select_many('QQuickRectangle', objectName='gametilebox') |
153 | + return item |
154 | + |
155 | + def get_word_label(self): |
156 | + item = self.select_single('Label', objectName='accumulate') |
157 | + return item |
158 | + |
159 | + def get_help_button(self): |
160 | + item = self.select_single('QQuickRectangle', objectName='introhelpbutton') |
161 | + return item |
162 | + |
163 | + def get_help_popover(self): |
164 | + #checking the popup seems to fail -- https://bugs.launchpad.net/autopilot/+bug/1195141? |
165 | + #we can't get the popup by objectname for ?? |
166 | + #this works OK because at the moment, there is only one popup -- needs fixed |
167 | + #item = self.select_single('Label', objectname='helpsheetpopoverlabel') |
168 | + #item = self.select_single('QQuickRectangle', objectname='helpsheetpopoverbox') |
169 | + #item = self.select_single('Popover', objectname='helpsheetpopover') |
170 | + |
171 | + item = self.select_single('Popover') |
172 | + return item |
173 | |
174 | === removed file 'tests/autopilot/dropping_letters_app/emulators/__init__.py' |
175 | --- tests/autopilot/dropping_letters_app/emulators/__init__.py 2013-07-10 18:26:02 +0000 |
176 | +++ tests/autopilot/dropping_letters_app/emulators/__init__.py 1970-01-01 00:00:00 +0000 |
177 | @@ -1,6 +0,0 @@ |
178 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
179 | -# Copyright 2013 Canonical |
180 | -# |
181 | -# This program is free software: you can redistribute it and/or modify it |
182 | -# under the terms of the GNU General Public License version 3, as published |
183 | -# by the Free Software Foundation. |
184 | |
185 | === removed file 'tests/autopilot/dropping_letters_app/emulators/main_window.py' |
186 | --- tests/autopilot/dropping_letters_app/emulators/main_window.py 2013-07-31 18:33:19 +0000 |
187 | +++ tests/autopilot/dropping_letters_app/emulators/main_window.py 1970-01-01 00:00:00 +0000 |
188 | @@ -1,33 +0,0 @@ |
189 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
190 | -# |
191 | -# Copyright (C) 2013 Canonical Ltd |
192 | -# |
193 | -# This program is free software: you can redistribute it and/or modify |
194 | -# it under the terms of the GNU General Public License version 3 as |
195 | -# published by the Free Software Foundation. |
196 | -# |
197 | -# This program is distributed in the hope that it will be useful, |
198 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
199 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
200 | -# GNU General Public License for more details. |
201 | -# |
202 | -# You should have received a copy of the GNU General Public License |
203 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
204 | -# |
205 | - |
206 | -"""Dropping Letters app autopilot emulators.""" |
207 | - |
208 | -class MainWindow(object): |
209 | - """An emulator class that makes it easy to interact with the Dropping |
210 | - Letters app.""" |
211 | - |
212 | - def __init__(self, app): |
213 | - self.app = app |
214 | - |
215 | - def get_main_view(self): |
216 | - """Get the main QML view""" |
217 | - return self.app.select_single("MainView", objectName="mainView") |
218 | - |
219 | - def get_qml_view(self): |
220 | - """Get the main QML view""" |
221 | - return self.app.select_single("QQuickView") |
222 | |
223 | === removed file 'tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py' |
224 | --- tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py 2013-07-26 07:38:40 +0000 |
225 | +++ tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000 |
226 | @@ -1,155 +0,0 @@ |
227 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
228 | -# |
229 | -# Copyright (C) 2013 Canonical Ltd |
230 | -# |
231 | -# This program is free software: you can redistribute it and/or modify |
232 | -# it under the terms of the GNU General Public License version 3 as |
233 | -# published by the Free Software Foundation. |
234 | -# |
235 | -# This program is distributed in the hope that it will be useful, |
236 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
237 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
238 | -# GNU General Public License for more details. |
239 | -# |
240 | -# You should have received a copy of the GNU General Public License |
241 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
242 | -# |
243 | -# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com> |
244 | - |
245 | - |
246 | -class ubuntusdk(object): |
247 | - """An emulator class that makes it easy to interact with the ubuntu sdk |
248 | - applications.""" |
249 | - |
250 | - def __init__(self, autopilot, app): |
251 | - self.app = app |
252 | - self.autopilot = autopilot |
253 | - |
254 | - def get_qml_view(self): |
255 | - """Get the main QML view""" |
256 | - return self.app.select_single("QQuickView") |
257 | - |
258 | - def get_object(self, typeName, name): |
259 | - """Get a specific object""" |
260 | - return self.app.select_single(typeName, objectName=name) |
261 | - |
262 | - def get_objects(self, typeName, name): |
263 | - """Get more than one object""" |
264 | - return self.app.select_many(typeName, objectName=name) |
265 | - |
266 | - def switch_to_tab(self, tab): |
267 | - """Switch to the specified tab number""" |
268 | - tabs = self.get_tabs() |
269 | - currentTab = tabs.selectedTabIndex |
270 | - |
271 | - #perform operations until tab == currentTab |
272 | - while tab != currentTab: |
273 | - if tab > currentTab: |
274 | - self._previous_tab() |
275 | - if tab < currentTab: |
276 | - self._next_tab() |
277 | - currentTab = tabs.selectedTabIndex |
278 | - |
279 | - def toggle_toolbar(self): |
280 | - """Toggle the toolbar between revealed and hidden""" |
281 | - #check and see if the toolbar is open or not |
282 | - if self.get_toolbar().opened: |
283 | - self.hide_toolbar() |
284 | - else: |
285 | - self.open_toolbar() |
286 | - |
287 | - def get_toolbar(self): |
288 | - """Returns the toolbar in the main events view.""" |
289 | - return self.app.select_single("Toolbar") |
290 | - |
291 | - def get_toolbar_button(self, buttonLabel): |
292 | - """Returns the toolbar button at position index""" |
293 | - toolbar = self.get_toolbar() |
294 | - if not toolbar.opened: |
295 | - self.open_toolbar() |
296 | - row = toolbar.select_single("ToolbarActions") |
297 | - loaderList = row.select_many("QQuickLoader") |
298 | - for loader in loaderList: |
299 | - buttonList = loader.select_many("Button") |
300 | - for button in buttonList: |
301 | - if button.text == buttonLabel: |
302 | - return button |
303 | - |
304 | - def click_toolbar_button(self, buttonLabel): |
305 | - """Clicks the toolbar button with buttonLabel""" |
306 | - #The toolbar button is assumed to be the following format |
307 | - #ToolbarActions { |
308 | - # Action { |
309 | - # objectName: "name" |
310 | - # text: value |
311 | - button = self.get_toolbar_button(buttonLabel) |
312 | - self.autopilot.pointing_device.click_object(button) |
313 | - |
314 | - def open_toolbar(self): |
315 | - """Open the toolbar""" |
316 | - qmlView = self.get_qml_view() |
317 | - |
318 | - lineX = int(qmlView.x + qmlView.width * 0.50) |
319 | - startY = int(qmlView.y + qmlView.height - 1) |
320 | - stopY = int(qmlView.y + qmlView.height * 0.95) |
321 | - |
322 | - self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY) |
323 | - |
324 | - def hide_toolbar(self): |
325 | - """Hide the toolbar""" |
326 | - qmlView = self.get_qml_view() |
327 | - |
328 | - lineX = int(qmlView.x + qmlView.width * 0.50) |
329 | - startY = int(qmlView.y + qmlView.height * 0.95) |
330 | - stopY = int(qmlView.y + qmlView.height - 1) |
331 | - |
332 | - self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY) |
333 | - |
334 | - def set_popup_value(self, popover, button, value): |
335 | - """Changes the given popover selector to the request value |
336 | - At the moment this only works for values that are currently visible. To |
337 | - access the remaining items, a help method to drag and recheck is |
338 | - needed.""" |
339 | - #The popover is assumed to be the following format |
340 | - # Popover { |
341 | - # Column { |
342 | - # ListView { |
343 | - # delegate: Standard { |
344 | - # objectName: "name" |
345 | - # text: value |
346 | - |
347 | - self.autopilot.pointing_device.click_object(button) |
348 | - #we'll get all matching objects, incase the popover is reused between |
349 | - # buttons |
350 | - itemList = lambda: self.get_objects("Standard", popover) |
351 | - |
352 | - for item in itemList(): |
353 | - if item.get_properties()['text'] == value: |
354 | - self.autopilot.pointing_device.click_object(item) |
355 | - |
356 | - def get_tabs(self): |
357 | - """Return all tabs""" |
358 | - return self.get_object("Tabs", "rootTabs") |
359 | - |
360 | - def _previous_tab(self): |
361 | - """Switch to the previous tab""" |
362 | - qmlView = self.get_qml_view() |
363 | - |
364 | - startX = int(qmlView.x + qmlView.width * 0.35) |
365 | - stopX = int(qmlView.x + qmlView.width * 0.50) |
366 | - lineY = int(qmlView.y + qmlView.height * 0.05) |
367 | - |
368 | - self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY) |
369 | - self.autopilot.pointing_device.click() |
370 | - self.autopilot.pointing_device.click() |
371 | - |
372 | - def _next_tab(self): |
373 | - """Switch to the next tab""" |
374 | - qmlView = self.get_qml_view() |
375 | - |
376 | - startX = int(qmlView.x + qmlView.width * 0.50) |
377 | - stopX = int(qmlView.x + qmlView.width * 0.35) |
378 | - lineY = int(qmlView.y + qmlView.height * 0.05) |
379 | - |
380 | - self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY) |
381 | - self.autopilot.pointing_device.click() |
382 | |
383 | === modified file 'tests/autopilot/dropping_letters_app/tests/__init__.py' |
384 | --- tests/autopilot/dropping_letters_app/tests/__init__.py 2013-07-26 07:38:40 +0000 |
385 | +++ tests/autopilot/dropping_letters_app/tests/__init__.py 2013-08-01 20:50:36 +0000 |
386 | @@ -1,9 +1,18 @@ |
387 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
388 | -# Copyright 2013 Canonical |
389 | -# |
390 | -# This program is free software: you can redistribute it and/or modify it |
391 | -# under the terms of the GNU General Public License version 3, as published |
392 | -# by the Free Software Foundation. |
393 | +# |
394 | +# Copyright (C) 2013 Canonical Ltd. |
395 | +# |
396 | +# This program is free software; you can redistribute it and/or modify |
397 | +# it under the terms of the GNU Lesser General Public License as published by |
398 | +# the Free Software Foundation; version 3. |
399 | +# |
400 | +# This program is distributed in the hope that it will be useful, |
401 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
402 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
403 | +# GNU Lesser General Public License for more details. |
404 | +# |
405 | +# You should have received a copy of the GNU Lesser General Public License |
406 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
407 | |
408 | """Dropping Letters app autopilot tests.""" |
409 | |
410 | @@ -13,8 +22,8 @@ |
411 | from autopilot.platform import model |
412 | from autopilot.testcase import AutopilotTestCase |
413 | |
414 | -from dropping_letters_app.emulators.main_window import MainWindow |
415 | -from dropping_letters_app.emulators.ubuntusdk import ubuntusdk |
416 | +from ubuntuuitoolkit import emulators as toolkit_emulators |
417 | +from dropping_letters_app import emulators |
418 | |
419 | |
420 | class DroppingLettersTestCase(AutopilotTestCase): |
421 | @@ -42,7 +51,8 @@ |
422 | self.app = self.launch_test_application( |
423 | "qmlscene", |
424 | self.local_location, |
425 | - app_type='qt') |
426 | + app_type='qt', |
427 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
428 | |
429 | def launch_test_installed(self): |
430 | self.app = self.launch_test_application( |
431 | @@ -50,12 +60,9 @@ |
432 | "/usr/share/dropping-letters/dropping-letters.qml", |
433 | "--desktop_file_hint=/usr/share/applications/" |
434 | "dropping-letters.desktop", |
435 | - app_type='qt') |
436 | - |
437 | - @property |
438 | - def main_window(self): |
439 | - return MainWindow(self.app) |
440 | - |
441 | - @property |
442 | - def ubuntusdk(self): |
443 | - return ubuntusdk(self, self.app) |
444 | + app_type='qt', |
445 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
446 | + |
447 | + @property |
448 | + def main_view(self): |
449 | + return self.app.select_single(emulators.MainView) |
450 | |
451 | === modified file 'tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py' |
452 | --- tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py 2013-07-31 18:33:19 +0000 |
453 | +++ tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py 2013-08-01 20:50:36 +0000 |
454 | @@ -1,18 +1,28 @@ |
455 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
456 | -# Copyright 2013 Canonical |
457 | -# |
458 | -# This program is free software: you can redistribute it and/or modify it |
459 | -# under the terms of the GNU General Public License version 3, as published |
460 | -# by the Free Software Foundation. |
461 | +# |
462 | +# Copyright (C) 2013 Canonical Ltd. |
463 | +# |
464 | +# This program is free software; you can redistribute it and/or modify |
465 | +# it under the terms of the GNU Lesser General Public License as published by |
466 | +# the Free Software Foundation; version 3. |
467 | +# |
468 | +# This program is distributed in the hope that it will be useful, |
469 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
470 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
471 | +# GNU Lesser General Public License for more details. |
472 | +# |
473 | +# You should have received a copy of the GNU Lesser General Public License |
474 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
475 | |
476 | """Dropping Letters app autopilot tests.""" |
477 | |
478 | from __future__ import absolute_import |
479 | |
480 | from autopilot.matchers import Eventually |
481 | -from testtools.matchers import Equals |
482 | +from testtools.matchers import Equals, NotEquals, LessThan |
483 | |
484 | from dropping_letters_app.tests import DroppingLettersTestCase |
485 | +from time import sleep |
486 | |
487 | |
488 | class TestMainWindow(DroppingLettersTestCase): |
489 | @@ -20,11 +30,90 @@ |
490 | def setUp(self): |
491 | super(TestMainWindow, self).setUp() |
492 | self.assertThat( |
493 | - self.main_window.get_qml_view().visible, Eventually(Equals(True))) |
494 | - |
495 | - def test_mainView_visible(self): |
496 | - self.assertThat( |
497 | - self.main_window.get_qml_view().visible, Eventually(Equals(True))) |
498 | - |
499 | - def tearDown(self): |
500 | - super(TestMainWindow, self).tearDown() |
501 | + self.main_view.visible, Eventually(Equals(True))) |
502 | + |
503 | + def _assert_game_screen(self): |
504 | + main_score_label = self.main_view.get_main_score_label() |
505 | + self.assertTrue(main_score_label.visible) |
506 | + |
507 | + def test_intro_screen(self): |
508 | + helpbutton = self.main_view.get_help_button() |
509 | + #check help button popup |
510 | + self.assertTrue(helpbutton.visible) |
511 | + |
512 | + #open the popup |
513 | + self.pointing_device.click_object(helpbutton) |
514 | + |
515 | + #check and ensure help popover appears |
516 | + helpPopover = self.main_view.get_help_popover() |
517 | + self.assertThat(lambda: helpPopover, Eventually(NotEquals(None))) |
518 | + properties = helpPopover.get_properties() |
519 | + self.assertTrue(properties["visible"]) |
520 | + |
521 | + #check and ensure help popover disappears |
522 | + self.pointing_device.click_object(helpbutton) |
523 | + helpPopover = self.main_view.get_help_popover() |
524 | + self.assertThat(lambda: helpPopover, Eventually(Equals(None))) |
525 | + |
526 | + def test_start_new_game(self): |
527 | + toolbar = self.main_view.open_toolbar() |
528 | + toolbar.click_button('new_game') |
529 | + self._assert_game_screen() |
530 | + main_score_label = self.main_view.get_main_score_label() |
531 | + self.assertEquals(main_score_label.text, '0') |
532 | + |
533 | + def test_finishing_a_word(self): |
534 | + #start game and close toolbar |
535 | + toolbar = self.main_view.open_toolbar() |
536 | + toolbar.click_button('new_game') |
537 | + self._assert_game_screen() |
538 | + toolbar = self.main_view.close_toolbar() |
539 | + |
540 | + #check for letters falling |
541 | + #select first 2 letters; wait for 3 letters to appear so first 2 are settled for clicking |
542 | + tiles = self.main_view.get_letter_tiles() |
543 | + while len(tiles) < 3: |
544 | + tiles = self.main_view.get_letter_tiles() |
545 | + |
546 | + #click the accumlated letters |
547 | + #check and make sure they get selected |
548 | + #add tries as a control to avoid infinite loop and provide better failure feedback |
549 | + tries = 0 |
550 | + self.pointing_device.click_object(tiles[0]) |
551 | + tileProperties = tiles[0].get_properties() |
552 | + while (tileProperties["selected"] == False and tries < 10): |
553 | + sleep(1) |
554 | + tries += 1 |
555 | + self.pointing_device.click_object(tiles[0]) |
556 | + tileProperties = tiles[0].get_properties() |
557 | + |
558 | + self.assertThat(tries, LessThan(10)) |
559 | + |
560 | + tries = 0 |
561 | + self.pointing_device.click_object(tiles[1]) |
562 | + tileProperties = tiles[1].get_properties() |
563 | + while (tileProperties["selected"] == False and tries < 10): |
564 | + sleep(1) |
565 | + tries += 1 |
566 | + self.pointing_device.click_object(tiles[1]) |
567 | + tileProperties = tiles[1].get_properties() |
568 | + |
569 | + self.assertThat(tries, LessThan(10)) |
570 | + |
571 | + #check the text to make sure it's the same |
572 | + wordValue = tiles[0].containedLetter + tiles[1].containedLetter |
573 | + word = self.main_view.get_word_label() |
574 | + self.assertEquals(word.text, wordValue) |
575 | + |
576 | + #click to complete word |
577 | + validWord = word.isValid |
578 | + self.pointing_device.click_object(word) |
579 | + |
580 | + #depending on if the property isValid is true or not, score should increase or stay the same after completion |
581 | + #we don't need to get fancy, since the start value is 0; check for zero or non-zero score |
582 | + main_score_label = self.main_view.get_main_score_label() |
583 | + if validWord: |
584 | + self.assertNotEquals(main_score_label.text, '0') |
585 | + else: |
586 | + self.assertEquals(main_score_label.text, '0') |
587 | + |
PASSED: Continuous integration, rev:40 91.189. 93.70:8080/ job/dropping- letters- ci/3/ 91.189. 93.70:8080/ job/dropping- letters- precise- amd64-ci/ 3 91.189. 93.70:8080/ job/dropping- letters- quantal- amd64-ci/ 3 91.189. 93.70:8080/ job/dropping- letters- raring- amd64-ci/ 3 91.189. 93.70:8080/ job/dropping- letters- saucy-amd64- ci/3
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/dropping- letters- ci/3/rebuild
http://