Merge lp:~nick-dedekind/qtmir/1355173.trust-prompt-suspend into lp:qtmir

Proposed by Nick Dedekind
Status: Merged
Approved by: Gerry Boland
Approved revision: 281
Merged at revision: 300
Proposed branch: lp:~nick-dedekind/qtmir/1355173.trust-prompt-suspend
Merge into: lp:qtmir
Prerequisite: lp:~nick-dedekind/qtmir/mir-0.10.0-compatibility
Diff against target: 117 lines (+73/-2)
3 files modified
src/modules/Unity/Application/session.cpp (+14/-1)
tests/modules/SessionManager/session_test.cpp (+58/-0)
tests/modules/common/mock_mir_session.h (+1/-1)
To merge this branch: bzr merge lp:~nick-dedekind/qtmir/1355173.trust-prompt-suspend
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+245750@code.launchpad.net

This proposal supersedes a proposal from 2014-11-19.

Commit message

Notify prompt sessions that sessions have been suspended/resumed.

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?
No

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Code looks reasonable, I didn't test though

review: Approve (code)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Again, code is reasonable. Need to functional test

review: Approve (code)
Revision history for this message
Gerry Boland (gerboland) wrote :

Please merge qtmir trunk. Note you also need to do this: http://pastebin.ubuntu.com/9698152/ to have it build.

Just building to test now.

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

Manual Testing brought up no issues, functionally it looks good to me

review: Approve (functional)
Revision history for this message
Gerry Boland (gerboland) :
review: Needs Fixing (code)
280. By Nick Dedekind

mirConfig->mirServer

281. By Nick Dedekind

merged with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Good to go

 * 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.
Is fine

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/session.cpp'
2--- src/modules/Unity/Application/session.cpp 2014-09-11 16:18:40 +0000
3+++ src/modules/Unity/Application/session.cpp 2015-01-09 15:14:09 +0000
4@@ -26,6 +26,7 @@
5
6 // mir
7 #include <mir/scene/session.h>
8+#include <mir/scene/prompt_session.h>
9 #include <mir/scene/prompt_session_manager.h>
10
11 // Qt
12@@ -223,7 +224,6 @@
13 {
14 case Session::State::Suspended:
15 if (m_state == Session::State::Running) {
16- stopPromptSessions();
17 session()->set_lifecycle_state(mir_lifecycle_state_will_suspend);
18 m_suspendTimer->start(3000);
19 }
20@@ -253,6 +253,19 @@
21 m_state = state;
22 Q_EMIT stateChanged(state);
23
24+ foreachPromptSession([this, state](const std::shared_ptr<ms::PromptSession>& promptSession) {
25+ switch (state) {
26+ case Session::State::Suspended:
27+ m_promptSessionManager->suspend_prompt_session(promptSession);
28+ break;
29+ case Session::State::Running:
30+ m_promptSessionManager->resume_prompt_session(promptSession);
31+ break;
32+ default:
33+ break;
34+ }
35+ });
36+
37 foreachChildSession([state](SessionInterface* session) {
38 session->setState(state);
39 });
40
41=== modified file 'tests/modules/SessionManager/session_test.cpp'
42--- tests/modules/SessionManager/session_test.cpp 2014-12-01 11:05:01 +0000
43+++ tests/modules/SessionManager/session_test.cpp 2015-01-09 15:14:09 +0000
44@@ -191,3 +191,61 @@
45 delete session;
46 EXPECT_THAT(destroyed, UnorderedElementsAre(session1, session2, session3));
47 }
48+
49+class MockQtMirSession : public qtmir::Session
50+{
51+public:
52+ MockQtMirSession(const std::shared_ptr<ms::Session>& session,
53+ const std::shared_ptr<ms::PromptSessionManager>& promptSessionManager)
54+ : Session(session, promptSessionManager)
55+ {}
56+
57+ using SessionInterface::appendPromptSession;
58+};
59+
60+TEST_F(SessionTests, SuspendPromptSessionWhenSessionSuspends)
61+{
62+ using namespace testing;
63+
64+ const QString appId("test-app");
65+ quint64 procId = 5551;
66+
67+ auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
68+ EXPECT_CALL(*mirSession, set_lifecycle_state(_));
69+
70+ auto session = std::make_shared<MockQtMirSession>(mirSession, mirServer->the_prompt_session_manager());
71+ session->setState(Session::State::Running);
72+
73+ auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
74+ session->appendPromptSession(mirPromptSession);
75+
76+ EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), suspend_prompt_session(_)).Times(1);
77+
78+ session->setState(Session::State::Suspended);
79+
80+ Mock::VerifyAndClear(mirServer->the_mock_prompt_session_manager().get());
81+}
82+
83+TEST_F(SessionTests, ResumePromptSessionWhenSessionResumes)
84+{
85+ using namespace testing;
86+
87+ const QString appId("test-app");
88+ quint64 procId = 5551;
89+
90+ auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
91+ EXPECT_CALL(*mirSession, set_lifecycle_state(_));
92+
93+ auto session = std::make_shared<MockQtMirSession>(mirSession, mirServer->the_prompt_session_manager());
94+ session->setState(Session::State::Suspended);
95+
96+ auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
97+ session->appendPromptSession(mirPromptSession);
98+
99+ EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), resume_prompt_session(_)).Times(1);
100+
101+ session->setState(Session::State::Running);
102+
103+ Mock::VerifyAndClear(mirServer->the_mock_prompt_session_manager().get());
104+}
105+
106
107=== modified file 'tests/modules/common/mock_mir_session.h'
108--- tests/modules/common/mock_mir_session.h 2015-01-06 17:28:52 +0000
109+++ tests/modules/common/mock_mir_session.h 2015-01-09 15:14:09 +0000
110@@ -31,7 +31,7 @@
111 struct MockSession : public Session
112 {
113 MockSession() {}
114- MockSession(std::string const& sessionName, pid_t processId)
115+ MockSession(std::string const& sessionName, pid_t processId)
116 : m_sessionName(sessionName), m_sessionId(processId)
117 {}
118

Subscribers

People subscribed via source and target branches