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
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 2014-11-25 16:16:29 +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 'src/platforms/mirserver/promptsessionlistener.cpp'
42--- src/platforms/mirserver/promptsessionlistener.cpp 2014-07-11 17:15:47 +0000
43+++ src/platforms/mirserver/promptsessionlistener.cpp 2014-11-25 16:16:29 +0000
44@@ -45,6 +45,18 @@
45 Q_EMIT promptSessionStopping(prompt_session);
46 }
47
48+void 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+
54+void 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+
60 void PromptSessionListener::prompt_provider_added(ms::PromptSession const& prompt_session,
61 std::shared_ptr<ms::Session> const& prompt_provider)
62 {
63
64=== modified file 'src/platforms/mirserver/promptsessionlistener.h'
65--- src/platforms/mirserver/promptsessionlistener.h 2014-07-11 17:15:47 +0000
66+++ src/platforms/mirserver/promptsessionlistener.h 2014-11-25 16:16:29 +0000
67@@ -30,6 +30,8 @@
68
69 void starting(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
70 void stopping(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
71+ void suspending(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
72+ void resuming(std::shared_ptr<mir::scene::PromptSession> const& prompt_session) override;
73
74 void prompt_provider_added(mir::scene::PromptSession const& prompt_session,
75 std::shared_ptr<mir::scene::Session> const& prompt_provider) override;
76@@ -39,6 +41,8 @@
77 Q_SIGNALS:
78 void promptSessionStarting(std::shared_ptr<mir::scene::PromptSession> const& session);
79 void promptSessionStopping(std::shared_ptr<mir::scene::PromptSession> const& session);
80+ void promptSessionSuspending(std::shared_ptr<mir::scene::PromptSession> const& session);
81+ void promptSessionResuming(std::shared_ptr<mir::scene::PromptSession> const& session);
82
83 void promptProviderAdded(mir::scene::PromptSession const*, std::shared_ptr<mir::scene::Session> const&);
84 void promptProviderRemoved(mir::scene::PromptSession const*, std::shared_ptr<mir::scene::Session> const&);
85
86=== modified file 'tests/modules/SessionManager/session_test.cpp'
87--- tests/modules/SessionManager/session_test.cpp 2014-09-11 16:18:40 +0000
88+++ tests/modules/SessionManager/session_test.cpp 2014-11-25 16:16:29 +0000
89@@ -191,3 +191,61 @@
90 delete session;
91 EXPECT_THAT(destroyed, UnorderedElementsAre(session1, session2, session3));
92 }
93+
94+class MockQtMirSession : public qtmir::Session
95+{
96+public:
97+ MockQtMirSession(const std::shared_ptr<ms::Session>& session,
98+ const std::shared_ptr<ms::PromptSessionManager>& promptSessionManager)
99+ : Session(session, promptSessionManager)
100+ {}
101+
102+ using SessionInterface::appendPromptSession;
103+};
104+
105+TEST_F(SessionTests, SuspendPromptSessionWhenSessionSuspends)
106+{
107+ using namespace testing;
108+
109+ const QString appId("test-app");
110+ quint64 procId = 5551;
111+
112+ auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
113+ EXPECT_CALL(*mirSession, set_lifecycle_state(_));
114+
115+ auto session = std::make_shared<MockQtMirSession>(mirSession, mirConfig->the_prompt_session_manager());
116+ session->setState(Session::State::Running);
117+
118+ auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
119+ session->appendPromptSession(mirPromptSession);
120+
121+ EXPECT_CALL(*mirConfig->the_mock_prompt_session_manager(), suspend_prompt_session(_)).Times(1);
122+
123+ session->setState(Session::State::Suspended);
124+
125+ Mock::VerifyAndClear(mirConfig->the_mock_prompt_session_manager().get());
126+}
127+
128+TEST_F(SessionTests, ResumePromptSessionWhenSessionResumes)
129+{
130+ using namespace testing;
131+
132+ const QString appId("test-app");
133+ quint64 procId = 5551;
134+
135+ auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
136+ EXPECT_CALL(*mirSession, set_lifecycle_state(_));
137+
138+ auto session = std::make_shared<MockQtMirSession>(mirSession, mirConfig->the_prompt_session_manager());
139+ session->setState(Session::State::Suspended);
140+
141+ auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
142+ session->appendPromptSession(mirPromptSession);
143+
144+ EXPECT_CALL(*mirConfig->the_mock_prompt_session_manager(), resume_prompt_session(_)).Times(1);
145+
146+ session->setState(Session::State::Running);
147+
148+ Mock::VerifyAndClear(mirConfig->the_mock_prompt_session_manager().get());
149+}
150+
151
152=== modified file 'tests/modules/common/mock_mir_session.h'
153--- tests/modules/common/mock_mir_session.h 2014-09-11 16:18:40 +0000
154+++ tests/modules/common/mock_mir_session.h 2014-11-25 16:16:29 +0000
155@@ -31,7 +31,7 @@
156 struct MockSession : public Session
157 {
158 MockSession() {}
159- MockSession(std::string const& sessionName, pid_t processId)
160+ MockSession(std::string const& sessionName, pid_t processId)
161 : m_sessionName(sessionName), m_sessionId(processId)
162 {}
163
164@@ -62,6 +62,8 @@
165
166 void start_prompt_session() override {};
167 void stop_prompt_session() override {};
168+ void suspend_prompt_session() override {};
169+ void resume_prompt_session() override {};
170
171 private:
172 std::string m_sessionName;
173
174=== modified file 'tests/modules/common/mock_prompt_session.h'
175--- tests/modules/common/mock_prompt_session.h 2014-09-11 16:18:40 +0000
176+++ tests/modules/common/mock_prompt_session.h 2014-11-25 16:16:29 +0000
177@@ -26,6 +26,11 @@
178
179 struct MockPromptSession : public PromptSession
180 {
181+public:
182+ MOCK_METHOD1(start, void(std::shared_ptr<Session> const&));
183+ MOCK_METHOD1(stop, void(std::shared_ptr<Session> const&));
184+ MOCK_METHOD1(suspend, void(std::shared_ptr<Session> const&));
185+ MOCK_METHOD1(resume, void(std::shared_ptr<Session> const&));
186 };
187
188 } // namespace scene
189
190=== modified file 'tests/modules/common/mock_prompt_session_manager.h'
191--- tests/modules/common/mock_prompt_session_manager.h 2014-09-11 16:18:40 +0000
192+++ tests/modules/common/mock_prompt_session_manager.h 2014-11-25 16:16:29 +0000
193@@ -34,12 +34,13 @@
194
195 MOCK_CONST_METHOD1(stop_prompt_session, void(std::shared_ptr<PromptSession> const&));
196
197+ MOCK_CONST_METHOD1(suspend_prompt_session, void(std::shared_ptr<PromptSession> const&));
198+
199+ MOCK_CONST_METHOD1(resume_prompt_session, void(std::shared_ptr<PromptSession> const&));
200+
201 MOCK_CONST_METHOD2(add_prompt_provider, void(std::shared_ptr<PromptSession> const&,
202 std::shared_ptr<mir::scene::Session> const&));
203
204- MOCK_CONST_METHOD2(add_prompt_provider_by_pid, void(std::shared_ptr<PromptSession> const&,
205- pid_t));
206-
207 MOCK_CONST_METHOD1(add_expected_session, void(std::shared_ptr<Session> const&));
208
209 MOCK_CONST_METHOD1(remove_session, void(std::shared_ptr<Session> const&));

Subscribers

People subscribed via source and target branches