Merge lp:~elopio/ubuntuone-credentials/fix1237112-autopilot_base_test_case into lp:ubuntuone-credentials
- fix1237112-autopilot_base_test_case
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Leo Arias |
Approved revision: | 75 |
Merged at revision: | 71 |
Proposed branch: | lp:~elopio/ubuntuone-credentials/fix1237112-autopilot_base_test_case |
Merge into: | lp:ubuntuone-credentials |
Diff against target: |
670 lines (+352/-249) 7 files modified
online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/TestWrapperExisting.qml (+1/-1) online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/TestWrapperNew.qml (+1/-1) online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/__init__.py (+89/-113) online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/emulators.py (+108/-0) online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/main/__init__.py (+0/-1) online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_existing_account.py (+47/-0) online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_new_account.py (+106/-133) |
To merge this branch: | bzr merge lp:~elopio/ubuntuone-credentials/fix1237112-autopilot_base_test_case |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mike McCracken (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email:
|
Commit message
Cleaned the autopilot tests.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:74
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mike McCracken (mikemc) wrote : | # |
Just about everything makes sense, nice cleanup.
Tests still pass for me, still test the same things.
Just a couple minor linty issues:
__init__.py:
- line 64 has extraneous whitespace
- line 70: "self.keyboard_" is a strange use of underscore. Is that
intended? also, this seems unused.
-lines 83 & 84: pyflakes complains about the indent here, wants four
more spaces
emulators.py:
- lines 30 and 31 have weird indentation (7 spaces)
- line 37 has trailing whitespace.
test_new_
- line 107 has extraneous whitespace
I think we need to add ubuntu-
build-depends for this project in this branch, too...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) wrote : | # |
> - line 70: "self.keyboard_" is a strange use of underscore. Is that
> intended? also, this seems unused.
Right, nice catch :)
I added the _ to check that it was not used anywhere and then forgot to delete it.
> Just a couple minor linty issues:
Sorry about that. We need to add pep8 and pyflakes checks to the jenkins tests. That's an easy thing to do, I'll tell fginther.
> I think we need to add ubuntu-
> build-depends for this project in this branch, too...
Yes. Where do I do that? I found no debian folder on this project.
Thanks for the detailed review. It should pass all the lint checks now.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:75
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mike McCracken (mikemc) wrote : | # |
+1, thanks for all the effort in cleaning this up & sharing best practices!
Preview Diff
1 | === renamed file 'online-accounts-provider/tests/autopilot/TestWrapperExisting.qml' => 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/TestWrapperExisting.qml' |
2 | --- online-accounts-provider/tests/autopilot/TestWrapperExisting.qml 2013-09-24 20:26:26 +0000 |
3 | +++ online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/TestWrapperExisting.qml 2013-10-10 02:40:10 +0000 |
4 | @@ -34,7 +34,7 @@ |
5 | |
6 | anchors.fill: parent |
7 | |
8 | - source: "../../Main.qml" |
9 | + source: "../../../Main.qml" |
10 | |
11 | } |
12 | |
13 | |
14 | === renamed file 'online-accounts-provider/tests/autopilot/TestWrapperNew.qml' => 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/TestWrapperNew.qml' |
15 | --- online-accounts-provider/tests/autopilot/TestWrapperNew.qml 2013-09-24 20:26:26 +0000 |
16 | +++ online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/TestWrapperNew.qml 2013-10-10 02:40:10 +0000 |
17 | @@ -40,7 +40,7 @@ |
18 | |
19 | anchors.fill: parent |
20 | |
21 | - source: "../../Main.qml" |
22 | + source: "../../../Main.qml" |
23 | |
24 | } |
25 | |
26 | |
27 | === modified file 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/__init__.py' |
28 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/__init__.py 2013-09-24 20:26:26 +0000 |
29 | +++ online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/__init__.py 2013-10-10 02:40:10 +0000 |
30 | @@ -1,124 +1,100 @@ |
31 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
32 | +# |
33 | +# Copyright (C) 2013 Canonical Ltd. |
34 | +# |
35 | +# This program is free software; you can redistribute it and/or modify |
36 | +# it under the terms of the GNU General Public License version 3, as published |
37 | +# by the Free Software Foundation. |
38 | +# |
39 | +# This program is distributed in the hope that it will be useful, |
40 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
41 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
42 | +# GNU General Public License for more details. |
43 | +# |
44 | +# You should have received a copy of the GNU General Public License |
45 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
46 | |
47 | """UbuntuOne Credentials Online-Accounts provider plugin autopilot tests.""" |
48 | |
49 | -from os import remove |
50 | -import os.path |
51 | -from tempfile import mktemp |
52 | +import os |
53 | import subprocess |
54 | +import tempfile |
55 | |
56 | -from autopilot.input import Mouse, Touch, Pointer |
57 | +from autopilot import input |
58 | from autopilot.matchers import Eventually |
59 | -from autopilot.platform import model |
60 | -from testtools.matchers import Is, Not, Equals |
61 | -from autopilot.testcase import AutopilotTestCase |
62 | - |
63 | - |
64 | -def get_module_include_path(): |
65 | +from testtools.matchers import Equals |
66 | +from ubuntuuitoolkit import ( |
67 | + base, |
68 | + emulators as toolkit_emulators, |
69 | +) |
70 | + |
71 | + |
72 | +def _get_module_include_path(): |
73 | + return _get_path_to_source_root() |
74 | + |
75 | + |
76 | +def _get_path_to_source_root(): |
77 | return os.path.abspath( |
78 | os.path.join( |
79 | - os.path.dirname(__file__), |
80 | - '..', |
81 | - '..', |
82 | - '..', |
83 | - '..', |
84 | - 'modules') |
85 | - ) |
86 | - |
87 | - |
88 | -class UbuntuTouchAppTestCase(AutopilotTestCase): |
89 | - """Provides several useful methods for the tests.""" |
90 | - |
91 | - if model() == 'Desktop': |
92 | - scenarios = [ |
93 | - ('with mouse', dict(input_device_class=Mouse)) |
94 | - ] |
95 | - else: |
96 | - scenarios = [ |
97 | - ('with touch', dict(input_device_class=Touch)) |
98 | - ] |
99 | + os.path.dirname(__file__), '..', '..', '..')) |
100 | + |
101 | + |
102 | +def _get_local_desktop_file_directory(): |
103 | + return os.path.join(os.environ['HOME'], '.local', 'share', 'applications') |
104 | + |
105 | + |
106 | +def _get_qmlscene_launch_command(): |
107 | + """Return the command to launch qmlscene for autopilot tests.""" |
108 | + # TODO replace this with the one from the ubuntu-ui-toolkit, that has just |
109 | + # been merged to trunk. --elopio - 2013-10-08 |
110 | + arch = subprocess.check_output( |
111 | + ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip() |
112 | + return '/usr/lib/' + arch + '/qt5/bin/qmlscene' |
113 | + |
114 | + |
115 | +class TestCaseWithQMLWrapper(base.UbuntuUIToolkitAppTestCase): |
116 | + |
117 | + _DESKTOP_FILE_CONTENTS = ("""[Desktop Entry] |
118 | +Type=Application |
119 | +Exec=Not important |
120 | +Path=Not important |
121 | +Name=Test app |
122 | +Icon=Not important |
123 | +""") |
124 | + |
125 | + test_qml_wrapper_file_name = None |
126 | + |
127 | + def setUp(self): |
128 | + super(TestCaseWithQMLWrapper, self).setUp() |
129 | + self.pointing_device = input.Pointer(self.input_device_class.create()) |
130 | + self.launch_application() |
131 | + |
132 | + def launch_application(self): |
133 | + qml_file_path = os.path.join( |
134 | + os.path.dirname(__file__), self.test_qml_wrapper_file_name) |
135 | + desktop_file_path = self._write_test_desktop_file() |
136 | + self.addCleanup(os.remove, desktop_file_path) |
137 | + self.app = self.launch_test_application( |
138 | + _get_qmlscene_launch_command(), |
139 | + '-I' + _get_module_include_path(), |
140 | + qml_file_path, |
141 | + '--desktop_file_hint={0}'.format(desktop_file_path), |
142 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase, |
143 | + app_type='qt') |
144 | + |
145 | + self.assertThat( |
146 | + self.main_view.visible, Eventually(Equals(True))) |
147 | + |
148 | + def _write_test_desktop_file(self): |
149 | + desktop_file_dir = _get_local_desktop_file_directory() |
150 | + if not os.path.exists(desktop_file_dir): |
151 | + os.makedirs(desktop_file_dir) |
152 | + desktop_file = tempfile.NamedTemporaryFile( |
153 | + suffix='.desktop', dir=desktop_file_dir, delete=False) |
154 | + desktop_file.write(self._DESKTOP_FILE_CONTENTS) |
155 | + desktop_file.close() |
156 | + return desktop_file.name |
157 | |
158 | @property |
159 | - def main_window(self): |
160 | - return MainWindow(self.app) |
161 | - |
162 | - def setUp(self): |
163 | - self.pointing_device = Pointer(self.input_device_class.create()) |
164 | - super(UbuntuTouchAppTestCase, self).setUp() |
165 | - self.launch_test_qml() |
166 | - |
167 | - def launch_test_qml(self): |
168 | - # If the test class has defined a 'test_qml' class attribute then we |
169 | - # write it to disk and launch it inside the QML Scene. If not, then we |
170 | - # silently do nothing (presumably the test has something else planned). |
171 | - arch = subprocess.check_output(["dpkg-architecture", |
172 | - "-qDEB_HOST_MULTIARCH"]).strip() |
173 | - |
174 | - if hasattr(self, 'test_qml') and isinstance(self.test_qml, basestring): |
175 | - qml_path = mktemp(suffix='.qml') |
176 | - open(qml_path, 'w').write(self.test_qml) |
177 | - self.addCleanup(remove, qml_path) |
178 | - |
179 | - self.app = self.launch_test_application( |
180 | - "/usr/lib/" + arch + "/qt5/bin/qmlscene", |
181 | - "-I", get_module_include_path(), |
182 | - qml_path, |
183 | - app_type='qt') |
184 | - |
185 | - if hasattr(self, 'test_qml_file') and isinstance(self.test_qml_file, basestring): |
186 | - qml_path = self.test_qml_file |
187 | - self.app = self.launch_test_application( |
188 | - "/usr/lib/" + arch + "/qt5/bin/qmlscene", |
189 | - "-I", get_module_include_path(), |
190 | - qml_path, |
191 | - app_type='qt') |
192 | - |
193 | - self.assertThat(self.get_qml_view().visible, Eventually(Equals(True))) |
194 | - |
195 | - def get_qml_view(self): |
196 | - """Get the main QML view""" |
197 | - |
198 | - return self.app.select_single("QQuickView") |
199 | - |
200 | - def get_mainview(self): |
201 | - """Get the QML MainView""" |
202 | - |
203 | - mainView = self.app.select_single("MainView") |
204 | - self.assertThat(mainView, Not(Is(None))) |
205 | - return mainView |
206 | - |
207 | - def get_object(self, objectName): |
208 | - """Get a object based on the objectName""" |
209 | - |
210 | - obj = self.app.select_single(objectName=objectName) |
211 | - self.assertThat(obj, Not(Is(None))) |
212 | - return obj |
213 | - |
214 | - def mouse_click(self, objectName): |
215 | - """Move mouse on top of the object and click on it""" |
216 | - |
217 | - obj = self.get_object(objectName) |
218 | - self.pointing_device.move_to_object(obj) |
219 | - self.pointing_device.click() |
220 | - |
221 | - def mouse_press(self, objectName): |
222 | - """Move mouse on top of the object and press and hold mouse button""" |
223 | - |
224 | - obj = self.get_object(objectName) |
225 | - self.pointing_device.move_to_object(obj) |
226 | - self.pointing_device.press() |
227 | - |
228 | - def mouse_release(self): |
229 | - """Release mouse button""" |
230 | - |
231 | - self.pointing_device.release() |
232 | - |
233 | - def type_string(self, string): |
234 | - """Type a string with keyboard""" |
235 | - |
236 | - self.keyboard.type(string) |
237 | - |
238 | - def type_key(self, key): |
239 | - """Type a single key with keyboard""" |
240 | - |
241 | - self.keyboard.key(key) |
242 | + def main_view(self): |
243 | + return self.app.select_single(toolkit_emulators.MainView) |
244 | |
245 | === added file 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/emulators.py' |
246 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/emulators.py 1970-01-01 00:00:00 +0000 |
247 | +++ online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/emulators.py 2013-10-10 02:40:10 +0000 |
248 | @@ -0,0 +1,108 @@ |
249 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
250 | +# |
251 | +# Copyright (C) 2013 Canonical Ltd. |
252 | +# |
253 | +# This program is free software; you can redistribute it and/or modify |
254 | +# it under the terms of the GNU General Public License version 3, as published |
255 | +# by the Free Software Foundation. |
256 | +# |
257 | +# This program is distributed in the hope that it will be useful, |
258 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
259 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
260 | +# GNU General Public License for more details. |
261 | +# |
262 | +# You should have received a copy of the GNU General Public License |
263 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
264 | + |
265 | +from autopilot import input |
266 | + |
267 | +from ubuntuuitoolkit import emulators as toolkit_emulators |
268 | + |
269 | + |
270 | +class NewAccount(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
271 | + """New Account Autopilot emulator.""" |
272 | + |
273 | + def is_error_label_visible(self): |
274 | + error_label = self.select_single(objectName='errorLabel') |
275 | + return error_label.visible |
276 | + |
277 | + def log_in(self, email, password): |
278 | + self._fill_log_in(email, password) |
279 | + self._click_continue() |
280 | + |
281 | + def _fill_log_in(self, email, password): |
282 | + self._enter_email(email) |
283 | + self._enter_login_password(password) |
284 | + |
285 | + def _enter_email(self, email): |
286 | + email_text_field = self.select_single( |
287 | + TextField, objectName='emailTextField') |
288 | + email_text_field.write(email) |
289 | + |
290 | + def _enter_login_password(self, password): |
291 | + password_text_field = self.select_single( |
292 | + TextField, objectName='loginFormPasswordTextField') |
293 | + password_text_field.write(password) |
294 | + |
295 | + def _click_continue(self): |
296 | + continue_button = self.select_single( |
297 | + objectName='continueButton', visible=True) |
298 | + self.pointing_device.click_object(continue_button) |
299 | + |
300 | + def register_new_account(self, email, name, password, |
301 | + password_confirmation, agree_to_terms): |
302 | + self._switch_to_new_account() |
303 | + self._enter_email(email) |
304 | + self._enter_name(name) |
305 | + self._enter_password_new_user(password) |
306 | + self._enter_password_confirmation(password_confirmation) |
307 | + self._agree_to_terms(agree_to_terms) |
308 | + self._click_continue() |
309 | + |
310 | + def _switch_to_new_account(self): |
311 | + new_user_switch = self.select_single( |
312 | + toolkit_emulators.CheckBox, objectName='newUserToggleSwitch') |
313 | + new_user_switch.check() |
314 | + |
315 | + def _enter_name(self, name): |
316 | + name_text_field = self.select_single( |
317 | + TextField, objectName='nameTextField') |
318 | + name_text_field.write(name) |
319 | + |
320 | + def _enter_password_new_user(self, password): |
321 | + password_text_field = self.select_single( |
322 | + TextField, objectName='passwordTextField') |
323 | + password_text_field.write(password) |
324 | + |
325 | + def _enter_password_confirmation(self, password_confirmation): |
326 | + confirm_password_text_field = self.select_single( |
327 | + TextField, objectName='confirmPasswordTextField') |
328 | + confirm_password_text_field.write(password_confirmation) |
329 | + |
330 | + def _agree_to_terms(self, agree): |
331 | + terms_and_conditions_check_box = self.select_single( |
332 | + toolkit_emulators.CheckBox, |
333 | + objectName='termsAndConditionsCheckBox') |
334 | + if agree: |
335 | + terms_and_conditions_check_box.check() |
336 | + else: |
337 | + terms_and_conditions_check_box.uncheck() |
338 | + |
339 | + |
340 | +class TextField(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
341 | + """TextField Autopilot emulator.""" |
342 | + # TODO change this to use the text field emulator, once it lands on |
343 | + # ubuntu-ui-toolkit. --elopio - 2013-10-08 |
344 | + |
345 | + def __init__(self, *args): |
346 | + super(TextField, self).__init__(*args) |
347 | + self.keyboard = input.Keyboard.create() |
348 | + |
349 | + def write(self, text): |
350 | + """Write into the text field. |
351 | + |
352 | + :parameter text: The text to write. |
353 | + |
354 | + """ |
355 | + self.pointing_device.click_object(self) |
356 | + self.keyboard.type(text) |
357 | |
358 | === removed directory 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/main' |
359 | === removed file 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/main/__init__.py' |
360 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/main/__init__.py 2013-09-24 20:26:26 +0000 |
361 | +++ online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/main/__init__.py 1970-01-01 00:00:00 +0000 |
362 | @@ -1,1 +0,0 @@ |
363 | -""" A Generic test suite """ |
364 | |
365 | === added file 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_existing_account.py' |
366 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_existing_account.py 1970-01-01 00:00:00 +0000 |
367 | +++ online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_existing_account.py 2013-10-10 02:40:10 +0000 |
368 | @@ -0,0 +1,47 @@ |
369 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
370 | +# |
371 | +# Copyright (C) 2013 Canonical Ltd. |
372 | +# |
373 | +# This program is free software; you can redistribute it and/or modify |
374 | +# it under the terms of the GNU General Public License version 3, as published |
375 | +# by the Free Software Foundation. |
376 | +# |
377 | +# This program is distributed in the hope that it will be useful, |
378 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
379 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
380 | +# GNU General Public License for more details. |
381 | +# |
382 | +# You should have received a copy of the GNU General Public License |
383 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
384 | + |
385 | +from autopilot.matchers import Eventually |
386 | +from testtools.matchers import Equals |
387 | + |
388 | +import UbuntuOneCredentialsProviderAutopilotTests |
389 | + |
390 | + |
391 | +class ExistingUOAAccountTests( |
392 | + UbuntuOneCredentialsProviderAutopilotTests.TestCaseWithQMLWrapper): |
393 | + |
394 | + test_qml_wrapper_file_name = 'TestWrapperExisting.qml' |
395 | + |
396 | + def test_show_remove_account_dialog(self): |
397 | + remove_account_button = self.main_view.select_single( |
398 | + objectName='removeAccountButton') |
399 | + self.pointing_device.click_object(remove_account_button) |
400 | + |
401 | + confirm_button = self.main_view.select_single( |
402 | + objectName='confirmRemoveAccountButton') |
403 | + |
404 | + self.assertThat( |
405 | + confirm_button.visible, Eventually(Equals(True))) |
406 | + |
407 | + cancel_button = self.main_view.select_single( |
408 | + objectName='cancelRemoveAccountButton') |
409 | + self.pointing_device.click_object(cancel_button) |
410 | + |
411 | + def test_shows_expected_email(self): |
412 | + email_list_item = self.main_view.select_single( |
413 | + objectName='emailListItem') |
414 | + self.assertThat( |
415 | + email_list_item.value, Eventually(Equals("my@email.com"))) |
416 | |
417 | === renamed file 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/main/test_main.py' => 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_new_account.py' |
418 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/main/test_main.py 2013-09-24 20:26:26 +0000 |
419 | +++ online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_new_account.py 2013-10-10 02:40:10 +0000 |
420 | @@ -1,144 +1,117 @@ |
421 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
422 | - |
423 | -"""Tests for launching the plugin""" |
424 | +# |
425 | +# Copyright (C) 2013 Canonical Ltd. |
426 | +# |
427 | +# This program is free software; you can redistribute it and/or modify |
428 | +# it under the terms of the GNU General Public License version 3, as published |
429 | +# by the Free Software Foundation. |
430 | +# |
431 | +# This program is distributed in the hope that it will be useful, |
432 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
433 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
434 | +# GNU General Public License for more details. |
435 | +# |
436 | +# You should have received a copy of the GNU General Public License |
437 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
438 | |
439 | from autopilot.matchers import Eventually |
440 | from testtools.matchers import Equals |
441 | -import os |
442 | -from UbuntuOneCredentialsProviderAutopilotTests import UbuntuTouchAppTestCase |
443 | - |
444 | - |
445 | -class NewUOAAccountTests(UbuntuTouchAppTestCase): |
446 | - |
447 | - test_qml_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
448 | - "../../") |
449 | - test_qml_filename = "TestWrapperNew.qml" |
450 | - test_qml_file = os.path.join(test_qml_path, test_qml_filename) |
451 | +from ubuntuuitoolkit import emulators as toolkit_emulators |
452 | + |
453 | +import UbuntuOneCredentialsProviderAutopilotTests |
454 | +from UbuntuOneCredentialsProviderAutopilotTests import emulators |
455 | + |
456 | + |
457 | +_VALID_NEW_USER = dict( |
458 | + email='valid@example.com', name='Name', password='password', |
459 | + password_confirmation='password', agree_to_terms=True) |
460 | + |
461 | + |
462 | +class NewUbuntuOneOnlineAccountTestCase( |
463 | + UbuntuOneCredentialsProviderAutopilotTests.TestCaseWithQMLWrapper): |
464 | + |
465 | + test_qml_wrapper_file_name = 'TestWrapperNew.qml' |
466 | |
467 | def setUp(self): |
468 | - super(NewUOAAccountTests, self).setUp() |
469 | - self.uoa_account = self.get_object(objectName="FakeNewUOAAccount") |
470 | - |
471 | - def test_select_mainView(self): |
472 | - mainView = self.get_mainview() |
473 | - self.assertThat(mainView.visible, Eventually(Equals(True))) |
474 | - |
475 | - def test_loadingOverlay_starts_invisible(self): |
476 | - overlay = self.get_object(objectName="loadingOverlay") |
477 | + super(NewUbuntuOneOnlineAccountTestCase, self).setUp() |
478 | + self.new_account = self.main_view.select_single(emulators.NewAccount) |
479 | + |
480 | + def test_loading_overlay_starts_invisible(self): |
481 | + overlay = self.main_view.select_single(objectName='loadingOverlay') |
482 | self.assertThat(overlay.visible, Eventually(Equals(False))) |
483 | |
484 | def test_email_field_visible_focused(self): |
485 | - emailTextField = self.get_object(objectName="emailTextField") |
486 | - self.assertThat(emailTextField.visible, Eventually(Equals(True))) |
487 | - self.assertThat(emailTextField.focus, Eventually(Equals(True))) |
488 | + email_text_field = self.main_view.select_single( |
489 | + objectName='emailTextField') |
490 | + self.assertThat(email_text_field.visible, Eventually(Equals(True))) |
491 | + self.assertThat(email_text_field.focus, Eventually(Equals(True))) |
492 | |
493 | def test_login_initial_state(self): |
494 | - passwordTextField = self.get_object("loginFormPasswordTextField") |
495 | - self.assertThat(passwordTextField.visible, Eventually(Equals(True))) |
496 | - twoFactorTextField = self.get_object(objectName="twoFactorTextField") |
497 | - self.assertThat(twoFactorTextField.visible, Eventually(Equals(False))) |
498 | - |
499 | - def test_switch_to_newuser(self): |
500 | - |
501 | - self.mouse_click(objectName="newUserToggleSwitch") |
502 | - |
503 | - passwordField = self.get_object("loginFormPasswordTextField") |
504 | - self.assertThat(passwordField.visible, Eventually(Equals(False))) |
505 | - |
506 | - nameTextField = self.get_object("nameTextField") |
507 | - self.assertThat(nameTextField.visible, Eventually(Equals(True))) |
508 | - |
509 | - def click_continuebutton_from(self, parentObjectName): |
510 | - parent = self.get_object(parentObjectName) |
511 | - continueButton = parent.select_single(objectName="continueButton") |
512 | - self.pointing_device.move_to_object(continueButton) |
513 | - self.pointing_device.click() |
514 | - |
515 | - def test_login_error_on_no_input(self): |
516 | - errorTextField = self.get_object("errorLabel") |
517 | - self.assertThat(errorTextField.visible, Eventually(Equals(False))) |
518 | - self.click_continuebutton_from("buttonRow-LoginForm-noTwoFactor") |
519 | - self.assertThat(errorTextField.visible, Eventually(Equals(True))) |
520 | - |
521 | - def test_login_error_on_bad_email(self): |
522 | - errorTextField = self.get_object("errorLabel") |
523 | - self.assertThat(errorTextField.visible, Eventually(Equals(False))) |
524 | - self.mouse_click("emailTextField") |
525 | - self.type_string("this isn't a valid email") |
526 | - |
527 | - self.click_continuebutton_from("buttonRow-LoginForm-noTwoFactor") |
528 | - self.assertThat(errorTextField.visible, Eventually(Equals(True))) |
529 | - |
530 | - def _setup_newuser_errors(self): |
531 | - self.emailTextField = self.get_object("emailTextField") |
532 | - self.mouse_click("emailTextField") |
533 | - self.type_string("valid@email.com") |
534 | - self.assertThat(self.emailTextField.acceptableInput, |
535 | - Eventually(Equals(True))) |
536 | - self.errorTextField = self.get_object("errorLabel") |
537 | - self.mouse_click(objectName="newUserToggleSwitch") |
538 | - |
539 | - def test_newuser_error_on_no_name(self): |
540 | - self._setup_newuser_errors() |
541 | - self.click_continuebutton_from("buttonRow-RegisterForm") |
542 | - self.assertThat(self.errorTextField.visible, Eventually(Equals(True))) |
543 | - |
544 | - def test_newuser_error_on_no_password(self): |
545 | - self._setup_newuser_errors() |
546 | - self.mouse_click("nameTextField") |
547 | - self.type_string("A Name") |
548 | - self.click_continuebutton_from("buttonRow-RegisterForm") |
549 | - self.assertThat(self.errorTextField.visible, Eventually(Equals(True))) |
550 | - |
551 | - def test_newuser_error_on_no_password_match(self): |
552 | - self._setup_newuser_errors() |
553 | - self.mouse_click("nameTextField") |
554 | - self.type_string("A Name") |
555 | - |
556 | - self.mouse_click("passwordTextField") |
557 | - self.type_string("12345678910111213141516") |
558 | - self.mouse_click("confirmPasswordTextField") |
559 | - self.type_string("123456789ABCDEF") |
560 | - self.mouse_click(objectName="termsAndConditionsCheckBox") |
561 | - self.click_continuebutton_from("buttonRow-RegisterForm") |
562 | - self.assertThat(self.errorTextField.visible, Eventually(Equals(True))) |
563 | - |
564 | - def test_newuser_error_on_short_password(self): |
565 | - self._setup_newuser_errors() |
566 | - self.mouse_click("nameTextField") |
567 | - self.type_string("A Name") |
568 | - self.mouse_click("passwordTextField") |
569 | - self.type_string("123") |
570 | - self.mouse_click("confirmPasswordTextField") |
571 | - self.type_string("123") |
572 | - self.mouse_click(objectName="termsAndConditionsCheckBox") |
573 | - self.click_continuebutton_from("buttonRow-RegisterForm") |
574 | - self.assertThat(self.errorTextField.visible, Eventually(Equals(True))) |
575 | - |
576 | - |
577 | -class ExistingUOAAccountTests(UbuntuTouchAppTestCase): |
578 | - |
579 | - test_qml_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
580 | - "../../") |
581 | - test_qml_filename = "TestWrapperExisting.qml" |
582 | - test_qml_file = os.path.join(test_qml_path, test_qml_filename) |
583 | - |
584 | - def setUp(self): |
585 | - super(ExistingUOAAccountTests, self).setUp() |
586 | - self.uoa_account = self.get_object(objectName="FakeExistingUOAAccount") |
587 | - |
588 | - def test_show_remove_account_dialog(self): |
589 | - |
590 | - self.mouse_click(objectName="removeAccountButton") |
591 | - |
592 | - confirmRemoveButton = self.get_object("confirmRemoveAccountButton") |
593 | - |
594 | - self.assertThat(confirmRemoveButton.visible, |
595 | - Eventually(Equals(True))) |
596 | - |
597 | - self.mouse_click(objectName="cancelRemoveAccountButton") |
598 | - |
599 | - def test_shows_expected_email(self): |
600 | - emailListItem = self.get_object("emailListItem") |
601 | - self.assertThat(emailListItem.value, |
602 | - Eventually(Equals("my@email.com"))) |
603 | + password_text_field = self.main_view.select_single( |
604 | + objectName='loginFormPasswordTextField') |
605 | + self.assertThat(password_text_field.visible, Eventually(Equals(True))) |
606 | + two_factor_text_field = self.main_view.select_single( |
607 | + objectName='twoFactorTextField') |
608 | + self.assertThat( |
609 | + two_factor_text_field.visible, Eventually(Equals(False))) |
610 | + |
611 | + def test_switch_to_new_user(self): |
612 | + new_user_switch = self.main_view.select_single( |
613 | + toolkit_emulators.CheckBox, objectName='newUserToggleSwitch') |
614 | + new_user_switch.check() |
615 | + |
616 | + password_text_field = self.main_view.select_single( |
617 | + objectName='loginFormPasswordTextField') |
618 | + self.assertThat(password_text_field.visible, Eventually(Equals(False))) |
619 | + |
620 | + name_text_field = self.main_view.select_single( |
621 | + objectName='nameTextField') |
622 | + self.assertThat(name_text_field.visible, Eventually(Equals(True))) |
623 | + |
624 | + def test_error_label_starts_invisible(self): |
625 | + self.assertThat( |
626 | + self.new_account.is_error_label_visible(), |
627 | + Eventually(Equals(False))) |
628 | + |
629 | + |
630 | +class LogInUbuntuOneOnlineAccountErrorsTestCase( |
631 | + UbuntuOneCredentialsProviderAutopilotTests.TestCaseWithQMLWrapper): |
632 | + |
633 | + scenarios = [ |
634 | + ('no input', dict(email='', password='')), |
635 | + ('invalid email', dict(email='invalid', password='password')) |
636 | + ] |
637 | + |
638 | + test_qml_wrapper_file_name = 'TestWrapperNew.qml' |
639 | + |
640 | + def test_log_in_error(self): |
641 | + new_account = self.main_view.select_single(emulators.NewAccount) |
642 | + new_account.log_in(self.email, self.password) |
643 | + |
644 | + self.assertThat( |
645 | + new_account.is_error_label_visible(), |
646 | + Eventually(Equals(True))) |
647 | + |
648 | + |
649 | +class NewUbuntuOneOnlineAccountErrorsTestCase( |
650 | + UbuntuOneCredentialsProviderAutopilotTests.TestCaseWithQMLWrapper): |
651 | + |
652 | + scenarios = [ |
653 | + ('no name', dict(_VALID_NEW_USER, name='')), |
654 | + ('no password', dict(_VALID_NEW_USER, password='')), |
655 | + ('password mismatch', dict( |
656 | + _VALID_NEW_USER, password_confirmation='different password')), |
657 | + ('short password', dict( |
658 | + _VALID_NEW_USER, password='short', password_confirmation='short')) |
659 | + ] |
660 | + |
661 | + test_qml_wrapper_file_name = 'TestWrapperNew.qml' |
662 | + |
663 | + def test_new_user_error(self): |
664 | + new_account = self.main_view.select_single(emulators.NewAccount) |
665 | + new_account.register_new_account( |
666 | + self.email, self.name, self.password, self.password_confirmation, |
667 | + self.agree_to_terms) |
668 | + |
669 | + self.assertThat( |
670 | + new_account.is_error_label_visible(), Eventually(Equals(True))) |
PASSED: Continuous integration, rev:73 jenkins. qa.ubuntu. com/job/ ubuntuone- credentials- ci/50/ jenkins. qa.ubuntu. com/job/ ubuntuone- credentials- saucy-amd64- manual/ 48
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/ubuntuone- credentials- ci/50/rebuild
http://