Merge lp:~alan-griffiths/miral/encapsulate-mir-PromptSession into lp:miral

Proposed by Alan Griffiths
Status: Merged
Approved by: Gerry Boland
Approved revision: 401
Merged at revision: 400
Proposed branch: lp:~alan-griffiths/miral/encapsulate-mir-PromptSession
Merge into: lp:miral
Diff against target: 558 lines (+131/-69)
16 files modified
miral-qt/src/common/mirqtconversion.h (+1/-1)
miral-qt/src/modules/Unity/Application/application.h (+0/-6)
miral-qt/src/modules/Unity/Application/session.cpp (+14/-14)
miral-qt/src/modules/Unity/Application/session.h (+5/-5)
miral-qt/src/modules/Unity/Application/session_interface.h (+5/-5)
miral-qt/src/modules/Unity/Application/sessionmanager.cpp (+3/-2)
miral-qt/src/modules/Unity/Application/sessionmanager.h (+2/-2)
miral-qt/src/platforms/mirserver/CMakeLists.txt (+1/-1)
miral-qt/src/platforms/mirserver/promptsession.h (+62/-0)
miral-qt/src/platforms/mirserver/promptsessionmanager.cpp (+6/-6)
miral-qt/src/platforms/mirserver/promptsessionmanager.h (+6/-6)
miral-qt/tests/framework/fake_session.cpp (+7/-5)
miral-qt/tests/framework/fake_session.h (+4/-4)
miral-qt/tests/framework/mock_session.h (+5/-4)
miral-qt/tests/modules/SessionManager/session_manager_test.cpp (+5/-4)
miral-qt/tests/modules/SessionManager/session_test.cpp (+5/-4)
To merge this branch: bzr merge lp:~alan-griffiths/miral/encapsulate-mir-PromptSession
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Review via email: mp+307823@code.launchpad.net

Commit message

[miral-qt] Encapsulate mir::scene::PromptSession

Description of the change

[miral-qt] Encapsulate mir::scene::PromptSession

(Almost) there's something with the signal/slot mechanism that still requires the complete type for mir::scene::PromptSession.

But this is another step towards isolating the prompt session requirements so they can be supported my libmiral

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

> (Almost) there's something with the signal/slot mechanism that still
> requires the complete type for mir::scene::PromptSession.

It's not ideal, but Qt refuses to let signal/slot connections work with types that are forward declared. Qt wants to check if the type is registered with the metatype system at compile time. Can't avoid it.

General change looks ok, however I'd prefer if you adopted the Qt style in PromptSession, e.g.
std::shared_ptr<mir::scene::PromptSession> const& promptSession
  -> const std::shared_ptr<mir::scene::PromptSession> &promptSession
and not use the newer C++ style "auto foo() -> bool"

review: Needs Fixing
398. By Alan Griffiths

Adopt local fashion

399. By Alan Griffiths

merge :parent

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> General change looks ok, however I'd prefer if you adopted the Qt style in
> PromptSession, e.g.
> std::shared_ptr<mir::scene::PromptSession> const& promptSession
> -> const std::shared_ptr<mir::scene::PromptSession> &promptSession
> and not use the newer C++ style "auto foo() -> bool"

Done

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

> > General change looks ok, however I'd prefer if you adopted the Qt style in
> > PromptSession, e.g.
> > std::shared_ptr<mir::scene::PromptSession> const& promptSession
> > -> const std::shared_ptr<mir::scene::PromptSession> &promptSession
> > and not use the newer C++ style "auto foo() -> bool"
>
> Done

Not quite, please put the const qualifier before the type, not after. * and & are attached to the variable name too, not the type.

> std::shared_ptr<mir::scene::PromptSession> const& promptSession
> -> const std::shared_ptr<mir::scene::PromptSession> &promptSession

400. By Alan Griffiths

Adopt local fashion

401. By Alan Griffiths

Adopt local fashion

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

Looks good, thank you

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'miral-qt/src/common/mirqtconversion.h'
2--- miral-qt/src/common/mirqtconversion.h 2016-10-06 11:27:59 +0000
3+++ miral-qt/src/common/mirqtconversion.h 2016-10-10 13:04:19 +0000
4@@ -93,8 +93,8 @@
5 return mir_surface_state_restored;
6
7 case Mir::HiddenState: return mir_surface_state_hidden;
8+ default: Q_UNREACHABLE();
9 }
10- Q_UNREACHABLE();
11 }
12
13 } // namespace qtmir
14
15=== modified file 'miral-qt/src/modules/Unity/Application/application.h'
16--- miral-qt/src/modules/Unity/Application/application.h 2016-08-16 14:21:14 +0000
17+++ miral-qt/src/modules/Unity/Application/application.h 2016-10-10 13:04:19 +0000
18@@ -31,12 +31,6 @@
19 #include "mirsurfacelistmodel.h"
20 #include "session_interface.h"
21
22-namespace mir {
23- namespace scene {
24- class Session;
25- }
26-}
27-
28 namespace qtmir
29 {
30
31
32=== modified file 'miral-qt/src/modules/Unity/Application/session.cpp'
33--- miral-qt/src/modules/Unity/Application/session.cpp 2016-10-06 15:36:43 +0000
34+++ miral-qt/src/modules/Unity/Application/session.cpp 2016-10-10 13:04:19 +0000
35@@ -20,13 +20,13 @@
36 #include "session.h"
37 #include "mirsurfaceinterface.h"
38 #include "mirsurfaceitem.h"
39+#include "promptsession.h"
40
41 // mirserver
42 #include "logging.h"
43
44 // mir
45 #include <mir/scene/session.h>
46-#include <mir/scene/prompt_session.h>
47
48 // Qt
49 #include <QPainter>
50@@ -294,7 +294,7 @@
51 session()->set_lifecycle_state(mir_lifecycle_state_will_suspend);
52 m_suspendTimer->start();
53
54- foreachPromptSession([this](const std::shared_ptr<ms::PromptSession>& promptSession) {
55+ foreachPromptSession([this](const qtmir::PromptSession &promptSession) {
56 m_promptSessionManager->suspendPromptSession(promptSession);
57 });
58
59@@ -326,7 +326,7 @@
60
61 session()->set_lifecycle_state(mir_lifecycle_state_resumed);
62
63- foreachPromptSession([this](const std::shared_ptr<ms::PromptSession>& promptSession) {
64+ foreachPromptSession([this](const qtmir::PromptSession &promptSession) {
65 m_promptSessionManager->resumePromptSession(promptSession);
66 });
67
68@@ -453,16 +453,16 @@
69 return m_children;
70 }
71
72-void Session::appendPromptSession(const std::shared_ptr<ms::PromptSession>& promptSession)
73+void Session::appendPromptSession(const qtmir::PromptSession &promptSession)
74 {
75- DEBUG_MSG << "(promptSession=" << (promptSession ? promptSession.get() : nullptr) << ")";
76+ DEBUG_MSG << "(promptSession=" << promptSession.get() << ")";
77
78 m_promptSessions.append(promptSession);
79 }
80
81-void Session::removePromptSession(const std::shared_ptr<ms::PromptSession>& promptSession)
82+void Session::removePromptSession(const qtmir::PromptSession &promptSession)
83 {
84- DEBUG_MSG << "(promptSession=" << (promptSession ? promptSession.get() : nullptr) << ")";
85+ DEBUG_MSG << "(promptSession=" << promptSession.get() << ")";
86
87 m_promptSessions.removeAll(promptSession);
88 }
89@@ -474,26 +474,26 @@
90 static_cast<Session*>(child)->stopPromptSessions();
91 }
92
93- QVector<std::shared_ptr<ms::PromptSession>> copy(m_promptSessions);
94- QVectorIterator<std::shared_ptr<ms::PromptSession>> it(copy);
95+ QVector<qtmir::PromptSession> copy(m_promptSessions);
96+ QVectorIterator<qtmir::PromptSession> it(copy);
97 for ( it.toBack(); it.hasPrevious(); ) {
98- std::shared_ptr<ms::PromptSession> promptSession = it.previous();
99+ qtmir::PromptSession promptSession = it.previous();
100 DEBUG_MSG << " - promptSession=" << promptSession.get();
101
102 m_promptSessionManager->stopPromptSession(promptSession);
103 }
104 }
105
106-std::shared_ptr<ms::PromptSession> Session::activePromptSession() const
107+qtmir::PromptSession Session::activePromptSession() const
108 {
109 if (m_promptSessions.count() > 0)
110 return m_promptSessions.back();
111- return nullptr;
112+ return {};
113 }
114
115-void Session::foreachPromptSession(const std::function<void(const std::shared_ptr<ms::PromptSession>&)>& f) const
116+void Session::foreachPromptSession(const std::function<void(const qtmir::PromptSession&)>& f) const
117 {
118- Q_FOREACH (std::shared_ptr<ms::PromptSession> promptSession, m_promptSessions) {
119+ Q_FOREACH (qtmir::PromptSession promptSession, m_promptSessions) {
120 f(promptSession);
121 }
122 }
123
124=== modified file 'miral-qt/src/modules/Unity/Application/session.h'
125--- miral-qt/src/modules/Unity/Application/session.h 2016-10-05 15:31:59 +0000
126+++ miral-qt/src/modules/Unity/Application/session.h 2016-10-10 13:04:19 +0000
127@@ -77,15 +77,15 @@
128
129 std::shared_ptr<mir::scene::Session> session() const override;
130
131- std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override;
132- void foreachPromptSession(const std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> &f) const override;
133+ PromptSession activePromptSession() const override;
134+ void foreachPromptSession(const std::function<void(const PromptSession&)> &f) const override;
135
136 SessionModel* childSessions() const override;
137
138 void setFullscreen(bool fullscreen) override;
139 void setLive(const bool) override;
140- void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override;
141- void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override;
142+ void appendPromptSession(const PromptSession& session) override;
143+ void removePromptSession(const PromptSession& session) override;
144
145 // useful for tests
146 void setSuspendTimer(AbstractTimer *timer);
147@@ -118,7 +118,7 @@
148 State m_state;
149 bool m_live;
150 AbstractTimer* m_suspendTimer{nullptr};
151- QVector<std::shared_ptr<mir::scene::PromptSession>> m_promptSessions;
152+ QVector<PromptSession> m_promptSessions;
153 std::shared_ptr<PromptSessionManager> const m_promptSessionManager;
154 QList<MirSurfaceInterface*> m_closingSurfaces;
155 bool m_hadSurface{false};
156
157=== modified file 'miral-qt/src/modules/Unity/Application/session_interface.h'
158--- miral-qt/src/modules/Unity/Application/session_interface.h 2016-09-30 14:04:24 +0000
159+++ miral-qt/src/modules/Unity/Application/session_interface.h 2016-10-10 13:04:19 +0000
160@@ -33,7 +33,6 @@
161 namespace mir {
162 namespace scene {
163 class Session;
164- class PromptSession;
165 }
166 }
167
168@@ -41,6 +40,7 @@
169
170 class MirSurfaceInterface;
171 class MirSurfaceListModel;
172+class PromptSession;
173
174 class SessionInterface : public QObject {
175 Q_OBJECT
176@@ -106,13 +106,13 @@
177 virtual void removeChildSession(SessionInterface* session) = 0;
178 virtual void foreachChildSession(const std::function<void(SessionInterface* session)>& f) const = 0;
179
180- virtual std::shared_ptr<mir::scene::PromptSession> activePromptSession() const = 0;
181- virtual void foreachPromptSession(const std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)>& f) const = 0;
182+ virtual PromptSession activePromptSession() const = 0;
183+ virtual void foreachPromptSession(const std::function<void(const PromptSession&)>& f) const = 0;
184
185 virtual void setFullscreen(bool fullscreen) = 0;
186 virtual void setLive(const bool) = 0;
187- virtual void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0;
188- virtual void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0;
189+ virtual void appendPromptSession(const PromptSession& session) = 0;
190+ virtual void removePromptSession(const PromptSession& session) = 0;
191
192 Q_SIGNALS:
193 void applicationChanged(unity::shell::application::ApplicationInfoInterface* application);
194
195=== modified file 'miral-qt/src/modules/Unity/Application/sessionmanager.cpp'
196--- miral-qt/src/modules/Unity/Application/sessionmanager.cpp 2016-10-05 16:08:44 +0000
197+++ miral-qt/src/modules/Unity/Application/sessionmanager.cpp 2016-10-10 13:04:19 +0000
198@@ -27,6 +27,7 @@
199 #include "logging.h"
200 #include "nativeinterface.h"
201 #include "promptsessionlistener.h"
202+#include "promptsession.h"
203
204 // mir
205 #include <mir/scene/prompt_session.h>
206@@ -155,7 +156,7 @@
207 Q_EMIT sessionStopping(qmlSession);
208 }
209
210-void SessionManager::onPromptSessionStarting(const std::shared_ptr<ms::PromptSession>& promptSession)
211+void SessionManager::onPromptSessionStarting(const qtmir::PromptSession &promptSession)
212 {
213 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStarting - promptSession=" << promptSession.get();
214
215@@ -169,7 +170,7 @@
216 }
217 }
218
219-void SessionManager::onPromptSessionStopping(const std::shared_ptr<ms::PromptSession>& promptSession)
220+void SessionManager::onPromptSessionStopping(const qtmir::PromptSession &promptSession)
221 {
222 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStopping - promptSession=" << promptSession.get();
223
224
225=== modified file 'miral-qt/src/modules/Unity/Application/sessionmanager.h'
226--- miral-qt/src/modules/Unity/Application/sessionmanager.h 2016-10-05 15:31:59 +0000
227+++ miral-qt/src/modules/Unity/Application/sessionmanager.h 2016-10-10 13:04:19 +0000
228@@ -70,8 +70,8 @@
229 void onSessionStarting(const miral::ApplicationInfo &appInfo);
230 void onSessionStopping(const miral::ApplicationInfo &appInfo);
231
232- void onPromptSessionStarting(const std::shared_ptr<mir::scene::PromptSession>& promptSession);
233- void onPromptSessionStopping(const std::shared_ptr<mir::scene::PromptSession>& promptSession);
234+ void onPromptSessionStarting(const PromptSession& promptSession);
235+ void onPromptSessionStopping(const PromptSession& promptSession);
236 void onPromptProviderAdded(const mir::scene::PromptSession *, const std::shared_ptr<mir::scene::Session> &);
237 void onPromptProviderRemoved(const mir::scene::PromptSession *, const std::shared_ptr<mir::scene::Session> &);
238
239
240=== modified file 'miral-qt/src/platforms/mirserver/CMakeLists.txt'
241--- miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-10-05 16:59:28 +0000
242+++ miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-10-10 13:04:19 +0000
243@@ -87,7 +87,7 @@
244 tracepoints.c
245 mirserverhooks.cpp mirserverhooks.h
246 openglcontextfactory.cpp openglcontextfactory.h
247- promptsessionmanager.cpp promptsessionmanager.h
248+ promptsessionmanager.cpp promptsessionmanager.h promptsession.h
249 setqtcompositor.cpp setqtcompositor.h
250 # We need to run moc on these headers
251 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
252
253=== added file 'miral-qt/src/platforms/mirserver/promptsession.h'
254--- miral-qt/src/platforms/mirserver/promptsession.h 1970-01-01 00:00:00 +0000
255+++ miral-qt/src/platforms/mirserver/promptsession.h 2016-10-10 13:04:19 +0000
256@@ -0,0 +1,62 @@
257+/*
258+ * Copyright © 2016 Canonical Ltd.
259+ *
260+ * This program is free software: you can redistribute it and/or modify it
261+ * under the terms of the GNU General Public License version 3,
262+ * as published by the Free Software Foundation.
263+ *
264+ * This program is distributed in the hope that it will be useful,
265+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
266+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
267+ * GNU General Public License for more details.
268+ *
269+ * You should have received a copy of the GNU General Public License
270+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
271+ *
272+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
273+ */
274+
275+#ifndef QTMIR_PROMPTSESSION_H
276+#define QTMIR_PROMPTSESSION_H
277+
278+#include <memory>
279+
280+namespace mir {
281+namespace scene {
282+class PromptSession;
283+}
284+}
285+
286+namespace qtmir {
287+class PromptSession
288+{
289+public:
290+ // Intentionally promiscuous converting constructor
291+ PromptSession(const std::shared_ptr<mir::scene::PromptSession> &promptSession) :
292+ m_promptSession{promptSession} {}
293+
294+ PromptSession() = default;
295+ PromptSession(const PromptSession &that) = default;
296+ PromptSession& operator=(const PromptSession &rhs) = default;
297+ ~PromptSession() = default;
298+
299+ mir::scene::PromptSession* get() const { return m_promptSession.get(); }
300+
301+ friend bool operator==(const PromptSession &lhs, const PromptSession &rhs)
302+ { return lhs.m_promptSession == rhs.m_promptSession; }
303+
304+ friend bool operator==(const PromptSession &lhs, mir::scene::PromptSession *rhs)
305+ { return lhs.m_promptSession.get() == rhs; }
306+
307+ friend bool operator==(mir::scene::PromptSession *lhs, const PromptSession &rhs)
308+ { return lhs == rhs.m_promptSession.get(); }
309+
310+ // Intentionally promiscuous converting operator
311+ operator std::shared_ptr<mir::scene::PromptSession> const&() const { return m_promptSession; }
312+
313+private:
314+ std::shared_ptr<mir::scene::PromptSession> m_promptSession;
315+};
316+}
317+
318+#endif //QTMIR_PROMPTSESSION_H
319
320=== modified file 'miral-qt/src/platforms/mirserver/promptsessionmanager.cpp'
321--- miral-qt/src/platforms/mirserver/promptsessionmanager.cpp 2016-10-05 16:08:44 +0000
322+++ miral-qt/src/platforms/mirserver/promptsessionmanager.cpp 2016-10-10 13:04:19 +0000
323@@ -15,33 +15,33 @@
324 */
325
326 #include "promptsessionmanager.h"
327+#include "promptsession.h"
328
329 #include <mir/scene/prompt_session_manager.h>
330
331-qtmir::PromptSessionManager::PromptSessionManager(std::shared_ptr<mir::scene::PromptSessionManager> const& promptSessionManager) :
332+qtmir::PromptSessionManager::PromptSessionManager(std::shared_ptr<mir::scene::PromptSessionManager> const &promptSessionManager) :
333 m_promptSessionManager{promptSessionManager}
334 {
335 }
336
337 qtmir::PromptSessionManager::~PromptSessionManager() = default;
338
339-miral::Application qtmir::PromptSessionManager::applicationFor(
340- std::shared_ptr<mir::scene::PromptSession> const& promptSession) const
341+miral::Application qtmir::PromptSessionManager::applicationFor(const PromptSession &promptSession) const
342 {
343 return m_promptSessionManager->application_for(promptSession);
344 }
345
346-void qtmir::PromptSessionManager::stopPromptSession(std::shared_ptr<mir::scene::PromptSession> const& promptSession) const
347+void qtmir::PromptSessionManager::stopPromptSession(const PromptSession &promptSession) const
348 {
349 m_promptSessionManager->stop_prompt_session(promptSession);
350 }
351
352-void qtmir::PromptSessionManager::suspendPromptSession(std::shared_ptr<mir::scene::PromptSession> const& promptSession) const
353+void qtmir::PromptSessionManager::suspendPromptSession(const PromptSession &promptSession) const
354 {
355 m_promptSessionManager->suspend_prompt_session(promptSession);
356 }
357
358-void qtmir::PromptSessionManager::resumePromptSession(std::shared_ptr<mir::scene::PromptSession> const& promptSession) const
359+void qtmir::PromptSessionManager::resumePromptSession(const PromptSession &promptSession) const
360 {
361 m_promptSessionManager->resume_prompt_session(promptSession);
362 }
363
364=== modified file 'miral-qt/src/platforms/mirserver/promptsessionmanager.h'
365--- miral-qt/src/platforms/mirserver/promptsessionmanager.h 2016-10-05 16:08:44 +0000
366+++ miral-qt/src/platforms/mirserver/promptsessionmanager.h 2016-10-10 13:04:19 +0000
367@@ -23,23 +23,23 @@
368
369 namespace mir {
370 namespace scene {
371-class PromptSession;
372 class PromptSessionManager;
373 }
374 }
375
376 namespace qtmir {
377+class PromptSession;
378 class PromptSessionManager
379 {
380 public:
381- explicit PromptSessionManager(std::shared_ptr<mir::scene::PromptSessionManager> const& promptSessionManager);
382+ explicit PromptSessionManager(const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager);
383 virtual ~PromptSessionManager();
384
385- miral::Application applicationFor(std::shared_ptr<mir::scene::PromptSession> const& promptSession) const;
386+ miral::Application applicationFor(qtmir::PromptSession const &promptSession) const;
387
388- void stopPromptSession(std::shared_ptr<mir::scene::PromptSession> const& promptSession) const;
389- void suspendPromptSession(std::shared_ptr<mir::scene::PromptSession> const& promptSession) const;
390- void resumePromptSession(std::shared_ptr<mir::scene::PromptSession> const& promptSession) const;
391+ void stopPromptSession(qtmir::PromptSession const &promptSession) const;
392+ void suspendPromptSession(qtmir::PromptSession const &promptSession) const;
393+ void resumePromptSession(qtmir::PromptSession const &promptSession) const;
394
395 private:
396 std::shared_ptr<mir::scene::PromptSessionManager> const m_promptSessionManager;
397
398=== modified file 'miral-qt/tests/framework/fake_session.cpp'
399--- miral-qt/tests/framework/fake_session.cpp 2016-08-16 14:15:26 +0000
400+++ miral-qt/tests/framework/fake_session.cpp 2016-10-10 13:04:19 +0000
401@@ -16,6 +16,8 @@
402
403 #include "fake_session.h"
404
405+#include "promptsession.h"
406+
407 namespace qtmir
408 {
409
410@@ -94,20 +96,20 @@
411
412 void FakeSession::foreachChildSession(const std::function<void (SessionInterface *)> &) const {}
413
414-std::shared_ptr<mir::scene::PromptSession> FakeSession::activePromptSession() const
415+qtmir::PromptSession FakeSession::activePromptSession() const
416 {
417- return std::shared_ptr<mir::scene::PromptSession>();
418+ return {};
419 }
420
421-void FakeSession::foreachPromptSession(const std::function<void (const std::shared_ptr<mir::scene::PromptSession> &)> &) const {}
422+void FakeSession::foreachPromptSession(const std::function<void (const qtmir::PromptSession &)> &) const {}
423
424 void FakeSession::setFullscreen(bool) {}
425
426 void FakeSession::setLive(const bool) {}
427
428-void FakeSession::appendPromptSession(const std::shared_ptr<mir::scene::PromptSession> &) {}
429+void FakeSession::appendPromptSession(const qtmir::PromptSession &) {}
430
431-void FakeSession::removePromptSession(const std::shared_ptr<mir::scene::PromptSession> &) {}
432+void FakeSession::removePromptSession(const qtmir::PromptSession &) {}
433
434 void FakeSession::setState(SessionInterface::State state)
435 {
436
437=== modified file 'miral-qt/tests/framework/fake_session.h'
438--- miral-qt/tests/framework/fake_session.h 2016-09-30 19:28:12 +0000
439+++ miral-qt/tests/framework/fake_session.h 2016-10-10 13:04:19 +0000
440@@ -70,13 +70,13 @@
441 void removeChildSession(SessionInterface*) override;
442 void foreachChildSession(const std::function<void(SessionInterface* session)> &) const override;
443
444- std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override;
445- void foreachPromptSession(const std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> &) const override;
446+ PromptSession activePromptSession() const override;
447+ void foreachPromptSession(const std::function<void(const PromptSession&)> &) const override;
448
449 void setFullscreen(bool) override;
450 void setLive(const bool) override;
451- void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override;
452- void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override;
453+ void appendPromptSession(const PromptSession&) override;
454+ void removePromptSession(const PromptSession&) override;
455
456 // For tests
457
458
459=== modified file 'miral-qt/tests/framework/mock_session.h'
460--- miral-qt/tests/framework/mock_session.h 2016-08-16 14:15:26 +0000
461+++ miral-qt/tests/framework/mock_session.h 2016-10-10 13:04:19 +0000
462@@ -18,6 +18,7 @@
463 #define MOCK_QTMIR_SESSION_H
464
465 #include <Unity/Application/session_interface.h>
466+#include "promptsession.h"
467 #include <gmock/gmock.h>
468
469 namespace qtmir {
470@@ -59,8 +60,8 @@
471 MOCK_METHOD1(removeChildSession, void(SessionInterface* session));
472 MOCK_CONST_METHOD1(foreachChildSession, void(const std::function<void(SessionInterface* session)> &f));
473
474- MOCK_CONST_METHOD0(activePromptSession, std::shared_ptr<mir::scene::PromptSession>());
475- MOCK_CONST_METHOD1(foreachPromptSession, void(const std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> &f));
476+ MOCK_CONST_METHOD0(activePromptSession, qtmir::PromptSession());
477+ MOCK_CONST_METHOD1(foreachPromptSession, void(const std::function<void(const qtmir::PromptSession&)> &f));
478
479 void setState(State state);
480
481@@ -72,8 +73,8 @@
482 protected:
483 MOCK_METHOD1(setFullscreen, void(bool fullscreen));
484 MOCK_METHOD1(setLive, void(const bool));
485- MOCK_METHOD1(appendPromptSession, void(const std::shared_ptr<mir::scene::PromptSession>& session));
486- MOCK_METHOD1(removePromptSession, void(const std::shared_ptr<mir::scene::PromptSession>& session));
487+ MOCK_METHOD1(appendPromptSession, void(const qtmir::PromptSession& session));
488+ MOCK_METHOD1(removePromptSession, void(const qtmir::PromptSession& session));
489
490 private:
491 State m_state;
492
493=== modified file 'miral-qt/tests/modules/SessionManager/session_manager_test.cpp'
494--- miral-qt/tests/modules/SessionManager/session_manager_test.cpp 2016-10-05 15:31:59 +0000
495+++ miral-qt/tests/modules/SessionManager/session_manager_test.cpp 2016-10-10 13:04:19 +0000
496@@ -18,6 +18,7 @@
497 #include <condition_variable>
498 #include <QSignalSpy>
499
500+#include "promptsession.h"
501 #include <Unity/Application/session.h>
502
503 #include "qtmir_test.h"
504@@ -33,9 +34,9 @@
505 SessionManagerTests()
506 {}
507
508- QList<std::shared_ptr<ms::PromptSession>> listPromptSessions(SessionInterface* session) {
509- QList<std::shared_ptr<ms::PromptSession>> promptSessions;
510- session->foreachPromptSession([&promptSessions](const std::shared_ptr<ms::PromptSession>& promptSession) {
511+ QList<qtmir::PromptSession> listPromptSessions(SessionInterface* session) {
512+ QList<qtmir::PromptSession> promptSessions;
513+ session->foreachPromptSession([&promptSessions](const qtmir::PromptSession &promptSession) {
514 promptSessions << promptSession;
515 });
516 return promptSessions;
517@@ -61,7 +62,7 @@
518 SessionInterface* qtmirAppSession = sessionManager.findSession(mirAppSession.get());
519 EXPECT_TRUE(qtmirAppSession != nullptr);
520
521- auto promptSession = std::make_shared<ms::MockPromptSession>();
522+ qtmir::PromptSession promptSession{std::make_shared<ms::MockPromptSession>()};
523 ON_CALL(*stubPromptSessionManager, application_for(_)).WillByDefault(Return(mirAppSession));
524
525 sessionManager.onPromptSessionStarting(promptSession);
526
527=== modified file 'miral-qt/tests/modules/SessionManager/session_test.cpp'
528--- miral-qt/tests/modules/SessionManager/session_test.cpp 2016-10-06 13:57:18 +0000
529+++ miral-qt/tests/modules/SessionManager/session_test.cpp 2016-10-10 13:04:19 +0000
530@@ -17,6 +17,7 @@
531 #include <qtmir_test.h>
532 #include <fake_mirsurface.h>
533
534+#include "promptsession.h"
535 #include <Unity/Application/application.h>
536 #include <Unity/Application/mirsurfaceitem.h>
537
538@@ -226,8 +227,8 @@
539 }
540 EXPECT_EQ(Session::Running, session->state());
541
542- auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
543- session->appendPromptSession(mirPromptSession);
544+ qtmir::PromptSession promptSession{std::make_shared<ms::MockPromptSession>()};
545+ session->appendPromptSession(promptSession);
546
547 EXPECT_CALL(*stubPromptSessionManager, suspend_prompt_session(_)).Times(1);
548
549@@ -264,8 +265,8 @@
550 session->doSuspend();
551 EXPECT_EQ(Session::Suspended, session->state());
552
553- auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
554- session->appendPromptSession(mirPromptSession);
555+ qtmir::PromptSession promptSession{std::make_shared<ms::MockPromptSession>()};
556+ session->appendPromptSession(promptSession);
557
558 EXPECT_CALL(*stubPromptSessionManager, resume_prompt_session(_)).Times(1);
559

Subscribers

People subscribed via source and target branches