on xenial help sign in
Added autopilot helpers and tests for the launcher and dash icon.
88d2915Leo Arias
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+8
@@ -115,3 +115,11 @@ class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
115 self.launch_upstart_application(application_name)
115 self.launch_upstart_application(application_name)
116 self.assertThat(greeter.created, Eventually(Equals(False)))
116 self.assertThat(greeter.created, Eventually(Equals(False)))
117 self.assert_current_focused_application(application_name)
117 self.assert_current_focused_application(application_name)
118+
119+ def test_click_dash_icon_must_unfocus_application(self):
120+ application_name = self.launch_fake_app()
121+ self.assert_current_focused_application(application_name)
122+
123+ self.main_window.show_dash_from_launcher()
124+
125+ self.assert_current_focused_application('unity8-dash')
tests/autopilot/unity8/shell/emulators/launcher.py+32−11
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -17,22 +17,43 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
18#
19
19
20−from unity8.shell.emulators import UnityEmulatorBase
20+import logging
21−from autopilot.input import Touch
22
21
22+import autopilot.logging
23
23
24+from unity8.shell import emulators
25+
26+
27+logger = logging.getLogger(__name__)
28+
29+
24−class Launcher(UnityEmulatorBase):
30+class Launcher(emulators.UnityEmulatorBase):
25
31
26 """An emulator that understands the Launcher."""
32 """An emulator that understands the Launcher."""
27
33
34+ @autopilot.logging.log_action(logger.debug)
28 def show(self):
35 def show(self):
29− """Swipes open the launcher."""
36+ """Show the launcher swiping it to the right."""
30− touch = Touch.create()
37+ if not self.shown:
38+ self._swipe_to_show_launcher()
39+ self.shown.wait_for(True)
40+ else:
41+ logger.debug('The launcher is already opened.')
31
42
43+ def _swipe_to_show_launcher(self):
32 view = self.get_root_instance().select_single('QQuickView')
44 view = self.get_root_instance().select_single('QQuickView')
45+ start_y = stop_y = view.y + view.height // 2
46+
33 start_x = view.x + 1
47 start_x = view.x + 1
34− start_y = view.y + view.height / 2
35− stop_x = start_x + self.panelWidth + 1
48+ stop_x = start_x + self.panelWidth - 1
36− stop_y = start_y
49+
37− touch.drag(start_x, start_y, stop_x, stop_y)
50+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
51+
52+ @autopilot.logging.log_action(logger.debug)
53+ def click_dash_icon(self):
38− self.shown.wait_for(True)
54+ if self.shown:
55+ dash_icon = self.select_single(
56+ 'QQuickImage', objectName='dashItem')
57+ self.pointing_device.click_object(dash_icon)
58+ else:
59+ raise emulators.UnityEmulatorException('The launcher is closed.')
tests/autopilot/unity8/shell/emulators/main_window.py+17−3
@@ -63,9 +63,6 @@ class QQuickView(emulators.UnityEmulatorBase):
63 def get_bottombar(self):
63 def get_bottombar(self):
64 return self.select_single("Bottombar")
64 return self.select_single("Bottombar")
65
65
66− def get_launcher(self):
67− return self.select_single(Launcher)
68−
69 def get_pinPadLoader(self):
66 def get_pinPadLoader(self):
70 return self.select_single(
67 return self.select_single(
71 "QQuickLoader",
68 "QQuickLoader",
@@ -122,6 +119,23 @@ class QQuickView(emulators.UnityEmulatorBase):
122 return self._get_shell().focusedApplicationId
119 return self._get_shell().focusedApplicationId
123
120
124 @autopilot_logging.log_action(logger.info)
121 @autopilot_logging.log_action(logger.info)
122+ def show_dash_from_launcher(self):
123+ """Open the dash clicking the dash icon on the launcher."""
124+ launcher = self.open_launcher()
125+ launcher.click_dash_icon()
126+
127+ @autopilot_logging.log_action(logger.info)
128+ def open_launcher(self):
129+ launcher = self._get_launcher()
130+ launcher.show()
131+ return launcher
132+
133+ def _get_launcher(self):
134+ return self.select_single(Launcher)
135+
136+ def is_launcher_open(self):
137+ return self._get_launcher().shown
138+
125 def enter_pin_code(self, code):
139 def enter_pin_code(self, code):
126 """Enter code 'code' into the single-pin lightdm pincode entry screen.
140 """Enter code 'code' into the single-pin lightdm pincode entry screen.
127
141
tests/autopilot/unity8/shell/tests/disabled_test_hud.py+1−2
@@ -184,12 +184,11 @@ class TestHud(UnityTestCase, DragMixin):
184 unity_proxy = self.launch_unity()
184 unity_proxy = self.launch_unity()
185 unlock_unity(unity_proxy)
185 unlock_unity(unity_proxy)
186 hud = self.main_window.get_hud()
186 hud = self.main_window.get_hud()
187− launcher = self.main_window.get_launcher()
188
187
189 self._launch_test_app_from_app_screen()
188 self._launch_test_app_from_app_screen()
190
189
191 hud.show()
190 hud.show()
192− launcher.show()
191+ self.main_window.open_launcher()
193
192
194 self.assertThat(hud.shown, Eventually(Equals(False)))
193 self.assertThat(hud.shown, Eventually(Equals(False)))
195
194
tests/autopilot/unity8/shell/tests/test_notifications.py+2−2
@@ -242,8 +242,8 @@ class InteractiveNotificationBase(NotificationsBase):
242 # the shell)
242 # the shell)
243 time.sleep(1)
243 time.sleep(1)
244 self.main_window.show_dash_swiping()
244 self.main_window.show_dash_swiping()
245− launcher = self.main_window.get_launcher()
246− self.assertThat(launcher.shown, Eventually(Equals(False)))
245+ self.assertThat(
246+ self.main_window.is_launcher_open, Eventually(Equals(False)))
247
247
248 # verify and interact with the triggered snap-decision notification
248 # verify and interact with the triggered snap-decision notification
249 notify_list = self._get_notifications_list()
249 notify_list = self._get_notifications_list()