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
=== modified file 'src/modules/Unity/Application/session.cpp'
--- src/modules/Unity/Application/session.cpp 2014-09-11 16:18:40 +0000
+++ src/modules/Unity/Application/session.cpp 2015-01-09 15:14:09 +0000
@@ -26,6 +26,7 @@
2626
27// mir27// mir
28#include <mir/scene/session.h>28#include <mir/scene/session.h>
29#include <mir/scene/prompt_session.h>
29#include <mir/scene/prompt_session_manager.h>30#include <mir/scene/prompt_session_manager.h>
3031
31// Qt32// Qt
@@ -223,7 +224,6 @@
223 {224 {
224 case Session::State::Suspended:225 case Session::State::Suspended:
225 if (m_state == Session::State::Running) {226 if (m_state == Session::State::Running) {
226 stopPromptSessions();
227 session()->set_lifecycle_state(mir_lifecycle_state_will_suspend);227 session()->set_lifecycle_state(mir_lifecycle_state_will_suspend);
228 m_suspendTimer->start(3000);228 m_suspendTimer->start(3000);
229 }229 }
@@ -253,6 +253,19 @@
253 m_state = state;253 m_state = state;
254 Q_EMIT stateChanged(state);254 Q_EMIT stateChanged(state);
255255
256 foreachPromptSession([this, state](const std::shared_ptr<ms::PromptSession>& promptSession) {
257 switch (state) {
258 case Session::State::Suspended:
259 m_promptSessionManager->suspend_prompt_session(promptSession);
260 break;
261 case Session::State::Running:
262 m_promptSessionManager->resume_prompt_session(promptSession);
263 break;
264 default:
265 break;
266 }
267 });
268
256 foreachChildSession([state](SessionInterface* session) {269 foreachChildSession([state](SessionInterface* session) {
257 session->setState(state);270 session->setState(state);
258 });271 });
259272
=== modified file 'tests/modules/SessionManager/session_test.cpp'
--- tests/modules/SessionManager/session_test.cpp 2014-12-01 11:05:01 +0000
+++ tests/modules/SessionManager/session_test.cpp 2015-01-09 15:14:09 +0000
@@ -191,3 +191,61 @@
191 delete session;191 delete session;
192 EXPECT_THAT(destroyed, UnorderedElementsAre(session1, session2, session3));192 EXPECT_THAT(destroyed, UnorderedElementsAre(session1, session2, session3));
193}193}
194
195class MockQtMirSession : public qtmir::Session
196{
197public:
198 MockQtMirSession(const std::shared_ptr<ms::Session>& session,
199 const std::shared_ptr<ms::PromptSessionManager>& promptSessionManager)
200 : Session(session, promptSessionManager)
201 {}
202
203 using SessionInterface::appendPromptSession;
204};
205
206TEST_F(SessionTests, SuspendPromptSessionWhenSessionSuspends)
207{
208 using namespace testing;
209
210 const QString appId("test-app");
211 quint64 procId = 5551;
212
213 auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
214 EXPECT_CALL(*mirSession, set_lifecycle_state(_));
215
216 auto session = std::make_shared<MockQtMirSession>(mirSession, mirServer->the_prompt_session_manager());
217 session->setState(Session::State::Running);
218
219 auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
220 session->appendPromptSession(mirPromptSession);
221
222 EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), suspend_prompt_session(_)).Times(1);
223
224 session->setState(Session::State::Suspended);
225
226 Mock::VerifyAndClear(mirServer->the_mock_prompt_session_manager().get());
227}
228
229TEST_F(SessionTests, ResumePromptSessionWhenSessionResumes)
230{
231 using namespace testing;
232
233 const QString appId("test-app");
234 quint64 procId = 5551;
235
236 auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
237 EXPECT_CALL(*mirSession, set_lifecycle_state(_));
238
239 auto session = std::make_shared<MockQtMirSession>(mirSession, mirServer->the_prompt_session_manager());
240 session->setState(Session::State::Suspended);
241
242 auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
243 session->appendPromptSession(mirPromptSession);
244
245 EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), resume_prompt_session(_)).Times(1);
246
247 session->setState(Session::State::Running);
248
249 Mock::VerifyAndClear(mirServer->the_mock_prompt_session_manager().get());
250}
251
194252
=== modified file 'tests/modules/common/mock_mir_session.h'
--- tests/modules/common/mock_mir_session.h 2015-01-06 17:28:52 +0000
+++ tests/modules/common/mock_mir_session.h 2015-01-09 15:14:09 +0000
@@ -31,7 +31,7 @@
31struct MockSession : public Session31struct MockSession : public Session
32{32{
33 MockSession() {}33 MockSession() {}
34 MockSession(std::string const& sessionName, pid_t processId) 34 MockSession(std::string const& sessionName, pid_t processId)
35 : m_sessionName(sessionName), m_sessionId(processId)35 : m_sessionName(sessionName), m_sessionId(processId)
36 {}36 {}
3737

Subscribers

People subscribed via source and target branches