on xenial help sign in
Added autopilot helpers and tests for the launcher and dash icon.

Approved by: Michał Sawicz, Brendan Donegan

commit88d29159f5656b2971697fb3e8d82d63a1397f2a authorLeo Arias <leo.arias@canonical.com> dateThu 14 Aug 2014, 01:29 (12 years ago) parent027f37ccb1f0d4
5 files changed+60−18
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+8 tests/autopilot/unity8/shell/emulators/launcher.py+32−11 tests/autopilot/unity8/shell/emulators/main_window.py+17−3 tests/autopilot/unity8/shell/tests/disabled_test_hud.py+1−2 tests/autopilot/unity8/shell/tests/test_notifications.py+2−2
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+8
@@ -115,3 +115,11 @@ class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
115115 self.launch_upstart_application(application_name)
116116 self.assertThat(greeter.created, Eventually(Equals(False)))
117117 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 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -17,22 +17,43 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20−from unity8.shell.emulators import UnityEmulatorBase
21−from autopilot.input import Touch
20+import logging
2221
22+import autopilot.logging
2323
24−class Launcher(UnityEmulatorBase):
24+from unity8.shell import emulators
25+
26+
27+logger = logging.getLogger(__name__)
28+
29+
30+class Launcher(emulators.UnityEmulatorBase):
2531
2632 """An emulator that understands the Launcher."""
2733
34+ @autopilot.logging.log_action(logger.debug)
2835 def show(self):
29− """Swipes open the launcher."""
30− touch = Touch.create()
36+ """Show the launcher swiping it to the right."""
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.')
3142
43+ def _swipe_to_show_launcher(self):
3244 view = self.get_root_instance().select_single('QQuickView')
45+ start_y = stop_y = view.y + view.height // 2
46+
3347 start_x = view.x + 1
34− start_y = view.y + view.height / 2
35− stop_x = start_x + self.panelWidth + 1
36− stop_y = start_y
37− touch.drag(start_x, start_y, stop_x, stop_y)
38− self.shown.wait_for(True)
48+ stop_x = start_x + self.panelWidth - 1
49+
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):
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):
6363 def get_bottombar(self):
6464 return self.select_single("Bottombar")
6565
66− def get_launcher(self):
67− return self.select_single(Launcher)
68−
6966 def get_pinPadLoader(self):
7067 return self.select_single(
7168 "QQuickLoader",
@@ -122,6 +119,23 @@ class QQuickView(emulators.UnityEmulatorBase):
122119 return self._get_shell().focusedApplicationId
123120
124121 @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+
125139 def enter_pin_code(self, code):
126140 """Enter code 'code' into the single-pin lightdm pincode entry screen.
127141
tests/autopilot/unity8/shell/tests/disabled_test_hud.py+1−2
@@ -184,12 +184,11 @@ class TestHud(UnityTestCase, DragMixin):
184184 unity_proxy = self.launch_unity()
185185 unlock_unity(unity_proxy)
186186 hud = self.main_window.get_hud()
187− launcher = self.main_window.get_launcher()
188187
189188 self._launch_test_app_from_app_screen()
190189
191190 hud.show()
192− launcher.show()
191+ self.main_window.open_launcher()
193192
194193 self.assertThat(hud.shown, Eventually(Equals(False)))
195194
tests/autopilot/unity8/shell/tests/test_notifications.py+2−2
@@ -242,8 +242,8 @@ class InteractiveNotificationBase(NotificationsBase):
242242 # the shell)
243243 time.sleep(1)
244244 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)))
247247
248248 # verify and interact with the triggered snap-decision notification
249249 notify_list = self._get_notifications_list()