Merge lp:~elopio/unity8/test_open_app_from_launcher into lp:unity8
- test_open_app_from_launcher
- Merge into trunk
Proposed by
Leo Arias
Status: | Superseded |
---|---|
Proposed branch: | lp:~elopio/unity8/test_open_app_from_launcher |
Merge into: | lp:unity8 |
Diff against target: |
844 lines (+307/-94) 15 files modified
.bazaar/plugins/makecheck_unity_phablet.py (+17/-9) qml/Launcher/LauncherDelegate.qml (+1/-0) qml/Launcher/LauncherPanel.qml (+1/-0) tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py (+15/-0) tests/autopilot/unity8/process_helpers.py (+4/-3) tests/autopilot/unity8/shell/emulators/launcher.py (+57/-14) tests/autopilot/unity8/shell/emulators/main_window.py (+35/-3) tests/autopilot/unity8/shell/tests/__init__.py (+1/-2) tests/autopilot/unity8/shell/tests/disabled_test_hud.py (+45/-15) tests/autopilot/unity8/shell/tests/test_emulators.py (+58/-3) tests/autopilot/unity8/shell/tests/test_lock_screen.py (+4/-5) tests/autopilot/unity8/shell/tests/test_notifications.py (+17/-12) tests/autopilot/unity8/shell/tests/test_system_integration.py (+10/-5) tests/autopilot/unity8/shell/tests/test_upstart.py (+20/-11) tests/whitespace/check_whitespace.py (+22/-12) |
To merge this branch: | bzr merge lp:~elopio/unity8/test_open_app_from_launcher |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2014-07-01.
Commit message
Description of the change
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bazaar/plugins/makecheck_unity_phablet.py' |
2 | --- .bazaar/plugins/makecheck_unity_phablet.py 2014-03-24 16:23:37 +0000 |
3 | +++ .bazaar/plugins/makecheck_unity_phablet.py 2014-07-01 05:57:22 +0000 |
4 | @@ -1,5 +1,5 @@ |
5 | #!/usr/bin/python |
6 | -# Copyright 2013 Canonical Ltd. |
7 | +# Copyright 2013, 2014 Canonical Ltd. |
8 | # |
9 | # This program is free software; you can redistribute it and/or modify |
10 | # it under the terms of the GNU Lesser General Public License as published by |
11 | @@ -13,11 +13,15 @@ |
12 | # You should have received a copy of the GNU Lesser General Public License |
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
14 | |
15 | -import os, subprocess |
16 | -from bzrlib import branch, errors |
17 | -from bzrlib.urlutils import dirname, local_path_from_url |
18 | - |
19 | -def execute_makecheck(local_branch, master_branch, old_revision_number, old_revision_id, future_revision_number, future_revision_id, tree_delta, future_tree): |
20 | +import os |
21 | +import subprocess |
22 | +from bzrlib import branch |
23 | +from bzrlib.urlutils import local_path_from_url |
24 | + |
25 | + |
26 | +def execute_makecheck( |
27 | + local_branch, master_branch, old_revision_number, old_revision_id, |
28 | + future_revision_number, future_revision_id, tree_delta, future_tree): |
29 | if not master_branch.basis_tree().has_filename("qml/Shell.qml"): |
30 | return |
31 | |
32 | @@ -27,7 +31,9 @@ |
33 | os.environ['CTEST_OUTPUT_ON_FAILURE'] = "1" |
34 | if (subprocess.call("make -C builddir test", shell=True) != 0): |
35 | |
36 | - print("\n\n*** Warning ***\n\nBasic tests failed. This commit will not pass continuous integration.") |
37 | + print("\n\n*** Warning ***\n\n" |
38 | + "Basic tests failed. This commit will not pass continuous " |
39 | + "integration.") |
40 | |
41 | branch = local_branch or master_branch |
42 | revision = branch.repository.get_revision(future_revision_id) |
43 | @@ -36,8 +42,10 @@ |
44 | msg_file.close() |
45 | |
46 | print("\n\nSaved commit message to $SRC_DIR/message.txt.") |
47 | - print("You can uncommit this revision, fix the tests and reuse your message running:\n\nbzr commit -F message.txt\n\n") |
48 | + print("You can uncommit this revision, fix the tests and reuse your " |
49 | + "message running:\n\nbzr commit -F message.txt\n\n") |
50 | elif os.path.isfile("message.txt"): |
51 | os.remove("message.txt") |
52 | |
53 | -branch.Branch.hooks.install_named_hook('pre_commit', execute_makecheck, 'make check pre-commit') |
54 | +branch.Branch.hooks.install_named_hook( |
55 | + 'pre_commit', execute_makecheck, 'make check pre-commit') |
56 | |
57 | === modified file 'qml/Launcher/LauncherDelegate.qml' |
58 | --- qml/Launcher/LauncherDelegate.qml 2013-10-16 11:33:26 +0000 |
59 | +++ qml/Launcher/LauncherDelegate.qml 2014-07-01 05:57:22 +0000 |
60 | @@ -20,6 +20,7 @@ |
61 | Item { |
62 | id: root |
63 | |
64 | + property string appId |
65 | property string iconName |
66 | property int count: -1 |
67 | property int progress: -1 |
68 | |
69 | === modified file 'qml/Launcher/LauncherPanel.qml' |
70 | --- qml/Launcher/LauncherPanel.qml 2013-12-11 12:57:14 +0000 |
71 | +++ qml/Launcher/LauncherPanel.qml 2014-07-01 05:57:22 +0000 |
72 | @@ -149,6 +149,7 @@ |
73 | delegate: FoldingLauncherDelegate { |
74 | id: launcherDelegate |
75 | objectName: "launcherDelegate" + index |
76 | + appId: model.appId |
77 | itemHeight: launcherListView.itemHeight |
78 | itemWidth: launcherListView.itemWidth |
79 | width: itemWidth |
80 | |
81 | === modified file 'tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py' |
82 | --- tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2014-06-11 15:36:51 +0000 |
83 | +++ tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2014-07-01 05:57:22 +0000 |
84 | @@ -115,3 +115,18 @@ |
85 | self.launch_upstart_application(application_name) |
86 | self.assertThat(greeter.created, Eventually(Equals(False))) |
87 | self.assert_current_focused_application(application_name) |
88 | + |
89 | + def test_click_dash_icon_must_unfocus_application(self): |
90 | + application_name = self.launch_fake_app() |
91 | + self.assert_current_focused_application(application_name) |
92 | + |
93 | + self.main_window.show_dash_from_launcher() |
94 | + |
95 | + self.assert_current_focused_application('') |
96 | + |
97 | + def test_click_app_icon_on_dash_must_focus_it(self): |
98 | + application_name = self.launch_fake_app() |
99 | + self.main_window.show_dash_from_launcher() |
100 | + |
101 | + self.main_window.launch_application(application_name) |
102 | + self.assert_current_focused_application(application_name) |
103 | |
104 | === modified file 'tests/autopilot/unity8/process_helpers.py' |
105 | --- tests/autopilot/unity8/process_helpers.py 2014-06-11 15:36:51 +0000 |
106 | +++ tests/autopilot/unity8/process_helpers.py 2014-07-01 05:57:22 +0000 |
107 | @@ -75,7 +75,7 @@ |
108 | main_window_emulator.QQuickView) |
109 | |
110 | greeter = main_window.get_greeter() |
111 | - if greeter.created == False: |
112 | + if greeter.created is False: |
113 | raise RuntimeWarning("Greeter appears to be already unlocked.") |
114 | |
115 | # Because of potential input jerkiness under heavy load, |
116 | @@ -98,7 +98,8 @@ |
117 | |
118 | def lock_unity(unity_proxy_obj=None): |
119 | """Helper function that attempts to lock the unity greeter.""" |
120 | - import evdev, time |
121 | + import evdev |
122 | + import time |
123 | uinput = evdev.UInput(name='unity8-autopilot-power-button', |
124 | devnode='/dev/autopilot-uinput') |
125 | # One press and release to turn screen off (locking unity) |
126 | @@ -172,7 +173,7 @@ |
127 | |
128 | def _get_unity_pid(): |
129 | status = _get_unity_status() |
130 | - if not "start/" in status: |
131 | + if "start/" not in status: |
132 | raise CannotAccessUnity("Unity is not in the running state.") |
133 | return int(status.split()[-1]) |
134 | |
135 | |
136 | === modified file 'tests/autopilot/unity8/shell/emulators/launcher.py' |
137 | --- tests/autopilot/unity8/shell/emulators/launcher.py 2013-11-01 13:59:50 +0000 |
138 | +++ tests/autopilot/unity8/shell/emulators/launcher.py 2014-07-01 05:57:22 +0000 |
139 | @@ -1,7 +1,7 @@ |
140 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
141 | # |
142 | # Unity Autopilot Test Suite |
143 | -# Copyright (C) 2012-2013 Canonical |
144 | +# Copyright (C) 2012, 2013, 2014 Canonical |
145 | # |
146 | # This program is free software: you can redistribute it and/or modify |
147 | # it under the terms of the GNU General Public License as published by |
148 | @@ -17,22 +17,65 @@ |
149 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
150 | # |
151 | |
152 | -from unity8.shell.emulators import UnityEmulatorBase |
153 | -from autopilot.input import Touch |
154 | - |
155 | - |
156 | -class Launcher(UnityEmulatorBase): |
157 | +import logging |
158 | + |
159 | +import autopilot.logging |
160 | + |
161 | +from unity8.shell import emulators |
162 | + |
163 | + |
164 | +logger = logging.getLogger(__name__) |
165 | + |
166 | + |
167 | +class Launcher(emulators.UnityEmulatorBase): |
168 | |
169 | """An emulator that understands the Launcher.""" |
170 | |
171 | + @autopilot.logging.log_action(logger.debug) |
172 | def show(self): |
173 | - """Swipes open the launcher.""" |
174 | - touch = Touch.create() |
175 | + """Show the launcher swiping it to the right.""" |
176 | + if not self.shown: |
177 | + self._swipe_launcher('right') |
178 | + self.shown.wait_for(True) |
179 | + else: |
180 | + logger.debug('The launcher is already opened.') |
181 | |
182 | + def _swipe_launcher(self, direction): |
183 | view = self.get_root_instance().select_single('QQuickView') |
184 | - start_x = view.x + 1 |
185 | - start_y = view.y + view.height / 2 |
186 | - stop_x = start_x + self.panelWidth + 1 |
187 | - stop_y = start_y |
188 | - touch.drag(start_x, start_y, stop_x, stop_y) |
189 | - self.shown.wait_for(True) |
190 | + start_y = stop_y = view.y + view.height // 2 |
191 | + |
192 | + left = view.x + 1 |
193 | + right = left + self.panelWidth - 1 |
194 | + |
195 | + if direction == 'right': |
196 | + start_x = left |
197 | + stop_x = right |
198 | + elif direction == 'left': |
199 | + start_x = right |
200 | + stop_x = left |
201 | + |
202 | + self.pointing_device.drag(start_x, start_y, stop_x, stop_y) |
203 | + |
204 | + @autopilot.logging.log_action(logger.debug) |
205 | + def hide(self): |
206 | + """Hide the launcher swiping it to the left.""" |
207 | + if self.shown: |
208 | + self._swipe_launcher('left') |
209 | + self.shown.wait_for(False) |
210 | + else: |
211 | + logger.debug('The launcher is already closed.') |
212 | + |
213 | + @autopilot.logging.log_action(logger.debug) |
214 | + def click_dash_icon(self): |
215 | + if self.shown: |
216 | + dash_icon = self.select_single( |
217 | + 'QQuickImage', objectName='dashItem') |
218 | + self.pointing_device.click_object(dash_icon) |
219 | + else: |
220 | + raise emulators.UnityEmulatorException('The launcher is closed.') |
221 | + |
222 | + @autopilot.logging.log_action(logger.debug) |
223 | + def click_application_launcher_icon(self, application_name): |
224 | + launcher_delegate = self.select_single( |
225 | + 'LauncherDelegate', appId=application_name) |
226 | + self.pointing_device.click_object(launcher_delegate) |
227 | |
228 | === modified file 'tests/autopilot/unity8/shell/emulators/main_window.py' |
229 | --- tests/autopilot/unity8/shell/emulators/main_window.py 2014-05-20 18:47:15 +0000 |
230 | +++ tests/autopilot/unity8/shell/emulators/main_window.py 2014-07-01 05:57:22 +0000 |
231 | @@ -67,9 +67,6 @@ |
232 | def get_bottombar(self): |
233 | return self.select_single("Bottombar") |
234 | |
235 | - def get_launcher(self): |
236 | - return self.select_single(Launcher) |
237 | - |
238 | def get_pinPadLoader(self): |
239 | return self.select_single( |
240 | "QQuickLoader", |
241 | @@ -139,3 +136,38 @@ |
242 | |
243 | def _get_search_indicator(self): |
244 | return self.select_single('SearchIndicator', objectName='search') |
245 | + |
246 | + @autopilot_logging.log_action(logger.info) |
247 | + def show_dash_from_launcher(self): |
248 | + """Open the dash clicking the dash icon on the launcher.""" |
249 | + launcher = self.open_launcher() |
250 | + launcher.click_dash_icon() |
251 | + return self.get_dash() |
252 | + |
253 | + @autopilot_logging.log_action(logger.info) |
254 | + def open_launcher(self): |
255 | + launcher = self._get_launcher() |
256 | + launcher.show() |
257 | + return launcher |
258 | + |
259 | + def _get_launcher(self): |
260 | + return self.select_single(Launcher) |
261 | + |
262 | + @autopilot_logging.log_action(logger.info) |
263 | + def close_launcher(self): |
264 | + launcher = self._get_launcher() |
265 | + launcher.hide() |
266 | + |
267 | + def is_launcher_open(self): |
268 | + return self._get_launcher().shown |
269 | + |
270 | + @autopilot_logging.log_action(logger.info) |
271 | + def launch_application(self, application_name): |
272 | + """Launch an application. |
273 | + |
274 | + :parameter application_name: The name of the application to launch. |
275 | + |
276 | + """ |
277 | + launcher = self.open_launcher() |
278 | + launcher.click_application_launcher_icon(application_name) |
279 | + self.get_current_focused_app_id().wait_for(application_name) |
280 | |
281 | === modified file 'tests/autopilot/unity8/shell/tests/__init__.py' |
282 | --- tests/autopilot/unity8/shell/tests/__init__.py 2014-06-11 15:36:51 +0000 |
283 | +++ tests/autopilot/unity8/shell/tests/__init__.py 2014-07-01 05:57:22 +0000 |
284 | @@ -142,12 +142,11 @@ |
285 | self._data_dirs_mock_enabled = True |
286 | self._environment = {} |
287 | |
288 | - #### FIXME: This is a work around re: lp:1238417 #### |
289 | + # FIXME: This is a work around re: lp:1238417 |
290 | if model() != "Desktop": |
291 | from autopilot.input import _uinput |
292 | _uinput._touch_device = _uinput.create_touch_device() |
293 | self.addCleanup(_uinput._touch_device.close) |
294 | - #### |
295 | |
296 | self.touch = Touch.create() |
297 | self._setup_display_details() |
298 | |
299 | === modified file 'tests/autopilot/unity8/shell/tests/disabled_test_hud.py' |
300 | --- tests/autopilot/unity8/shell/tests/disabled_test_hud.py 2014-06-11 15:36:51 +0000 |
301 | +++ tests/autopilot/unity8/shell/tests/disabled_test_hud.py 2014-07-01 05:57:22 +0000 |
302 | @@ -20,12 +20,13 @@ |
303 | from __future__ import absolute_import |
304 | |
305 | from unity8.process_helpers import unlock_unity |
306 | -from unity8.shell import with_lightdm_mock, DragMixin |
307 | +from unity8.shell import DragMixin |
308 | from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios |
309 | |
310 | from testtools.matchers import Equals |
311 | from autopilot.matchers import Eventually |
312 | |
313 | + |
314 | class TestHud(UnityTestCase, DragMixin): |
315 | |
316 | """Tests the Shell HUD.""" |
317 | @@ -33,10 +34,14 @@ |
318 | scenarios = _get_device_emulation_scenarios() |
319 | |
320 | def test_show_hud_button_appears(self): |
321 | - """Swiping up while an app is active must show the 'show hud' button, following some behaviours. |
322 | + """Swiping up while an app is active must show the 'show hud' button. |
323 | + |
324 | + It should follow some behaviours. |
325 | The button must disappear not opening the HUD when releasing the |
326 | - mouse again somewhere on the screen except on the button itself following a timeout. |
327 | - The button must disappear when touching somewhere on the screen except the button itself. |
328 | + mouse again somewhere on the screen except on the button itself |
329 | + following a timeout. |
330 | + The button must disappear when touching somewhere on the screen |
331 | + except the button itself. |
332 | |
333 | """ |
334 | unity_proxy = self.launch_unity() |
335 | @@ -55,29 +60,47 @@ |
336 | |
337 | self.touch.press(swipe_coords.start_x, swipe_coords.start_y) |
338 | self.addCleanup(self._maybe_release_finger) |
339 | - self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5) |
340 | + self._drag( |
341 | + swipe_coords.start_x, |
342 | + swipe_coords.start_y, |
343 | + swipe_coords.start_x, |
344 | + swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5) |
345 | self.assertThat(hud_show_button.opacity, Eventually(Equals(0.5))) |
346 | - self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(initialBottomMargin))) |
347 | - self._drag(swipe_coords.start_x, swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5, swipe_coords.end_x, swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - int(edge_drag_area.commitDistance) - 5) |
348 | + self.assertThat( |
349 | + hud_show_button.bottomMargin, |
350 | + Eventually(Equals(initialBottomMargin))) |
351 | + self._drag( |
352 | + swipe_coords.start_x, |
353 | + swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5, |
354 | + swipe_coords.end_x, |
355 | + swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - |
356 | + int(edge_drag_area.commitDistance) - 5) |
357 | self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0))) |
358 | self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0))) |
359 | - self.touch.release(); |
360 | + self.touch.release() |
361 | self.assertThat(hud.shown, Equals(False)) |
362 | self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0))) |
363 | |
364 | self.touch.press(swipe_coords.start_x, swipe_coords.start_y) |
365 | - self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y - int(hud_show_button.height)) |
366 | + self._drag( |
367 | + swipe_coords.start_x, |
368 | + swipe_coords.start_y, |
369 | + swipe_coords.start_x, |
370 | + swipe_coords.end_y - int(hud_show_button.height)) |
371 | self.assertThat(hud.shown, Equals(False)) |
372 | self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0))) |
373 | self.touch.release() |
374 | self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0))) |
375 | - self.touch.tap(swipe_coords.end_x, swipe_coords.end_y - int(hud_show_button.height)) |
376 | + self.touch.tap( |
377 | + swipe_coords.end_x, |
378 | + swipe_coords.end_y - int(hud_show_button.height)) |
379 | self.assertThat(hud.shown, Equals(False)) |
380 | self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0))) |
381 | |
382 | def test_show_hud_appears(self): |
383 | """Releasing the touch on the 'show hud' button must display the hud. |
384 | - Test that the hud button stays on screen and tapping it opens the hud. |
385 | + Test that the hud button stays on screen and tapping it opens the |
386 | + hud. |
387 | |
388 | """ |
389 | unity_proxy = self.launch_unity() |
390 | @@ -94,7 +117,11 @@ |
391 | |
392 | self.touch.press(swipe_coords.start_x, swipe_coords.start_y) |
393 | self.addCleanup(self._maybe_release_finger) |
394 | - self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y) |
395 | + self._drag( |
396 | + swipe_coords.start_x, |
397 | + swipe_coords.start_y, |
398 | + swipe_coords.start_x, |
399 | + swipe_coords.end_y) |
400 | self.assertThat(hud.shown, Eventually(Equals(False))) |
401 | self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0))) |
402 | self.touch.release() |
403 | @@ -105,7 +132,11 @@ |
404 | self.assertThat(hud.shown, Eventually(Equals(False))) |
405 | |
406 | self.touch.press(swipe_coords.start_x, swipe_coords.start_y) |
407 | - self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y - int(hud_show_button.height)) |
408 | + self._drag( |
409 | + swipe_coords.start_x, |
410 | + swipe_coords.start_y, |
411 | + swipe_coords.start_x, |
412 | + swipe_coords.end_y - int(hud_show_button.height)) |
413 | self.assertThat(hud.shown, Equals(False)) |
414 | self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0))) |
415 | self.touch.release() |
416 | @@ -153,12 +184,11 @@ |
417 | unity_proxy = self.launch_unity() |
418 | unlock_unity(unity_proxy) |
419 | hud = self.main_window.get_hud() |
420 | - launcher = self.main_window.get_launcher() |
421 | |
422 | self._launch_test_app_from_app_screen() |
423 | |
424 | hud.show() |
425 | - launcher.show() |
426 | + self.main_window.open_launcher() |
427 | |
428 | self.assertThat(hud.shown, Eventually(Equals(False))) |
429 | |
430 | |
431 | === modified file 'tests/autopilot/unity8/shell/tests/test_emulators.py' |
432 | --- tests/autopilot/unity8/shell/tests/test_emulators.py 2014-06-11 15:36:51 +0000 |
433 | +++ tests/autopilot/unity8/shell/tests/test_emulators.py 2014-07-01 05:57:22 +0000 |
434 | @@ -32,11 +32,12 @@ |
435 | except ImportError: |
436 | import mock |
437 | |
438 | -from testtools.matchers import Contains, HasLength |
439 | - |
440 | from unity8 import process_helpers |
441 | from unity8.shell import emulators, fixture_setup, tests |
442 | -from unity8.shell.emulators import dash as dash_emulators |
443 | +from unity8.shell.emulators import ( |
444 | + dash as dash_emulators, |
445 | + launcher as launcher_emulator |
446 | +) |
447 | |
448 | |
449 | class MainWindowTestCase(tests.UnityTestCase): |
450 | @@ -54,6 +55,24 @@ |
451 | self.assertEqual(text_field.text, 'Test') |
452 | self.assertEqual(text_field.state, 'idle') |
453 | |
454 | + def test_open_launcher_must_return_launcher_custom_proxy_object(self): |
455 | + launcher = self.main_window.open_launcher() |
456 | + self.assertIsInstance(launcher, launcher_emulator.Launcher) |
457 | + |
458 | + def test_open_launcher_must_open_it(self): |
459 | + # Make sure that the launcher is closed. |
460 | + self.main_window.close_launcher() |
461 | + self.main_window.open_launcher() |
462 | + |
463 | + self.assertTrue(self.main_window.is_launcher_open()) |
464 | + |
465 | + def test_close_launcher_must_close_it(self): |
466 | + # Make sure that the launcher is open. |
467 | + self.main_window.open_launcher() |
468 | + self.main_window.close_launcher() |
469 | + |
470 | + self.assertFalse(self.main_window.is_launcher_open()) |
471 | + |
472 | |
473 | class DashBaseTestCase(tests.UnityTestCase): |
474 | |
475 | @@ -200,3 +219,39 @@ |
476 | return filtergrid.collapsedRowCount * filtergrid.columns |
477 | else: |
478 | return filtergrid.uncollapsedRowCount * filtergrid.columns |
479 | + |
480 | + |
481 | +class LauncherTestCase(tests.UnityTestCase): |
482 | + |
483 | + scenarios = tests._get_device_emulation_scenarios() |
484 | + |
485 | + def setUp(self): |
486 | + super(LauncherTestCase, self).setUp() |
487 | + unity_proxy = self.launch_unity() |
488 | + process_helpers.unlock_unity(unity_proxy) |
489 | + |
490 | + def test_show_launcher_with_launcher_open_must_do_nothing(self): |
491 | + launcher = self.main_window.open_launcher() |
492 | + with mock.patch.object(launcher.pointing_device, 'drag') as mock_drag: |
493 | + launcher.show() |
494 | + |
495 | + self.assertFalse(mock_drag.called) |
496 | + |
497 | + def test_hide_launcher_with_launcher_closed_must_do_nothing(self): |
498 | + launcher = self.main_window.open_launcher() |
499 | + launcher.hide() |
500 | + with mock.patch.object(launcher.pointing_device, 'drag') as mock_drag: |
501 | + launcher.hide() |
502 | + |
503 | + self.assertFalse(mock_drag.called) |
504 | + |
505 | + def test_click_dash_icon_with_launcher_closed_must_raise_exception(self): |
506 | + launcher = self.main_window.open_launcher() |
507 | + launcher.hide() |
508 | + |
509 | + exception = self.assertRaises( |
510 | + emulators.UnityEmulatorException, |
511 | + launcher.click_dash_icon) |
512 | + |
513 | + self.assertEqual( |
514 | + 'The launcher is closed.', str(exception)) |
515 | |
516 | === modified file 'tests/autopilot/unity8/shell/tests/test_lock_screen.py' |
517 | --- tests/autopilot/unity8/shell/tests/test_lock_screen.py 2014-06-11 15:36:51 +0000 |
518 | +++ tests/autopilot/unity8/shell/tests/test_lock_screen.py 2014-07-01 05:57:22 +0000 |
519 | @@ -1,7 +1,7 @@ |
520 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
521 | # |
522 | # Unity Autopilot Test Suite |
523 | -# Copyright (C) 2012-2013 Canonical |
524 | +# Copyright (C) 2012, 2013, 2014 Canonical |
525 | # |
526 | # This program is free software: you can redistribute it and/or modify |
527 | # it under the terms of the GNU General Public License as published by |
528 | @@ -25,9 +25,7 @@ |
529 | from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios |
530 | |
531 | from autopilot.matchers import Eventually |
532 | -from autopilot.platform import model |
533 | import sys |
534 | -from testtools import skipUnless |
535 | from testtools.matchers import Equals |
536 | import logging |
537 | |
538 | @@ -133,7 +131,7 @@ |
539 | if not isinstance(code, basestring): |
540 | raise TypeError( |
541 | "'code' parameter must be a string, not %r." |
542 | - % type(passphrase) |
543 | + % type(code) |
544 | ) |
545 | for num in code: |
546 | if not num.isdigit(): |
547 | @@ -190,7 +188,8 @@ |
548 | current_text = prompt.text |
549 | self.keyboard.type(character) |
550 | try: |
551 | - self.assertThat(prompt.text, Eventually(Equals(current_text + character))) |
552 | + self.assertThat( |
553 | + prompt.text, Eventually(Equals(current_text + character))) |
554 | except AssertionError: |
555 | if retries > 0: |
556 | self._type_character(character, prompt, retries-1) |
557 | |
558 | === modified file 'tests/autopilot/unity8/shell/tests/test_notifications.py' |
559 | --- tests/autopilot/unity8/shell/tests/test_notifications.py 2014-06-11 15:36:51 +0000 |
560 | +++ tests/autopilot/unity8/shell/tests/test_notifications.py 2014-07-01 05:57:22 +0000 |
561 | @@ -211,8 +211,8 @@ |
562 | self.touch.tap_object(notification.select_single(objectName="button4")) |
563 | self.assert_notification_action_id_was_called("action_decline_4") |
564 | |
565 | - def test_modal_sd_without_greeter (self): |
566 | - """A snap-decision on a phone should block input to shell beneath it when there's no greeter.""" |
567 | + def test_modal_sd_without_greeter(self): |
568 | + """Snap-decision should block input to shell without greeter.""" |
569 | unity_proxy = self.launch_unity() |
570 | unlock_unity(unity_proxy) |
571 | |
572 | @@ -238,24 +238,26 @@ |
573 | hints |
574 | ) |
575 | |
576 | - # verify that we cannot reveal the launcher (no longer interact with the shell) |
577 | + # verify that we cannot reveal the launcher (no longer interact with |
578 | + # the shell) |
579 | time.sleep(1) |
580 | self.main_window.show_dash_swiping() |
581 | - launcher = self.main_window.get_launcher() |
582 | - self.assertThat(launcher.shown, Eventually(Equals(False))) |
583 | + self.assertThat( |
584 | + self.main_window.is_launcher_open, Eventually(Equals(False))) |
585 | |
586 | # verify and interact with the triggered snap-decision notification |
587 | notify_list = self._get_notifications_list() |
588 | get_notification = lambda: notify_list.wait_select_single( |
589 | 'Notification', objectName='notification1') |
590 | notification = get_notification() |
591 | - self._assert_notification(notification, summary, body, True, False, 1.0) |
592 | + self._assert_notification( |
593 | + notification, summary, body, True, False, 1.0) |
594 | self.touch.tap_object(notification.select_single(objectName="button0")) |
595 | self.assert_notification_action_id_was_called("action_accept") |
596 | |
597 | - def test_modal_sd_with_greeter (self): |
598 | - """A snap-decision on a phone should not block input to the greeter beneath it.""" |
599 | - unity_proxy = self.launch_unity() |
600 | + def test_modal_sd_with_greeter(self): |
601 | + """A snap-decision should not block input to the greeter beneath it.""" |
602 | + self.launch_unity() |
603 | |
604 | summary = "Incoming file" |
605 | body = "Frank would like to send you the file: essay.pdf" |
606 | @@ -290,7 +292,8 @@ |
607 | get_notification = lambda: notify_list.wait_select_single( |
608 | 'Notification', objectName='notification1') |
609 | notification = get_notification() |
610 | - self._assert_notification(notification, summary, body, True, False, 1.0) |
611 | + self._assert_notification( |
612 | + notification, summary, body, True, False, 1.0) |
613 | self.touch.tap_object(notification.select_single(objectName="button0")) |
614 | self.assert_notification_action_id_was_called("action_accept") |
615 | |
616 | @@ -663,7 +666,8 @@ |
617 | icon_path = self._get_icon_path('avatars/amanda.png') |
618 | notification.update(summary, body, icon_path) |
619 | notification.show() |
620 | - self._assert_notification(get_notification(), summary, body, True, False, 1.0) |
621 | + self._assert_notification( |
622 | + get_notification(), summary, body, True, False, 1.0) |
623 | |
624 | def test_update_notification_layout_change(self): |
625 | """Notification must allow updating its contents and layout while |
626 | @@ -710,7 +714,8 @@ |
627 | notification.show() |
628 | |
629 | self.assertThat(get_notification, Eventually(NotEquals(None))) |
630 | - self._assert_notification(get_notification(), summary, body, False, False, 1.0) |
631 | + self._assert_notification( |
632 | + get_notification(), summary, body, False, False, 1.0) |
633 | |
634 | def test_append_hint(self): |
635 | """Notification has to accumulate body-text using append-hint.""" |
636 | |
637 | === modified file 'tests/autopilot/unity8/shell/tests/test_system_integration.py' |
638 | --- tests/autopilot/unity8/shell/tests/test_system_integration.py 2014-04-09 17:31:15 +0000 |
639 | +++ tests/autopilot/unity8/shell/tests/test_system_integration.py 2014-07-01 05:57:22 +0000 |
640 | @@ -23,19 +23,24 @@ |
641 | import unittest |
642 | |
643 | from autopilot import platform |
644 | -from unity8.shell.emulators import UnityEmulatorBase |
645 | from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios |
646 | |
647 | -from testtools.matchers._basic import Equals |
648 | |
649 | class SystemIntegrationTests(UnityTestCase): |
650 | |
651 | scenarios = _get_device_emulation_scenarios() |
652 | |
653 | - @unittest.skipIf(platform.model() == "Desktop", "Test is broken on otto, see bug 1281634.") |
654 | + @unittest.skipIf( |
655 | + platform.model() == "Desktop", |
656 | + "Test is broken on otto, see bug 1281634.") |
657 | def test_networkmanager_integration(self): |
658 | self.launch_unity() |
659 | |
660 | # invoke policykit to check permissions |
661 | - pid = subprocess.check_output(["pidof", "-s", "unity8"], universal_newlines=True) |
662 | - subprocess.check_call("pkcheck --action-id org.freedesktop.NetworkManager.enable-disable-network --process " + pid, shell=True) |
663 | + pid = subprocess.check_output( |
664 | + ["pidof", "-s", "unity8"], universal_newlines=True) |
665 | + subprocess.check_call( |
666 | + "pkcheck --action-id " |
667 | + "org.freedesktop.NetworkManager.enable-disable-network " |
668 | + "--process " + pid, |
669 | + shell=True) |
670 | |
671 | === modified file 'tests/autopilot/unity8/shell/tests/test_upstart.py' |
672 | --- tests/autopilot/unity8/shell/tests/test_upstart.py 2014-05-01 14:25:18 +0000 |
673 | +++ tests/autopilot/unity8/shell/tests/test_upstart.py 2014-07-01 05:57:22 +0000 |
674 | @@ -1,7 +1,7 @@ |
675 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
676 | # |
677 | # Unity Autopilot Test Suite |
678 | -# Copyright (C) 2013 Canonical |
679 | +# Copyright (C) 2013, 2014 Canonical |
680 | # |
681 | # This program is free software: you can redistribute it and/or modify |
682 | # it under the terms of the GNU General Public License as published by |
683 | @@ -42,19 +42,24 @@ |
684 | if sys.version_info < (3,): |
685 | range = xrange |
686 | |
687 | + |
688 | class UpstartIntegrationTests(UnityTestCase): |
689 | |
690 | scenarios = _get_device_emulation_scenarios() |
691 | |
692 | def _get_status(self): |
693 | - pid, status = os.waitpid(self.process.pid, os.WUNTRACED | os.WCONTINUED | os.WNOHANG) |
694 | - logger.debug("Got status: {0}; stopped: {1}; continued: {2}"\ |
695 | - .format(status, os.WIFSTOPPED(status), os.WIFCONTINUED(status))) |
696 | + pid, status = os.waitpid( |
697 | + self.process.pid, os.WUNTRACED | os.WCONTINUED | os.WNOHANG) |
698 | + logger.debug( |
699 | + "Got status: {0}; stopped: {1}; continued: {2}".format( |
700 | + status, os.WIFSTOPPED(status), os.WIFCONTINUED(status))) |
701 | return status |
702 | |
703 | def _launch_unity(self): |
704 | self.patch_environment("QT_LOAD_TESTABILITY", "1") |
705 | - self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args) |
706 | + self.process = subprocess.Popen( |
707 | + [get_binary_path()] + self.unity_geometry_args) |
708 | + |
709 | def ensure_stopped(): |
710 | self.process.terminate() |
711 | for i in range(10): |
712 | @@ -76,10 +81,10 @@ |
713 | self.addCleanup(ensure_stopped) |
714 | |
715 | def _set_proxy(self): |
716 | - super(UpstartIntegrationTests, self)._set_proxy(get_proxy_object_for_existing_process( |
717 | - pid=self.process.pid, |
718 | - emulator_base=UnityEmulatorBase, |
719 | - )) |
720 | + super(UpstartIntegrationTests, self)._set_proxy( |
721 | + get_proxy_object_for_existing_process( |
722 | + pid=self.process.pid, |
723 | + emulator_base=UnityEmulatorBase,)) |
724 | |
725 | def test_no_sigstop(self): |
726 | self.patch_environment("UNITY_MIR_EMITS_SIGSTOP", "") |
727 | @@ -93,10 +98,14 @@ |
728 | def test_expect_sigstop(self): |
729 | self.patch_environment("UNITY_MIR_EMITS_SIGSTOP", "1") |
730 | self._launch_unity() |
731 | - self.assertThat(lambda: os.WIFSTOPPED(self._get_status()), Eventually(Equals(True)), "Unity8 should raise SIGSTOP when ready") |
732 | + self.assertThat( |
733 | + lambda: os.WIFSTOPPED(self._get_status()), |
734 | + Eventually(Equals(True)), "Unity8 should raise SIGSTOP when ready") |
735 | |
736 | self.process.send_signal(signal.SIGCONT) |
737 | - self.assertThat(lambda: os.WIFCONTINUED(self._get_status()), Eventually(Equals(True)), "Unity8 should have resumed") |
738 | + self.assertThat( |
739 | + lambda: os.WIFCONTINUED(self._get_status()), |
740 | + Eventually(Equals(True)), "Unity8 should have resumed") |
741 | |
742 | logger.debug("Unity started, waiting for it to be ready.") |
743 | self._set_proxy() |
744 | |
745 | === modified file 'tests/whitespace/check_whitespace.py' |
746 | --- tests/whitespace/check_whitespace.py 2013-06-05 22:03:08 +0000 |
747 | +++ tests/whitespace/check_whitespace.py 2014-07-01 05:57:22 +0000 |
748 | @@ -1,7 +1,7 @@ |
749 | #! /usr/bin/env python3 |
750 | |
751 | # |
752 | -# Copyright (C) 2013 Canonical Ltd |
753 | +# Copyright (C) 2013, 2014 Canonical Ltd |
754 | # |
755 | # This program is free software: you can redistribute it and/or modify |
756 | # it under the terms of the GNU General Public License version 3 as |
757 | @@ -19,8 +19,8 @@ |
758 | # |
759 | |
760 | # |
761 | -# Little helper program to test that source files do not contain trailing whitespace |
762 | -# or tab indentation. |
763 | +# Little helper program to test that source files do not contain trailing |
764 | +# whitespace or tab indentation. |
765 | # |
766 | # Usage: check_whitespace.py directory [ignore_prefix] |
767 | # |
768 | @@ -31,18 +31,20 @@ |
769 | # See the file_pat definition below for a list of files that are checked. |
770 | # |
771 | |
772 | +from __future__ import print_function |
773 | + |
774 | import argparse |
775 | import os |
776 | import re |
777 | import sys |
778 | |
779 | + |
780 | # Print msg on stderr, preceded by program name and followed by newline |
781 | - |
782 | def error(msg): |
783 | print(os.path.basename(sys.argv[0]) + ": " + msg, file=sys.stderr) |
784 | |
785 | + |
786 | # Function to raise errors encountered by os.walk |
787 | - |
788 | def raise_error(e): |
789 | raise e |
790 | |
791 | @@ -52,6 +54,7 @@ |
792 | whitespace_pat = re.compile(r'.*[ \t]$') |
793 | tab_indent_pat = re.compile(r'^ *\t') |
794 | |
795 | + |
796 | def scan_for_bad_whitespace(file_path): |
797 | global tab_indent_pat, whitespace_pat |
798 | errors = [] |
799 | @@ -69,7 +72,9 @@ |
800 | plural = 's' |
801 | else: |
802 | plural = '' |
803 | - print("%s: bad whitespace in line%s %s" % (file_path, plural, ", ".join((str(i) for i in errors)))) |
804 | + print( |
805 | + "%s: bad whitespace in line%s %s" % ( |
806 | + file_path, plural, ", ".join((str(i) for i in errors)))) |
807 | elif errors: |
808 | print("%s: bad whitespace in multiple lines" % file_path) |
809 | if newlines_at_end: |
810 | @@ -78,15 +83,20 @@ |
811 | |
812 | # Parse args |
813 | |
814 | -parser = argparse.ArgumentParser(description = 'Test that source files do not contain trailing whitespace.') |
815 | -parser.add_argument('dir', nargs = 1, help = 'The directory to (recursively) search for source files') |
816 | -parser.add_argument('ignore_prefix', nargs = '?', default=None, |
817 | - help = 'Ignore source files with a path that starts with the given prefix.') |
818 | +parser = argparse.ArgumentParser( |
819 | + description='Test that source files do not contain trailing whitespace.') |
820 | +parser.add_argument( |
821 | + 'dir', nargs=1, |
822 | + help='The directory to (recursively) search for source files') |
823 | +parser.add_argument( |
824 | + 'ignore_prefix', nargs='?', default=None, |
825 | + help='Ignore source files with a path that starts with the given prefix.') |
826 | args = parser.parse_args() |
827 | |
828 | # Files we want to check for trailing whitespace. |
829 | |
830 | -file_pat = r'(.*\.(c|cpp|h|hpp|hh|in|install|js|py|qml|sh)$)|(.*CMakeLists\.txt$)' |
831 | +file_pat = ( |
832 | + r'(.*\.(c|cpp|h|hpp|hh|in|install|js|py|qml|sh)$)|(.*CMakeLists\.txt$)') |
833 | pat = re.compile(file_pat) |
834 | |
835 | # Find all the files with matching file extension in the specified |
836 | @@ -97,7 +107,7 @@ |
837 | |
838 | found_whitespace = False |
839 | try: |
840 | - for root, dirs, files in os.walk(directory, onerror = raise_error): |
841 | + for root, dirs, files in os.walk(directory, onerror=raise_error): |
842 | for file in files: |
843 | path = os.path.join(root, file) |
844 | if not (ignore and path.startswith(ignore)) and pat.match(file): |