on xenial help sign in
When an application requests focus, handle it in Shell.qml by hiding the greeter and stopping any edge demo. Fixes: 1227753, 1267624, 1307489
e628844Michael Terry
qml/Shell.qml+5−12
@@ -240,6 +240,8 @@ FocusScope {
240 function show(focusApp) {
240 function show(focusApp) {
241 shown = true;
241 shown = true;
242 panel.indicators.hide();
242 panel.indicators.hide();
243+ edgeDemo.stopDemo();
244+ greeter.hide();
243 if (!ApplicationManager.focusedApplicationId && ApplicationManager.count > 0 && focusApp) {
245 if (!ApplicationManager.focusedApplicationId && ApplicationManager.count > 0 && focusApp) {
244 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
246 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
245 }
247 }
@@ -267,12 +269,6 @@ FocusScope {
267 stages.hide();
269 stages.hide();
268 }
270 }
269 }
271 }
270−
271− // If any app is focused when greeter is open, it's due to a user action
272− // like a snap decision (say, an incoming call).
273− // TODO: these should be protected to only unlock for certain applications / certain usecases
274− // potentially only in connection with a notification.
275− greeter.hide()
276 }
272 }
277
273
278 onApplicationAdded: {
274 onApplicationAdded: {
@@ -559,12 +555,9 @@ FocusScope {
559 }
555 }
560 }
556 }
561 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
557 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
562− onLauncherApplicationSelected:{
558+ onLauncherApplicationSelected: {
563− if (edgeDemo.running)
559+ if (!edgeDemo.running)
564− return;
565−
566− greeter.hide()
567− shell.activateApplication(appId)
560+ shell.activateApplication(appId)
568 }
561 }
569 onShownChanged: {
562 onShownChanged: {
570 if (shown) {
563 if (shown) {
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+4−1
@@ -35,7 +35,10 @@ class ApplicationLifeCycleTestCase(tests.UnityTestCase):
35 process_helpers.unlock_unity(unity_proxy)
35 process_helpers.unlock_unity(unity_proxy)
36
36
37 def create_test_application(self):
37 def create_test_application(self):
38+ desktop_file_dict = fixture_setup.DEFAULT_DESKTOP_FILE_DICT
39+ desktop_file_dict.update({'X-Ubuntu-Single-Instance': 'true'})
38− fake_application = fixture_setup.FakeApplication()
40+ fake_application = fixture_setup.FakeApplication(
41+ desktop_file_dict=desktop_file_dict)
39 self.useFixture(fake_application)
42 self.useFixture(fake_application)
40 return (
43 return (
41 fake_application.qml_file_path, fake_application.desktop_file_path)
44 fake_application.qml_file_path, fake_application.desktop_file_path)
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+29
@@ -24,8 +24,11 @@ from __future__ import absolute_import
24import logging
24import logging
25import os
25import os
26
26
27+from autopilot.matchers import Eventually
27from autopilot.platform import model
28from autopilot.platform import model
29+from testtools.matchers import Equals
28
30
31+from unity8 import process_helpers
29from unity8.application_lifecycle import tests
32from unity8.application_lifecycle import tests
30
33
31
34
@@ -86,3 +89,29 @@ class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
86 self.swipe_screen_from_right()
89 self.swipe_screen_from_right()
87
90
88 self.assert_current_focused_application(application1_name)
91 self.assert_current_focused_application(application1_name)
92+
93+ def test_greeter_hides_on_app_open(self):
94+ """Greeter should hide when an app is opened"""
95+ process_helpers.lock_unity()
96+ greeter = self.main_window.get_greeter()
97+ self.assertThat(greeter.created, Eventually(Equals(True)))
98+
99+ application_name = self.launch_fake_app()
100+ self.assertThat(greeter.created, Eventually(Equals(False)))
101+ self.assert_current_focused_application(application_name)
102+
103+ def test_greeter_hides_on_app_focus(self):
104+ """Greeter should hide when an app is re-focused"""
105+ application_name = self.launch_fake_app()
106+ self.assert_current_focused_application(application_name)
107+
108+ self.main_window.show_dash_swiping()
109+ self.assert_current_focused_application('')
110+
111+ process_helpers.lock_unity()
112+ greeter = self.main_window.get_greeter()
113+ self.assertThat(greeter.created, Eventually(Equals(True)))
114+
115+ self.launch_upstart_application(application_name)
116+ self.assertThat(greeter.created, Eventually(Equals(False)))
117+ self.assert_current_focused_application(application_name)
tests/autopilot/unity8/process_helpers.py+16
@@ -89,6 +89,22 @@ def unlock_unity(unity_proxy_obj=None):
89 break
89 break
90
90
91
91
92+def lock_unity(unity_proxy_obj=None):
93+ """Helper function that attempts to lock the unity greeter."""
94+ import evdev, time
95+ uinput = evdev.UInput(name='unity8-autopilot-power-button',
96+ devnode='/dev/autopilot-uinput')
97+ # One press and release to turn screen off (locking unity)
98+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
99+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
100+ uinput.syn()
101+ time.sleep(1)
102+ # And another press and release to turn screen back on
103+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
104+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
105+ uinput.syn()
106+
107+
92def restart_unity_with_testability(*args):
108def restart_unity_with_testability(*args):
93 """Restarts (or starts) unity with testability enabled.
109 """Restarts (or starts) unity with testability enabled.
94
110
tests/qmltests/tst_Shell.qml+11
@@ -554,5 +554,16 @@ Item {
554
554
555 tryCompare(searchIndicator, "opacity", 0);
555 tryCompare(searchIndicator, "opacity", 0);
556 }
556 }
557+
558+ function test_focusRequestedHidesGreeter() {
559+ var greeter = findChild(shell, "greeter")
560+
561+ greeter.show()
562+ tryCompare(greeter, "showProgress", 1)
563+
564+ ApplicationManager.focusRequested("notes-app")
565+ tryCompare(greeter, "showProgress", 0)
566+ waitUntilApplicationWindowIsFullyVisible()
567+ }
557 }
568 }
558}
569}