Merge lp:~dandrader/qtmir/frozenApps-lp1295623 into lp:qtmir

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Michael Zanetti
Approved revision: 253
Merged at revision: 249
Proposed branch: lp:~dandrader/qtmir/frozenApps-lp1295623
Merge into: lp:qtmir
Diff against target: 1687 lines (+667/-239)
27 files modified
src/modules/Unity/Application/Application.pro (+1/-0)
src/modules/Unity/Application/application.cpp (+3/-3)
src/modules/Unity/Application/mirsurfaceitem.cpp (+135/-30)
src/modules/Unity/Application/mirsurfaceitem.h (+38/-7)
src/modules/Unity/Application/mirsurfacemanager.cpp (+6/-6)
src/modules/Unity/Application/plugin.cpp (+1/-0)
src/modules/Unity/Application/session.cpp (+21/-19)
src/modules/Unity/Application/session.h (+35/-63)
src/modules/Unity/Application/session_interface.h (+106/-0)
src/modules/Unity/Application/sessionmanager.cpp (+8/-8)
src/modules/Unity/Application/sessionmanager.h (+4/-4)
src/modules/Unity/Application/sessionmodel.h (+2/-2)
tests/modules/ApplicationManager/application_manager_test.cpp (+3/-2)
tests/modules/MirSurfaceItem/MirSurfaceItem.pro (+13/-0)
tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp (+113/-0)
tests/modules/SessionManager/session_manager_test.cpp (+10/-9)
tests/modules/SessionManager/session_test.cpp (+5/-6)
tests/modules/common/common.pri (+1/-0)
tests/modules/common/mock_focus_controller.h (+9/-6)
tests/modules/common/mock_mir_session.h (+14/-13)
tests/modules/common/mock_prompt_session.h (+7/-4)
tests/modules/common/mock_prompt_session_manager.h (+21/-18)
tests/modules/common/mock_renderable.h (+9/-6)
tests/modules/common/mock_session.h (+65/-0)
tests/modules/common/mock_surface.h (+24/-23)
tests/modules/common/qtmir_test.h (+12/-9)
tests/modules/modules.pro (+1/-1)
To merge this branch: bzr merge lp:~dandrader/qtmir/frozenApps-lp1295623
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+234393@code.launchpad.net

Commit message

MirSurfaceItem: Ensure all touch sequences sent to Mir surface are properly ended.

In order to have a testable MirSurfaceItem I had to mock qtmir::Session.
To mock qtmir::Session I had to define a qtmir::SessionInterface. That caused many s/Session/SessionInterfaces throughout the code base.
When creating a testing::MockSession for qtmir::Session it clashed with the existing testing::MockSession for mir::scene::Surface. Thus I had to refactor the namespacing of all mocks.

So most of the diff is just about refactoring code to enable a MirSurfaceItem unit test.

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?
Not applicable

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Confirming this fixes the issue. Code looks ok despite the fact that we're drifting even further from unity-api. However, there's plans to restructure this. So ok with me.

 * Did you perform an exploratory manual test run of the code change and any related functionality?

yes

 * Did CI run pass? If not, please explain why.

yes

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/Application.pro'
2--- src/modules/Unity/Application/Application.pro 2014-09-07 19:42:33 +0000
3+++ src/modules/Unity/Application/Application.pro 2014-09-11 21:25:08 +0000
4@@ -63,6 +63,7 @@
5 processcontroller.h \
6 proc_info.h \
7 session.h \
8+ session_interface.h \
9 sessionmodel.h \
10 upstart/applicationcontroller.h
11
12
13=== modified file 'src/modules/Unity/Application/application.cpp'
14--- src/modules/Unity/Application/application.cpp 2014-09-07 19:42:14 +0000
15+++ src/modules/Unity/Application/application.cpp 2014-09-11 21:25:08 +0000
16@@ -183,9 +183,9 @@
17 m_session->setApplication(this);
18 m_session->setState(state());
19
20- connect(m_session, &Session::suspended, this, &Application::onSessionSuspended);
21- connect(m_session, &Session::resumed, this, &Application::onSessionResumed);
22- connect(m_session, &Session::fullscreenChanged, this, &Application::fullscreenChanged);
23+ connect(m_session, &SessionInterface::suspended, this, &Application::onSessionSuspended);
24+ connect(m_session, &SessionInterface::resumed, this, &Application::onSessionResumed);
25+ connect(m_session, &SessionInterface::fullscreenChanged, this, &Application::fullscreenChanged);
26
27 if (oldFullscreen != fullscreen())
28 Q_EMIT fullscreenChanged(fullscreen());
29
30=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
31--- src/modules/Unity/Application/mirsurfaceitem.cpp 2014-09-07 19:42:14 +0000
32+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2014-09-11 21:25:08 +0000
33@@ -87,7 +87,10 @@
34 return true;
35 }
36
37-bool fillInMirEvent(MirEvent &mirEvent, QTouchEvent *qtEvent)
38+bool fillInMirEvent(MirEvent &mirEvent,
39+ const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
40+ Qt::TouchPointStates qtTouchPointStates,
41+ ulong qtTimestamp)
42 {
43 mirEvent.type = mir_event_type_motion;
44
45@@ -99,14 +102,14 @@
46 // NB: it's assumed that touch points are pressed and released
47 // one at a time.
48
49- if (qtEvent->touchPointStates().testFlag(Qt::TouchPointPressed)) {
50- if (qtEvent->touchPoints().count() > 1) {
51+ if (qtTouchPointStates.testFlag(Qt::TouchPointPressed)) {
52+ if (qtTouchPoints.count() > 1) {
53 mirEvent.motion.action = mir_motion_action_pointer_down;
54 } else {
55 mirEvent.motion.action = mir_motion_action_down;
56 }
57- } else if (qtEvent->touchPointStates().testFlag(Qt::TouchPointReleased)) {
58- if (qtEvent->touchPoints().count() > 1) {
59+ } else if (qtTouchPointStates.testFlag(Qt::TouchPointReleased)) {
60+ if (qtTouchPoints.count() > 1) {
61 mirEvent.motion.action = mir_motion_action_pointer_up;
62 } else {
63 mirEvent.motion.action = mir_motion_action_up;
64@@ -138,18 +141,17 @@
65
66 // Note: QtEventFeeder scales the event time down, scale it back up - precision is
67 // lost but the time difference should still be accurate to milliseconds
68- mirEvent.motion.event_time = static_cast<nsecs_t>(qtEvent->timestamp()) * 1000000;
69-
70- mirEvent.motion.pointer_count = qtEvent->touchPoints().count();
71-
72- auto touchPoints = qtEvent->touchPoints();
73- for (int i = 0; i < touchPoints.count(); ++i) {
74- auto touchPoint = touchPoints.at(i);
75+ mirEvent.motion.event_time = static_cast<nsecs_t>(qtTimestamp) * 1000000;
76+
77+ mirEvent.motion.pointer_count = qtTouchPoints.count();
78+
79+ for (int i = 0; i < qtTouchPoints.count(); ++i) {
80+ auto touchPoint = qtTouchPoints.at(i);
81 auto &pointer = mirEvent.motion.pointer_coordinates[i];
82
83 // FIXME: https://bugs.launchpad.net/mir/+bug/1311699
84 // When multiple touch points are transmitted with a MirEvent
85- // and one of them (only one is allowed) indicates a pressed
86+ // and one of them (only one is allowed) indicates a presse
87 // state change the index is encoded in the second byte of the
88 // action value.
89 const int mir_motion_event_pointer_index_shift = 8;
90@@ -234,7 +236,7 @@
91 UbuntuKeyboardInfo *MirSurfaceItem::m_ubuntuKeyboardInfo = nullptr;
92
93 MirSurfaceItem::MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
94- QPointer<Session> session,
95+ SessionInterface* session,
96 QQuickItem *parent)
97 : QQuickItem(parent)
98 , m_surface(surface)
99@@ -242,6 +244,7 @@
100 , m_firstFrameDrawn(false)
101 , m_live(true)
102 , m_textureProvider(nullptr)
103+ , m_lastTouchEvent(nullptr)
104 {
105 qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::MirSurfaceItem";
106
107@@ -316,6 +319,8 @@
108 m_surface->remove_observer(m_surfaceObserver);
109 if (m_textureProvider)
110 m_textureProvider->deleteLater();
111+
112+ delete m_lastTouchEvent;
113 }
114
115 // For QML to destroy this surface
116@@ -329,7 +334,7 @@
117 deleteLater();
118 }
119
120-Session* MirSurfaceItem::session() const
121+SessionInterface* MirSurfaceItem::session() const
122 {
123 return m_session.data();
124 }
125@@ -478,31 +483,115 @@
126 }
127 }
128
129+QString MirSurfaceItem::appId() const
130+{
131+ QString appId;
132+ if (session() && session()->application()) {
133+ appId = session()->application()->appId();
134+ } else {
135+ appId.append("-");
136+ }
137+ return appId;
138+}
139+
140+void MirSurfaceItem::endCurrentTouchSequence(ulong timestamp)
141+{
142+ MirEvent mirEvent;
143+
144+ Q_ASSERT(m_lastTouchEvent);
145+ Q_ASSERT(m_lastTouchEvent->type != QEvent::TouchEnd);
146+ Q_ASSERT(m_lastTouchEvent->touchPoints.count() > 0);
147+
148+ TouchEvent touchEvent = *m_lastTouchEvent;
149+ touchEvent.timestamp = timestamp;
150+
151+ // Remove all already released touch points
152+ int i = 0;
153+ while (i < touchEvent.touchPoints.count()) {
154+ if (touchEvent.touchPoints[i].state() == Qt::TouchPointReleased) {
155+ touchEvent.touchPoints.removeAt(i);
156+ } else {
157+ ++i;
158+ }
159+ }
160+
161+ // And release the others one by one as Mir expects one press/release per event
162+ while (touchEvent.touchPoints.count() > 0) {
163+ touchEvent.touchPoints[0].setState(Qt::TouchPointReleased);
164+
165+ touchEvent.updateTouchPointStatesAndType();
166+
167+ if (fillInMirEvent(mirEvent, touchEvent.touchPoints,
168+ touchEvent.touchPointStates, touchEvent.timestamp)) {
169+ m_surface->consume(mirEvent);
170+ }
171+ *m_lastTouchEvent = touchEvent;
172+
173+ touchEvent.touchPoints.removeAt(0);
174+ }
175+}
176+
177+void MirSurfaceItem::validateAndDeliverTouchEvent(int eventType,
178+ ulong timestamp,
179+ const QList<QTouchEvent::TouchPoint> &touchPoints,
180+ Qt::TouchPointStates touchPointStates)
181+{
182+ MirEvent mirEvent;
183+
184+ if (eventType == QEvent::TouchBegin && m_lastTouchEvent && m_lastTouchEvent->type != QEvent::TouchEnd) {
185+ qCWarning(QTMIR_SURFACES) << qPrintable(QString("MirSurfaceItem(%1) - Got a QEvent::TouchBegin while "
186+ "there's still an active/unfinished touch sequence.").arg(appId()));
187+ // Qt forgot to end the last touch sequence. Let's do it ourselves.
188+ endCurrentTouchSequence(timestamp);
189+ }
190+
191+ if (fillInMirEvent(mirEvent, touchPoints, touchPointStates, timestamp)) {
192+ m_surface->consume(mirEvent);
193+ }
194+
195+ if (!m_lastTouchEvent) {
196+ m_lastTouchEvent = new TouchEvent;
197+ }
198+ m_lastTouchEvent->type = eventType;
199+ m_lastTouchEvent->timestamp = timestamp;
200+ m_lastTouchEvent->touchPoints = touchPoints;
201+ m_lastTouchEvent->touchPointStates = touchPointStates;
202+}
203+
204 void MirSurfaceItem::touchEvent(QTouchEvent *event)
205 {
206- MirEvent mirEvent;
207- if (type() == InputMethod && event->type() == QEvent::TouchBegin) {
208+ bool accepted = processTouchEvent(event->type(),
209+ event->timestamp(),
210+ event->touchPoints(),
211+ event->touchPointStates());
212+ event->setAccepted(accepted);
213+}
214+
215+bool MirSurfaceItem::processTouchEvent(
216+ int eventType,
217+ ulong timestamp,
218+ const QList<QTouchEvent::TouchPoint> &touchPoints,
219+ Qt::TouchPointStates touchPointStates)
220+{
221+ bool accepted = true;
222+ if (type() == InputMethod && eventType == QEvent::TouchBegin) {
223 // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place.
224- if (hasTouchInsideUbuntuKeyboard(event)) {
225- if (fillInMirEvent(mirEvent, event)) {
226- m_surface->consume(mirEvent);
227- }
228+ if (hasTouchInsideUbuntuKeyboard(touchPoints)) {
229+ validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates);
230 } else {
231- event->ignore();
232+ accepted = false;
233 }
234
235 } else {
236 // NB: If we are getting QEvent::TouchUpdate or QEvent::TouchEnd it's because we've
237 // previously accepted the corresponding QEvent::TouchBegin
238- if (fillInMirEvent(mirEvent, event)) {
239- m_surface->consume(mirEvent);
240- }
241+ validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates);
242 }
243+ return accepted;
244 }
245
246-bool MirSurfaceItem::hasTouchInsideUbuntuKeyboard(QTouchEvent *event)
247+bool MirSurfaceItem::hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints)
248 {
249- const QList<QTouchEvent::TouchPoint> &touchPoints = event->touchPoints();
250 for (int i = 0; i < touchPoints.count(); ++i) {
251 QPoint pos = touchPoints.at(i).pos().toPoint();
252 if (pos.x() >= m_ubuntuKeyboardInfo->x()
253@@ -639,15 +728,15 @@
254 m_frameDropperTimer.start();
255 }
256
257-void MirSurfaceItem::setSession(Session *session)
258+void MirSurfaceItem::setSession(SessionInterface *session)
259 {
260 m_session = session;
261 }
262
263-void MirSurfaceItem::onSessionStateChanged(Session::State state)
264+void MirSurfaceItem::onSessionStateChanged(SessionInterface::State state)
265 {
266 switch (state) {
267- case Session::State::Running:
268+ case SessionInterface::State::Running:
269 syncSurfaceSizeWithItemSize();
270 break;
271 default:
272@@ -676,6 +765,22 @@
273 || !m_session;
274 }
275
276+void MirSurfaceItem::TouchEvent::updateTouchPointStatesAndType()
277+{
278+ touchPointStates = 0;
279+ for (int i = 0; i < touchPoints.count(); ++i) {
280+ touchPointStates |= touchPoints.at(i).state();
281+ }
282+
283+ if (touchPointStates == Qt::TouchPointReleased) {
284+ type = QEvent::TouchEnd;
285+ } else if (touchPointStates == Qt::TouchPointPressed) {
286+ type = QEvent::TouchBegin;
287+ } else {
288+ type = QEvent::TouchUpdate;
289+ }
290+}
291+
292 } // namespace qtmir
293
294 #include "mirsurfaceitem.moc"
295
296=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
297--- src/modules/Unity/Application/mirsurfaceitem.h 2014-08-29 14:58:07 +0000
298+++ src/modules/Unity/Application/mirsurfaceitem.h 2014-09-11 21:25:08 +0000
299@@ -32,7 +32,7 @@
300 #include <mir/scene/surface_observer.h>
301 #include <mir_toolkit/common.h>
302
303-#include "session.h"
304+#include "session_interface.h"
305 #include "ubuntukeyboardinfo.h"
306
307 namespace qtmir {
308@@ -78,7 +78,7 @@
309
310 public:
311 explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
312- QPointer<Session> session,
313+ SessionInterface* session,
314 QQuickItem *parent = 0);
315 ~MirSurfaceItem();
316
317@@ -107,7 +107,7 @@
318 State state() const;
319 QString name() const;
320 bool live() const;
321- Session *session() const;
322+ SessionInterface *session() const;
323
324 Q_INVOKABLE void release();
325
326@@ -120,7 +120,13 @@
327
328 bool isFirstFrameDrawn() const { return m_firstFrameDrawn; }
329
330- void setSession(Session *app);
331+ void setSession(SessionInterface *app);
332+
333+ // to allow easy touch event injection from tests
334+ bool processTouchEvent(int eventType,
335+ ulong timestamp,
336+ const QList<QTouchEvent::TouchPoint> &touchPoints,
337+ Qt::TouchPointStates touchPointStates);
338
339 Q_SIGNALS:
340 void typeChanged();
341@@ -130,7 +136,7 @@
342 void firstFrameDrawn(MirSurfaceItem *item);
343
344 protected Q_SLOTS:
345- void onSessionStateChanged(Session::State state);
346+ void onSessionStateChanged(SessionInterface::State state);
347
348 protected:
349 void mousePressEvent(QMouseEvent *event) override;
350@@ -167,15 +173,22 @@
351 void setAttribute(const MirSurfaceAttrib, const int);
352 void setSurfaceValid(const bool);
353
354- bool hasTouchInsideUbuntuKeyboard(QTouchEvent *event);
355+ bool hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints);
356 void syncSurfaceSizeWithItemSize();
357
358 bool clientIsRunning() const;
359
360+ QString appId() const;
361+ void endCurrentTouchSequence(ulong timestamp);
362+ void validateAndDeliverTouchEvent(int eventType,
363+ ulong timestamp,
364+ const QList<QTouchEvent::TouchPoint> &touchPoints,
365+ Qt::TouchPointStates touchPointStates);
366+
367 QMutex m_mutex;
368
369 std::shared_ptr<mir::scene::Surface> m_surface;
370- QPointer<Session> m_session;
371+ QPointer<SessionInterface> m_session;
372 bool m_firstFrameDrawn;
373 bool m_live;
374
375@@ -189,6 +202,24 @@
376
377 QTimer m_updateMirSurfaceSizeTimer;
378
379+ class TouchEvent {
380+ public:
381+ TouchEvent &operator= (const QTouchEvent &qtEvent) {
382+ type = qtEvent.type();
383+ timestamp = qtEvent.timestamp();
384+ touchPoints = qtEvent.touchPoints();
385+ touchPointStates = qtEvent.touchPointStates();
386+ return *this;
387+ }
388+
389+ void updateTouchPointStatesAndType();
390+
391+ int type;
392+ ulong timestamp;
393+ QList<QTouchEvent::TouchPoint> touchPoints;
394+ Qt::TouchPointStates touchPointStates;
395+ } *m_lastTouchEvent;
396+
397 friend class MirSurfaceManager;
398 };
399
400
401=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
402--- src/modules/Unity/Application/mirsurfacemanager.cpp 2014-09-07 19:42:33 +0000
403+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2014-09-11 21:25:08 +0000
404@@ -99,21 +99,21 @@
405 m_mirSurfaceToItemHash.clear();
406 }
407
408-void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *session,
409+void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *mirSession,
410 const std::shared_ptr<mir::scene::Surface> &surface)
411 {
412- qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionCreatedSurface - session=" << session
413+ qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionCreatedSurface - mirSession=" << mirSession
414 << "surface=" << surface.get() << "surface.name=" << surface->name().c_str();
415
416- Session* sessionItem = m_sessionManager->findSession(session);
417- auto qmlSurface = new MirSurfaceItem(surface, sessionItem);
418+ SessionInterface* session = m_sessionManager->findSession(mirSession);
419+ auto qmlSurface = new MirSurfaceItem(surface, session);
420 {
421 QMutexLocker lock(&m_mutex);
422 m_mirSurfaceToItemHash.insert(surface.get(), qmlSurface);
423 }
424
425- if (sessionItem)
426- sessionItem->setSurface(qmlSurface);
427+ if (session)
428+ session->setSurface(qmlSurface);
429
430 // Only notify QML of surface creation once it has drawn its first frame.
431 connect(qmlSurface, &MirSurfaceItem::firstFrameDrawn, this, [&](MirSurfaceItem *item) {
432
433=== modified file 'src/modules/Unity/Application/plugin.cpp'
434--- src/modules/Unity/Application/plugin.cpp 2014-09-01 16:07:27 +0000
435+++ src/modules/Unity/Application/plugin.cpp 2014-09-11 21:25:08 +0000
436@@ -65,6 +65,7 @@
437 qRegisterMetaType<qtmir::MirSurfaceItem*>("MirSurfaceItem*");
438 qRegisterMetaType<qtmir::MirSurfaceItemModel*>("MirSurfaceItemModel*");
439 qRegisterMetaType<qtmir::Session*>("Session*");
440+ qRegisterMetaType<qtmir::SessionInterface*>("SessionInterface*");
441 qRegisterMetaType<qtmir::SessionModel*>("SessionModel*");
442
443 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(
444
445=== modified file 'src/modules/Unity/Application/session.cpp'
446--- src/modules/Unity/Application/session.cpp 2014-09-01 16:07:27 +0000
447+++ src/modules/Unity/Application/session.cpp 2014-09-11 21:25:08 +0000
448@@ -34,13 +34,15 @@
449
450 namespace ms = mir::scene;
451
452+using unity::shell::application::ApplicationInfoInterface;
453+
454 namespace qtmir
455 {
456
457 Session::Session(const std::shared_ptr<ms::Session>& session,
458 const std::shared_ptr<ms::PromptSessionManager>& promptSessionManager,
459 QObject *parent)
460- : QObject(parent)
461+ : SessionInterface(parent)
462 , m_session(session)
463 , m_application(nullptr)
464 , m_surface(nullptr)
465@@ -72,8 +74,8 @@
466 qCDebug(QTMIR_SESSIONS) << "Session::~Session() " << name();
467 stopPromptSessions();
468
469- QList<Session*> children(m_children->list());
470- for (Session* child : children) {
471+ QList<SessionInterface*> children(m_children->list());
472+ for (SessionInterface* child : children) {
473 delete child;
474 }
475 if (m_parentSession) {
476@@ -112,7 +114,7 @@
477 return m_session;
478 }
479
480-Application* Session::application() const
481+ApplicationInfoInterface* Session::application() const
482 {
483 return m_application;
484 }
485@@ -127,7 +129,7 @@
486 }
487 }
488
489-Session* Session::parentSession() const
490+SessionInterface* Session::parentSession() const
491 {
492 return m_parentSession;
493 }
494@@ -147,12 +149,12 @@
495 return m_live;
496 }
497
498-void Session::setApplication(Application* application)
499+void Session::setApplication(ApplicationInfoInterface* application)
500 {
501 if (m_application == application)
502 return;
503
504- m_application = application;
505+ m_application = static_cast<Application*>(application);
506 Q_EMIT applicationChanged(application);
507 }
508
509@@ -251,7 +253,7 @@
510 m_state = state;
511 Q_EMIT stateChanged(state);
512
513- foreachChildSession([state](Session* session) {
514+ foreachChildSession([state](SessionInterface* session) {
515 session->setState(state);
516 });
517 }
518@@ -275,35 +277,35 @@
519 Q_EMIT parentSessionChanged(session);
520 }
521
522-void Session::addChildSession(Session* session)
523+void Session::addChildSession(SessionInterface* session)
524 {
525 insertChildSession(m_children->rowCount(), session);
526 }
527
528-void Session::insertChildSession(uint index, Session* session)
529+void Session::insertChildSession(uint index, SessionInterface* session)
530 {
531 qCDebug(QTMIR_SESSIONS) << "Session::insertChildSession - " << session->name() << " to " << name() << " @ " << index;
532
533- session->setParentSession(this);
534+ static_cast<Session*>(session)->setParentSession(this);
535 m_children->insert(index, session);
536
537 session->setState(state());
538 }
539
540-void Session::removeChildSession(Session* session)
541+void Session::removeChildSession(SessionInterface* session)
542 {
543 qCDebug(QTMIR_SESSIONS) << "Session::removeChildSession - " << session->name() << " from " << name();
544
545 if (m_children->contains(session)) {
546 m_children->remove(session);
547- session->setParentSession(nullptr);
548+ static_cast<Session*>(session)->setParentSession(nullptr);
549 }
550 }
551
552-void Session::foreachChildSession(std::function<void(Session* session)> f) const
553+void Session::foreachChildSession(std::function<void(SessionInterface* session)> f) const
554 {
555- QList<Session*> children(m_children->list());
556- for (Session* child : children) {
557+ QList<SessionInterface*> children(m_children->list());
558+ for (SessionInterface* child : children) {
559 f(child);
560 }
561 }
562@@ -331,9 +333,9 @@
563
564 void Session::stopPromptSessions()
565 {
566- QList<Session*> children(m_children->list());
567- for (Session* child : children) {
568- child->stopPromptSessions();
569+ QList<SessionInterface*> children(m_children->list());
570+ for (SessionInterface* child : children) {
571+ static_cast<Session*>(child)->stopPromptSessions();
572 }
573
574 QList<std::shared_ptr<ms::PromptSession>> copy(m_promptSessions);
575
576=== modified file 'src/modules/Unity/Application/session.h'
577--- src/modules/Unity/Application/session.h 2014-09-01 16:07:27 +0000
578+++ src/modules/Unity/Application/session.h 2014-09-11 21:25:08 +0000
579@@ -21,19 +21,15 @@
580 #include <memory>
581
582 // local
583-#include "sessionmodel.h"
584+#include "session_interface.h"
585
586 // Qt
587 #include <QObject>
588 #include <QTimer>
589
590-// Unity API
591-#include <unity/shell/application/ApplicationInfoInterface.h>
592
593 namespace mir {
594 namespace scene {
595- class Session;
596- class PromptSession;
597 class PromptSessionManager;
598 }
599 }
600@@ -41,83 +37,61 @@
601 namespace qtmir {
602
603 class Application;
604-class MirSurfaceItem;
605
606-class Session : public QObject
607+class Session : public SessionInterface
608 {
609 Q_OBJECT
610- Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
611- Q_PROPERTY(Application* application READ application NOTIFY applicationChanged DESIGNABLE false)
612- Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
613- Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
614- Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
615- Q_PROPERTY(bool live READ live NOTIFY liveChanged)
616-
617 public:
618 explicit Session(const std::shared_ptr<mir::scene::Session>& session,
619 const std::shared_ptr<mir::scene::PromptSessionManager>& promptSessionManager,
620 QObject *parent = 0);
621- ~Session();
622-
623- // Session State
624- typedef unity::shell::application::ApplicationInfoInterface::State State;
625-
626- Q_INVOKABLE void release();
627+ virtual ~Session();
628+
629+ Q_INVOKABLE void release() override;
630
631 //getters
632- QString name() const;
633- Application* application() const;
634- MirSurfaceItem* surface() const;
635- Session* parentSession() const;
636- State state() const;
637- bool fullscreen() const;
638- bool live() const;
639-
640- void setSession();
641- void setApplication(Application* item);
642- void setSurface(MirSurfaceItem* surface);
643- void setState(State state);
644-
645- void addChildSession(Session* session);
646- void insertChildSession(uint index, Session* session);
647- void removeChildSession(Session* session);
648- void foreachChildSession(std::function<void(Session* session)> f) const;
649-
650- std::shared_ptr<mir::scene::Session> session() const;
651-
652- std::shared_ptr<mir::scene::PromptSession> activePromptSession() const;
653- void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> f) const;
654-
655-Q_SIGNALS:
656- void surfaceChanged(MirSurfaceItem*);
657- void parentSessionChanged(Session*);
658- void applicationChanged(Application* application);
659- void aboutToBeDestroyed();
660- void stateChanged(State state);
661- void fullscreenChanged(bool fullscreen);
662- void liveChanged(bool live);
663-
664- void suspended();
665- void resumed();
666+ QString name() const override;
667+ unity::shell::application::ApplicationInfoInterface* application() const override;
668+ MirSurfaceItem* surface() const override;
669+ SessionInterface* parentSession() const override;
670+ State state() const override;
671+ bool fullscreen() const override;
672+ bool live() const override;
673+
674+ void setApplication(unity::shell::application::ApplicationInfoInterface* item) override;
675+ void setSurface(MirSurfaceItem* surface) override;
676+ void setState(State state) override;
677+
678+ void addChildSession(SessionInterface* session) override;
679+ void insertChildSession(uint index, SessionInterface* session) override;
680+ void removeChildSession(SessionInterface* session) override;
681+ void foreachChildSession(std::function<void(SessionInterface* session)> f) const override;
682+
683+ std::shared_ptr<mir::scene::Session> session() const override;
684+
685+ std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override;
686+ void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> f) const override;
687+
688+ SessionModel* childSessions() const override;
689+
690+protected:
691+ void setFullscreen(bool fullscreen) override;
692+ void setLive(const bool) override;
693+ void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override;
694+ void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override;
695
696 private Q_SLOTS:
697 void updateFullscreenProperty();
698
699 private:
700- SessionModel* childSessions() const;
701 void setParentSession(Session* session);
702
703- void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session);
704- void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session);
705 void stopPromptSessions();
706
707- void setFullscreen(bool fullscreen);
708- void setLive(const bool);
709-
710 std::shared_ptr<mir::scene::Session> m_session;
711 Application* m_application;
712 MirSurfaceItem* m_surface;
713- Session* m_parentSession;
714+ SessionInterface* m_parentSession;
715 SessionModel* m_children;
716 bool m_fullscreen;
717 State m_state;
718@@ -125,8 +99,6 @@
719 QTimer* m_suspendTimer;
720 QList<std::shared_ptr<mir::scene::PromptSession>> m_promptSessions;
721 std::shared_ptr<mir::scene::PromptSessionManager> const m_promptSessionManager;
722-
723- friend class SessionManager;
724 };
725
726 } // namespace qtmir
727
728=== added file 'src/modules/Unity/Application/session_interface.h'
729--- src/modules/Unity/Application/session_interface.h 1970-01-01 00:00:00 +0000
730+++ src/modules/Unity/Application/session_interface.h 2014-09-11 21:25:08 +0000
731@@ -0,0 +1,106 @@
732+/*
733+ * Copyright (C) 2014 Canonical, Ltd.
734+ *
735+ * This program is free software; you can redistribute it and/or modify
736+ * it under the terms of the GNU General Public License as published by
737+ * the Free Software Foundation; version 3.
738+ *
739+ * This program is distributed in the hope that it will be useful,
740+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
741+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
742+ * GNU General Public License for more details.
743+ *
744+ * You should have received a copy of the GNU General Public License
745+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
746+ */
747+
748+#ifndef SESSION_INTERFACE_H
749+#define SESSION_INTERFACE_H
750+
751+#include <functional>
752+#include <memory>
753+
754+// Unity API
755+#include <unity/shell/application/ApplicationInfoInterface.h>
756+
757+// local
758+#include "sessionmodel.h"
759+
760+namespace mir {
761+ namespace scene {
762+ class Session;
763+ class PromptSession;
764+ }
765+}
766+
767+namespace qtmir {
768+
769+class MirSurfaceItem;
770+
771+class SessionInterface : public QObject {
772+ Q_OBJECT
773+ Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
774+ Q_PROPERTY(unity::shell::application::ApplicationInfoInterface* application READ application NOTIFY applicationChanged DESIGNABLE false)
775+ Q_PROPERTY(SessionInterface* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
776+ Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
777+ Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
778+ Q_PROPERTY(bool live READ live NOTIFY liveChanged)
779+public:
780+ SessionInterface(QObject *parent = 0) : QObject(parent) {}
781+ virtual ~SessionInterface() {}
782+
783+ // Session State
784+ typedef unity::shell::application::ApplicationInfoInterface::State State;
785+
786+ Q_INVOKABLE virtual void release() = 0;
787+
788+ //getters
789+ virtual QString name() const = 0;
790+ virtual unity::shell::application::ApplicationInfoInterface* application() const = 0;
791+ virtual MirSurfaceItem* surface() const = 0;
792+ virtual SessionInterface* parentSession() const = 0;
793+ virtual State state() const = 0;
794+ virtual bool fullscreen() const = 0;
795+ virtual bool live() const = 0;
796+
797+ virtual void setApplication(unity::shell::application::ApplicationInfoInterface* item) = 0;
798+ virtual void setSurface(MirSurfaceItem* surface) = 0;
799+ virtual void setState(State state) = 0;
800+
801+ virtual void addChildSession(SessionInterface* session) = 0;
802+ virtual void insertChildSession(uint index, SessionInterface* session) = 0;
803+ virtual void removeChildSession(SessionInterface* session) = 0;
804+ virtual void foreachChildSession(std::function<void(SessionInterface* session)> f) const = 0;
805+
806+ virtual std::shared_ptr<mir::scene::Session> session() const = 0;
807+
808+ virtual std::shared_ptr<mir::scene::PromptSession> activePromptSession() const = 0;
809+ virtual void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> f) const = 0;
810+
811+ virtual SessionModel* childSessions() const = 0;
812+
813+Q_SIGNALS:
814+ void surfaceChanged(MirSurfaceItem*);
815+ void parentSessionChanged(SessionInterface*);
816+ void applicationChanged(unity::shell::application::ApplicationInfoInterface* application);
817+ void aboutToBeDestroyed();
818+ void stateChanged(State state);
819+ void fullscreenChanged(bool fullscreen);
820+ void liveChanged(bool live);
821+
822+ void suspended();
823+ void resumed();
824+
825+protected:
826+ virtual void setFullscreen(bool fullscreen) = 0;
827+ virtual void setLive(const bool) = 0;
828+ virtual void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0;
829+ virtual void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0;
830+
831+ friend class SessionManager;
832+};
833+
834+} // namespace qtmir
835+
836+
837+#endif // SESSION_INTERFACE_H
838
839=== modified file 'src/modules/Unity/Application/sessionmanager.cpp'
840--- src/modules/Unity/Application/sessionmanager.cpp 2014-08-29 14:58:07 +0000
841+++ src/modules/Unity/Application/sessionmanager.cpp 2014-09-11 21:25:08 +0000
842@@ -103,11 +103,11 @@
843 qCDebug(QTMIR_SESSIONS) << "SessionManager::~SessionManager - this=" << this;
844 }
845
846-Session *SessionManager::findSession(const mir::scene::Session* session) const
847+SessionInterface *SessionManager::findSession(const mir::scene::Session* session) const
848 {
849 if (!session) return nullptr;
850
851- for (Session* child : list()) {
852+ for (SessionInterface* child : list()) {
853 if (child->session().get() == session)
854 return child;
855 }
856@@ -139,7 +139,7 @@
857 {
858 qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStopping - sessionName=" << session->name().c_str();
859
860- Session* qmlSession = findSession(session.get());
861+ SessionInterface* qmlSession = findSession(session.get());
862 if (!qmlSession) return;
863
864 remove(qmlSession);
865@@ -153,7 +153,7 @@
866 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStarting - promptSession=" << promptSession.get();
867
868 std::shared_ptr<mir::scene::Session> appSession = m_mirConfig->the_prompt_session_manager()->application_for(promptSession);
869- Session *qmlAppSession = findSession(appSession.get());
870+ SessionInterface *qmlAppSession = findSession(appSession.get());
871 if (qmlAppSession) {
872 m_mirPromptToSessionHash[promptSession.get()] = qmlAppSession;
873 qmlAppSession->appendPromptSession(promptSession);
874@@ -166,7 +166,7 @@
875 {
876 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStopping - promptSession=" << promptSession.get();
877
878- for (Session *qmlSession : this->list()) {
879+ for (SessionInterface *qmlSession : this->list()) {
880 qmlSession->removePromptSession(promptSession);
881 }
882 m_mirPromptToSessionHash.remove(promptSession.get());
883@@ -177,13 +177,13 @@
884 {
885 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - promptSession=" << promptSession << " promptProvider=" << promptProvider.get();
886
887- Session* qmlAppSession = m_mirPromptToSessionHash.value(promptSession, nullptr);
888+ SessionInterface* qmlAppSession = m_mirPromptToSessionHash.value(promptSession, nullptr);
889 if (!qmlAppSession) {
890 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - could not find session item for app session";
891 return;
892 }
893
894- Session* qmlPromptProvider = findSession(promptProvider.get());
895+ SessionInterface* qmlPromptProvider = findSession(promptProvider.get());
896 if (!qmlPromptProvider) {
897 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - could not find session item for provider session";
898 return;
899@@ -197,7 +197,7 @@
900 {
901 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderRemoved - promptSession=" << promptSession << " promptProvider=" << promptProvider.get();
902
903- Session* qmlPromptProvider = findSession(promptProvider.get());
904+ SessionInterface* qmlPromptProvider = findSession(promptProvider.get());
905 if (!qmlPromptProvider) {
906 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - could not find session item for provider session";
907 return;
908
909=== modified file 'src/modules/Unity/Application/sessionmanager.h'
910--- src/modules/Unity/Application/sessionmanager.h 2014-08-28 23:36:42 +0000
911+++ src/modules/Unity/Application/sessionmanager.h 2014-09-11 21:25:08 +0000
912@@ -59,11 +59,11 @@
913
914 static SessionManager* singleton();
915
916- Session *findSession(const mir::scene::Session* session) const;
917+ SessionInterface *findSession(const mir::scene::Session* session) const;
918
919 Q_SIGNALS:
920- void sessionStarting(Session* session);
921- void sessionStopping(Session* session);
922+ void sessionStarting(SessionInterface* session);
923+ void sessionStopping(SessionInterface* session);
924
925 public Q_SLOTS:
926 void onSessionStarting(std::shared_ptr<mir::scene::Session> const& session);
927@@ -82,7 +82,7 @@
928 static SessionManager *the_session_manager;
929
930 QList<Session*> m_sessions;
931- QHash<const mir::scene::PromptSession *, Session *> m_mirPromptToSessionHash;
932+ QHash<const mir::scene::PromptSession *, SessionInterface *> m_mirPromptToSessionHash;
933 };
934
935 } // namespace qtmir
936
937=== modified file 'src/modules/Unity/Application/sessionmodel.h'
938--- src/modules/Unity/Application/sessionmodel.h 2014-08-29 11:15:51 +0000
939+++ src/modules/Unity/Application/sessionmodel.h 2014-09-11 21:25:08 +0000
940@@ -22,8 +22,8 @@
941
942 namespace qtmir {
943
944-class Session;
945-typedef ObjectListModel<Session> SessionModel;
946+class SessionInterface;
947+typedef ObjectListModel<SessionInterface> SessionModel;
948
949 } // namespace qtmir
950
951
952=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
953--- tests/modules/ApplicationManager/application_manager_test.cpp 2014-08-29 10:18:57 +0000
954+++ tests/modules/ApplicationManager/application_manager_test.cpp 2014-09-11 21:25:08 +0000
955@@ -25,6 +25,7 @@
956 #include "qtmir_test.h"
957
958 using namespace qtmir;
959+using mir::scene::MockSession;
960
961 namespace ms = mir::scene;
962
963@@ -1774,7 +1775,7 @@
964 }).detach();
965 }));
966
967- auto mockSurface = std::make_shared<MockSurface>();
968+ auto mockSurface = std::make_shared<ms::MockSurface>();
969 EXPECT_CALL(*session, default_surface()).WillRepeatedly(Return(mockSurface));
970
971 {
972@@ -1826,7 +1827,7 @@
973 }).detach();
974 }));
975
976- auto mockSurface = std::make_shared<MockSurface>();
977+ auto mockSurface = std::make_shared<ms::MockSurface>();
978 EXPECT_CALL(*session, default_surface()).WillRepeatedly(Return(mockSurface));
979
980 {
981
982=== added directory 'tests/modules/MirSurfaceItem'
983=== added file 'tests/modules/MirSurfaceItem/MirSurfaceItem.pro'
984--- tests/modules/MirSurfaceItem/MirSurfaceItem.pro 1970-01-01 00:00:00 +0000
985+++ tests/modules/MirSurfaceItem/MirSurfaceItem.pro 2014-09-11 21:25:08 +0000
986@@ -0,0 +1,13 @@
987+include(../../test-includes.pri)
988+include(../common/common.pri)
989+
990+TARGET = mirsurfaceitem_test
991+
992+QT += testlib
993+
994+INCLUDEPATH += \
995+ ../../../src/platforms/mirserver \
996+ ../../../src/modules/Unity/Application
997+
998+SOURCES += \
999+ mirsurfaceitem_test.cpp
1000
1001=== added file 'tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp'
1002--- tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 1970-01-01 00:00:00 +0000
1003+++ tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 2014-09-11 21:25:08 +0000
1004@@ -0,0 +1,113 @@
1005+/*
1006+ * Copyright (C) 2014 Canonical, Ltd.
1007+ *
1008+ * This program is free software: you can redistribute it and/or modify it under
1009+ * the terms of the GNU Lesser General Public License version 3, as published by
1010+ * the Free Software Foundation.
1011+ *
1012+ * This program is distributed in the hope that it will be useful, but WITHOUT
1013+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1014+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1015+ * Lesser General Public License for more details.
1016+ *
1017+ * You should have received a copy of the GNU Lesser General Public License
1018+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1019+ *
1020+ */
1021+
1022+#include <gtest/gtest.h>
1023+
1024+#include <QLoggingCategory>
1025+#include <QTest>
1026+
1027+// the test subject
1028+#include <mirsurfaceitem.h>
1029+
1030+// mocks
1031+#include <mock_surface.h>
1032+#include <mock_session.h>
1033+
1034+using namespace qtmir;
1035+
1036+using mir::scene::MockSurface;
1037+using qtmir::MockSession;
1038+
1039+// gtest stuff
1040+using ::testing::_;
1041+using ::testing::AnyNumber;
1042+using ::testing::Invoke;
1043+using ::testing::InSequence;
1044+using ::testing::Return;
1045+
1046+/*
1047+ Tests that even if Qt fails to finish a touch sequence, MirSurfaceItem will
1048+ properly finish it when forwarding it to its mir::input::surface. So
1049+ mir::input::surface will still consume a proper sequence of touch events
1050+ (comprised of a begin, zero or more updates and an end).
1051+ */
1052+TEST(MirSurfaceItemTest, MissingTouchEnd)
1053+{
1054+ // We don't want the logging spam cluttering the test results
1055+ QLoggingCategory::setFilterRules(QStringLiteral("qtmir*=false"));
1056+
1057+ std::shared_ptr<MockSurface> mockSurface = std::make_shared<MockSurface>();
1058+ MockSession *mockSession = new MockSession;
1059+
1060+ // Set some expectations and behavior for calls we are not interested in
1061+ EXPECT_CALL(*mockSurface, add_observer(_)).Times(AnyNumber());
1062+ EXPECT_CALL(*mockSurface, remove_observer(_)).Times(AnyNumber());
1063+ EXPECT_CALL(*mockSurface, size()).Times(AnyNumber()).WillRepeatedly(Return(mir::geometry::Size(100,100)));
1064+ EXPECT_CALL(*mockSurface, type()).Times(AnyNumber()).WillRepeatedly(Return(mir_surface_type_normal));
1065+ EXPECT_CALL(*mockSession, setSurface(_)).Times(AnyNumber());
1066+
1067+ // The touch event sequence we expect mir::input::surface to receive from MirSurfaceItem.
1068+ // It should properly finish the sequence for touch 0 ('down', 'move' and 'up') before starting
1069+ // the sequence for touch 1.
1070+ EXPECT_CALL(*mockSurface, consume(_))
1071+ .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1072+ ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action);
1073+ ASSERT_EQ(1, mirEvent.motion.pointer_count);
1074+ ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);
1075+ }))
1076+ .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1077+ ASSERT_EQ(mir_motion_action_move, mirEvent.motion.action);
1078+ ASSERT_EQ(1, mirEvent.motion.pointer_count);
1079+ ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);
1080+ }))
1081+ .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1082+ ASSERT_EQ(mir_motion_action_up, mirEvent.motion.action);
1083+ ASSERT_EQ(1, mirEvent.motion.pointer_count);
1084+ ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);
1085+ }))
1086+ .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1087+ ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action);
1088+ ASSERT_EQ(1, mirEvent.motion.pointer_count);
1089+ ASSERT_EQ(1, mirEvent.motion.pointer_coordinates[0].id);
1090+ }));
1091+
1092+
1093+ MirSurfaceItem *surfaceItem = new MirSurfaceItem(mockSurface, mockSession);
1094+
1095+ ulong timestamp = 1234;
1096+ QList<QTouchEvent::TouchPoint> touchPoints;
1097+ touchPoints.append(QTouchEvent::TouchPoint());
1098+
1099+ touchPoints[0].setId(0);
1100+ touchPoints[0].setState(Qt::TouchPointPressed);
1101+ surfaceItem->processTouchEvent(QEvent::TouchBegin,
1102+ timestamp, touchPoints, touchPoints[0].state());
1103+
1104+ touchPoints[0].setState(Qt::TouchPointMoved);
1105+ surfaceItem->processTouchEvent(QEvent::TouchUpdate,
1106+ timestamp + 10, touchPoints, touchPoints[0].state());
1107+
1108+ // Starting a new touch sequence (with touch 1) without ending the current one
1109+ // (wich has touch 0).
1110+ touchPoints[0].setId(1);
1111+ touchPoints[0].setState(Qt::TouchPointPressed);
1112+ surfaceItem->processTouchEvent(QEvent::TouchBegin,
1113+ timestamp + 20, touchPoints, touchPoints[0].state());
1114+
1115+ delete surfaceItem;
1116+ delete mockSession;
1117+}
1118
1119=== modified file 'tests/modules/SessionManager/session_manager_test.cpp'
1120--- tests/modules/SessionManager/session_manager_test.cpp 2014-08-29 14:58:07 +0000
1121+++ tests/modules/SessionManager/session_manager_test.cpp 2014-09-11 21:25:08 +0000
1122@@ -24,6 +24,7 @@
1123 #include "qtmir_test.h"
1124
1125 using namespace qtmir;
1126+using mir::scene::MockSession;
1127
1128 namespace ms = mir::scene;
1129
1130@@ -33,7 +34,7 @@
1131 SessionManagerTests()
1132 {}
1133
1134- QList<std::shared_ptr<ms::PromptSession>> listPromptSessions(Session* session) {
1135+ QList<std::shared_ptr<ms::PromptSession>> listPromptSessions(SessionInterface* session) {
1136 QList<std::shared_ptr<ms::PromptSession>> promptSessions;
1137 session->foreachPromptSession([&promptSessions](const std::shared_ptr<ms::PromptSession>& promptSession) {
1138 promptSessions << promptSession;
1139@@ -41,9 +42,9 @@
1140 return promptSessions;
1141 }
1142
1143- QList<Session*> listChildSessions(Session* session) {
1144- QList<Session*> sessions;
1145- session->foreachChildSession([&sessions](Session* session) {
1146+ QList<SessionInterface*> listChildSessions(SessionInterface* session) {
1147+ QList<SessionInterface*> sessions;
1148+ session->foreachChildSession([&sessions](SessionInterface* session) {
1149 sessions << session;
1150 });
1151 return sessions;
1152@@ -56,10 +57,10 @@
1153
1154 std::shared_ptr<ms::Session> mirAppSession = std::make_shared<MockSession>("mirAppSession", __LINE__);
1155 sessionManager.onSessionStarting(mirAppSession);
1156- Session* qtmirAppSession = sessionManager.findSession(mirAppSession.get());
1157+ SessionInterface* qtmirAppSession = sessionManager.findSession(mirAppSession.get());
1158 EXPECT_TRUE(qtmirAppSession != nullptr);
1159
1160- auto promptSession = std::make_shared<MockPromptSession>();
1161+ auto promptSession = std::make_shared<ms::MockPromptSession>();
1162 ON_CALL(*mirConfig->the_mock_prompt_session_manager(), application_for(_)).WillByDefault(Return(mirAppSession));
1163
1164 sessionManager.onPromptSessionStarting(promptSession);
1165@@ -80,18 +81,18 @@
1166
1167 std::shared_ptr<ms::Session> mirAppSession = std::make_shared<MockSession>("mirAppSession", __LINE__);
1168 sessionManager.onSessionStarting(mirAppSession);
1169- Session* qtmirAppSession = sessionManager.findSession(mirAppSession.get());
1170+ SessionInterface* qtmirAppSession = sessionManager.findSession(mirAppSession.get());
1171 EXPECT_TRUE(qtmirAppSession != nullptr);
1172
1173 EXPECT_CALL(*mirConfig->the_mock_prompt_session_manager(), application_for(_)).WillRepeatedly(Return(mirAppSession));
1174 EXPECT_CALL(*mirConfig->the_mock_prompt_session_manager(), helper_for(_)).WillRepeatedly(Return(nullptr));
1175
1176- std::shared_ptr<ms::PromptSession> mirPromptSession = std::make_shared<MockPromptSession>();
1177+ std::shared_ptr<ms::PromptSession> mirPromptSession = std::make_shared<ms::MockPromptSession>();
1178
1179 // prompt provider session
1180 std::shared_ptr<ms::Session> mirProviderSession = std::make_shared<MockSession>("mirProviderSession", __LINE__);
1181 sessionManager.onSessionStarting(mirProviderSession);
1182- Session* qtmirProviderSession = sessionManager.findSession(mirProviderSession.get());
1183+ SessionInterface* qtmirProviderSession = sessionManager.findSession(mirProviderSession.get());
1184
1185 EXPECT_CALL(*mirConfig->the_mock_prompt_session_manager(), for_each_provider_in(mirPromptSession,_)).WillRepeatedly(WithArgs<1>(Invoke(
1186 [&](std::function<void(std::shared_ptr<ms::Session> const& prompt_provider)> const& f) {
1187
1188=== modified file 'tests/modules/SessionManager/session_test.cpp'
1189--- tests/modules/SessionManager/session_test.cpp 2014-08-28 23:36:42 +0000
1190+++ tests/modules/SessionManager/session_test.cpp 2014-09-11 21:25:08 +0000
1191@@ -22,6 +22,8 @@
1192 #include "stub_scene_surface.h"
1193
1194 using namespace qtmir;
1195+using mir::scene::MockSession;
1196+
1197
1198 namespace ms = mir::scene;
1199 namespace mtd = mir::test::doubles;
1200@@ -32,9 +34,9 @@
1201 SessionTests()
1202 {}
1203
1204- QList<Session*> listChildSessions(Session* session) {
1205- QList<Session*> sessions;
1206- session->foreachChildSession([&sessions](Session* session) {
1207+ QList<SessionInterface*> listChildSessions(Session* session) {
1208+ QList<SessionInterface*> sessions;
1209+ session->foreachChildSession([&sessions](SessionInterface* session) {
1210 sessions << session;
1211 });
1212 return sessions;
1213@@ -151,17 +153,14 @@
1214
1215 // delete surfaces
1216 delete session2;
1217- EXPECT_EQ(session2->parentSession(), nullptr);
1218 EXPECT_THAT(listChildSessions(&session), ElementsAre(session1, session3));
1219
1220 // delete surfaces
1221 delete session3;
1222- EXPECT_EQ(session3->parentSession(), nullptr);
1223 EXPECT_THAT(listChildSessions(&session), ElementsAre(session1));
1224
1225 // delete surfaces
1226 delete session1;
1227- EXPECT_EQ(session1->parentSession(), nullptr);
1228 EXPECT_THAT(listChildSessions(&session), IsEmpty());
1229 }
1230
1231
1232=== modified file 'tests/modules/common/common.pri'
1233--- tests/modules/common/common.pri 2014-09-07 19:42:14 +0000
1234+++ tests/modules/common/common.pri 2014-09-11 21:25:08 +0000
1235@@ -6,6 +6,7 @@
1236 HEADERS += ../common/mock_application_controller.h \
1237 ../common/mock_desktop_file_reader.h \
1238 ../common/mock_focus_controller.h \
1239+ ../common/mock_mir_session.h \
1240 ../common/mock_oom_controller.h \
1241 ../common/mock_process_controller.h \
1242 ../common/mock_proc_info.h \
1243
1244=== modified file 'tests/modules/common/mock_focus_controller.h'
1245--- tests/modules/common/mock_focus_controller.h 2014-07-01 13:38:06 +0000
1246+++ tests/modules/common/mock_focus_controller.h 2014-09-11 21:25:08 +0000
1247@@ -23,15 +23,18 @@
1248
1249 #include <string>
1250
1251-namespace testing
1252-{
1253-class MockFocusController : public mir::shell::FocusController
1254+namespace mir {
1255+namespace shell {
1256+
1257+class MockFocusController : public FocusController
1258 {
1259 public:
1260 MOCK_METHOD0(focus_next, void());
1261- MOCK_CONST_METHOD0(focussed_application, std::weak_ptr<mir::scene::Session>());
1262- MOCK_METHOD1(set_focus_to, void(std::shared_ptr<mir::scene::Session>const&));
1263+ MOCK_CONST_METHOD0(focussed_application, std::weak_ptr<scene::Session>());
1264+ MOCK_METHOD1(set_focus_to, void(std::shared_ptr<scene::Session>const&));
1265 };
1266-}
1267+
1268+} // namespace shell
1269+} // namespace mir
1270
1271 #endif // MOCK_MIR_SHELL_FOCUS_CONTROLLER_H_
1272
1273=== renamed file 'tests/modules/common/mock_session.h' => 'tests/modules/common/mock_mir_session.h'
1274--- tests/modules/common/mock_session.h 2014-07-01 13:38:06 +0000
1275+++ tests/modules/common/mock_mir_session.h 2014-09-11 21:25:08 +0000
1276@@ -25,9 +25,10 @@
1277
1278 #include <string>
1279
1280-namespace testing
1281-{
1282-struct MockSession : public mir::scene::Session
1283+namespace mir {
1284+namespace scene {
1285+
1286+struct MockSession : public Session
1287 {
1288 MockSession() {}
1289 MockSession(std::string const& sessionName, pid_t processId)
1290@@ -44,22 +45,20 @@
1291 return m_sessionId;
1292 }
1293
1294- typedef mir::frontend::SurfaceId SurfaceId;
1295-
1296 MOCK_METHOD0(force_requests_to_complete, void());
1297
1298- MOCK_CONST_METHOD0(default_surface, std::shared_ptr<mir::scene::Surface>());
1299- MOCK_CONST_METHOD1(get_surface, std::shared_ptr<mir::frontend::Surface>(SurfaceId));
1300+ MOCK_CONST_METHOD0(default_surface, std::shared_ptr<Surface>());
1301+ MOCK_CONST_METHOD1(get_surface, std::shared_ptr<frontend::Surface>(frontend::SurfaceId));
1302
1303- MOCK_METHOD1(take_snapshot, void(mir::scene::SnapshotCallback const&));
1304+ MOCK_METHOD1(take_snapshot, void(SnapshotCallback const&));
1305 MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState));
1306- MOCK_METHOD1(create_surface, SurfaceId(mir::scene::SurfaceCreationParameters const&));
1307- MOCK_METHOD1(destroy_surface, void (SurfaceId));
1308+ MOCK_METHOD1(create_surface, frontend::SurfaceId(SurfaceCreationParameters const&));
1309+ MOCK_METHOD1(destroy_surface, void (frontend::SurfaceId));
1310
1311 MOCK_METHOD0(hide, void());
1312 MOCK_METHOD0(show, void());
1313- MOCK_METHOD1(send_display_config, void(mir::graphics::DisplayConfiguration const&));
1314- MOCK_METHOD3(configure_surface, int(SurfaceId, MirSurfaceAttrib, int));
1315+ MOCK_METHOD1(send_display_config, void(graphics::DisplayConfiguration const&));
1316+ MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
1317
1318 void start_prompt_session() override {};
1319 void stop_prompt_session() override {};
1320@@ -68,6 +67,8 @@
1321 std::string m_sessionName;
1322 pid_t m_sessionId;
1323 };
1324-}
1325+
1326+} // namespace scene
1327+} // namespace mir
1328
1329 #endif // MOCK_MIR_SCENE_SESSION_H
1330
1331=== modified file 'tests/modules/common/mock_prompt_session.h'
1332--- tests/modules/common/mock_prompt_session.h 2014-07-21 15:51:17 +0000
1333+++ tests/modules/common/mock_prompt_session.h 2014-09-11 21:25:08 +0000
1334@@ -21,11 +21,14 @@
1335 #include <mir/scene/prompt_session.h>
1336 #include <gmock/gmock.h>
1337
1338-namespace testing
1339-{
1340-struct MockPromptSession : public mir::scene::PromptSession
1341+namespace mir {
1342+namespace scene {
1343+
1344+struct MockPromptSession : public PromptSession
1345 {
1346 };
1347-}
1348+
1349+} // namespace scene
1350+} // namespace mir
1351
1352 #endif // MOCK_MIR_PROMPT_SESSION_H
1353
1354=== modified file 'tests/modules/common/mock_prompt_session_manager.h'
1355--- tests/modules/common/mock_prompt_session_manager.h 2014-07-21 15:51:17 +0000
1356+++ tests/modules/common/mock_prompt_session_manager.h 2014-09-11 21:25:08 +0000
1357@@ -23,33 +23,36 @@
1358
1359 #include <gmock/gmock.h>
1360
1361-namespace testing
1362-{
1363-class MockPromptSessionManager: public mir::scene::PromptSessionManager
1364+namespace mir {
1365+namespace scene {
1366+
1367+class MockPromptSessionManager: public PromptSessionManager
1368 {
1369 public:
1370- MOCK_CONST_METHOD2(start_prompt_session_for, std::shared_ptr<mir::scene::PromptSession>(std::shared_ptr<mir::scene::Session> const&,
1371+ MOCK_CONST_METHOD2(start_prompt_session_for, std::shared_ptr<PromptSession>(std::shared_ptr<mir::scene::Session> const&,
1372 mir::scene::PromptSessionCreationParameters const&));
1373
1374- MOCK_CONST_METHOD1(stop_prompt_session, void(std::shared_ptr<mir::scene::PromptSession> const&));
1375+ MOCK_CONST_METHOD1(stop_prompt_session, void(std::shared_ptr<PromptSession> const&));
1376
1377- MOCK_CONST_METHOD2(add_prompt_provider, void(std::shared_ptr<mir::scene::PromptSession> const&,
1378+ MOCK_CONST_METHOD2(add_prompt_provider, void(std::shared_ptr<PromptSession> const&,
1379 std::shared_ptr<mir::scene::Session> const&));
1380
1381- MOCK_CONST_METHOD2(add_prompt_provider_by_pid, void(std::shared_ptr<mir::scene::PromptSession> const&,
1382+ MOCK_CONST_METHOD2(add_prompt_provider_by_pid, void(std::shared_ptr<PromptSession> const&,
1383 pid_t));
1384
1385- MOCK_CONST_METHOD1(add_expected_session, void(std::shared_ptr<mir::scene::Session> const&));
1386-
1387- MOCK_CONST_METHOD1(remove_session, void(std::shared_ptr<mir::scene::Session> const&));
1388-
1389- MOCK_CONST_METHOD1(application_for, std::shared_ptr<mir::scene::Session>(std::shared_ptr<mir::scene::PromptSession> const&));
1390-
1391- MOCK_CONST_METHOD1(helper_for, std::shared_ptr<mir::scene::Session>(std::shared_ptr<mir::scene::PromptSession> const&));
1392-
1393- MOCK_CONST_METHOD2(for_each_provider_in, void(std::shared_ptr<mir::scene::PromptSession> const&,
1394- std::function<void(std::shared_ptr<mir::scene::Session> const&)> const&));
1395+ MOCK_CONST_METHOD1(add_expected_session, void(std::shared_ptr<Session> const&));
1396+
1397+ MOCK_CONST_METHOD1(remove_session, void(std::shared_ptr<Session> const&));
1398+
1399+ MOCK_CONST_METHOD1(application_for, std::shared_ptr<Session>(std::shared_ptr<PromptSession> const&));
1400+
1401+ MOCK_CONST_METHOD1(helper_for, std::shared_ptr<Session>(std::shared_ptr<PromptSession> const&));
1402+
1403+ MOCK_CONST_METHOD2(for_each_provider_in, void(std::shared_ptr<PromptSession> const&,
1404+ std::function<void(std::shared_ptr<Session> const&)> const&));
1405 };
1406-} // namespace testing
1407+
1408+} // namespace scene
1409+} // namespace mir
1410
1411 #endif // MOCK_MIR_SCENE_PROMPT_SESSION_MANAGER_H_
1412
1413=== modified file 'tests/modules/common/mock_renderable.h'
1414--- tests/modules/common/mock_renderable.h 2014-08-14 15:38:15 +0000
1415+++ tests/modules/common/mock_renderable.h 2014-09-11 21:25:08 +0000
1416@@ -21,23 +21,26 @@
1417 #include <mir/graphics/renderable.h>
1418 #include <gmock/gmock.h>
1419
1420-namespace testing
1421-{
1422-struct MockRenderable : public mir::graphics::Renderable
1423+namespace mir {
1424+namespace graphics {
1425+
1426+struct MockRenderable : public Renderable
1427 {
1428 MockRenderable() {};
1429
1430 MOCK_CONST_METHOD0(id, ID());
1431- MOCK_CONST_METHOD0(buffer, std::shared_ptr<mir::graphics::Buffer>());
1432+ MOCK_CONST_METHOD0(buffer, std::shared_ptr<Buffer>());
1433 MOCK_CONST_METHOD0(alpha_enabled, bool());
1434- MOCK_CONST_METHOD0(screen_position, mir::geometry::Rectangle());
1435+ MOCK_CONST_METHOD0(screen_position, geometry::Rectangle());
1436 MOCK_CONST_METHOD0(alpha, float() );
1437 MOCK_CONST_METHOD0(transformation, glm::mat4());
1438 MOCK_CONST_METHOD0(visible, bool());
1439 MOCK_CONST_METHOD0(shaped, bool());
1440 MOCK_CONST_METHOD0(buffers_ready_for_compositor, int());
1441 };
1442-}
1443+
1444+} // namespace graphics
1445+} // namespace mir
1446
1447 #endif // MOCK_MIR_GRAPHICS_RENDERABLE_H
1448
1449
1450=== added file 'tests/modules/common/mock_session.h'
1451--- tests/modules/common/mock_session.h 1970-01-01 00:00:00 +0000
1452+++ tests/modules/common/mock_session.h 2014-09-11 21:25:08 +0000
1453@@ -0,0 +1,65 @@
1454+/*
1455+ * Copyright (C) 2014 Canonical, Ltd.
1456+ *
1457+ * This program is free software: you can redistribute it and/or modify it under
1458+ * the terms of the GNU Lesser General Public License version 3, as published by
1459+ * the Free Software Foundation.
1460+ *
1461+ * This program is distributed in the hope that it will be useful, but WITHOUT
1462+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1463+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1464+ * Lesser General Public License for more details.
1465+ *
1466+ * You should have received a copy of the GNU Lesser General Public License
1467+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1468+ *
1469+ */
1470+
1471+#ifndef MOCK_QTMIR_SESSION_H
1472+#define MOCK_QTMIR_SESSION_H
1473+
1474+#include <session_interface.h>
1475+#include <gmock/gmock.h>
1476+
1477+namespace qtmir {
1478+
1479+class MockSession : public SessionInterface {
1480+public:
1481+ MockSession() : SessionInterface(0) {}
1482+
1483+ MOCK_METHOD0(release, void());
1484+
1485+ MOCK_CONST_METHOD0(name, QString());
1486+ MOCK_CONST_METHOD0(application, unity::shell::application::ApplicationInfoInterface*());
1487+ MOCK_CONST_METHOD0(surface, MirSurfaceItem*());
1488+ MOCK_CONST_METHOD0(parentSession, SessionInterface*());
1489+ MOCK_CONST_METHOD0(state, State());
1490+ MOCK_CONST_METHOD0(fullscreen, bool());
1491+ MOCK_CONST_METHOD0(live, bool());
1492+
1493+ MOCK_METHOD1(setApplication, void(unity::shell::application::ApplicationInfoInterface* item));
1494+ MOCK_METHOD1(setSurface, void(MirSurfaceItem* surface));
1495+ MOCK_METHOD1(setState, void(State state));
1496+
1497+ MOCK_METHOD1(addChildSession, void(SessionInterface* session));
1498+ MOCK_METHOD2(insertChildSession, void(uint index, SessionInterface* session));
1499+ MOCK_METHOD1(removeChildSession, void(SessionInterface* session));
1500+ MOCK_CONST_METHOD1(foreachChildSession, void(std::function<void(SessionInterface* session)> f));
1501+
1502+ MOCK_CONST_METHOD0(session, std::shared_ptr<mir::scene::Session>());
1503+
1504+ MOCK_CONST_METHOD0(activePromptSession, std::shared_ptr<mir::scene::PromptSession>());
1505+ MOCK_CONST_METHOD1(foreachPromptSession, void(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> f));
1506+
1507+ MOCK_CONST_METHOD0(childSessions, SessionModel*());
1508+
1509+protected:
1510+ MOCK_METHOD1(setFullscreen, void(bool fullscreen));
1511+ MOCK_METHOD1(setLive, void(const bool));
1512+ MOCK_METHOD1(appendPromptSession, void(const std::shared_ptr<mir::scene::PromptSession>& session));
1513+ MOCK_METHOD1(removePromptSession, void(const std::shared_ptr<mir::scene::PromptSession>& session));
1514+};
1515+
1516+} // namespace qtmir
1517+
1518+#endif // MOCK_QTMIR_SESSION_H
1519
1520=== modified file 'tests/modules/common/mock_surface.h'
1521--- tests/modules/common/mock_surface.h 2014-08-18 19:40:31 +0000
1522+++ tests/modules/common/mock_surface.h 2014-09-11 21:25:08 +0000
1523@@ -24,22 +24,22 @@
1524 #include <string>
1525 #include "mock_renderable.h"
1526
1527-namespace testing
1528-{
1529+namespace mir {
1530+namespace scene {
1531
1532 struct MockSurface : public mir::scene::Surface
1533 {
1534 MockSurface() {}
1535
1536 MOCK_CONST_METHOD0(name, std::string());
1537- MOCK_CONST_METHOD0(client_size, mir::geometry::Size());
1538- MOCK_CONST_METHOD0(input_bounds, mir::geometry::Rectangle());
1539- MOCK_CONST_METHOD0(top_left, mir::geometry::Point());
1540- MOCK_CONST_METHOD0(size, mir::geometry::Size());
1541+ MOCK_CONST_METHOD0(client_size, geometry::Size());
1542+ MOCK_CONST_METHOD0(input_bounds, geometry::Rectangle());
1543+ MOCK_CONST_METHOD0(top_left, geometry::Point());
1544+ MOCK_CONST_METHOD0(size, geometry::Size());
1545
1546- std::unique_ptr<mir::graphics::Renderable> compositor_snapshot(void const* /*compositor_id*/) const
1547+ std::unique_ptr<graphics::Renderable> compositor_snapshot(void const* /*compositor_id*/) const
1548 {
1549- return std::unique_ptr<mir::graphics::Renderable>(new MockRenderable);
1550+ return std::unique_ptr<graphics::Renderable>(new graphics::MockRenderable);
1551 }
1552
1553 MOCK_CONST_METHOD0(alpha, float());
1554@@ -47,39 +47,40 @@
1555 MOCK_CONST_METHOD0(state, MirSurfaceState());
1556 MOCK_METHOD0(hide, void());
1557 MOCK_METHOD0(show, void());
1558- MOCK_METHOD1(move_to, void(mir::geometry::Point const& top_left));
1559- MOCK_METHOD1(take_input_focus, void(std::shared_ptr<mir::shell::InputTargeter> const& targeter));
1560- MOCK_METHOD1(set_input_region, void(std::vector<mir::geometry::Rectangle> const& region));
1561+ MOCK_METHOD1(move_to, void(geometry::Point const& top_left));
1562+ MOCK_METHOD1(take_input_focus, void(std::shared_ptr<shell::InputTargeter> const& targeter));
1563+ MOCK_METHOD1(set_input_region, void(std::vector<geometry::Rectangle> const& region));
1564 MOCK_METHOD1(allow_framedropping, void(bool));
1565- MOCK_METHOD1(resize, void(mir::geometry::Size const& size));
1566+ MOCK_METHOD1(resize, void(geometry::Size const& size));
1567 MOCK_METHOD1(set_transformation, void(glm::mat4 const& t));
1568 MOCK_METHOD1(set_alpha, void(float alpha));
1569 MOCK_METHOD1(set_orientation, void(MirOrientation orientation));
1570 MOCK_METHOD0(force_requests_to_complete, void());
1571- MOCK_METHOD1(set_cursor_image, void(std::shared_ptr<mir::graphics::CursorImage> const& image));
1572- MOCK_CONST_METHOD0(cursor_image, std::shared_ptr<mir::graphics::CursorImage>());
1573- MOCK_METHOD1(add_observer, void(std::shared_ptr<mir::scene::SurfaceObserver> const& observer));
1574- MOCK_METHOD1(remove_observer, void(std::weak_ptr<mir::scene::SurfaceObserver> const& observer));
1575- MOCK_CONST_METHOD0(input_channel, std::shared_ptr<mir::input::InputChannel>());
1576- MOCK_METHOD1(set_reception_mode, void(mir::input::InputReceptionMode mode));
1577+ MOCK_METHOD1(set_cursor_image, void(std::shared_ptr<graphics::CursorImage> const& image));
1578+ MOCK_CONST_METHOD0(cursor_image, std::shared_ptr<graphics::CursorImage>());
1579+ MOCK_METHOD1(add_observer, void(std::shared_ptr<SurfaceObserver> const& observer));
1580+ MOCK_METHOD1(remove_observer, void(std::weak_ptr<SurfaceObserver> const& observer));
1581+ MOCK_CONST_METHOD0(input_channel, std::shared_ptr<input::InputChannel>());
1582+ MOCK_METHOD1(set_reception_mode, void(input::InputReceptionMode mode));
1583
1584 // from mir::input::surface
1585- MOCK_CONST_METHOD1(input_area_contains, bool(mir::geometry::Point const& point));
1586- MOCK_CONST_METHOD0(reception_mode, mir::input::InputReceptionMode());
1587+ MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point));
1588+ MOCK_CONST_METHOD0(reception_mode, input::InputReceptionMode());
1589 MOCK_METHOD1(consume, void(MirEvent const& event));
1590
1591 // from mir::frontend::surface
1592 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
1593- MOCK_METHOD2(swap_buffers, void(mir::graphics::Buffer* old_buffer, std::function<void(mir::graphics::Buffer* new_buffer)> complete));
1594+ MOCK_METHOD2(swap_buffers, void(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete));
1595 MOCK_CONST_METHOD0(supports_input, bool());
1596 MOCK_CONST_METHOD0(client_input_fd, int());
1597 MOCK_METHOD2(configure, int(MirSurfaceAttrib attrib, int value));
1598 MOCK_METHOD1(query, int(MirSurfaceAttrib attrib));
1599
1600 // from mir::scene::SurfaceBufferAccess
1601- MOCK_METHOD1(with_most_recent_buffer_do, void(std::function<void(mir::graphics::Buffer&)> const& exec));
1602+ MOCK_METHOD1(with_most_recent_buffer_do, void(std::function<void(graphics::Buffer&)> const& exec));
1603 };
1604
1605-}
1606+} // namespace scene
1607+} // namespace mir
1608
1609 #endif // MOCK_MIR_SCENE_SURFACE_H
1610
1611=== modified file 'tests/modules/common/qtmir_test.h'
1612--- tests/modules/common/qtmir_test.h 2014-08-28 23:36:42 +0000
1613+++ tests/modules/common/qtmir_test.h 2014-09-11 21:25:08 +0000
1614@@ -35,7 +35,7 @@
1615 #include "mock_oom_controller.h"
1616 #include "mock_process_controller.h"
1617 #include "mock_proc_info.h"
1618-#include "mock_session.h"
1619+#include "mock_mir_session.h"
1620 #include "mock_focus_controller.h"
1621 #include "mock_prompt_session_manager.h"
1622 #include "mock_prompt_session.h"
1623@@ -43,14 +43,13 @@
1624 namespace ms = mir::scene;
1625 using namespace qtmir;
1626
1627-namespace testing
1628-{
1629+namespace qtmir {
1630
1631-class QtMirTestConfiguration: public MirServerConfiguration
1632+class FakeMirServerConfiguration: public MirServerConfiguration
1633 {
1634- typedef NiceMock<testing::MockPromptSessionManager> StubPromptSessionManager;
1635+ typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;
1636 public:
1637- QtMirTestConfiguration()
1638+ FakeMirServerConfiguration()
1639 : MirServerConfiguration(0, nullptr)
1640 , mock_prompt_session_manager(std::make_shared<StubPromptSessionManager>())
1641 {
1642@@ -73,6 +72,10 @@
1643 std::shared_ptr<StubPromptSessionManager> mock_prompt_session_manager;
1644 };
1645
1646+} // namespace qtmir
1647+
1648+namespace testing {
1649+
1650 class QtMirTest : public ::testing::Test
1651 {
1652 public:
1653@@ -83,7 +86,7 @@
1654 [](ProcessController::OomController*){})
1655 }
1656 , mirConfig{
1657- QSharedPointer<QtMirTestConfiguration> (new QtMirTestConfiguration)
1658+ QSharedPointer<FakeMirServerConfiguration> (new FakeMirServerConfiguration)
1659 }
1660 , taskController{
1661 QSharedPointer<TaskController> (
1662@@ -141,7 +144,7 @@
1663 applicationManager.authorizeSession(procId, authed);
1664 EXPECT_EQ(authed, true);
1665
1666- auto appSession = std::make_shared<MockSession>(appId.toStdString(), procId);
1667+ auto appSession = std::make_shared<mir::scene::MockSession>(appId.toStdString(), procId);
1668 sessionManager.onSessionStarting(appSession);
1669 return application;
1670 return nullptr;
1671@@ -152,7 +155,7 @@
1672 testing::NiceMock<testing::MockApplicationController> appController;
1673 testing::NiceMock<testing::MockProcInfo> procInfo;
1674 testing::NiceMock<testing::MockDesktopFileReaderFactory> desktopFileReaderFactory;
1675- QSharedPointer<QtMirTestConfiguration> mirConfig;
1676+ QSharedPointer<FakeMirServerConfiguration> mirConfig;
1677 QSharedPointer<TaskController> taskController;
1678 ApplicationManager applicationManager;
1679 SessionManager sessionManager;
1680
1681=== modified file 'tests/modules/modules.pro'
1682--- tests/modules/modules.pro 2014-08-28 23:36:42 +0000
1683+++ tests/modules/modules.pro 2014-09-11 21:25:08 +0000
1684@@ -1,2 +1,2 @@
1685 TEMPLATE = subdirs
1686-SUBDIRS = ApplicationManager General SessionManager TaskController
1687+SUBDIRS = ApplicationManager General MirSurfaceItem SessionManager TaskController

Subscribers

People subscribed via source and target branches