Merge lp:~dandrader/qtmir/focusFromSideToMainStage into lp:qtmir

Proposed by Daniel d'Andrada on 2015-01-27
Status: Merged
Approved by: Gerry Boland on 2015-01-27
Approved revision: 310
Merged at revision: 313
Proposed branch: lp:~dandrader/qtmir/focusFromSideToMainStage
Merge into: lp:qtmir
Diff against target: 119 lines (+100/-1)
2 files modified
src/modules/Unity/Application/application_manager.cpp (+3/-1)
tests/modules/ApplicationManager/application_manager_test.cpp (+97/-0)
To merge this branch: bzr merge lp:~dandrader/qtmir/focusFromSideToMainStage
Reviewer Review Type Date Requested Status
Gerry Boland 2015-01-27 Approve on 2015-01-27
PS Jenkins bot continuous-integration Approve on 2015-01-27
Review via email: mp+247702@code.launchpad.net

Commit Message

Don't suspend&resume the main stage app when switching focus from side to main stage

Description of the Change

* Are there any related MPs required for this MP to build/function as expected? Please list.
No

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Gerry Boland (gerboland) wrote :

LGTM

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Y
 * Did CI run pass? If not, please explain why.
Y

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/application_manager.cpp'
2--- src/modules/Unity/Application/application_manager.cpp 2015-01-07 17:56:07 +0000
3+++ src/modules/Unity/Application/application_manager.cpp 2015-01-27 12:29:39 +0000
4@@ -413,7 +413,9 @@
5 if (m_focusedApplication) {
6 m_focusedApplication->setFocused(false);
7 Application *lastApplication = applicationForStage(application->stage());
8- suspendApplication(lastApplication);
9+ if (lastApplication != application) {
10+ suspendApplication(lastApplication);
11+ }
12 }
13
14 if (application->stage() == Application::MainStage) {
15
16=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
17--- tests/modules/ApplicationManager/application_manager_test.cpp 2014-11-13 16:26:03 +0000
18+++ tests/modules/ApplicationManager/application_manager_test.cpp 2015-01-27 12:29:39 +0000
19@@ -2135,3 +2135,100 @@
20 cv.wait(lk, [&] { return done; } );
21 }
22 }
23+
24+/*
25+ 1 - launch and focus a main stage app
26+ * main stage app is running and focused
27+ 2 - launch and focus a side stage app
28+ * main stage app is running but is not focused
29+ * side stage app is running and has focus
30+ 3 - focus the main stage app
31+ * main stage app is running and has focus
32+ * side stage app is running but is not focused
33+
34+ This is a regression test for the bug where on step 3, the main stage app was momentarily
35+ suspended and then resumed again.
36+ */
37+TEST_F(ApplicationManagerTests, focusMainStageAfterSideStage)
38+{
39+ using namespace testing;
40+
41+ QString webbrowserAppId("webbrowser-app");
42+ quint64 webbrowserPID = 123;
43+ std::shared_ptr<mir::scene::Surface> webbrowserSurface(nullptr);
44+
45+ QString dialerAppId("dialer-app");
46+ quint64 dialerPID = 456;
47+ std::shared_ptr<mir::scene::Surface> dialerSurface(nullptr);
48+
49+ /*** Start webbrowser-app (main stage) ***/
50+
51+ ON_CALL(appController,appIdHasProcessId(webbrowserPID, webbrowserAppId)).WillByDefault(Return(true));
52+
53+ {
54+ auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(webbrowserAppId, QFileInfo());
55+ ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
56+ ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(webbrowserAppId));
57+ ON_CALL(*mockDesktopFileReader, stageHint()).WillByDefault(Return("MainStage"));
58+
59+ ON_CALL(desktopFileReaderFactory, createInstance(webbrowserAppId, _))
60+ .WillByDefault(Return(mockDesktopFileReader));
61+ }
62+
63+ EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(webbrowserAppId, _))
64+ .Times(1)
65+ .WillOnce(Return(true));
66+
67+ /*auto application =*/ applicationManager.startApplication(webbrowserAppId, ApplicationManager::NoFlag);
68+ applicationManager.onProcessStarting(webbrowserAppId);
69+
70+ {
71+ bool authed = false;
72+ applicationManager.authorizeSession(webbrowserPID, authed);
73+ EXPECT_EQ(authed, true);
74+ }
75+
76+ auto webbrowserSession = std::make_shared<mir::scene::MockSession>(webbrowserAppId.toStdString(), webbrowserPID);
77+ sessionManager.onSessionStarting(webbrowserSession);
78+ applicationManager.focusApplication(webbrowserAppId);
79+ applicationManager.onSessionCreatedSurface(webbrowserSession.get(), webbrowserSurface);
80+
81+ /*** Start dialer-app (side stage) ***/
82+
83+ ON_CALL(appController, appIdHasProcessId(dialerPID, dialerAppId)).WillByDefault(Return(true));
84+
85+ {
86+ auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(dialerAppId, QFileInfo());
87+ ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
88+ ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(dialerAppId));
89+ ON_CALL(*mockDesktopFileReader, stageHint()).WillByDefault(Return("SideStage"));
90+
91+ ON_CALL(desktopFileReaderFactory, createInstance(dialerAppId, _))
92+ .WillByDefault(Return(mockDesktopFileReader));
93+ }
94+
95+ EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(dialerAppId, _))
96+ .Times(1)
97+ .WillOnce(Return(true));
98+
99+ /*auto application =*/ applicationManager.startApplication(dialerAppId, ApplicationManager::NoFlag);
100+ applicationManager.onProcessStarting(dialerAppId);
101+
102+ {
103+ bool authed = false;
104+ applicationManager.authorizeSession(dialerPID, authed);
105+ EXPECT_EQ(authed, true);
106+ }
107+
108+ auto dialerSession = std::make_shared<mir::scene::MockSession>(dialerAppId.toStdString(), dialerPID);
109+ sessionManager.onSessionStarting(dialerSession);
110+ applicationManager.focusApplication(dialerAppId);
111+ applicationManager.onSessionCreatedSurface(dialerSession.get(), dialerSurface);
112+
113+ /*** Focus webbrowser ***/
114+
115+ // Nothing should happen as it's already the running main stage app
116+ EXPECT_CALL(*webbrowserSession.get(), set_lifecycle_state(_))
117+ .Times(0);
118+ applicationManager.focusApplication(webbrowserAppId);
119+}

Subscribers

People subscribed via source and target branches