on xenial help sign in
Added an autopilot test for focusing an app clicking the icon on the launcher.
a144003Leo Arias
qml/Launcher/LauncherPanel.qml+4
@@ -146,6 +146,10 @@ Rectangle {
146 delegate: FoldingLauncherDelegate {
146 delegate: FoldingLauncherDelegate {
147 id: launcherDelegate
147 id: launcherDelegate
148 objectName: "launcherDelegate" + index
148 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
149 itemHeight: launcherListView.itemHeight
153 itemHeight: launcherListView.itemHeight
150 itemWidth: launcherListView.itemWidth
154 itemWidth: launcherListView.itemWidth
151 width: itemWidth
155 width: itemWidth
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+7
@@ -123,3 +123,10 @@ class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
123 self.main_window.show_dash_from_launcher()
123 self.main_window.show_dash_from_launcher()
124
124
125 self.assert_current_focused_application('unity8-dash')
125 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):
57 self.pointing_device.click_object(dash_icon)
57 self.pointing_device.click_object(dash_icon)
58 else:
58 else:
59 raise emulators.UnityEmulatorException('The launcher is closed.')
59 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):
110 start_y = end_y = y + height // 2
110 start_y = end_y = y + height // 2
111
111
112 self.pointing_device.drag(start_x, start_y, end_x, end_y)
112 self.pointing_device.drag(start_x, start_y, end_x, end_y)
113+ self.get_current_focused_app_id().wait_for('unity8-dash')
113
114
114 def _get_shell(self):
115 def _get_shell(self):
115 return self.select_single('Shell')
116 return self.select_single('Shell')
@@ -123,6 +124,8 @@ class QQuickView(emulators.UnityEmulatorBase):
123 """Open the dash clicking the dash icon on the launcher."""
124 """Open the dash clicking the dash icon on the launcher."""
124 launcher = self.open_launcher()
125 launcher = self.open_launcher()
125 launcher.click_dash_icon()
126 launcher.click_dash_icon()
127+ self.get_current_focused_app_id().wait_for('unity8-dash')
128+ launcher.shown.wait_for(False)
126
129
127 @autopilot_logging.log_action(logger.info)
130 @autopilot_logging.log_action(logger.info)
128 def open_launcher(self):
131 def open_launcher(self):
@@ -136,6 +139,18 @@ class QQuickView(emulators.UnityEmulatorBase):
136 def is_launcher_open(self):
139 def is_launcher_open(self):
137 return self._get_launcher().shown
140 return self._get_launcher().shown
138
141
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+
139 def enter_pin_code(self, code):
154 def enter_pin_code(self, code):
140 """Enter code 'code' into the single-pin lightdm pincode entry screen.
155 """Enter code 'code' into the single-pin lightdm pincode entry screen.
141
156