on xenial help sign in
Added an autopilot test for focusing an app clicking the icon on the launcher.

Approved by: Michał Sawicz, Brendan Donegan

commita1440031731f8255796f0beddc23e246869536bb authorLeo Arias <leo.arias@canonical.com> dateThu 14 Aug 2014, 01:29 (12 years ago) parentc3620299dd830b
4 files changed+32
qml/Launcher/LauncherPanel.qml+4 tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+7 tests/autopilot/unity8/shell/emulators/launcher.py+6 tests/autopilot/unity8/shell/emulators/main_window.py+15
qml/Launcher/LauncherPanel.qml+4
@@ -146,6 +146,10 @@ Rectangle {
146146 delegate: FoldingLauncherDelegate {
147147 id: launcherDelegate
148148 objectName: "launcherDelegate" + index
149+ // We need the appId in the delegate in order to find
150+ // the right app when running autopilot tests for
151+ // multiple apps.
152+ readonly property string appId: model.appId
149153 itemHeight: launcherListView.itemHeight
150154 itemWidth: launcherListView.itemWidth
151155 width: itemWidth
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+7
@@ -123,3 +123,10 @@ class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
123123 self.main_window.show_dash_from_launcher()
124124
125125 self.assert_current_focused_application('unity8-dash')
126+
127+ def test_click_app_icon_on_dash_must_focus_it(self):
128+ application_name = self.launch_fake_app()
129+ self.main_window.show_dash_from_launcher()
130+
131+ self.main_window.launch_application(application_name)
132+ self.assert_current_focused_application(application_name)
tests/autopilot/unity8/shell/emulators/launcher.py+6
@@ -57,3 +57,9 @@ class Launcher(emulators.UnityEmulatorBase):
5757 self.pointing_device.click_object(dash_icon)
5858 else:
5959 raise emulators.UnityEmulatorException('The launcher is closed.')
60+
61+ @autopilot.logging.log_action(logger.debug)
62+ def click_application_launcher_icon(self, application_name):
63+ launcher_delegate = self.select_single(
64+ 'LauncherDelegate', appId=application_name)
65+ self.pointing_device.click_object(launcher_delegate)
tests/autopilot/unity8/shell/emulators/main_window.py+15
@@ -110,6 +110,7 @@ class QQuickView(emulators.UnityEmulatorBase):
110110 start_y = end_y = y + height // 2
111111
112112 self.pointing_device.drag(start_x, start_y, end_x, end_y)
113+ self.get_current_focused_app_id().wait_for('unity8-dash')
113114
114115 def _get_shell(self):
115116 return self.select_single('Shell')
@@ -123,6 +124,8 @@ class QQuickView(emulators.UnityEmulatorBase):
123124 """Open the dash clicking the dash icon on the launcher."""
124125 launcher = self.open_launcher()
125126 launcher.click_dash_icon()
127+ self.get_current_focused_app_id().wait_for('unity8-dash')
128+ launcher.shown.wait_for(False)
126129
127130 @autopilot_logging.log_action(logger.info)
128131 def open_launcher(self):
@@ -136,6 +139,18 @@ class QQuickView(emulators.UnityEmulatorBase):
136139 def is_launcher_open(self):
137140 return self._get_launcher().shown
138141
142+ @autopilot_logging.log_action(logger.info)
143+ def launch_application(self, application_name):
144+ """Launch an application.
145+
146+ :parameter application_name: The name of the application to launch.
147+
148+ """
149+ launcher = self.open_launcher()
150+ launcher.click_application_launcher_icon(application_name)
151+ self.get_current_focused_app_id().wait_for(application_name)
152+ launcher.shown.wait_for(False)
153+
139154 def enter_pin_code(self, code):
140155 """Enter code 'code' into the single-pin lightdm pincode entry screen.
141156