Merge lp:~om26er/unity8/launcher_integration_test into lp:unity8

Proposed by Omer Akram
Status: Superseded
Proposed branch: lp:~om26er/unity8/launcher_integration_test
Merge into: lp:unity8
Prerequisite: lp:~elopio/unity8/test_open_app_from_launcher
Diff against target: 367 lines (+216/-22)
9 files modified
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/shell/emulators/launcher.py (+57/-14)
tests/autopilot/unity8/shell/emulators/main_window.py (+35/-3)
tests/autopilot/unity8/shell/fixture_setup.py (+46/-0)
tests/autopilot/unity8/shell/tests/disabled_test_hud.py (+1/-2)
tests/autopilot/unity8/shell/tests/test_emulators.py (+58/-1)
tests/autopilot/unity8/shell/tests/test_notifications.py (+2/-2)
To merge this branch: bzr merge lp:~om26er/unity8/launcher_integration_test
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Needs Fixing
Leo Arias Pending
PS Jenkins bot continuous-integration Pending
Víctor R. Ruiz Pending
Review via email: mp+226087@code.launchpad.net

This proposal supersedes a proposal from 2014-06-26.

Description of the change

Autopilot: launch application from the launcher

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Víctor R. Ruiz (vrruiz) wrote : Posted in a previous version of this proposal

Please, use docstrings whenever possible. Specially, document a little bit what LauncherIcon class and its methods do.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Víctor R. Ruiz (vrruiz) wrote : Posted in a previous version of this proposal

Sorry, Omer. Can you describe in docstrings what the _backup_launcher_icons, _set_launcher_icons and _add_messaging_app_icon_to_launcher do? Something like "Calls to blahblah via DBus to blahblahblah".

Also, if possible, for portability would be better to use dbus python module than doing calls to the system (what if gdbus command is not available?).

review: Needs Fixing
Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

> Sorry, Omer. Can you describe in docstrings what the _backup_launcher_icons,
> _set_launcher_icons and _add_messaging_app_icon_to_launcher do? Something like
> "Calls to blahblah via DBus to blahblahblah".

They all are private methods, I don't think docstrings are necessary for them.
>
> Also, if possible, for portability would be better to use dbus python module
> than doing calls to the system (what if gdbus command is not available?).

Need to investigate more on that, can you give pointers on where to look, probably an example would help.

Revision history for this message
Víctor R. Ruiz (vrruiz) wrote : Posted in a previous version of this proposal
Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

> There is a nice tutorial here: http://dbus.freedesktop.org/doc/dbus-
> python/doc/tutorial.html

Thanks for that. Now I am using python for dbus call.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote : Posted in a previous version of this proposal

Omer, please take a look at the existing branches in review before writing a new one, or consult with ubuntu-qa.
You duplicated some of the work I did here: https://code.launchpad.net/~elopio/unity8/test_open_app_from_launcher/+merge/225112

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
996. By Omer Akram

merge trunk

Revision history for this message
Michael Zanetti (mzanetti) wrote :

see inline

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

one more inline comment :)

Revision history for this message
Michael Zanetti (mzanetti) wrote :

And more inline comments for the tests.

review: Needs Fixing

Unmerged revisions

996. By Omer Akram

merge trunk

995. By Omer Akram

merge open_app_launcher test branch

994. By Omer Akram

remove newly added test, seems some of that is already done elsewhere.

993. By Omer Akram

give the messaging-app more time to start

992. By Omer Akram

fix crazy

991. By Omer Akram

Dummy commit for CI

990. By Omer Akram

change cleanUp call

989. By Omer Akram

don't call gdbus, use the python api to talk to accountsservice.

988. By Omer Akram

merge trunk

987. By Omer Akram

add docstring for fixture class.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Launcher/LauncherDelegate.qml'
2--- qml/Launcher/LauncherDelegate.qml 2014-05-09 10:48:19 +0000
3+++ qml/Launcher/LauncherDelegate.qml 2014-07-09 10:09:36 +0000
4@@ -20,6 +20,7 @@
5 Item {
6 id: root
7
8+ property string appId
9 property string iconName
10 property int count: -1
11 property int progress: -1
12
13=== modified file 'qml/Launcher/LauncherPanel.qml'
14--- qml/Launcher/LauncherPanel.qml 2014-06-23 10:21:52 +0000
15+++ qml/Launcher/LauncherPanel.qml 2014-07-09 10:09:36 +0000
16@@ -148,6 +148,7 @@
17 delegate: FoldingLauncherDelegate {
18 id: launcherDelegate
19 objectName: "launcherDelegate" + index
20+ appId: model.appId
21 itemHeight: launcherListView.itemHeight
22 itemWidth: launcherListView.itemWidth
23 width: itemWidth
24
25=== modified file 'tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py'
26--- tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2014-06-11 15:36:51 +0000
27+++ tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2014-07-09 10:09:36 +0000
28@@ -115,3 +115,18 @@
29 self.launch_upstart_application(application_name)
30 self.assertThat(greeter.created, Eventually(Equals(False)))
31 self.assert_current_focused_application(application_name)
32+
33+ def test_click_dash_icon_must_unfocus_application(self):
34+ application_name = self.launch_fake_app()
35+ self.assert_current_focused_application(application_name)
36+
37+ self.main_window.show_dash_from_launcher()
38+
39+ self.assert_current_focused_application('')
40+
41+ def test_click_app_icon_on_dash_must_focus_it(self):
42+ application_name = self.launch_fake_app()
43+ self.main_window.show_dash_from_launcher()
44+
45+ self.main_window.launch_application(application_name)
46+ self.assert_current_focused_application(application_name)
47
48=== modified file 'tests/autopilot/unity8/shell/emulators/launcher.py'
49--- tests/autopilot/unity8/shell/emulators/launcher.py 2013-11-01 13:59:50 +0000
50+++ tests/autopilot/unity8/shell/emulators/launcher.py 2014-07-09 10:09:36 +0000
51@@ -1,7 +1,7 @@
52 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
53 #
54 # Unity Autopilot Test Suite
55-# Copyright (C) 2012-2013 Canonical
56+# Copyright (C) 2012, 2013, 2014 Canonical
57 #
58 # This program is free software: you can redistribute it and/or modify
59 # it under the terms of the GNU General Public License as published by
60@@ -17,22 +17,65 @@
61 # along with this program. If not, see <http://www.gnu.org/licenses/>.
62 #
63
64-from unity8.shell.emulators import UnityEmulatorBase
65-from autopilot.input import Touch
66-
67-
68-class Launcher(UnityEmulatorBase):
69+import logging
70+
71+import autopilot.logging
72+
73+from unity8.shell import emulators
74+
75+
76+logger = logging.getLogger(__name__)
77+
78+
79+class Launcher(emulators.UnityEmulatorBase):
80
81 """An emulator that understands the Launcher."""
82
83+ @autopilot.logging.log_action(logger.debug)
84 def show(self):
85- """Swipes open the launcher."""
86- touch = Touch.create()
87+ """Show the launcher swiping it to the right."""
88+ if not self.shown:
89+ self._swipe_launcher('right')
90+ self.shown.wait_for(True)
91+ else:
92+ logger.debug('The launcher is already opened.')
93
94+ def _swipe_launcher(self, direction):
95 view = self.get_root_instance().select_single('QQuickView')
96- start_x = view.x + 1
97- start_y = view.y + view.height / 2
98- stop_x = start_x + self.panelWidth + 1
99- stop_y = start_y
100- touch.drag(start_x, start_y, stop_x, stop_y)
101- self.shown.wait_for(True)
102+ start_y = stop_y = view.y + view.height // 2
103+
104+ left = view.x + 1
105+ right = left + self.panelWidth - 1
106+
107+ if direction == 'right':
108+ start_x = left
109+ stop_x = right
110+ elif direction == 'left':
111+ start_x = right
112+ stop_x = left
113+
114+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
115+
116+ @autopilot.logging.log_action(logger.debug)
117+ def hide(self):
118+ """Hide the launcher swiping it to the left."""
119+ if self.shown:
120+ self._swipe_launcher('left')
121+ self.shown.wait_for(False)
122+ else:
123+ logger.debug('The launcher is already closed.')
124+
125+ @autopilot.logging.log_action(logger.debug)
126+ def click_dash_icon(self):
127+ if self.shown:
128+ dash_icon = self.select_single(
129+ 'QQuickImage', objectName='dashItem')
130+ self.pointing_device.click_object(dash_icon)
131+ else:
132+ raise emulators.UnityEmulatorException('The launcher is closed.')
133+
134+ @autopilot.logging.log_action(logger.debug)
135+ def click_application_launcher_icon(self, application_name):
136+ launcher_delegate = self.select_single(
137+ 'LauncherDelegate', appId=application_name)
138+ self.pointing_device.click_object(launcher_delegate)
139
140=== modified file 'tests/autopilot/unity8/shell/emulators/main_window.py'
141--- tests/autopilot/unity8/shell/emulators/main_window.py 2014-05-20 18:47:15 +0000
142+++ tests/autopilot/unity8/shell/emulators/main_window.py 2014-07-09 10:09:36 +0000
143@@ -67,9 +67,6 @@
144 def get_bottombar(self):
145 return self.select_single("Bottombar")
146
147- def get_launcher(self):
148- return self.select_single(Launcher)
149-
150 def get_pinPadLoader(self):
151 return self.select_single(
152 "QQuickLoader",
153@@ -139,3 +136,38 @@
154
155 def _get_search_indicator(self):
156 return self.select_single('SearchIndicator', objectName='search')
157+
158+ @autopilot_logging.log_action(logger.info)
159+ def show_dash_from_launcher(self):
160+ """Open the dash clicking the dash icon on the launcher."""
161+ launcher = self.open_launcher()
162+ launcher.click_dash_icon()
163+ return self.get_dash()
164+
165+ @autopilot_logging.log_action(logger.info)
166+ def open_launcher(self):
167+ launcher = self._get_launcher()
168+ launcher.show()
169+ return launcher
170+
171+ def _get_launcher(self):
172+ return self.select_single(Launcher)
173+
174+ @autopilot_logging.log_action(logger.info)
175+ def close_launcher(self):
176+ launcher = self._get_launcher()
177+ launcher.hide()
178+
179+ def is_launcher_open(self):
180+ return self._get_launcher().shown
181+
182+ @autopilot_logging.log_action(logger.info)
183+ def launch_application(self, application_name):
184+ """Launch an application.
185+
186+ :parameter application_name: The name of the application to launch.
187+
188+ """
189+ launcher = self.open_launcher()
190+ launcher.click_application_launcher_icon(application_name)
191+ self.get_current_focused_app_id().wait_for(application_name)
192
193=== modified file 'tests/autopilot/unity8/shell/fixture_setup.py'
194--- tests/autopilot/unity8/shell/fixture_setup.py 2014-01-23 14:40:17 +0000
195+++ tests/autopilot/unity8/shell/fixture_setup.py 2014-07-09 10:09:36 +0000
196@@ -19,7 +19,9 @@
197
198 """Set up and clean up fixtures for the Unity acceptance tests."""
199
200+import dbus
201 import os
202+import subprocess
203 import sysconfig
204
205 import fixtures
206@@ -51,3 +53,47 @@
207 'Expected library path does not exists: %s.' % (
208 ld_library_path))
209 return ld_library_path
210+
211+
212+class LauncherIcon(fixtures.Fixture):
213+ """Fixture to setup launcher icons."""
214+
215+ def setUp(self):
216+ super(LauncherIcon, self).setUp()
217+ self._add_messaging_app_icon_to_launcher()
218+
219+ def _get_accounts_service_dbus_iface(self):
220+ bus = dbus.SystemBus()
221+ proxy = bus.get_object(
222+ 'org.freedesktop.Accounts',
223+ '/org/freedesktop/Accounts/User32011')
224+ return dbus.Interface(proxy, 'org.freedesktop.DBus.Properties')
225+
226+ def _backup_launcher_icons(self):
227+ manager = self._get_accounts_service_dbus_iface()
228+ self.backup = manager.Get(
229+ 'com.canonical.unity.AccountsService',
230+ 'launcher-items')
231+ self.addCleanup(self._set_launcher_icons, self.backup)
232+
233+ def _set_launcher_icons(self, icons_config):
234+ manager = self._get_accounts_service_dbus_iface()
235+ manager.Set(
236+ 'com.canonical.unity.AccountsService',
237+ 'launcher-items', icons_config)
238+
239+ def _add_messaging_app_icon_to_launcher(self):
240+ self._backup_launcher_icons()
241+
242+ messaging_icon = dbus.Array([dbus.Dictionary({
243+ dbus.String('count'): dbus.Int32(0, variant_level=1),
244+ dbus.String('countVisible'): dbus.Boolean(False, variant_level=1),
245+ dbus.String('name'): dbus.String('Messaging', variant_level=1),
246+ dbus.String('id'): dbus.String('messaging-app', variant_level=1),
247+ dbus.String('icon'): dbus.String('image://theme/messaging-app',
248+ variant_level=1)},
249+ signature=dbus.Signature('sv'))],
250+ signature=dbus.Signature('a{sv}'),
251+ variant_level=1)
252+
253+ self._set_launcher_icons(messaging_icon)
254
255=== modified file 'tests/autopilot/unity8/shell/tests/disabled_test_hud.py'
256--- tests/autopilot/unity8/shell/tests/disabled_test_hud.py 2014-06-18 01:52:15 +0000
257+++ tests/autopilot/unity8/shell/tests/disabled_test_hud.py 2014-07-09 10:09:36 +0000
258@@ -184,12 +184,11 @@
259 unity_proxy = self.launch_unity()
260 unlock_unity(unity_proxy)
261 hud = self.main_window.get_hud()
262- launcher = self.main_window.get_launcher()
263
264 self._launch_test_app_from_app_screen()
265
266 hud.show()
267- launcher.show()
268+ self.main_window.open_launcher()
269
270 self.assertThat(hud.shown, Eventually(Equals(False)))
271
272
273=== modified file 'tests/autopilot/unity8/shell/tests/test_emulators.py'
274--- tests/autopilot/unity8/shell/tests/test_emulators.py 2014-06-18 01:52:15 +0000
275+++ tests/autopilot/unity8/shell/tests/test_emulators.py 2014-07-09 10:09:36 +0000
276@@ -34,7 +34,10 @@
277
278 from unity8 import process_helpers
279 from unity8.shell import emulators, fixture_setup, tests
280-from unity8.shell.emulators import dash as dash_emulators
281+from unity8.shell.emulators import (
282+ dash as dash_emulators,
283+ launcher as launcher_emulator
284+)
285
286
287 class MainWindowTestCase(tests.UnityTestCase):
288@@ -52,6 +55,24 @@
289 self.assertEqual(text_field.text, 'Test')
290 self.assertEqual(text_field.state, 'idle')
291
292+ def test_open_launcher_must_return_launcher_custom_proxy_object(self):
293+ launcher = self.main_window.open_launcher()
294+ self.assertIsInstance(launcher, launcher_emulator.Launcher)
295+
296+ def test_open_launcher_must_open_it(self):
297+ # Make sure that the launcher is closed.
298+ self.main_window.close_launcher()
299+ self.main_window.open_launcher()
300+
301+ self.assertTrue(self.main_window.is_launcher_open())
302+
303+ def test_close_launcher_must_close_it(self):
304+ # Make sure that the launcher is open.
305+ self.main_window.open_launcher()
306+ self.main_window.close_launcher()
307+
308+ self.assertFalse(self.main_window.is_launcher_open())
309+
310
311 class DashBaseTestCase(tests.UnityTestCase):
312
313@@ -198,3 +219,39 @@
314 return filtergrid.collapsedRowCount * filtergrid.columns
315 else:
316 return filtergrid.uncollapsedRowCount * filtergrid.columns
317+
318+
319+class LauncherTestCase(tests.UnityTestCase):
320+
321+ scenarios = tests._get_device_emulation_scenarios()
322+
323+ def setUp(self):
324+ super(LauncherTestCase, self).setUp()
325+ unity_proxy = self.launch_unity()
326+ process_helpers.unlock_unity(unity_proxy)
327+
328+ def test_show_launcher_with_launcher_open_must_do_nothing(self):
329+ launcher = self.main_window.open_launcher()
330+ with mock.patch.object(launcher.pointing_device, 'drag') as mock_drag:
331+ launcher.show()
332+
333+ self.assertFalse(mock_drag.called)
334+
335+ def test_hide_launcher_with_launcher_closed_must_do_nothing(self):
336+ launcher = self.main_window.open_launcher()
337+ launcher.hide()
338+ with mock.patch.object(launcher.pointing_device, 'drag') as mock_drag:
339+ launcher.hide()
340+
341+ self.assertFalse(mock_drag.called)
342+
343+ def test_click_dash_icon_with_launcher_closed_must_raise_exception(self):
344+ launcher = self.main_window.open_launcher()
345+ launcher.hide()
346+
347+ exception = self.assertRaises(
348+ emulators.UnityEmulatorException,
349+ launcher.click_dash_icon)
350+
351+ self.assertEqual(
352+ 'The launcher is closed.', str(exception))
353
354=== modified file 'tests/autopilot/unity8/shell/tests/test_notifications.py'
355--- tests/autopilot/unity8/shell/tests/test_notifications.py 2014-06-18 01:52:15 +0000
356+++ tests/autopilot/unity8/shell/tests/test_notifications.py 2014-07-09 10:09:36 +0000
357@@ -242,8 +242,8 @@
358 # the shell)
359 time.sleep(1)
360 self.main_window.show_dash_swiping()
361- launcher = self.main_window.get_launcher()
362- self.assertThat(launcher.shown, Eventually(Equals(False)))
363+ self.assertThat(
364+ self.main_window.is_launcher_open, Eventually(Equals(False)))
365
366 # verify and interact with the triggered snap-decision notification
367 notify_list = self._get_notifications_list()

Subscribers

People subscribed via source and target branches