Merge lp:~elopio/unity8/url-dispatcher_test into lp:unity8
- url-dispatcher_test
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Albert Astals Cid |
Approved revision: | 700 |
Merged at revision: | 707 |
Proposed branch: | lp:~elopio/unity8/url-dispatcher_test |
Merge into: | lp:unity8 |
Diff against target: |
633 lines (+213/-77) 9 files modified
debian/control (+2/-0) tests/autopilot/unity8/__init__.py (+16/-12) tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py (+9/-13) tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py (+116/-0) tests/autopilot/unity8/process_helpers.py (+9/-7) tests/autopilot/unity8/shell/emulators/main_window.py (+47/-29) tests/autopilot/unity8/shell/tests/__init__.py (+8/-6) tests/autopilot/unity8/shell/tests/test_hud.py (+4/-7) tests/autopilot/unity8/shell/tests/test_notifications.py (+2/-3) |
To merge this branch: | bzr merge lp:~elopio/unity8/url-dispatcher_test |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Michael Terry | Approve | ||
Richard Huddie | Pending | ||
Víctor R. Ruiz | Pending | ||
Javier Collado | Pending | ||
Ubuntu Unity PS integration team | Pending | ||
Review via email: mp+205037@code.launchpad.net |
Commit message
Added a test to swipe out an application started by url-dispatcher.
Description of the change
The branch is a little big because I refactored the MainWindow, so we could use it as the rest of emulators. That makes it clearer, and we don't have to instantiate the pointing device again.
Please note that this test uses the real applications manager.
* Are there any related MPs required for this MP to build/function as expected? No, there are not.
* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP? Yes.
* If you changed the UI, has there been a design review? I didn't change the UI.
Michael Terry (mterry) wrote : | # |
Leo Arias (elopio) wrote : | # |
Right, thanks for catching those things. Fixed and pushed.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:686
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Leo Arias (elopio) wrote : | # |
Taking a look at the error...
Leo Arias (elopio) wrote : | # |
Setting again for review, to see how jenkins goes this time.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:691
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michael Terry (mterry) wrote : | # |
As discussed on IRC, to actually hit the code path that we want, we'll need to launch settings:
Leo Arias (elopio) wrote : | # |
Yes, the thing is that I can't launch online accounts, even without the mocks.
Sometimes I can launch the camera app, so I was checking if jenkins could do it too. It seems it can't :(
I'm going to have lunch, and then back to try some more things. This new deb makes things easier to debug.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:692
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:694
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:695
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:696
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:697
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:698
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:699
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michael Terry (mterry) wrote : | # |
Refactoring seems fine. Test works for me.
* Did you perform an exploratory manual test run of the code change and any related functionality?
- Yes. Ran test manually.
* Did CI run pass? If not, please explain why.
- Yup!
Albert Astals Cid (aacid) wrote : | # |
Doesn't cleanly merge into trunk anymore.
Please remerge.
Leo Arias (elopio) wrote : | # |
Merged and solved the conflict.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:700
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:700
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2014-02-04 14:08:24 +0000 |
3 | +++ debian/control 2014-02-12 06:11:39 +0000 |
4 | @@ -111,8 +111,10 @@ |
5 | python-fixtures, |
6 | python-gi, |
7 | python-mock, |
8 | + ubuntu-ui-toolkit-autopilot, |
9 | unity8 (>= ${source:Version}), |
10 | unity8-fake-env (>= ${source:Version}), |
11 | + url-dispatcher-tools, |
12 | ${misc:Depends}, |
13 | ${python:Depends}, |
14 | ${shlibs:Depends}, |
15 | |
16 | === modified file 'tests/autopilot/unity8/__init__.py' |
17 | --- tests/autopilot/unity8/__init__.py 2013-10-17 09:01:20 +0000 |
18 | +++ tests/autopilot/unity8/__init__.py 2014-02-12 06:11:39 +0000 |
19 | @@ -1,7 +1,7 @@ |
20 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
21 | # |
22 | # Unity Autopilot Test Suite |
23 | -# Copyright (C) 2012-2013 Canonical |
24 | +# Copyright (C) 2012, 2013, 2014 Canonical |
25 | # |
26 | # This program is free software: you can redistribute it and/or modify |
27 | # it under the terms of the GNU General Public License as published by |
28 | @@ -88,28 +88,31 @@ |
29 | return binary_path |
30 | |
31 | |
32 | -def get_data_dirs(): |
33 | +def get_data_dirs(data_dirs_mock_enabled=True): |
34 | """Prepend a mock data path to XDG_DATA_DIRS.""" |
35 | + data_dirs = _get_xdg_env_path() |
36 | + if data_dirs_mock_enabled: |
37 | + mock_data_path = _get_full_mock_data_path() |
38 | + if os.path.exists(mock_data_path): |
39 | + if data_dirs is not None: |
40 | + data_dirs = '{0}:{1}'.format(mock_data_path, data_dirs) |
41 | + else: |
42 | + data_dirs = mock_data_path |
43 | + return data_dirs |
44 | + |
45 | + |
46 | +def _get_full_mock_data_path(): |
47 | if running_installed_tests(): |
48 | data_path = "/usr/share/unity8/mocks/data" |
49 | else: |
50 | data_path = "../../mocks/data" |
51 | - full_data_path = os.path.abspath( |
52 | + return os.path.abspath( |
53 | os.path.join( |
54 | os.path.dirname(__file__), |
55 | data_path |
56 | ) |
57 | ) |
58 | |
59 | - if os.path.exists(full_data_path): |
60 | - xdg_path = _get_xdg_env_path() |
61 | - if xdg_path is not None: |
62 | - return "{0}:{1}".format(full_data_path, xdg_path) |
63 | - else: |
64 | - return full_data_path |
65 | - else: |
66 | - return None |
67 | - |
68 | |
69 | def _get_xdg_env_path(): |
70 | path = os.getenv("XDG_DATA_DIRS") |
71 | @@ -129,6 +132,7 @@ |
72 | except subprocess.CalledProcessError: |
73 | return None |
74 | |
75 | + |
76 | def get_grid_size(): |
77 | grid_size = os.getenv('GRID_UNIT_PX') |
78 | if grid_size is None: |
79 | |
80 | === modified file 'tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py' |
81 | --- tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2013-12-16 22:51:30 +0000 |
82 | +++ tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2014-02-12 06:11:39 +0000 |
83 | @@ -1,7 +1,7 @@ |
84 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
85 | # |
86 | # Unity Autopilot Test Suite |
87 | -# Copyright (C) 2013 Canonical |
88 | +# Copyright (C) 2013, 2014 Canonical |
89 | # |
90 | # This program is free software: you can redistribute it and/or modify |
91 | # it under the terms of the GNU General Public License as published by |
92 | @@ -44,9 +44,8 @@ |
93 | self.skipTest("Test cannot be run on the desktop.") |
94 | |
95 | def swipe_screen_from_right(self): |
96 | - qml_view = self.main_window.get_qml_view() |
97 | - width = qml_view.width |
98 | - height = qml_view.height |
99 | + width = self.main_window.width |
100 | + height = self.main_window.height |
101 | start_x = width |
102 | start_y = int(height/2) |
103 | end_x = int(width/2) |
104 | @@ -55,9 +54,6 @@ |
105 | logger.info("Swiping screen from the right edge") |
106 | self.touch.drag(start_x, start_y, end_x, end_y) |
107 | |
108 | - def _get_current_focused_app_id(self): |
109 | - return self._proxy.select_single("Shell").currentFocusedAppId |
110 | - |
111 | def _launch_app(self, app_name): |
112 | """Launches the application *app_name* |
113 | |
114 | @@ -86,7 +82,7 @@ |
115 | |
116 | self.assertThat(app, NotEquals(None)) |
117 | self.assertThat( |
118 | - self._get_current_focused_app_id(), |
119 | + self.main_window.get_current_focused_app_id(), |
120 | Eventually(Equals("messaging-app")) |
121 | ) |
122 | |
123 | @@ -98,13 +94,13 @@ |
124 | |
125 | self._launch_app("messaging-app") |
126 | self.assertThat( |
127 | - self._get_current_focused_app_id(), |
128 | + self.main_window.get_current_focused_app_id(), |
129 | Eventually(Equals("messaging-app")) |
130 | ) |
131 | |
132 | self._launch_app("address-book-app") |
133 | self.assertThat( |
134 | - self._get_current_focused_app_id(), |
135 | + self.main_window.get_current_focused_app_id(), |
136 | Eventually(Equals("address-book-app")) |
137 | ) |
138 | |
139 | @@ -119,19 +115,19 @@ |
140 | |
141 | self._launch_app("messaging-app") |
142 | self.assertThat( |
143 | - self._get_current_focused_app_id(), |
144 | + self.main_window.get_current_focused_app_id(), |
145 | Eventually(Equals("messaging-app")) |
146 | ) |
147 | |
148 | self._launch_app("address-book-app") |
149 | self.assertThat( |
150 | - self._get_current_focused_app_id(), |
151 | + self.main_window.get_current_focused_app_id(), |
152 | Eventually(Equals("address-book-app")) |
153 | ) |
154 | |
155 | self.swipe_screen_from_right() |
156 | |
157 | self.assertThat( |
158 | - self._get_current_focused_app_id(), |
159 | + self.main_window.get_current_focused_app_id(), |
160 | Eventually(Equals("messaging-app")) |
161 | ) |
162 | |
163 | === added file 'tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py' |
164 | --- tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py 1970-01-01 00:00:00 +0000 |
165 | +++ tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py 2014-02-12 06:11:39 +0000 |
166 | @@ -0,0 +1,116 @@ |
167 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
168 | +# |
169 | +# Unity Autopilot Test Suite |
170 | +# Copyright (C) 2014 Canonical |
171 | +# |
172 | +# This program is free software: you can redistribute it and/or modify |
173 | +# it under the terms of the GNU General Public License as published by |
174 | +# the Free Software Foundation, either version 3 of the License, or |
175 | +# (at your option) any later version. |
176 | +# |
177 | +# This program is distributed in the hope that it will be useful, |
178 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
179 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
180 | +# GNU General Public License for more details. |
181 | +# |
182 | +# You should have received a copy of the GNU General Public License |
183 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
184 | +# |
185 | + |
186 | +"""Test the integration with the URL dispatcher service.""" |
187 | + |
188 | +import os |
189 | +import tempfile |
190 | + |
191 | +from autopilot import platform |
192 | +from autopilot.matchers import Eventually |
193 | +from testtools.matchers import Equals |
194 | +from ubuntuuitoolkit import base as toolkit_base |
195 | + |
196 | +from unity8 import process_helpers |
197 | +from unity8.shell import tests |
198 | + |
199 | + |
200 | +class URLDispatcherTestCase(tests.UnityTestCase): |
201 | + |
202 | + scenarios = tests._get_device_emulation_scenarios() |
203 | + |
204 | + test_qml = (""" |
205 | +import QtQuick 2.0 |
206 | +import Ubuntu.Components 0.1 |
207 | + |
208 | +MainView { |
209 | + width: units.gu(48) |
210 | + height: units.gu(60) |
211 | + |
212 | + Label { |
213 | + text: 'Test application.' |
214 | + } |
215 | +} |
216 | +""") |
217 | + |
218 | + desktop_file_contents = ("""[Desktop Entry] |
219 | +Type=Application |
220 | +Name=test |
221 | +Exec={qmlscene} {qml_file_path} |
222 | +Icon=Not important |
223 | +""") |
224 | + |
225 | + def setUp(self): |
226 | + if platform.model() == 'Desktop': |
227 | + self.skipTest("URL dispatcher doesn't work on the desktop.") |
228 | + super(URLDispatcherTestCase, self).setUp() |
229 | + self._qml_mock_enabled = False |
230 | + self._data_dirs_mock_enabled = False |
231 | + unity_proxy = self.launch_unity() |
232 | + process_helpers.unlock_unity(unity_proxy) |
233 | + |
234 | + def create_test_application(self): |
235 | + # FIXME most of this code is duplicated in the toolkit. We should |
236 | + # create a fixture on the toolkit for other projects to use. |
237 | + # http://pad.lv/1277334 --elopio - 2014-02-06 |
238 | + qml_file_path = self._write_test_qml_file() |
239 | + self.addCleanup(os.remove, qml_file_path) |
240 | + desktop_file_path = self._write_test_desktop_file(qml_file_path) |
241 | + self.addCleanup(os.remove, desktop_file_path) |
242 | + return qml_file_path, desktop_file_path |
243 | + |
244 | + def _write_test_qml_file(self): |
245 | + qml_file = tempfile.NamedTemporaryFile(suffix='.qml', delete=False) |
246 | + qml_file.write(self.test_qml.encode('utf-8')) |
247 | + qml_file.close() |
248 | + return qml_file.name |
249 | + |
250 | + def _write_test_desktop_file(self, qml_file_path): |
251 | + desktop_file_dir = self._get_local_desktop_file_directory() |
252 | + if not os.path.exists(desktop_file_dir): |
253 | + os.makedirs(desktop_file_dir) |
254 | + desktop_file = tempfile.NamedTemporaryFile( |
255 | + suffix='.desktop', dir=desktop_file_dir, delete=False) |
256 | + contents = self.desktop_file_contents.format( |
257 | + qmlscene=toolkit_base.get_qmlscene_launch_command(), |
258 | + qml_file_path=qml_file_path) |
259 | + desktop_file.write(contents.encode('utf-8')) |
260 | + desktop_file.close() |
261 | + return desktop_file.name |
262 | + |
263 | + def _get_local_desktop_file_directory(self): |
264 | + return os.path.join( |
265 | + os.environ.get('HOME'), '.local', 'share', 'applications') |
266 | + |
267 | + def test_swipe_out_application_started_by_url_dispatcher(self): |
268 | + _, desktop_file_path = self.create_test_application() |
269 | + desktop_file_name = os.path.basename(desktop_file_path) |
270 | + application_name, _ = os.path.splitext(desktop_file_name) |
271 | + |
272 | + self.assertEqual('', self.main_window.get_current_focused_app_id()) |
273 | + self.addCleanup(os.system, 'pkill qmlscene') |
274 | + os.system('url-dispatcher application:///{}'.format(desktop_file_name)) |
275 | + self.assertThat( |
276 | + self.main_window.get_current_focused_app_id, |
277 | + Eventually(Equals(application_name))) |
278 | + |
279 | + self.main_window.show_dash_swiping() |
280 | + self.assertThat( |
281 | + self.main_window.get_current_focused_app_id, |
282 | + Eventually(Equals(''))) |
283 | |
284 | === modified file 'tests/autopilot/unity8/process_helpers.py' |
285 | --- tests/autopilot/unity8/process_helpers.py 2014-01-24 09:30:49 +0000 |
286 | +++ tests/autopilot/unity8/process_helpers.py 2014-02-12 06:11:39 +0000 |
287 | @@ -1,7 +1,7 @@ |
288 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
289 | # |
290 | # Unity Autopilot Utilities |
291 | -# Copyright (C) 2013 Canonical |
292 | +# Copyright (C) 2013, 2014 Canonical |
293 | # |
294 | # This program is free software: you can redistribute it and/or modify |
295 | # it under the terms of the GNU General Public License as published by |
296 | @@ -23,8 +23,8 @@ |
297 | ) |
298 | import logging |
299 | import subprocess |
300 | -from unity8.shell.emulators import UnityEmulatorBase |
301 | -from unity8.shell.emulators.main_window import MainWindow |
302 | +from unity8.shell import emulators |
303 | +from unity8.shell.emulators import main_window as main_window_emulator |
304 | |
305 | logger = logging.getLogger(__name__) |
306 | |
307 | @@ -54,7 +54,7 @@ |
308 | try: |
309 | pid = _get_unity_pid() |
310 | unity = _get_unity_proxy_object(pid) |
311 | - main_window = MainWindow(unity) |
312 | + main_window = unity.select_single(main_window_emulator.QQuickView) |
313 | except ProcessSearchError as e: |
314 | raise CannotAccessUnity( |
315 | "Cannot introspect unity, make sure that it has been started " |
316 | @@ -64,7 +64,8 @@ |
317 | % str(e) |
318 | ) |
319 | else: |
320 | - main_window = MainWindow(unity_proxy_obj) |
321 | + main_window = unity_proxy_obj.select_single( |
322 | + main_window_emulator.QQuickView) |
323 | |
324 | greeter = main_window.get_greeter() |
325 | if greeter.created == False: |
326 | @@ -110,7 +111,8 @@ |
327 | status = _get_unity_status() |
328 | if "start/" in status: |
329 | try: |
330 | - output = subprocess.check_output(['/sbin/initctl', 'stop', 'unity8']) |
331 | + output = subprocess.check_output( |
332 | + ['/sbin/initctl', 'stop', 'unity8']) |
333 | logger.info(output) |
334 | except subprocess.CalledProcessError as e: |
335 | e.args += ( |
336 | @@ -155,5 +157,5 @@ |
337 | def _get_unity_proxy_object(pid): |
338 | return get_proxy_object_for_existing_process( |
339 | pid=pid, |
340 | - emulator_base=UnityEmulatorBase, |
341 | + emulator_base=emulators.UnityEmulatorBase, |
342 | ) |
343 | |
344 | === modified file 'tests/autopilot/unity8/shell/emulators/main_window.py' |
345 | --- tests/autopilot/unity8/shell/emulators/main_window.py 2014-02-05 11:46:38 +0000 |
346 | +++ tests/autopilot/unity8/shell/emulators/main_window.py 2014-02-12 06:11:39 +0000 |
347 | @@ -1,7 +1,7 @@ |
348 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
349 | # |
350 | # Unity Autopilot Test Suite |
351 | -# Copyright (C) 2012-2013 Canonical |
352 | +# Copyright (C) 2012, 2013, 2014 Canonical |
353 | # |
354 | # This program is free software: you can redistribute it and/or modify |
355 | # it under the terms of the GNU General Public License as published by |
356 | @@ -17,85 +17,103 @@ |
357 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
358 | # |
359 | |
360 | - |
361 | +import logging |
362 | + |
363 | +from autopilot import logging as autopilot_logging |
364 | + |
365 | +from unity8.shell import emulators |
366 | from unity8.shell.emulators.greeter import Greeter |
367 | from unity8.shell.emulators.hud import Hud |
368 | from unity8.shell.emulators.dash import Dash |
369 | from unity8.shell.emulators.launcher import Launcher |
370 | |
371 | - |
372 | -class MainWindow(object): |
373 | +logger = logging.getLogger(__name__) |
374 | + |
375 | + |
376 | +class QQuickView(emulators.UnityEmulatorBase): |
377 | """An emulator class that makes it easy to interact with the shell""" |
378 | |
379 | - def __init__(self, app): |
380 | - self.app = app |
381 | - |
382 | - def get_qml_view(self): |
383 | - """Get the main QML view""" |
384 | - return self.app.select_single("QQuickView") |
385 | - |
386 | def get_greeter(self): |
387 | - return self.app.select_single(Greeter) |
388 | + return self.select_single(Greeter) |
389 | |
390 | def get_greeter_content_loader(self): |
391 | - return self.app.wait_select_single( |
392 | + return self.wait_select_single( |
393 | "QQuickLoader", |
394 | objectName="greeterContentLoader" |
395 | ) |
396 | |
397 | def get_greeter_background(self): |
398 | - return self.app.select_single("CrossFadeImage", objectName="greeterBackground") |
399 | + return self.select_single( |
400 | + "CrossFadeImage", objectName="greeterBackground") |
401 | |
402 | def get_login_loader(self): |
403 | - return self.app.select_single("QQuickLoader", objectName="loginLoader") |
404 | + return self.select_single("QQuickLoader", objectName="loginLoader") |
405 | |
406 | def get_login_list(self): |
407 | - return self.app.select_single("LoginList") |
408 | + return self.select_single("LoginList") |
409 | |
410 | def get_hud(self): |
411 | - return self.app.select_single(Hud) |
412 | + return self.select_single(Hud) |
413 | |
414 | def get_hud_showable(self): |
415 | - return self.app.select_single("Showable", objectName="hudShowable") |
416 | + return self.select_single("Showable", objectName="hudShowable") |
417 | |
418 | def get_hud_show_button(self): |
419 | - return self.app.select_single("HudButton") |
420 | + return self.select_single("HudButton") |
421 | |
422 | def get_hud_edge_drag_area(self): |
423 | - return self.app.select_single(objectName="hudDragArea") |
424 | + return self.select_single(objectName="hudDragArea") |
425 | |
426 | def get_dash(self): |
427 | - return self.app.select_single(Dash) |
428 | + return self.select_single(Dash) |
429 | |
430 | def get_bottombar(self): |
431 | - return self.app.select_single("Bottombar") |
432 | + return self.select_single("Bottombar") |
433 | |
434 | def get_launcher(self): |
435 | - return self.app.select_single(Launcher) |
436 | + return self.select_single(Launcher) |
437 | |
438 | def get_pinPadLoader(self): |
439 | - return self.app.select_single( |
440 | + return self.select_single( |
441 | "QQuickLoader", |
442 | objectName="pinPadLoader" |
443 | ) |
444 | |
445 | def get_pinPadButton(self, buttonId): |
446 | - return self.app.select_single( |
447 | + return self.select_single( |
448 | "PinPadButton", |
449 | objectName="pinPadButton%i" % buttonId |
450 | ) |
451 | |
452 | def get_lockscreen(self): |
453 | - return self.app.select_single("Lockscreen") |
454 | + return self.select_single("Lockscreen") |
455 | |
456 | def get_pinentryField(self): |
457 | - return self.app.select_single(objectName="pinentryField") |
458 | + return self.select_single(objectName="pinentryField") |
459 | |
460 | def get_indicator(self, indicator_name): |
461 | - return self.app.wait_select_single( |
462 | + return self.wait_select_single( |
463 | 'DefaultIndicatorWidget', |
464 | objectName=indicator_name+'-widget' |
465 | ) |
466 | |
467 | def get_shell_background(self): |
468 | - return self.app.select_single("CrossFadeImage", objectName="backgroundImage") |
469 | + return self.select_single( |
470 | + "CrossFadeImage", objectName="backgroundImage") |
471 | + |
472 | + @autopilot_logging.log_action(logger.info) |
473 | + def show_dash_swiping(self): |
474 | + """Show the dash swiping from the left.""" |
475 | + width = self.width |
476 | + height = self.height |
477 | + start_x = 0 |
478 | + start_y = height // 2 |
479 | + end_x = width |
480 | + end_y = start_y |
481 | + |
482 | + self.pointing_device.drag(start_x, start_y, end_x, end_y) |
483 | + return self.get_dash() |
484 | + |
485 | + def get_current_focused_app_id(self): |
486 | + """Return the id of the focused application.""" |
487 | + return self.select_single('Shell').currentFocusedAppId |
488 | |
489 | === modified file 'tests/autopilot/unity8/shell/tests/__init__.py' |
490 | --- tests/autopilot/unity8/shell/tests/__init__.py 2014-01-09 21:23:23 +0000 |
491 | +++ tests/autopilot/unity8/shell/tests/__init__.py 2014-02-12 06:11:39 +0000 |
492 | @@ -1,7 +1,7 @@ |
493 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
494 | # |
495 | # Unity Autopilot Test Suite |
496 | -# Copyright (C) 2012-2013 Canonical |
497 | +# Copyright (C) 2012, 2013, 2014 Canonical |
498 | # |
499 | # This program is free software: you can redistribute it and/or modify |
500 | # it under the terms of the GNU General Public License as published by |
501 | @@ -43,8 +43,8 @@ |
502 | get_data_dirs |
503 | ) |
504 | from unity8.process_helpers import restart_unity_with_testability |
505 | +from unity8.shell.emulators import main_window as main_window_emulator |
506 | from unity8.shell.emulators.dash import Dash |
507 | -from unity8.shell.emulators.main_window import MainWindow |
508 | |
509 | |
510 | logger = logging.getLogger(__name__) |
511 | @@ -139,10 +139,9 @@ |
512 | self._proxy = None |
513 | self._lightdm_mock_type = None |
514 | self._qml_mock_enabled = True |
515 | + self._data_dirs_mock_enabled = True |
516 | self._environment = {} |
517 | |
518 | - self._patch_data_dirs() |
519 | - |
520 | #### FIXME: This is a work around re: lp:1238417 #### |
521 | if model() != "Desktop": |
522 | from autopilot.input import _uinput |
523 | @@ -268,6 +267,9 @@ |
524 | if self._qml_mock_enabled: |
525 | self._setup_extra_mock_environment_patch() |
526 | |
527 | + if self._data_dirs_mock_enabled: |
528 | + self._patch_data_dirs() |
529 | + |
530 | # FIXME: we shouldn't be doing this |
531 | # $MIR_SOCKET, fallback to $XDG_RUNTIME_DIR/mir_socket and |
532 | # /tmp/mir_socket as last resort |
533 | @@ -321,7 +323,7 @@ |
534 | logger.warning("Appears unity was already stopped!") |
535 | |
536 | def _patch_data_dirs(self): |
537 | - data_dirs = get_data_dirs() |
538 | + data_dirs = get_data_dirs(self._data_dirs_mock_enabled) |
539 | if data_dirs is not None: |
540 | self._environment['XDG_DATA_DIRS'] = data_dirs |
541 | |
542 | @@ -391,4 +393,4 @@ |
543 | |
544 | @property |
545 | def main_window(self): |
546 | - return MainWindow(self._proxy) |
547 | + return self._proxy.select_single(main_window_emulator.QQuickView) |
548 | |
549 | === modified file 'tests/autopilot/unity8/shell/tests/test_hud.py' |
550 | --- tests/autopilot/unity8/shell/tests/test_hud.py 2013-10-17 08:18:45 +0000 |
551 | +++ tests/autopilot/unity8/shell/tests/test_hud.py 2014-02-12 06:11:39 +0000 |
552 | @@ -1,7 +1,7 @@ |
553 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
554 | # |
555 | # Unity Autopilot Test Suite |
556 | -# Copyright (C) 2012-2013 Canonical |
557 | +# Copyright (C) 2012, 2013, 2014 Canonical |
558 | # |
559 | # This program is free software: you can redistribute it and/or modify |
560 | # it under the terms of the GNU General Public License as published by |
561 | @@ -41,7 +41,6 @@ |
562 | """ |
563 | unity_proxy = self.launch_unity() |
564 | unlock_unity(unity_proxy) |
565 | - window = self.main_window.get_qml_view() |
566 | hud_show_button = self.main_window.get_hud_show_button() |
567 | edge_drag_area = self.main_window.get_hud_edge_drag_area() |
568 | hud = self.main_window.get_hud() |
569 | @@ -49,7 +48,7 @@ |
570 | self._launch_test_app_from_app_screen() |
571 | |
572 | swipe_coords = hud.get_button_swipe_coords( |
573 | - window, |
574 | + self.main_window, |
575 | hud_show_button |
576 | ) |
577 | initialBottomMargin = int(hud_show_button.bottomMargin) |
578 | @@ -83,14 +82,13 @@ |
579 | """ |
580 | unity_proxy = self.launch_unity() |
581 | unlock_unity(unity_proxy) |
582 | - window = self.main_window.get_qml_view() |
583 | hud_show_button = self.main_window.get_hud_show_button() |
584 | hud = self.main_window.get_hud() |
585 | |
586 | self._launch_test_app_from_app_screen() |
587 | |
588 | swipe_coords = hud.get_button_swipe_coords( |
589 | - window, |
590 | + self.main_window, |
591 | hud_show_button |
592 | ) |
593 | |
594 | @@ -137,7 +135,6 @@ |
595 | """ |
596 | unity_proxy = self.launch_unity() |
597 | unlock_unity(unity_proxy) |
598 | - window = self.main_window.get_qml_view() |
599 | hud = self.main_window.get_hud() |
600 | |
601 | self._launch_test_app_from_app_screen() |
602 | @@ -146,7 +143,7 @@ |
603 | |
604 | start_x, start_y = hud.get_close_button_coords() |
605 | end_x = start_x |
606 | - end_y = int(window.height / 2) |
607 | + end_y = int(self.main_window.height / 2) |
608 | |
609 | self.touch.drag(start_x, start_y, end_x, end_y) |
610 | self.assertThat(hud.shown, Eventually(Equals(False))) |
611 | |
612 | === modified file 'tests/autopilot/unity8/shell/tests/test_notifications.py' |
613 | --- tests/autopilot/unity8/shell/tests/test_notifications.py 2014-01-28 16:20:24 +0000 |
614 | +++ tests/autopilot/unity8/shell/tests/test_notifications.py 2014-02-12 06:11:39 +0000 |
615 | @@ -1,7 +1,7 @@ |
616 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
617 | # |
618 | # Unity Autopilot Test Suite |
619 | -# Copyright (C) 2012-2013 Canonical |
620 | +# Copyright (C) 2012, 2013, 2014 Canonical |
621 | # |
622 | # This program is free software: you can redistribute it and/or modify |
623 | # it under the terms of the GNU General Public License as published by |
624 | @@ -61,8 +61,7 @@ |
625 | return os.path.dirname(__file__) + "/../../../../../qml/graphics/" + icon_name |
626 | |
627 | def _get_notifications_list(self): |
628 | - main_view = self.main_window.get_qml_view() |
629 | - return main_view.select_single( |
630 | + return self.main_window.select_single( |
631 | "Notifications", |
632 | objectName='notificationList' |
633 | ) |
Some quick nits before I get into testing this:
"it while the url-dispatcher implements" -> Do you mean "it until the url-dispatcher implements"?
The whitespace change in tests/autopilot /unity8/ shell/emulators /__init_ _.py isn't needed, eh? pep8 has two empty lines before a class definition I thought.