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