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

Proposed by Nick Dedekind
Status: Superseded
Proposed branch: lp:~nick-dedekind/qtmir/1355173.trust-prompt-suspend
Merge into: lp:qtmir
Diff against target: 209 lines (+100/-5)
7 files modified
src/modules/Unity/Application/session.cpp (+14/-1)
src/platforms/mirserver/promptsessionlistener.cpp (+12/-0)
src/platforms/mirserver/promptsessionlistener.h (+4/-0)
tests/modules/SessionManager/session_test.cpp (+58/-0)
tests/modules/common/mock_mir_session.h (+3/-1)
tests/modules/common/mock_prompt_session.h (+5/-0)
tests/modules/common/mock_prompt_session_manager.h (+4/-3)
To merge this branch: bzr merge lp:~nick-dedekind/qtmir/1355173.trust-prompt-suspend
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Gerry Boland (community) code Approve
Review via email: mp+242211@code.launchpad.net

This proposal has been superseded by a proposal from 2015-01-07.

Commit message

Added support for prompt suspension

We don't want to suspend the trust helper, but we need to inform it that the application has been "backgrounded" (suspended). It should be the responsibility of the trust helper to deal with the providers if the application has been suspended.

To post a comment you must log in.
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 :

Code looks reasonable, I didn't test though

review: Approve (code)
277. By Nick Dedekind

updated for changes in mir

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
278. By Nick Dedekind

merged with trunk

279. By Nick Dedekind

merged with compatibility branch

280. By Nick Dedekind

mirConfig->mirServer

281. By Nick Dedekind

merged with trunk

Unmerged revisions

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 2014-11-25 16:16:29 +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 'src/platforms/mirserver/promptsessionlistener.cpp'
--- src/platforms/mirserver/promptsessionlistener.cpp 2014-07-11 17:15:47 +0000
+++ src/platforms/mirserver/promptsessionlistener.cpp 2014-11-25 16:16:29 +0000
@@ -45,6 +45,18 @@
45 Q_EMIT promptSessionStopping(prompt_session);45 Q_EMIT promptSessionStopping(prompt_session);
46}46}
4747
48void PromptSessionListener::suspending(std::shared_ptr<ms::PromptSession> const& prompt_session)
49{
50 qCDebug(QTMIR_MIR_MESSAGES) << "PromptSessionListener::suspending - this=" << this << "prompt_session=" << prompt_session.get();
51 Q_EMIT promptSessionSuspending(prompt_session);
52}
53
54void PromptSessionListener::resuming(std::shared_ptr<ms::PromptSession> const& prompt_session)
55{
56 qCDebug(QTMIR_MIR_MESSAGES) << "PromptSessionListener::resuming - this=" << this << "prompt_session=" << prompt_session.get();
57 Q_EMIT promptSessionResuming(prompt_session);
58}
59
48void PromptSessionListener::prompt_provider_added(ms::PromptSession const& prompt_session,60void PromptSessionListener::prompt_provider_added(ms::PromptSession const& prompt_session,
49 std::shared_ptr<ms::Session> const& prompt_provider)61 std::shared_ptr<ms::Session> const& prompt_provider)
50{62{
5163
=== modified file 'src/platforms/mirserver/promptsessionlistener.h'
--- src/platforms/mirserver/promptsessionlistener.h 2014-07-11 17:15:47 +0000
+++ src/platforms/mirserver/promptsessionlistener.h 2014-11-25 16:16:29 +0000
@@ -30,6 +30,8 @@
3030
31 void starting(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;31 void starting(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
32 void stopping(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;32 void stopping(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
33 void suspending(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
34 void resuming(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
3335
34 void prompt_provider_added(mir::scene::PromptSession const& prompt_session,36 void prompt_provider_added(mir::scene::PromptSession const& prompt_session,
35 std::shared_ptr<mir::scene::Session> const& prompt_provider) override;37 std::shared_ptr<mir::scene::Session> const& prompt_provider) override;
@@ -39,6 +41,8 @@
39Q_SIGNALS:41Q_SIGNALS:
40 void promptSessionStarting(std::shared_ptr<mir::scene::PromptSession> const& session);42 void promptSessionStarting(std::shared_ptr<mir::scene::PromptSession> const& session);
41 void promptSessionStopping(std::shared_ptr<mir::scene::PromptSession> const& session);43 void promptSessionStopping(std::shared_ptr<mir::scene::PromptSession> const& session);
44 void promptSessionSuspending(std::shared_ptr<mir::scene::PromptSession> const& session);
45 void promptSessionResuming(std::shared_ptr<mir::scene::PromptSession> const& session);
4246
43 void promptProviderAdded(mir::scene::PromptSession const*, std::shared_ptr<mir::scene::Session> const&);47 void promptProviderAdded(mir::scene::PromptSession const*, std::shared_ptr<mir::scene::Session> const&);
44 void promptProviderRemoved(mir::scene::PromptSession const*, std::shared_ptr<mir::scene::Session> const&);48 void promptProviderRemoved(mir::scene::PromptSession const*, std::shared_ptr<mir::scene::Session> const&);
4549
=== modified file 'tests/modules/SessionManager/session_test.cpp'
--- tests/modules/SessionManager/session_test.cpp 2014-09-11 16:18:40 +0000
+++ tests/modules/SessionManager/session_test.cpp 2014-11-25 16:16:29 +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, mirConfig->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(*mirConfig->the_mock_prompt_session_manager(), suspend_prompt_session(_)).Times(1);
223
224 session->setState(Session::State::Suspended);
225
226 Mock::VerifyAndClear(mirConfig->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, mirConfig->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(*mirConfig->the_mock_prompt_session_manager(), resume_prompt_session(_)).Times(1);
246
247 session->setState(Session::State::Running);
248
249 Mock::VerifyAndClear(mirConfig->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 2014-09-11 16:18:40 +0000
+++ tests/modules/common/mock_mir_session.h 2014-11-25 16:16:29 +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
@@ -62,6 +62,8 @@
6262
63 void start_prompt_session() override {};63 void start_prompt_session() override {};
64 void stop_prompt_session() override {};64 void stop_prompt_session() override {};
65 void suspend_prompt_session() override {};
66 void resume_prompt_session() override {};
6567
66private:68private:
67 std::string m_sessionName;69 std::string m_sessionName;
6870
=== modified file 'tests/modules/common/mock_prompt_session.h'
--- tests/modules/common/mock_prompt_session.h 2014-09-11 16:18:40 +0000
+++ tests/modules/common/mock_prompt_session.h 2014-11-25 16:16:29 +0000
@@ -26,6 +26,11 @@
2626
27struct MockPromptSession : public PromptSession27struct MockPromptSession : public PromptSession
28{28{
29public:
30 MOCK_METHOD1(start, void(std::shared_ptr<Session> const&));
31 MOCK_METHOD1(stop, void(std::shared_ptr<Session> const&));
32 MOCK_METHOD1(suspend, void(std::shared_ptr<Session> const&));
33 MOCK_METHOD1(resume, void(std::shared_ptr<Session> const&));
29};34};
3035
31} // namespace scene36} // namespace scene
3237
=== modified file 'tests/modules/common/mock_prompt_session_manager.h'
--- tests/modules/common/mock_prompt_session_manager.h 2014-09-11 16:18:40 +0000
+++ tests/modules/common/mock_prompt_session_manager.h 2014-11-25 16:16:29 +0000
@@ -34,12 +34,13 @@
3434
35 MOCK_CONST_METHOD1(stop_prompt_session, void(std::shared_ptr<PromptSession> const&));35 MOCK_CONST_METHOD1(stop_prompt_session, void(std::shared_ptr<PromptSession> const&));
3636
37 MOCK_CONST_METHOD1(suspend_prompt_session, void(std::shared_ptr<PromptSession> const&));
38
39 MOCK_CONST_METHOD1(resume_prompt_session, void(std::shared_ptr<PromptSession> const&));
40
37 MOCK_CONST_METHOD2(add_prompt_provider, void(std::shared_ptr<PromptSession> const&,41 MOCK_CONST_METHOD2(add_prompt_provider, void(std::shared_ptr<PromptSession> const&,
38 std::shared_ptr<mir::scene::Session> const&));42 std::shared_ptr<mir::scene::Session> const&));
3943
40 MOCK_CONST_METHOD2(add_prompt_provider_by_pid, void(std::shared_ptr<PromptSession> const&,
41 pid_t));
42
43 MOCK_CONST_METHOD1(add_expected_session, void(std::shared_ptr<Session> const&));44 MOCK_CONST_METHOD1(add_expected_session, void(std::shared_ptr<Session> const&));
4445
45 MOCK_CONST_METHOD1(remove_session, void(std::shared_ptr<Session> const&));46 MOCK_CONST_METHOD1(remove_session, void(std::shared_ptr<Session> const&));

Subscribers

People subscribed via source and target branches