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
commite6288442c6b9b983d785daef01c574f2b7e43e79 authorMichael Terry <michael.terry@canonical.com> dateTue 15 Apr 2014, 12:47 (13 years ago) parent5b24052295ab57
5 files changed+65−13
qml/Shell.qml+5−12 tests/autopilot/unity8/application_lifecycle/tests/__init__.py+4−1 tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+29 tests/autopilot/unity8/process_helpers.py+16 tests/qmltests/tst_Shell.qml+11
qml/Shell.qml+5−12
@@ -240,6 +240,8 @@ FocusScope {
240240 function show(focusApp) {
241241 shown = true;
242242 panel.indicators.hide();
243+ edgeDemo.stopDemo();
244+ greeter.hide();
243245 if (!ApplicationManager.focusedApplicationId && ApplicationManager.count > 0 && focusApp) {
244246 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
245247 }
@@ -267,12 +269,6 @@ FocusScope {
267269 stages.hide();
268270 }
269271 }
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()
276272 }
277273
278274 onApplicationAdded: {
@@ -559,12 +555,9 @@ FocusScope {
559555 }
560556 }
561557 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
562− onLauncherApplicationSelected:{
563− if (edgeDemo.running)
564− return;
565−
566− greeter.hide()
567− shell.activateApplication(appId)
558+ onLauncherApplicationSelected: {
559+ if (!edgeDemo.running)
560+ shell.activateApplication(appId)
568561 }
569562 onShownChanged: {
570563 if (shown) {
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+4−1
@@ -35,7 +35,10 @@ class ApplicationLifeCycleTestCase(tests.UnityTestCase):
3535 process_helpers.unlock_unity(unity_proxy)
3636
3737 def create_test_application(self):
38− fake_application = fixture_setup.FakeApplication()
38+ desktop_file_dict = fixture_setup.DEFAULT_DESKTOP_FILE_DICT
39+ desktop_file_dict.update({'X-Ubuntu-Single-Instance': 'true'})
40+ fake_application = fixture_setup.FakeApplication(
41+ desktop_file_dict=desktop_file_dict)
3942 self.useFixture(fake_application)
4043 return (
4144 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
2424import logging
2525import os
2626
27+from autopilot.matchers import Eventually
2728from autopilot.platform import model
29+from testtools.matchers import Equals
2830
31+from unity8 import process_helpers
2932from unity8.application_lifecycle import tests
3033
3134
@@ -86,3 +89,29 @@ class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
8689 self.swipe_screen_from_right()
8790
8891 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):
8989 break
9090
9191
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+
92108def restart_unity_with_testability(*args):
93109 """Restarts (or starts) unity with testability enabled.
94110
tests/qmltests/tst_Shell.qml+11
@@ -554,5 +554,16 @@ Item {
554554
555555 tryCompare(searchIndicator, "opacity", 0);
556556 }
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+ }
557568 }
558569}