Merge lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into lp:sudoku-app
- convert-ap-tests-to-sdk
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Dinko Osmankovic | ||||||||
Approved revision: | 126 | ||||||||
Merged at revision: | 126 | ||||||||
Proposed branch: | lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk | ||||||||
Merge into: | lp:sudoku-app | ||||||||
Diff against target: |
1288 lines (+378/-641) 7 files modified
debian/control (+2/-1) tests/autopilot/sudoku_app/emulators.py (+154/-0) tests/autopilot/sudoku_app/emulators/__init__.py (+0/-6) tests/autopilot/sudoku_app/emulators/main_window.py (+0/-158) tests/autopilot/sudoku_app/emulators/ubuntusdk.py (+0/-163) tests/autopilot/sudoku_app/tests/__init__.py (+60/-57) tests/autopilot/sudoku_app/tests/test_sudoku.py (+162/-256) |
||||||||
To merge this branch: | bzr merge lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dinko Osmankovic | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+187945@code.launchpad.net |
Commit message
Convert tests to sdk and add click support
Description of the change
This ports the tests to the sdk, and in general cleans them up a bit. Also click support for running tests has been added. There is likely still more tweaks that can be done here. One test is disable due to a critical bug and should be re-enabled once the bug is closed.
- 120. By Nicholas Skaggs
-
typo in test_click :-)
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Dinko Osmankovic (dinko-metalac) wrote : | # |
Can you merge in new code from trunk and try out the CI? I think I fixed the bug with new game, so you can enable that test again.
Nicholas Skaggs (nskaggs) wrote : | # |
Sure thing dinko, let me remerge and push.
- 121. By Nicholas Skaggs
-
merge upstream fixes for https:/
/bugs.launchpad .net/sudoku- app/+bug/ 1231700
and re-enable test
Nicholas Skaggs (nskaggs) wrote : | # |
Looks like your fix works great, and I re-enabled the test.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:121
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Dinko Osmankovic (dinko-metalac) wrote : | # |
Hahaha now settings tab test fails...
Dinko Osmankovic (dinko-metalac) wrote : | # |
Hahaha, it seems your counting abilities failed you :D
- 122. By Nicholas Skaggs
-
ensure themeChoices exists before grabbing
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:121
http://
Executed test runs:
None: http://
None: http://
None: http://
None: http://
None: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:122
http://
Executed test runs:
UNSTABLE: http://
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 : | # |
FAILED: Continuous integration, rev:122
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Dinko Osmankovic (dinko-metalac) wrote : | # |
Why it fails now? Looks like jenkins gone mad...
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:122
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Omer Akram (om26er) wrote : | # |
that's a problem with tab switching emulators in the UIToolkit. elopio is
working on it.
On Tue, Oct 1, 2013 at 6:42 PM, Ubuntu Phone Apps Jenkins Bot <
<email address hidden>> wrote:
> Review: Needs Fixing continuous-
>
> FAILED: Continuous integration, rev:122
> http://
> Executed test runs:
> UNSTABLE: http://
> SUCCESS: http://
> SUCCESS: http://
> SUCCESS: http://
> SUCCESS: http://
>
> Click here to trigger a rebuild:
> http://
>
> --
>
> https:/
> Your team Sudoku Touch developers is requested to review the proposed
> merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into lp:sudoku-app.
>
Dinko Osmankovic (dinko-metalac) wrote : | # |
@om26er: It seems that's not the only problem. After watching videos I concluded that it seems that database is not empty (previous configuration stays) which should not happen. fginther implemented that part on purpose.
Omer Akram (om26er) wrote : | # |
Dinko, right. but from the logs all the failures suggest that the tab
switching was not successful.
On Tue, Oct 1, 2013 at 6:48 PM, Dinko Osmankovic <email address hidden>wrote:
> @om26er: It seems that's not the only problem. After watching videos I
> concluded that it seems that database is not empty (previous configuration
> stays) which should not happen. fginther implemented that part on purpose.
> --
>
> https:/
> Your team Sudoku Touch developers is requested to review the proposed
> merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into lp:sudoku-app.
>
Dinko Osmankovic (dinko-metalac) wrote : | # |
I you see the video you can guess the reason. The new game dialog pops up
and the tabs are under the dialog. It should not happen in default
configuration. But, who knows, maybe the database remove-restoration
mechanism is also affected by the jenkins issue.
On Tue, Oct 1, 2013 at 3:51 PM, Omer Akram <email address hidden> wrote:
> Dinko, right. but from the logs all the failures suggest that the tab
> switching was not successful.
>
>
> On Tue, Oct 1, 2013 at 6:48 PM, Dinko Osmankovic <<email address hidden>
> >wrote:
>
> > @om26er: It seems that's not the only problem. After watching videos I
> > concluded that it seems that database is not empty (previous
> configuration
> > stays) which should not happen. fginther implemented that part on
> purpose.
> > --
> >
> >
> https:/
> > Your team Sudoku Touch developers is requested to review the proposed
> > merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into
> lp:sudoku-app.
> >
>
> --
>
> https:/
> Your team Sudoku Touch developers is requested to review the proposed
> merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into lp:sudoku-app.
>
Omer Akram (om26er) wrote : | # |
right, just saw the videos. probably the database removal code needs
tweaking, it might be missing some condition.
On Tue, Oct 1, 2013 at 6:57 PM, Dinko Osmankovic <email address hidden>wrote:
> I you see the video you can guess the reason. The new game dialog pops up
> and the tabs are under the dialog. It should not happen in default
> configuration. But, who knows, maybe the database remove-restoration
> mechanism is also affected by the jenkins issue.
>
>
> On Tue, Oct 1, 2013 at 3:51 PM, Omer Akram <email address hidden> wrote:
>
> > Dinko, right. but from the logs all the failures suggest that the tab
> > switching was not successful.
> >
> >
> > On Tue, Oct 1, 2013 at 6:48 PM, Dinko Osmankovic <
> <email address hidden>
> > >wrote:
> >
> > > @om26er: It seems that's not the only problem. After watching videos I
> > > concluded that it seems that database is not empty (previous
> > configuration
> > > stays) which should not happen. fginther implemented that part on
> > purpose.
> > > --
> > >
> > >
> >
> https:/
> > > Your team Sudoku Touch developers is requested to review the proposed
> > > merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into
> > lp:sudoku-app.
> > >
> >
> > --
> >
> >
> https:/
> > Your team Sudoku Touch developers is requested to review the proposed
> > merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into
> lp:sudoku-app.
> >
>
> --
>
> https:/
> Your team Sudoku Touch developers is requested to review the proposed
> merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into lp:sudoku-app.
>
Nicholas Skaggs (nskaggs) wrote : | # |
I've got to tweak the db removal code; it has some issues beyond this potential failure. I too saw what dinko saw and grew concerned.
- 123. By Nicholas Skaggs
-
fix db backup/restore logic
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:123
http://
Executed test runs:
UNSTABLE: http://
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 : | # |
FAILED: Continuous integration, rev:123
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 124. By Nicholas Skaggs
-
swith to getting tab by name for highscorestab
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:124
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 125. By Nicholas Skaggs
-
update sqlite dir
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:125
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 126. By Nicholas Skaggs
-
fix typo
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:125
http://
Executed test runs:
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:126
http://
Executed test runs:
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:126
http://
Executed test runs:
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:126
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
SUCCESS! :-)
Dinko Osmankovic (dinko-metalac) wrote : | # |
Yeeeeeee! Party time :D
On 3 Oct 2013 20:01, "Nicholas Skaggs" <email address hidden>
wrote:
> SUCCESS! :-)
> --
>
> https:/
> Your team Sudoku Touch developers is requested to review the proposed
> merge of lp:~nskaggs/sudoku-app/convert-ap-tests-to-sdk into lp:sudoku-app.
>
Dinko Osmankovic (dinko-metalac) : | # |
Loïc Minier (lool) wrote : | # |
It would have been better not to hardcode the new pathname... Now these tests may only run with the updated SDK, not the "old" one which means they need to land together.
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2013-07-12 20:05:03 +0000 |
3 | +++ debian/control 2013-10-03 17:33:06 +0000 |
4 | @@ -2,7 +2,7 @@ |
5 | Section: games |
6 | Priority: extra |
7 | Maintainer: Dinko Osmankovic <dinko.metalac@gmail.com> |
8 | -Build-Depends: debhelper (>= 9), |
9 | +Build-Depends: debhelper (>= 9), |
10 | gettext, |
11 | Standards-Version: 3.9.4 |
12 | Homepage: http://launchpad.net/sudoku-app |
13 | @@ -26,6 +26,7 @@ |
14 | Architecture: all |
15 | Depends: libautopilot-qt, |
16 | libqt5test5, |
17 | + ubuntu-ui-toolkit-autopilot, |
18 | sudoku-app (= ${source:Version}) |
19 | Description: Autopilot UI tests for sudoku game for Ubuntu devices |
20 | This package contains the autopilot tests for the Sudoku App |
21 | |
22 | === removed directory 'tests/autopilot/sudoku_app/emulators' |
23 | === added file 'tests/autopilot/sudoku_app/emulators.py' |
24 | --- tests/autopilot/sudoku_app/emulators.py 1970-01-01 00:00:00 +0000 |
25 | +++ tests/autopilot/sudoku_app/emulators.py 2013-10-03 17:33:06 +0000 |
26 | @@ -0,0 +1,154 @@ |
27 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
28 | +# Copyright 2013 Canonical |
29 | +# |
30 | +# This program is free software: you can redistribute it and/or modify it |
31 | +# under the terms of the GNU General Public License version 3, as published |
32 | +# by the Free Software Foundation. |
33 | + |
34 | +"""Sudoku app autopilot emulators.""" |
35 | + |
36 | +from autopilot.introspection.dbus import StateNotFoundError |
37 | +from ubuntuuitoolkit import emulators as toolkit_emulators |
38 | + |
39 | + |
40 | +class MainView(toolkit_emulators.MainView): |
41 | + |
42 | + def get_blank_inputs(self): |
43 | + #generate a list of blank input fields from the game board |
44 | + #SudokuBlocksGrid->..->SudokuButton->QQuickTest->enabled == true |
45 | + inputs = self.select_single("SudokuBlocksGrid") |
46 | + blankInputsList = inputs.select_many("QQuickText", enabled=True) |
47 | + return blankInputsList |
48 | + |
49 | + def get_dialog_button(self, name): |
50 | + numberdialog = self.get_number_dialog() |
51 | + |
52 | + #SudokuDialogButton->QQuickText text = |
53 | + button = numberdialog.select_single("QQuickText",text=name) |
54 | + return button |
55 | + |
56 | + def get_number_dialog(self): |
57 | + return self.select_single("Dialog", objectName="picknumberscreen") |
58 | + |
59 | + def get_hints_switch(self): |
60 | + return self.select_single("CheckBox", objectName="hintsSwitch") |
61 | + |
62 | + #clicking on this works instead on the previous one (get_hints_switch) it doesn't(but the previous |
63 | + #has the clicked property so I am using both |
64 | + def get_hints_switchClickable(self): |
65 | + return self.select_single("Standard", objectName="hintsSwitchClickable") |
66 | + |
67 | + def get_difficulty_selector(self): |
68 | + return self.select_single("ValueSelector", objectName="difficultySelector") |
69 | + |
70 | + def get_difficulty_selector_labelvisual(self): |
71 | + difficultylabelvisual = self.get_difficulty_selector() |
72 | + difficutlylabelvisualList = difficultylabelvisual.select_many("LabelVisual", visible="True") |
73 | + return difficutlylabelvisualList |
74 | + |
75 | + def get_theme_selector(self): |
76 | + return self.select_single("ValueSelector", objectName="themeSelector") |
77 | + |
78 | + def get_theme_selector_labelvisual(self): |
79 | + themelabelvisual = self.get_theme_selector() |
80 | + themelabelvisualList = themelabelvisual.select_many("LabelVisual", visible="True") |
81 | + return themelabelvisualList |
82 | + |
83 | + def get_current_profile(self): |
84 | + return self.select_single("SingleValue", objectName="Current profile") |
85 | + |
86 | + def get_sudoku_user_profile(self): |
87 | + return self.select_single("Standard", text="Sudoku User") |
88 | + |
89 | + def get_user_profile_cancel_button(self): |
90 | + return self.select_single("Button", objectName="profileCancelButton") |
91 | + |
92 | + def get_add_profile(self): |
93 | + return self.select_single("SingleValue", objectName="Add profile") |
94 | + |
95 | + def get_add_profile_dialog(self): |
96 | + return self.select_single("Dialog", objectName="Add new profile") |
97 | + |
98 | + def get_add_profile_Lastname_field(self): |
99 | + return self.select_single("TextField", objectName = "Lastname") |
100 | + |
101 | + def get_add_profile_Firstname_field(self): |
102 | + return self.select_single("TextField", objectName = "Firstname") |
103 | + |
104 | + def get_add_profile_OKbutton(self): |
105 | + return self.select_single("SudokuDialogButton", objectName = "OKbutton") |
106 | + |
107 | + def get_manage_profiles(self): |
108 | + return self.select_single("SingleValue", objectName = "Manage profiles") |
109 | + |
110 | + def get_Myfirstname_Mylastname_profile(self): |
111 | + return self.select_single("Standard", text="Myfirstname Mylastname") |
112 | + |
113 | + def get_edit_profile_dialog(self): |
114 | + return self.select_single("Dialog", objectName="Edit profile") |
115 | + |
116 | + def get_edit_profile_delete_button(self): |
117 | + return self.select_single("SudokuDialogButton", objectName ="deleteButton") |
118 | + |
119 | + def get_new_game_easy_button(self): |
120 | + return self.select_single("NewGameSelectionButton", objectName ="easyGameButton") |
121 | + |
122 | + def get_new_game_moderate_button(self): |
123 | + return self.select_single("NewGameSelectionButton", objectName ="moderateGameButton") |
124 | + |
125 | + def get_new_game_hard_button(self): |
126 | + return self.select_single("NewGameSelectionButton", objectName ="hardGameButton") |
127 | + |
128 | + def get_new_game_ultrahard_button(self): |
129 | + return self.select_single("NewGameSelectionButton", objectName ="ultrahardGameButton") |
130 | + |
131 | + def get_new_game_button(self, objectName): |
132 | + return self.select_single("NewGameSelectionButton", objectName = objectName) |
133 | + |
134 | + def try_OK_Button(self): |
135 | + try: |
136 | + return self.get_add_profile_OKbutton().buttonText |
137 | + except StateNotFoundError: |
138 | + return None |
139 | + |
140 | + def try_manage_profile(self): |
141 | + try: |
142 | + return self.get_manage_profiles().text |
143 | + except StateNotFoundError: |
144 | + return None |
145 | + |
146 | + def try_delete_Button(self): |
147 | + try: |
148 | + return self.get_edit_profile_delete_button().buttonText |
149 | + except StateNotFoundError: |
150 | + return None |
151 | + |
152 | + def try_new_game_easy_button(self): |
153 | + try: |
154 | + return self.get_new_game_easy_button().buttonText |
155 | + except StateNotFoundError: |
156 | + return None |
157 | + |
158 | + def try_new_game_moderate_button(self): |
159 | + try: |
160 | + return self.get_new_game_moderate_button().buttonText |
161 | + except StateNotFoundError: |
162 | + return None |
163 | + |
164 | + def try_new_game_hard_button(self): |
165 | + try: |
166 | + return self.get_new_game_hard_button().buttonText |
167 | + except StateNotFoundError: |
168 | + return None |
169 | + |
170 | + def try_new_game_ultrahard_button(self): |
171 | + try: |
172 | + return self.get_new_game_ultrahard_button().buttonText |
173 | + except StateNotFoundError: |
174 | + return None |
175 | + |
176 | + def try_my_profile(self): |
177 | + try: |
178 | + return self.get_Myfirstname_Mylastname_profile().text |
179 | + except StateNotFoundError: |
180 | + return None |
181 | |
182 | === removed file 'tests/autopilot/sudoku_app/emulators/__init__.py' |
183 | --- tests/autopilot/sudoku_app/emulators/__init__.py 2013-07-08 18:15:44 +0000 |
184 | +++ tests/autopilot/sudoku_app/emulators/__init__.py 1970-01-01 00:00:00 +0000 |
185 | @@ -1,6 +0,0 @@ |
186 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
187 | -# Copyright 2013 Canonical |
188 | -# |
189 | -# This program is free software: you can redistribute it and/or modify it |
190 | -# under the terms of the GNU General Public License version 3, as published |
191 | -# by the Free Software Foundation. |
192 | \ No newline at end of file |
193 | |
194 | === removed file 'tests/autopilot/sudoku_app/emulators/main_window.py' |
195 | --- tests/autopilot/sudoku_app/emulators/main_window.py 2013-08-19 07:20:22 +0000 |
196 | +++ tests/autopilot/sudoku_app/emulators/main_window.py 1970-01-01 00:00:00 +0000 |
197 | @@ -1,158 +0,0 @@ |
198 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
199 | -# Copyright 2013 Canonical |
200 | -# |
201 | -# This program is free software: you can redistribute it and/or modify it |
202 | -# under the terms of the GNU General Public License version 3, as published |
203 | -# by the Free Software Foundation. |
204 | - |
205 | -"""Sudoku app autopilot emulators.""" |
206 | - |
207 | -from autopilot.introspection.dbus import StateNotFoundError |
208 | - |
209 | -class MainWindow(object): |
210 | - """An emulator class that makes it easy to interact with the |
211 | - sudoku-app. |
212 | - |
213 | - """ |
214 | - def __init__(self, app): |
215 | - self.app = app |
216 | - |
217 | - def get_blank_inputs(self): |
218 | - #generate a list of blank input fields from the game board |
219 | - #SudokuBlocksGrid->..->SudokuButton->QQuickTest->enabled == true |
220 | - inputs = self.app.select_single("SudokuBlocksGrid") |
221 | - blankInputsList = inputs.select_many("QQuickText", enabled=True) |
222 | - return blankInputsList |
223 | - |
224 | - def get_dialog_button(self, name): |
225 | - numberdialog = self.get_number_dialog() |
226 | - |
227 | - #SudokuDialogButton->QQuickText text = |
228 | - button = numberdialog.select_single("QQuickText",text=name) |
229 | - return button |
230 | - |
231 | - def get_number_dialog(self): |
232 | - return self.app.select_single("Dialog", objectName="picknumberscreen") |
233 | - |
234 | - def get_hints_switch(self): |
235 | - return self.app.select_single("CheckBox", objectName="hintsSwitch") |
236 | - |
237 | - #clicking on this works instead on the previous one (get_hints_switch) it doesn't(but the previous |
238 | - #has the clicked property so I am using both |
239 | - def get_hints_switchClickable(self): |
240 | - return self.app.select_single("Standard", objectName="hintsSwitchClickable") |
241 | - |
242 | - def get_difficulty_selector(self): |
243 | - return self.app.select_single("ValueSelector", objectName="difficultySelector") |
244 | - |
245 | - def get_difficulty_selector_labelvisual(self): |
246 | - difficultylabelvisual = self.get_difficulty_selector() |
247 | - difficutlylabelvisualList = difficultylabelvisual.select_many("LabelVisual", visible="True") |
248 | - return difficutlylabelvisualList |
249 | - |
250 | - def get_theme_selector(self): |
251 | - return self.app.select_single("ValueSelector", objectName="themeSelector") |
252 | - |
253 | - def get_theme_selector_labelvisual(self): |
254 | - themelabelvisual = self.get_theme_selector() |
255 | - themelabelvisualList = themelabelvisual.select_many("LabelVisual", visible="True") |
256 | - return themelabelvisualList |
257 | - |
258 | - def get_current_profile(self): |
259 | - return self.app.select_single("SingleValue", objectName="Current profile") |
260 | - |
261 | - def get_select_profile_sheet(self): |
262 | - return self.app.select_single("DefaultSheet", title="Select profile") |
263 | - |
264 | - def get_sudoku_user_profile(self): |
265 | - return self.app.select_single("Standard", text="Sudoku User") |
266 | - |
267 | - def get_user_profile_cancel_button(self): |
268 | - return self.app.select_single("Button", objectName="profileCancelButton") |
269 | - |
270 | - def get_add_profile(self): |
271 | - return self.app.select_single("SingleValue", objectName="Add profile") |
272 | - |
273 | - def get_add_profile_dialog(self): |
274 | - return self.app.select_single("Dialog", objectName="Add new profile") |
275 | - |
276 | - def get_add_profile_Lastname_field(self): |
277 | - return self.app.select_single("TextField", objectName = "Lastname") |
278 | - |
279 | - def get_add_profile_Firstname_field(self): |
280 | - return self.app.select_single("TextField", objectName = "Firstname") |
281 | - |
282 | - def get_add_profile_OKbutton(self): |
283 | - return self.app.select_single("SudokuDialogButton", objectName = "OKbutton") |
284 | - |
285 | - def get_manage_profiles(self): |
286 | - return self.app.select_single("SingleValue", objectName = "Manage profiles") |
287 | - |
288 | - def get_Myfirstname_Mylastname_profile(self): |
289 | - return self.app.select_single("Standard", text="Myfirstname Mylastname") |
290 | - |
291 | - def get_edit_profile_dialog(self): |
292 | - return self.app.select_single("Dialog", objectName="Edit profile") |
293 | - |
294 | - def get_edit_profile_delete_button(self): |
295 | - return self.app.select_single("SudokuDialogButton", objectName ="deleteButton") |
296 | - |
297 | - def get_new_game_easy_button(self): |
298 | - return self.app.select_single("NewGameSelectionButton", objectName ="easyGameButton") |
299 | - |
300 | - def get_new_game_moderate_button(self): |
301 | - return self.app.select_single("NewGameSelectionButton", objectName ="moderateGameButton") |
302 | - |
303 | - def get_new_game_hard_button(self): |
304 | - return self.app.select_single("NewGameSelectionButton", objectName ="hardGameButton") |
305 | - |
306 | - def get_new_game_ultrahard_button(self): |
307 | - return self.app.select_single("NewGameSelectionButton", objectName ="ultrahardGameButton") |
308 | - |
309 | - def try_OK_Button(self): |
310 | - try: |
311 | - return self.get_add_profile_OKbutton().buttonText |
312 | - except StateNotFoundError: |
313 | - return None |
314 | - |
315 | - def try_manage_profile(self): |
316 | - try: |
317 | - return self.get_manage_profiles().text |
318 | - except StateNotFoundError: |
319 | - return None |
320 | - |
321 | - def try_delete_Button(self): |
322 | - try: |
323 | - return self.get_edit_profile_delete_button().buttonText |
324 | - except StateNotFoundError: |
325 | - return None |
326 | - |
327 | - def try_new_game_easy_button(self): |
328 | - try: |
329 | - return self.get_new_game_easy_button().buttonText |
330 | - except StateNotFoundError: |
331 | - return None |
332 | - |
333 | - def try_new_game_moderate_button(self): |
334 | - try: |
335 | - return self.get_new_game_moderate_button().buttonText |
336 | - except StateNotFoundError: |
337 | - return None |
338 | - |
339 | - def try_new_game_hard_button(self): |
340 | - try: |
341 | - return self.get_new_game_hard_button().buttonText |
342 | - except StateNotFoundError: |
343 | - return None |
344 | - |
345 | - def try_new_game_ultrahard_button(self): |
346 | - try: |
347 | - return self.get_new_game_ultrahard_button().buttonText |
348 | - except StateNotFoundError: |
349 | - return None |
350 | - |
351 | - def try_my_profile(self): |
352 | - try: |
353 | - return self.get_Myfirstname_Mylastname_profile().text |
354 | - except StateNotFoundError: |
355 | - return None |
356 | |
357 | === removed file 'tests/autopilot/sudoku_app/emulators/ubuntusdk.py' |
358 | --- tests/autopilot/sudoku_app/emulators/ubuntusdk.py 2013-08-20 15:40:09 +0000 |
359 | +++ tests/autopilot/sudoku_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000 |
360 | @@ -1,163 +0,0 @@ |
361 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
362 | -# |
363 | -# Copyright (C) 2013 Canonical Ltd |
364 | -# |
365 | -# This program is free software: you can redistribute it and/or modify |
366 | -# it under the terms of the GNU General Public License version 3 as |
367 | -# published by the Free Software Foundation. |
368 | -# |
369 | -# This program is distributed in the hope that it will be useful, |
370 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
371 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
372 | -# GNU General Public License for more details. |
373 | -# |
374 | -# You should have received a copy of the GNU General Public License |
375 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
376 | -# |
377 | -# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com> |
378 | - |
379 | -from testtools.matchers import Equals, NotEquals, Not, Is |
380 | -from autopilot.matchers import Eventually |
381 | - |
382 | -class ubuntusdk(object): |
383 | - """An emulator class that makes it easy to interact with the ubuntu sdk applications.""" |
384 | - |
385 | - def __init__(self, autopilot, app): |
386 | - self.app = app |
387 | - self.autopilot = autopilot |
388 | - |
389 | - def get_qml_view(self): |
390 | - """Get the main QML view""" |
391 | - return self.app.select_single("QQuickView") |
392 | - |
393 | - def get_object(self, typeName, name): |
394 | - """Get a specific object""" |
395 | - return self.app.select_single(typeName, objectName=name) |
396 | - |
397 | - def get_objects(self, typeName, name): |
398 | - """Get more than one object""" |
399 | - return self.app.select_many(typeName, objectName=name) |
400 | - |
401 | - def get_tabs(self): |
402 | - """Return all tabs""" |
403 | - return self.app.select_single("Tabs") |
404 | - |
405 | - def switch_to_tab(self, tab): |
406 | - """Switch to the specified tab number""" |
407 | - tabs = self.get_tabs() |
408 | - currentTab = tabs.selectedTabIndex |
409 | - |
410 | - #perform operations until tab == currentTab |
411 | - while tab != currentTab: |
412 | - if tab > currentTab: |
413 | - self._next_tab() |
414 | - if tab < currentTab: |
415 | - self._previous_tab() |
416 | - currentTab = tabs.selectedTabIndex |
417 | - |
418 | - def _previous_tab(self): |
419 | - """Switch to the previous tab""" |
420 | - qmlView = self.get_qml_view() |
421 | - |
422 | - startX = int(qmlView.x + qmlView.width * 0.10) |
423 | - stopX = int(qmlView.x + qmlView.width * 0.35) |
424 | - lineY = int(qmlView.y + qmlView.height * 0.05) |
425 | - |
426 | - self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY) |
427 | - self.autopilot.pointing_device.move(startX, lineY) |
428 | - self.autopilot.pointing_device.click() |
429 | - self.autopilot.pointing_device.click() |
430 | - |
431 | - def _next_tab(self): |
432 | - """Switch to the next tab""" |
433 | - qmlView = self.get_qml_view() |
434 | - |
435 | - startX = int(qmlView.x + qmlView.width * 0.35) |
436 | - stopX = int(qmlView.x + qmlView.width * 0.10) |
437 | - lineY = int(qmlView.y + qmlView.height * 0.05) |
438 | - |
439 | - self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY) |
440 | - self.autopilot.pointing_device.move(startX, lineY) |
441 | - self.autopilot.pointing_device.click() |
442 | - self.autopilot.pointing_device.click() |
443 | - |
444 | - def toggle_toolbar(self): |
445 | - """Toggle the toolbar between revealed and hidden""" |
446 | - #check and see if the toolbar is open or not |
447 | - if self.get_toolbar().opened: |
448 | - self.hide_toolbar() |
449 | - else: |
450 | - self.open_toolbar() |
451 | - |
452 | - def get_toolbar(self): |
453 | - """Returns the toolbar in the main events view.""" |
454 | - return self.app.select_single("Toolbar") |
455 | - |
456 | - def get_toolbar_button(self, buttonObject): |
457 | - """Returns the toolbar button with objectName buttonObject""" |
458 | - toolbar = self.get_toolbar() |
459 | - if not toolbar.opened: |
460 | - self.open_toolbar() |
461 | - buttonList = toolbar.select_many("ActionItem") |
462 | - #old version is ToolbarButton |
463 | - if not buttonList: |
464 | - buttonList = toolbar.select_many("ToolbarButton") |
465 | - for button in buttonList: |
466 | - if button.objectName == buttonObject: |
467 | - return button |
468 | - |
469 | - def click_toolbar_button(self, buttonObject): |
470 | - """Clicks the toolbar button with objectName buttonObject""" |
471 | - #The toolbar button is assumed to be the following format |
472 | - #Toolbar { |
473 | - # ... |
474 | - # ActionItem { |
475 | - # objectName: "name" |
476 | - button = self.get_toolbar_button(buttonObject) |
477 | - self.autopilot.pointing_device.click_object(button) |
478 | - return button |
479 | - |
480 | - def open_toolbar(self): |
481 | - """Open the toolbar""" |
482 | - panel = self.app.select_single("Toolbar") |
483 | - qmlView = self.get_qml_view() |
484 | - |
485 | - lineX = int(qmlView.x + qmlView.width * 0.50) |
486 | - startY = int(qmlView.y + qmlView.height - 1) |
487 | - stopY = int(qmlView.y + qmlView.height * 0.95) |
488 | - |
489 | - self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY) |
490 | - panel.animating.wait_for(False) |
491 | - panel.state.wait_for("spread") |
492 | - |
493 | - def hide_toolbar(self): |
494 | - """Hide the toolbar""" |
495 | - panel = self.app.select_single("Toolbar") |
496 | - qmlView = self.get_qml_view() |
497 | - |
498 | - lineX = int(qmlView.x + qmlView.width * 0.50) |
499 | - startY = int(qmlView.y + qmlView.height * 0.95) |
500 | - stopY = int(qmlView.y + qmlView.height - 1) |
501 | - |
502 | - self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY) |
503 | - panel.animating.wait_for(False) |
504 | - panel.state.wait_for("") |
505 | - |
506 | - def set_popup_value(self, popover, button, value): |
507 | - """Changes the given popover selector to the request value |
508 | - At the moment this only works for values that are currently visible. To |
509 | - access the remaining items, a help method to drag and recheck is needed.""" |
510 | - #The popover is assumed to be the following format |
511 | - #Component { |
512 | - # id: actionSelectionPopover |
513 | - # |
514 | - #ActionSelectionPopover { |
515 | - # actions: ActionList { |
516 | - # Action { |
517 | - |
518 | - popList = self.get_object("ActionSelectionPopover", popover) |
519 | - itemList = popList.select_many("Label") |
520 | - for item in itemList: |
521 | - if item.text == value: |
522 | - self.autopilot.pointing_device.click_object(item) |
523 | - return item |
524 | |
525 | === modified file 'tests/autopilot/sudoku_app/tests/__init__.py' |
526 | --- tests/autopilot/sudoku_app/tests/__init__.py 2013-09-17 12:51:23 +0000 |
527 | +++ tests/autopilot/sudoku_app/tests/__init__.py 2013-10-03 17:33:06 +0000 |
528 | @@ -8,13 +8,20 @@ |
529 | """Sudoku app autopilot tests.""" |
530 | |
531 | import os.path |
532 | +import os |
533 | +import shutil |
534 | +import logging |
535 | |
536 | from autopilot.input import Mouse, Touch, Pointer |
537 | from autopilot.platform import model |
538 | from autopilot.testcase import AutopilotTestCase |
539 | - |
540 | -from sudoku_app.emulators.main_window import MainWindow |
541 | -from sudoku_app.emulators.ubuntusdk import ubuntusdk |
542 | +from autopilot.matchers import Eventually |
543 | +from testtools.matchers import GreaterThan, Equals |
544 | + |
545 | +from ubuntuuitoolkit import emulators as toolkit_emulators |
546 | +from sudoku_app import emulators |
547 | + |
548 | +logger = logging.getLogger(__name__) |
549 | |
550 | |
551 | class SudokuTestCase(AutopilotTestCase): |
552 | @@ -29,77 +36,73 @@ |
553 | scenarios = [('with touch', dict(input_device_class=Touch))] |
554 | |
555 | local_location = "../../sudoku-app.qml" |
556 | + sqlite_dir = os.path.expanduser("~/.local/share/sudoku-app/Databases") |
557 | + backup_dir = sqlite_dir + ".backup" |
558 | |
559 | def setUp(self): |
560 | - self.clean_db() |
561 | self.pointing_device = Pointer(self.input_device_class.create()) |
562 | super(SudokuTestCase, self).setUp() |
563 | + |
564 | + #backup and wipe db's before testing |
565 | + self.temp_move_sqlite_db() |
566 | + self.addCleanup(self.restore_sqlite_db) |
567 | + |
568 | if os.path.exists(self.local_location): |
569 | self.launch_test_local() |
570 | - else: |
571 | + elif os.path.exists('/usr/share/sudoku-app/sudoku-app.qml'): |
572 | self.launch_test_installed() |
573 | + else: |
574 | + self.launch_test_click() |
575 | |
576 | def launch_test_local(self): |
577 | self.app = self.launch_test_application( |
578 | "qmlscene", |
579 | self.local_location, |
580 | - app_type='qt') |
581 | + app_type='qt', |
582 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
583 | |
584 | def launch_test_installed(self): |
585 | self.app = self.launch_test_application( |
586 | "qmlscene", |
587 | "/usr/share/sudoku-app/sudoku-app.qml", |
588 | "--desktop_file_hint=/usr/share/applications/sudoku-app.desktop", |
589 | - app_type='qt') |
590 | - |
591 | - def find_db(self): |
592 | - dbs_path = os.path.expanduser("~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/Databases/") |
593 | - if not os.path.exists(dbs_path): |
594 | - return None |
595 | - |
596 | - files = [ f for f in os.listdir(dbs_path) if os.path.splitext(f)[1] == ".ini" ] |
597 | - for f in files: |
598 | - ini_path = os.path.join(dbs_path, f) |
599 | - with open(ini_path) as ini: |
600 | - for line in ini: |
601 | - if "=" in line: |
602 | - key, val = line.strip().split("=") |
603 | - if key == "Name" and val == "SudokuTouch": |
604 | - try: |
605 | - return ini_path.replace(".ini", ".sqlite") |
606 | - except OSError: |
607 | - pass |
608 | - return None |
609 | - |
610 | - def launch_and_quit_app(self): |
611 | - self.launch_app() |
612 | - self.main_window.get_qml_view().visible.wait_for(True) |
613 | - |
614 | - # When calling launch_app an instance of the spawned process |
615 | - # control object will be stored in self.app.process, and a cleanup |
616 | - # handler will be registered that essentially kills the process. |
617 | - # Therefore, by triggering the cleanup handler here we're killing the |
618 | - # process and removing the handler, which allows a clean launch of |
619 | - # the process during regular test setup. |
620 | - self.doCleanups() |
621 | - |
622 | - def clean_db(self): |
623 | - path = self.find_db() |
624 | - if path is None: |
625 | - self.launch_and_quit_app() |
626 | - path = self.find_db() |
627 | - if path is None: |
628 | - self.assertNotEquals(path, None) |
629 | - |
630 | + app_type='qt', |
631 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
632 | + |
633 | + def launch_test_click(self): |
634 | + self.app = self.launch_click_package( |
635 | + 'com.ubuntu.sudoku-app', |
636 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
637 | + |
638 | + def temp_move_sqlite_db(self): |
639 | try: |
640 | - os.remove(path) |
641 | - except OSError: |
642 | + shutil.rmtree(self.backup_dir) |
643 | + except: |
644 | pass |
645 | - |
646 | - @property |
647 | - def main_window(self): |
648 | - return MainWindow(self.app) |
649 | - |
650 | - @property |
651 | - def ubuntusdk(self): |
652 | - return ubuntusdk(self, self.app) |
653 | + else: |
654 | + logger.warning("Prexisting backup database found and removed") |
655 | + |
656 | + try: |
657 | + shutil.move(self.sqlite_dir, self.backup_dir) |
658 | + except: |
659 | + logger.warning("No current database found") |
660 | + else: |
661 | + logger.debug("Backed up database") |
662 | + |
663 | + def restore_sqlite_db(self): |
664 | + if os.path.exists(self.backup_dir): |
665 | + if os.path.exists(self.sqlite_dir): |
666 | + try: |
667 | + shutil.rmtree(self.sqlite_dir) |
668 | + except: |
669 | + logger.error("Failed to remove test database and restore" / |
670 | + "database") |
671 | + return |
672 | + try: |
673 | + shutil.move(self.backup_dir, self.sqlite_dir) |
674 | + except: |
675 | + logger.error("Failed to restore database") |
676 | + |
677 | + @property |
678 | + def main_view(self): |
679 | + return self.app.select_single(emulators.MainView) |
680 | |
681 | === modified file 'tests/autopilot/sudoku_app/tests/test_sudoku.py' |
682 | --- tests/autopilot/sudoku_app/tests/test_sudoku.py 2013-09-04 18:25:09 +0000 |
683 | +++ tests/autopilot/sudoku_app/tests/test_sudoku.py 2013-10-03 17:33:06 +0000 |
684 | @@ -8,9 +8,10 @@ |
685 | """Sudoku app autopilot tests.""" |
686 | |
687 | from __future__ import absolute_import |
688 | +import unittest |
689 | |
690 | from autopilot.matchers import Eventually |
691 | -from testtools.matchers import Equals, Contains, NotEquals |
692 | +from testtools.matchers import Equals, Contains, NotEquals, Not, Is |
693 | |
694 | from sudoku_app.tests import SudokuTestCase |
695 | from time import sleep |
696 | @@ -20,18 +21,15 @@ |
697 | def setUp(self): |
698 | super(TestMainWindow, self).setUp() |
699 | self.assertThat( |
700 | - self.ubuntusdk.get_qml_view().visible, Eventually(Equals(True))) |
701 | - |
702 | - def tearDown(self): |
703 | - super(TestMainWindow, self).tearDown() |
704 | + self.main_view.visible, Eventually(Equals(True))) |
705 | |
706 | def test_enter_and_clear_number(self): |
707 | #find the first button that has a blank value |
708 | - gridButtons = self.main_window.get_blank_inputs() |
709 | + gridButtons = self.main_view.get_blank_inputs() |
710 | gridButton = gridButtons[0] |
711 | |
712 | #create a value function to check later using id |
713 | - buttonValue = lambda: self.app.select_single("QQuickText",id=gridButton.id).text |
714 | + buttonValue = lambda: self.main_view.select_single("QQuickText",id=gridButton.id).text |
715 | |
716 | #double check that it's blank |
717 | self.assertThat(buttonValue, Eventually(Equals(""))) |
718 | @@ -40,11 +38,11 @@ |
719 | self.pointing_device.click_object(gridButton) |
720 | |
721 | #assert that we can see the input screen |
722 | - inputScreen = lambda: self.main_window.get_number_dialog() |
723 | + inputScreen = lambda: self.main_view.get_number_dialog() |
724 | self.assertThat(inputScreen, Eventually(NotEquals(None))) |
725 | |
726 | #set a value, choose 4 |
727 | - dialogButton = self.main_window.get_dialog_button("4") |
728 | + dialogButton = self.main_view.get_dialog_button("4") |
729 | self.assertThat(dialogButton, NotEquals(None)) |
730 | self.pointing_device.click_object(dialogButton) |
731 | |
732 | @@ -55,11 +53,11 @@ |
733 | self.pointing_device.click_object(gridButton) |
734 | |
735 | #assert that we can see the input screen |
736 | - inputScreen = lambda: self.main_window.get_number_dialog() |
737 | + inputScreen = lambda: self.main_view.get_number_dialog() |
738 | self.assertThat(inputScreen, Eventually(NotEquals(None))) |
739 | |
740 | #set a value, choose clear |
741 | - dialogButton = self.main_window.get_dialog_button("Clear") |
742 | + dialogButton = self.main_view.get_dialog_button("Clear") |
743 | self.assertThat(dialogButton, NotEquals(None)) |
744 | self.pointing_device.click_object(dialogButton) |
745 | |
746 | @@ -68,32 +66,34 @@ |
747 | |
748 | def test_best_scores_tab(self): |
749 | #switch to best scores tab |
750 | - self.ubuntusdk.switch_to_tab(1) |
751 | + self.main_view.switch_to_tab("highscoresTab") |
752 | |
753 | #make sure we are in the right place |
754 | - tabName = lambda: self.ubuntusdk.get_object("Tab","highscoresTab") |
755 | + tabName = lambda: self.main_view.select_single("Tab", objectName="highscoresTab") |
756 | self.assertThat(tabName, Eventually(NotEquals(None))) |
757 | |
758 | #click current user button |
759 | - self.ubuntusdk.click_toolbar_button("currentuserbutton") |
760 | + toolbar = self.main_view.open_toolbar() |
761 | + toolbar.click_button("currentuserbutton") |
762 | |
763 | #check label |
764 | - label = lambda: self.ubuntusdk.get_object("Header","highscoreslabel").text |
765 | + label = lambda: self.main_view.select_single("Header", objectName="highscoreslabel").text |
766 | self.assertThat(label, Eventually(NotEquals("<b>Best scores for all players</b>"))) |
767 | |
768 | #click all users button |
769 | - self.ubuntusdk.click_toolbar_button("allusersbutton") |
770 | + toolbar = self.main_view.open_toolbar() |
771 | + toolbar.click_button("allusersbutton") |
772 | |
773 | #check label again |
774 | self.assertThat(label, Eventually(Equals("<b>Best scores for all players</b>"))) |
775 | |
776 | def test_enter_and_cancel(self): |
777 | #find the first button that has a blank value |
778 | - gridButtons = self.main_window.get_blank_inputs() |
779 | + gridButtons = self.main_view.get_blank_inputs() |
780 | gridButton = gridButtons[0] |
781 | |
782 | #create a value function to check later using id |
783 | - buttonValue = lambda: self.app.select_single("QQuickText",id=gridButton.id).text |
784 | + buttonValue = lambda: self.main_view.select_single("QQuickText",id=gridButton.id).text |
785 | |
786 | #double check that it's blank |
787 | self.assertThat(buttonValue, Eventually(Equals(""))) |
788 | @@ -102,11 +102,11 @@ |
789 | self.pointing_device.click_object(gridButton) |
790 | |
791 | #assert that we can see the input screen |
792 | - inputScreen = lambda: self.main_window.get_number_dialog() |
793 | + inputScreen = lambda: self.main_view.get_number_dialog() |
794 | self.assertThat(inputScreen, Eventually(NotEquals(None))) |
795 | |
796 | #set a value, choose 4 |
797 | - dialogButton = self.main_window.get_dialog_button("4") |
798 | + dialogButton = self.main_view.get_dialog_button("4") |
799 | self.assertThat(dialogButton, NotEquals(None)) |
800 | self.pointing_device.click_object(dialogButton) |
801 | |
802 | @@ -117,207 +117,127 @@ |
803 | self.pointing_device.click_object(gridButton) |
804 | |
805 | #assert that we can see the input screen |
806 | - inputScreen = lambda: self.main_window.get_number_dialog() |
807 | + inputScreen = lambda: self.main_view.get_number_dialog() |
808 | self.assertThat(inputScreen, Eventually(NotEquals(None))) |
809 | |
810 | #set a value, choose clear |
811 | - dialogButton = self.main_window.get_dialog_button("Cancel") |
812 | + dialogButton = self.main_view.get_dialog_button("Cancel") |
813 | self.assertThat(dialogButton, NotEquals(None)) |
814 | self.pointing_device.click_object(dialogButton) |
815 | |
816 | #check the value to ensure it worked |
817 | self.assertThat(buttonValue, Eventually(Equals("4"))) |
818 | |
819 | - |
820 | def test_new_game_button(self): |
821 | - self.open_and_check_settings_tab() |
822 | - difficultySelector = self.main_window.get_difficulty_selector() |
823 | - self.pointing_device.click_object(difficultySelector) |
824 | - difficultyChoices = self.main_window.get_difficulty_selector_labelvisual() |
825 | - difficultyChoice = difficultyChoices[3] |
826 | - self.assertThat(difficultyChoice.text, Eventually(Equals("Moderate"))) |
827 | - |
828 | - self.pointing_device.click_object(difficultyChoice) |
829 | - self.verify_settings_tab_open() |
830 | - self.ubuntusdk.switch_to_tab(0) |
831 | - |
832 | - #verify settings sudoku tab is open |
833 | - self.verify_settings_tab_open() |
834 | - |
835 | - #testing new game with moderate mode |
836 | - self.ubuntusdk.click_toolbar_button("newgamebutton") |
837 | - |
838 | - number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints |
839 | - number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions |
840 | - game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds |
841 | - |
842 | - self.assertThat(number_of_hints, Eventually(Equals(0))) |
843 | - self.assertThat(number_of_actions, Eventually(Equals(0))) |
844 | - #self.assertThat(game_seconds, Eventually(Equals(0))) #This cannot be known because timer will not stop |
845 | - self.ubuntusdk.hide_toolbar() |
846 | - |
847 | - #---------------------------------------------------------- |
848 | - |
849 | - self.open_and_check_settings_tab() |
850 | - difficultySelector = self.main_window.get_difficulty_selector() |
851 | - self.pointing_device.click_object(difficultySelector) |
852 | - difficultyChoices = self.main_window.get_difficulty_selector_labelvisual() |
853 | - difficultyChoice = difficultyChoices[6] |
854 | - self.assertThat(difficultyChoice.text, Eventually(Equals("Always ask"))) |
855 | - |
856 | - self.pointing_device.click_object(difficultyChoice) |
857 | - self.verify_settings_tab_open() |
858 | - self.ubuntusdk.switch_to_tab(0) |
859 | - |
860 | - #verify settings sudoku tab is open |
861 | - self.verify_settings_tab_open() |
862 | - |
863 | + #testing new game with moderate mode |
864 | + self._set_difficulty(3, "Moderate") |
865 | + self._verify_game_start() |
866 | + |
867 | + #testing new game with always ask |
868 | + self._set_difficulty(6, "Always ask") |
869 | + |
870 | #testing new game with always ask mode - easy |
871 | - self.ubuntusdk.open_toolbar() |
872 | - self.ubuntusdk.click_toolbar_button("newgamebutton") |
873 | - |
874 | - newGameEasyButton = self.main_window.get_new_game_easy_button() |
875 | - self.main_window.try_new_game_easy_button() |
876 | - self.assertThat(newGameEasyButton.buttonText, Eventually(Equals("Easy"))) |
877 | - self.pointing_device.click_object(newGameEasyButton) |
878 | - |
879 | - number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints |
880 | - number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions |
881 | - game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds |
882 | + self._verify_game_start(True, "easyGameButton") |
883 | |
884 | - self.assertThat(number_of_hints, Eventually(Equals(0))) |
885 | - self.assertThat(number_of_actions, Eventually(Equals(0))) |
886 | - #self.assertThat(game_seconds, Eventually(Equals(0))) |
887 | - self.ubuntusdk.hide_toolbar() |
888 | - |
889 | - #---------------------------------------------------------- |
890 | #testing new game with always ask mode - moderate |
891 | - self.ubuntusdk.open_toolbar() |
892 | - self.ubuntusdk.click_toolbar_button("newgamebutton") |
893 | - |
894 | - newGameModerateButton = self.main_window.get_new_game_moderate_button() |
895 | - self.main_window.try_new_game_moderate_button() |
896 | - self.assertThat(newGameModerateButton.buttonText, Eventually(Equals("Moderate"))) |
897 | - self.pointing_device.click_object(newGameModerateButton) |
898 | - |
899 | - number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints |
900 | - number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions |
901 | - game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds |
902 | + self._verify_game_start(True, "moderateGameButton") |
903 | |
904 | - self.assertThat(number_of_hints, Eventually(Equals(0))) |
905 | - self.assertThat(number_of_actions, Eventually(Equals(0))) |
906 | - #self.assertThat(game_seconds, Eventually(Equals(0))) |
907 | - self.ubuntusdk.hide_toolbar() |
908 | - |
909 | - #---------------------------------------------------------- |
910 | #testing new game with always ask mode - hard |
911 | - self.ubuntusdk.open_toolbar() |
912 | - self.ubuntusdk.click_toolbar_button("newgamebutton") |
913 | - |
914 | - newGameHardButton = self.main_window.get_new_game_hard_button() |
915 | - self.main_window.try_new_game_hard_button() |
916 | - self.assertThat(newGameHardButton.buttonText, Eventually(Equals("Hard"))) |
917 | - self.pointing_device.click_object(newGameHardButton) |
918 | - |
919 | - number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints |
920 | - number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions |
921 | - game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds |
922 | + self._verify_game_start(True, "hardGameButton") |
923 | |
924 | - self.assertThat(number_of_hints, Eventually(Equals(0))) |
925 | - self.assertThat(number_of_actions, Eventually(Equals(0))) |
926 | - #self.assertThat(game_seconds, Eventually(Equals(0))) |
927 | - self.ubuntusdk.hide_toolbar() |
928 | - |
929 | - #---------------------------------------------------------- |
930 | #testing new game with always ask mode - ultra hard |
931 | - self.ubuntusdk.open_toolbar() |
932 | - self.ubuntusdk.click_toolbar_button("newgamebutton") |
933 | - |
934 | - newGameUltraHardButton = self.main_window.get_new_game_ultrahard_button() |
935 | - self.main_window.try_new_game_ultrahard_button() |
936 | - self.assertThat(newGameUltraHardButton.buttonText, Eventually(Equals("Ultra\nHard"))) |
937 | - self.pointing_device.click_object(newGameUltraHardButton) |
938 | - |
939 | - number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints |
940 | - number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions |
941 | - game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds |
942 | - |
943 | - self.assertThat(number_of_hints, Eventually(Equals(0))) |
944 | - self.assertThat(number_of_actions, Eventually(Equals(0))) |
945 | - #self.assertThat(game_seconds, Eventually(Equals(0))) |
946 | - self.ubuntusdk.hide_toolbar() |
947 | - |
948 | - # Reverting to standard |
949 | - self.open_and_check_settings_tab() |
950 | - difficultySelector = self.main_window.get_difficulty_selector() |
951 | - self.pointing_device.click_object(difficultySelector) |
952 | - difficultyChoices = self.main_window.get_difficulty_selector_labelvisual() |
953 | - difficultyChoice = difficultyChoices[1] |
954 | - |
955 | + self._verify_game_start(True, "ultrahardGameButton") |
956 | |
957 | def test_about_tab(self): |
958 | #Switch to the 'About' tab |
959 | - self.ubuntusdk.switch_to_tab(3) |
960 | - |
961 | - #Check for'About' tab selection |
962 | - tabName = lambda: self.ubuntusdk.get_object("Tab", "aboutTab") |
963 | + self.main_view.switch_to_tab("aboutTab") |
964 | + |
965 | + #Check image loads |
966 | + aboutImage = lambda: self.main_view.select_single("QQuickImage", objectName="aboutImage").progress |
967 | + self.assertThat(aboutImage, Eventually(Equals(1.0))) |
968 | + |
969 | + #Check the 'Author(s):' label is displayed |
970 | + aboutLabel = lambda: self.main_view.select_single("Label", objectName="authorLabel").text |
971 | + self.assertThat(aboutLabel, Eventually(Equals("Author(s): "))) |
972 | + |
973 | + #Check the 'Contact:' label is displayed |
974 | + contactLabel = lambda: self.main_view.select_single("Label", objectName="contactLabel").text |
975 | + self.assertThat(contactLabel, Eventually(Equals("Contact: "))) |
976 | + |
977 | + #Check correct Launchpad URL: is displayed |
978 | + urlLabel = lambda: self.main_view.select_single("Label", objectName="urlLabel").text |
979 | + self.assertThat(urlLabel, Eventually(Equals( |
980 | + "<a href=\"https://launchpad.net/sudoku-app\">https://launchpad.net/sudoku-app</a>"))) |
981 | + |
982 | + #Check the 'Version:' label is displayed |
983 | + versionLabel = lambda: self.main_view.select_single("Label", objectName="versionLabel").text |
984 | + self.assertThat(versionLabel, Eventually(Equals("Version: "))) |
985 | + |
986 | + #Check correct version is displayed |
987 | + version = lambda: self.main_view.select_single("Label", objectName="version").text |
988 | + self.assertThat(version, Eventually(Equals("0.4.3"))) |
989 | + |
990 | + #Check correct year is displayed |
991 | + yearLabel = lambda: self.main_view.select_single("Label", objectName="yearLabel").text |
992 | + self.assertThat(yearLabel, Eventually(Equals("2013"))) |
993 | |
994 | def test_hint_button(self): |
995 | #open settings tab |
996 | - self.open_and_check_settings_tab() |
997 | + self.main_view.switch_to_tab("settingsTab") |
998 | |
999 | #click on hints switch to enalbe hints toolbar button |
1000 | - hintsSwitchClickable = self.main_window.get_hints_switchClickable() |
1001 | - lambda: self.assertThat(hintsSwitchClickable.text, Eventually(Equals("Hints"))) |
1002 | + self.assertThat(self.main_view.get_hints_switchClickable, Eventually(Not(Is(None)))) |
1003 | + hintsSwitchClickable = self.main_view.get_hints_switchClickable() |
1004 | + self.assertThat(hintsSwitchClickable.text, Eventually(Equals("Hints"))) |
1005 | |
1006 | #turn on (by clicking on it) hints switch if not already |
1007 | - hintsSwitch = self.main_window.get_hints_switch() |
1008 | - lambda: self.assertThat(hintsSwitch.id, Eventually(Equals("disableHints"))) |
1009 | + self.assertThat(self.main_view.get_hints_switch, Eventually(Not(Is(None)))) |
1010 | + hintsSwitch = self.main_view.get_hints_switch() |
1011 | if hintsSwitch.checked == False: |
1012 | self.pointing_device.click_object(hintsSwitchClickable) |
1013 | |
1014 | #verify hints switch is clicked |
1015 | - self.assertThat(hintsSwitch.checked, Eventually(Equals(True))) |
1016 | + self.assertThat(self.main_view.get_hints_switch().checked, Eventually(Equals(True))) |
1017 | |
1018 | # exit settings tab by clicking on sudoku tab |
1019 | - self.ubuntusdk.switch_to_tab(0) |
1020 | - |
1021 | - #verify settings sudoku tab is open |
1022 | - self.verify_settings_tab_open() |
1023 | + self.main_view.switch_to_tab("MainTab") |
1024 | |
1025 | #click on hint button on tuolbar |
1026 | - self.ubuntusdk.click_toolbar_button("hintbutton") |
1027 | - gridButtons = self.main_window.get_blank_inputs() |
1028 | + toolbar = self.main_view.open_toolbar() |
1029 | + toolbar.click_button("hintbutton") |
1030 | + gridButtons = self.main_view.get_blank_inputs() |
1031 | |
1032 | - number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints |
1033 | + number_of_hints = lambda: self.main_view.select_single(objectName="blockgrid").numberOfHints |
1034 | self.assertThat(number_of_hints, Eventually(Equals(1))) |
1035 | |
1036 | def test_settings_tab(self): |
1037 | #open settings tab |
1038 | - self.open_and_check_settings_tab() |
1039 | + self.main_view.switch_to_tab("settingsTab") |
1040 | |
1041 | #********check difficulty selector ******** |
1042 | #click on difficulty selector |
1043 | - difficultySelector = self.main_window.get_difficulty_selector() |
1044 | - lambda: self.assertThat(difficultySelector.text, Eventually(Equals("Difficulty"))) |
1045 | + self.assertThat(self.main_view.get_difficulty_selector, Eventually(Not(Is(None)))) |
1046 | + difficultySelector = self.main_view.get_difficulty_selector() |
1047 | + self.assertThat(difficultySelector.text, Eventually(Equals("Default Difficulty"))) |
1048 | self.pointing_device.click_object(difficultySelector) |
1049 | |
1050 | #select "Moderate" choice of difficulty selector |
1051 | - difficultyChoices = self.main_window.get_difficulty_selector_labelvisual() |
1052 | + difficultyChoices = self.main_view.get_difficulty_selector_labelvisual() |
1053 | difficultyChoice = difficultyChoices[3] |
1054 | self.assertThat(difficultyChoice.text, Eventually(Equals("Moderate"))) |
1055 | |
1056 | self.pointing_device.click_object(difficultyChoice) |
1057 | - self.verify_settings_tab_open() |
1058 | |
1059 | #********check theme selector ******** |
1060 | #click on theme selector |
1061 | - themeSelector = self.main_window.get_theme_selector() |
1062 | - lambda: self.assertThat(themeSelector.text, Eventually(Equals("Theme"))) |
1063 | + self.assertThat(self.main_view.get_theme_selector, Eventually(Not(Is(None)))) |
1064 | + themeSelector = self.main_view.get_theme_selector() |
1065 | + self.assertThat(themeSelector.text, Eventually(Equals("Theme"))) |
1066 | self.pointing_device.click_object(themeSelector) |
1067 | |
1068 | #select "Simple" choice of theme selector |
1069 | - themeChoices = self.main_window.get_theme_selector_labelvisual() |
1070 | + self.assertThat(self.main_view.get_theme_selector_labelvisual, Eventually(Not(Is(None)))) |
1071 | + themeChoices = self.main_view.get_theme_selector_labelvisual() |
1072 | themeChoice = themeChoices[3] |
1073 | self.assertThat(themeChoice.text, Eventually(Equals("Simple"))) |
1074 | |
1075 | @@ -325,10 +245,11 @@ |
1076 | |
1077 | #******** check hint switch ******** |
1078 | #select hints switch |
1079 | - hintsSwitchClickable = self.main_window.get_hints_switchClickable() |
1080 | - lambda: self.assertThat(hintsSwitchClickable.text, Eventually(Equals("Hints"))) |
1081 | - hintsSwitch = self.main_window.get_hints_switch() |
1082 | - lambda: self.assertThat(hintsSwitch.id, Eventually(Equals("disableHints"))) |
1083 | + self.assertThat(self.main_view.get_hints_switchClickable, Eventually(Not(Is(None)))) |
1084 | + hintsSwitchClickable = self.main_view.get_hints_switchClickable() |
1085 | + self.assertThat(hintsSwitchClickable.text, Eventually(Equals("Hints"))) |
1086 | + self.assertThat(self.main_view.get_hints_switch, Eventually(Not(Is(None)))) |
1087 | + hintsSwitch = self.main_view.get_hints_switch() |
1088 | |
1089 | #switch it on or off depending on it's state |
1090 | if hintsSwitch.checked == False: |
1091 | @@ -340,125 +261,110 @@ |
1092 | |
1093 | #******** check profile settings ******** |
1094 | #select current profile |
1095 | - currentProfile = self.main_window.get_current_profile() |
1096 | - lambda: self.assertThat(currentProfile.text, Eventually(Equals("Current profile"))) |
1097 | + self.assertThat(self.main_view.get_current_profile, Eventually(Not(Is(None)))) |
1098 | + currentProfile = self.main_view.get_current_profile() |
1099 | self.pointing_device.click_object(currentProfile) |
1100 | |
1101 | #let's change profile |
1102 | - #verify select profile page opens |
1103 | - self.get_and_verify_profile_page() |
1104 | - |
1105 | #select "sudoku user" profile |
1106 | - sudokuUserProfile = self.main_window.get_sudoku_user_profile() |
1107 | - lambda: self.assertThat(sudokuUserProfile, Eventually(Equals("Sudoku User"))) |
1108 | + self.assertThat(self.main_view.get_sudoku_user_profile, Eventually(Not(Is(None)))) |
1109 | + sudokuUserProfile = self.main_view.get_sudoku_user_profile() |
1110 | self.pointing_device.click_object(sudokuUserProfile) |
1111 | |
1112 | #verify changed profile |
1113 | - currentProfile = self.main_window.get_current_profile() |
1114 | - lambda: self.assertThat(currentProfile.value, Eventually(Equals("Sudoku User"))) |
1115 | + self.assertThat(self.main_view.get_current_profile, Eventually(Not(Is(None)))) |
1116 | + currentProfile = self.main_view.get_current_profile() |
1117 | + self.assertThat(currentProfile.value, Equals("Sudoku User")) |
1118 | |
1119 | #let's add a user profile |
1120 | #verify add profile page opens |
1121 | - sudokuAddProfile = self.main_window.get_add_profile() |
1122 | - lambda: self.assertThat(sudokuAddProfile, Eventually(Equals("Sudoku User"))) |
1123 | + self.assertThat(self.main_view.get_add_profile, Eventually(Not(Is(None)))) |
1124 | + sudokuAddProfile = self.main_view.get_add_profile() |
1125 | self.pointing_device.click_object(sudokuAddProfile) |
1126 | |
1127 | - #verify add profile dialog opens |
1128 | - addDialog = self.main_window.get_add_profile_dialog() |
1129 | - lambda: self.assertThat(addDialog.title, Eventually(Equals("Add new profile"))) |
1130 | - |
1131 | #insert Lastname |
1132 | - lastName = self.main_window.get_add_profile_Lastname_field() |
1133 | + self.assertThat(self.main_view.get_add_profile_Lastname_field, Eventually(Not(Is(None)))) |
1134 | + lastName = self.main_view.get_add_profile_Lastname_field() |
1135 | self.pointing_device.click_object(lastName) |
1136 | - lambda: self.assertThat(lastName.placeholderText, Eventually(Equals("Lastname"))) |
1137 | + self.assertThat(lastName.placeholderText, Eventually(Equals("Lastname"))) |
1138 | self.keyboard.type("Mylastname") |
1139 | - lambda: self.assertThat(lastName.text, Eventually(Equals("Mylastname"))) |
1140 | + self.assertThat(lastName.text, Eventually(Equals("Mylastname"))) |
1141 | |
1142 | #insert Firstname |
1143 | - firstName = self.main_window.get_add_profile_Firstname_field() |
1144 | + self.assertThat(self.main_view.get_add_profile_Firstname_field, Eventually(Not(Is(None)))) |
1145 | + firstName = self.main_view.get_add_profile_Firstname_field() |
1146 | self.pointing_device.click_object(firstName) |
1147 | - lambda: self.assertThat(firstName.placeholderText, Eventually(Equals("Firstname"))) |
1148 | + self.assertThat(firstName.placeholderText, Eventually(Equals("Firstname"))) |
1149 | self.keyboard.type("Myfirstname") |
1150 | - lambda: self.assertThat(firstName.text, Eventually(Equals("Myfirstname"))) |
1151 | + self.assertThat(firstName.text, Eventually(Equals("Myfirstname"))) |
1152 | |
1153 | #click OK button |
1154 | - OKButton = self.main_window.get_add_profile_OKbutton() |
1155 | - self.main_window.try_OK_Button() |
1156 | + OKButton = self.main_view.get_add_profile_OKbutton() |
1157 | + self.main_view.try_OK_Button() |
1158 | self.assertThat(OKButton.buttonText, Eventually(Equals("OK"))) |
1159 | self.pointing_device.click_object(OKButton) |
1160 | - self.verify_settings_tab_open() |
1161 | |
1162 | #******** check manage profiles ******** |
1163 | #select manage profile |
1164 | - manageProfile = self.main_window.get_manage_profiles() |
1165 | - self.main_window.try_manage_profile() |
1166 | - self.assertThat(manageProfile.text, Eventually(Equals("Manage profiles"))) |
1167 | + self.assertThat(self.main_view.get_manage_profiles, Eventually(Not(Is(None)))) |
1168 | + manageProfile = self.main_view.get_manage_profiles() |
1169 | + self.main_view.try_manage_profile() |
1170 | self.pointing_device.click_object(manageProfile) |
1171 | |
1172 | - #verify select profile page opens |
1173 | - self.get_and_verify_profile_page() |
1174 | - |
1175 | #click on the new profile just added |
1176 | - myProfile = self.main_window.get_Myfirstname_Mylastname_profile() |
1177 | - self.main_window.try_my_profile() |
1178 | + timeout = 0 |
1179 | + myProfile = self.main_view.get_Myfirstname_Mylastname_profile() |
1180 | + while myProfile == None and timeout < 10: |
1181 | + timeout += 1 |
1182 | + manageProfile = self.main_view.get_manage_profiles() |
1183 | + self.main_view.try_manage_profile() |
1184 | + self.pointing_device.click_object(manageProfile) |
1185 | + |
1186 | + #self.assertThat(self.main_view.get_Myfirstname_Mylastname_profile, Eventually(Not(Is(None)))) |
1187 | + myProfile = self.main_view.get_Myfirstname_Mylastname_profile() |
1188 | self.assertThat(myProfile.text, Eventually(Equals("Myfirstname Mylastname"))) |
1189 | self.pointing_device.click_object(myProfile) |
1190 | |
1191 | - #verify the edit profile dialog opens |
1192 | - editProfileDialog = self.main_window.get_edit_profile_dialog() |
1193 | - lambda: self.assertThat(editProfileDialog.text, Eventually(Equals("editProfileDialog"))) |
1194 | - |
1195 | #click on delete |
1196 | - deleteButton = self.main_window.get_edit_profile_delete_button() |
1197 | - self.main_window.try_delete_Button() |
1198 | + deleteButton = self.main_view.get_edit_profile_delete_button() |
1199 | + self.main_view.try_delete_Button() |
1200 | self.assertThat(deleteButton.buttonText, Eventually(Equals("Delete"))) |
1201 | self.pointing_device.click_object(deleteButton) |
1202 | - self.verify_settings_tab_open() |
1203 | - |
1204 | - #verify settings tab is open |
1205 | - self.verify_settings_tab_open() |
1206 | - |
1207 | - def open_and_check_settings_tab(self): |
1208 | - #click on settings tab so to enable the hints button |
1209 | - self.ubuntusdk.switch_to_tab(2) |
1210 | - self.verify_settings_tab_open() |
1211 | - |
1212 | - def verify_settings_tab_open(self): |
1213 | - #verify settings tab is open |
1214 | - tabName = lambda: self.ubuntusdk.get_object("Tab","settingsTab") |
1215 | - |
1216 | - self.assertThat(tabName, Eventually(NotEquals(None))) |
1217 | - |
1218 | - #Check image loads |
1219 | - aboutImage = lambda: self.ubuntusdk.get_object("QQuickImage", "aboutImage").progress |
1220 | - self.assertThat(aboutImage, Eventually(Equals(1.0))) |
1221 | - |
1222 | - #Check the 'Author(s):' label is displayed |
1223 | - aboutLabel = lambda: self.ubuntusdk.get_object("Label", "authorLabel").text |
1224 | - self.assertThat(aboutLabel, Eventually(Equals("Author(s): "))) |
1225 | - |
1226 | - #Check the 'Contact:' label is displayed |
1227 | - contactLabel = lambda: self.ubuntusdk.get_object("Label", "contactLabel").text |
1228 | - self.assertThat(contactLabel, Eventually(Equals("Contact: "))) |
1229 | - |
1230 | - #Check correct Launchpad URL: is displayed |
1231 | - urlLabel = lambda: self.ubuntusdk.get_object("Label", "urlLabel").text |
1232 | - self.assertThat(urlLabel, Eventually(Equals( |
1233 | - "<a href=\"https://launchpad.net/sudoku-app\">https://launchpad.net/sudoku-app</a>"))) |
1234 | - |
1235 | - #Check the 'Version:' label is displayed |
1236 | - versionLabel = lambda: self.ubuntusdk.get_object("Label", "versionLabel").text |
1237 | - self.assertThat(versionLabel, Eventually(Equals("Version: "))) |
1238 | - |
1239 | - #Check correct version is displayed |
1240 | - version = lambda: self.ubuntusdk.get_object("Label", "version").text |
1241 | - self.assertThat(version, Eventually(Equals("0.4.3"))) |
1242 | - |
1243 | - #Check correct year is displayed |
1244 | - yearLabel = lambda: self.ubuntusdk.get_object("Label", "yearLabel").text |
1245 | - self.assertThat(yearLabel, Eventually(Equals("2013"))) |
1246 | - |
1247 | - def get_and_verify_profile_page(self): |
1248 | - profilePage = self.main_window.get_select_profile_sheet() |
1249 | - lambda: self.assertThat(profilePage.title, Eventually(Equals("Select profile"))) |
1250 | - |
1251 | + |
1252 | + #check and make sure the profile is gone |
1253 | + |
1254 | + def _set_difficulty(self, selection, label): |
1255 | + #set the difficulty of the game |
1256 | + self.main_view.switch_to_tab("settingsTab") |
1257 | + difficultySelector = self.main_view.get_difficulty_selector() |
1258 | + self.pointing_device.click_object(difficultySelector) |
1259 | + difficultyChoices = self.main_view.get_difficulty_selector_labelvisual() |
1260 | + difficultyChoice = difficultyChoices[selection] |
1261 | + self.assertThat(difficultyChoice.text, Eventually(Equals(label))) |
1262 | + self.pointing_device.click_object(difficultyChoice) |
1263 | + |
1264 | + def _verify_game_start(self, askmode = False, button = None): |
1265 | + #check the game starts properly (according to difficulty) |
1266 | + self.main_view.switch_to_tab("MainTab") |
1267 | + toolbar = self.main_view.open_toolbar() |
1268 | + toolbar.click_button("newgamebutton") |
1269 | + |
1270 | + #if we're in ask mode, make sure we can grab all the buttons |
1271 | + #and click the proper button |
1272 | + if askmode: |
1273 | + self.assertThat(self.main_view.get_new_game_easy_button().buttonText, Eventually(Equals("Easy"))) |
1274 | + self.assertThat(self.main_view.get_new_game_moderate_button().buttonText, Eventually(Equals("Moderate"))) |
1275 | + self.assertThat(self.main_view.get_new_game_hard_button().buttonText, Eventually(Equals("Hard"))) |
1276 | + self.assertThat(self.main_view.get_new_game_ultrahard_button().buttonText, Eventually(Equals("Ultra\nHard"))) |
1277 | + self.pointing_device.click_object(self.main_view.get_new_game_button(button)) |
1278 | + |
1279 | + number_of_hints = lambda: self.main_view.select_single(objectName="blockgrid").numberOfHints |
1280 | + number_of_actions = lambda: self.main_view.select_single(objectName="blockgrid").numberOfActions |
1281 | + |
1282 | + self.assertThat(number_of_hints, Eventually(Equals(0))) |
1283 | + self.assertThat(number_of_actions, Eventually(Equals(0))) |
1284 | + |
1285 | + #verify clock is moving |
1286 | + game_seconds = self.main_view.select_single(objectName="blockgrid").gameSeconds |
1287 | + self.assertThat(self.main_view.select_single(objectName="blockgrid").gameSeconds, Eventually(NotEquals(game_seconds))) |
1288 | + self.main_view.close_toolbar() |
PASSED: Continuous integration, rev:120 91.189. 93.70:8080/ job/sudoku- app-ci/ 22/ 91.189. 93.70:8080/ job/generic- mediumtests/ 498 91.189. 93.70:8080/ job/sudoku- app-precise- amd64-ci/ 22 91.189. 93.70:8080/ job/sudoku- app-quantal- amd64-ci/ 22 91.189. 93.70:8080/ job/sudoku- app-raring- amd64-ci/ 22 91.189. 93.70:8080/ job/sudoku- app-saucy- amd64-ci/ 22
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/sudoku- app-ci/ 22/rebuild
http://