Merge lp:~unity-team/qtmir/sizeHints into lp:qtmir

Proposed by Michał Sawicz on 2016-02-03
Status: Superseded
Proposed branch: lp:~unity-team/qtmir/sizeHints
Merge into: lp:qtmir
Diff against target: 6397 lines (+2892/-1327)
91 files modified
CMakeLists.txt (+1/-1)
src/modules/Unity/Application/CMakeLists.txt (+4/-3)
src/modules/Unity/Application/application.cpp (+33/-12)
src/modules/Unity/Application/application.h (+6/-4)
src/modules/Unity/Application/application_manager.cpp (+29/-10)
src/modules/Unity/Application/application_manager.h (+4/-2)
src/modules/Unity/Application/mirsurface.cpp (+93/-1)
src/modules/Unity/Application/mirsurface.h (+26/-1)
src/modules/Unity/Application/mirsurfaceinterface.h (+7/-0)
src/modules/Unity/Application/mirsurfacemanager.cpp (+4/-2)
src/modules/Unity/Application/mirsurfacemanager.h (+4/-1)
src/modules/Unity/Application/taskcontroller.cpp (+0/-119)
src/modules/Unity/Application/taskcontroller.h (+0/-63)
src/modules/Unity/Application/timer.cpp (+109/-0)
src/modules/Unity/Application/timer.h (+88/-0)
src/modules/Unity/Application/timesource.cpp (+48/-0)
src/modules/Unity/Application/timesource.h (+61/-0)
src/modules/Unity/Application/upstart/taskcontroller.cpp (+34/-34)
src/modules/Unity/Application/upstart/taskcontroller.h (+15/-15)
src/platforms/mirserver/CMakeLists.txt (+1/-0)
src/platforms/mirserver/mirserver.cpp (+10/-2)
src/platforms/mirserver/mirserver.h (+3/-1)
src/platforms/mirserver/mirwindowmanager.cpp (+39/-14)
src/platforms/mirserver/mirwindowmanager.h (+10/-3)
src/platforms/mirserver/sessionlistener.cpp (+11/-1)
src/platforms/mirserver/sessionlistener.h (+10/-1)
src/platforms/mirserver/sizehints.cpp (+44/-0)
src/platforms/mirserver/sizehints.h (+52/-0)
src/platforms/mirserver/surfaceobserver.cpp (+58/-1)
src/platforms/mirserver/surfaceobserver.h (+25/-0)
tests/CMakeLists.txt (+1/-0)
tests/framework/CMakeLists.txt (+45/-0)
tests/framework/fake_desktopfilereader.cpp (+76/-0)
tests/framework/fake_desktopfilereader.h (+23/-21)
tests/framework/fake_mirsurface.cpp (+212/-0)
tests/framework/fake_mirsurface.h (+62/-138)
tests/framework/fake_session.cpp (+119/-0)
tests/framework/fake_session.h (+35/-62)
tests/framework/mock_desktop_file_reader.cpp (+117/-0)
tests/framework/mock_desktop_file_reader.h (+20/-85)
tests/framework/mock_display.cpp (+35/-0)
tests/framework/mock_display.h (+6/-2)
tests/framework/mock_display_configuration.cpp (+25/-0)
tests/framework/mock_display_configuration.h (+4/-0)
tests/framework/mock_gl_display_buffer.cpp (+30/-0)
tests/framework/mock_gl_display_buffer.h (+3/-9)
tests/framework/mock_main_loop.cpp (+28/-0)
tests/framework/mock_main_loop.h (+5/-8)
tests/framework/mock_mir_session.cpp (+63/-0)
tests/framework/mock_mir_session.h (+13/-20)
tests/framework/mock_proc_info.cpp (+35/-0)
tests/framework/mock_proc_info.h (+8/-7)
tests/framework/mock_prompt_session.cpp (+33/-0)
tests/framework/mock_prompt_session.h (+3/-0)
tests/framework/mock_prompt_session_manager.cpp (+33/-0)
tests/framework/mock_prompt_session_manager.h (+3/-0)
tests/framework/mock_renderable.cpp (+33/-0)
tests/framework/mock_renderable.h (+2/-1)
tests/framework/mock_session.cpp (+69/-0)
tests/framework/mock_session.h (+7/-30)
tests/framework/mock_settings.cpp (+40/-0)
tests/framework/mock_settings.h (+7/-11)
tests/framework/mock_shared_wakelock.cpp (+61/-0)
tests/framework/mock_shared_wakelock.h (+8/-33)
tests/framework/mock_surface.cpp (+45/-0)
tests/framework/mock_surface.h (+5/-4)
tests/framework/mock_task_controller.cpp (+129/-0)
tests/framework/mock_task_controller.h (+36/-113)
tests/framework/qtmir_test.cpp (+95/-1)
tests/framework/qtmir_test.h (+19/-116)
tests/framework/stub_input_channel.cpp (+52/-0)
tests/framework/stub_input_channel.h (+8/-18)
tests/framework/stub_scene_surface.cpp (+103/-0)
tests/framework/stub_scene_surface.h (+41/-49)
tests/mirserver/Screen/CMakeLists.txt (+1/-1)
tests/mirserver/ScreenController/CMakeLists.txt (+4/-1)
tests/mirserver/WindowManager/window_manager.cpp (+3/-23)
tests/modules/Application/CMakeLists.txt (+7/-6)
tests/modules/ApplicationManager/CMakeLists.txt (+7/-5)
tests/modules/ApplicationManager/application_manager_test.cpp (+216/-120)
tests/modules/CMakeLists.txt (+0/-1)
tests/modules/DesktopFileReader/CMakeLists.txt (+0/-6)
tests/modules/SessionManager/CMakeLists.txt (+6/-4)
tests/modules/SessionManager/session_manager_test.cpp (+5/-5)
tests/modules/SessionManager/session_test.cpp (+5/-5)
tests/modules/SharedWakelock/CMakeLists.txt (+0/-1)
tests/modules/SurfaceManager/CMakeLists.txt (+4/-4)
tests/modules/SurfaceManager/mirsurface_test.cpp (+7/-4)
tests/modules/SurfaceManager/mirsurfaceitem_test.cpp (+1/-1)
tests/modules/TaskController/CMakeLists.txt (+0/-26)
tests/modules/TaskController/taskcontroller_test.cpp (+0/-95)
To merge this branch: bzr merge lp:~unity-team/qtmir/sizeHints
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing on 2016-02-03
PS Jenkins bot continuous-integration 2016-02-03 Needs Fixing on 2016-02-03
Lukáš Tinkl 2016-02-03 Pending
Review via email: mp+284826@code.launchpad.net

This proposal supersedes a proposal from 2015-11-26.

This proposal has been superseded by a proposal from 2016-02-03.

Commit Message

Surface Size Hints

Description of the Change

* Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~unity-team/unity-api/surfaceItemSizeHints/+merge/284890
lp:~unity-team/unity8/sizeHints

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes. See unity8 MP.

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

To post a comment you must log in.
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Text conflict in debian/control
Text conflict in src/modules/Unity/Application/mirsurface.cpp
Text conflict in src/modules/Unity/Application/mirsurface.h
Text conflict in src/platforms/mirserver/surfaceobserver.cpp
Text conflict in src/platforms/mirserver/surfaceobserver.h

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

> Text conflict in debian/control
> Text conflict in src/modules/Unity/Application/mirsurface.cpp
> Text conflict in src/modules/Unity/Application/mirsurface.h
> Text conflict in src/platforms/mirserver/surfaceobserver.cpp
> Text conflict in src/platforms/mirserver/surfaceobserver.h

Fixed.

Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Code looks good, didn't test yet

review: Approve (code-review)
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=11)

Needs a bump to 12 here, otherwise it doesn't compile:

In file included from /home/ltinkl/bzr/qtmir/sizeHints/src/modules/Unity/Application/mirsurfacemanager.cpp:24:0:
/home/ltinkl/bzr/qtmir/sizeHints/src/modules/Unity/Application/mirsurface.h:80:9: error: 'int qtmir::MirSurface::minimumWidth() const' marked override, but does not override
     int minimumWidth() const override;

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

> pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=11)
>
> Needs a bump to 12 here, otherwise it doesn't compile:

Done

Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

LGTM, worked fine in unity8

review: Approve
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:424
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-1-ci/54/
Executed test runs:

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-1-ci/54/rebuild

review: Needs Fixing (continuous-integration)
lp:~unity-team/qtmir/sizeHints updated on 2016-02-11
395. By Nick Dedekind on 2016-02-10

merged with trunk

396. By Daniel d'Andrada on 2016-02-11

Remove the useless TaskController

It was just forwarding calls between ApplicationManager and ApplicationCrontroller.
Had no logic of its own.

ApplicationCrontroller was then renamed to TaskController as the latter has a better API and it also keeps ApplicationManager code more or less untouched.

Tests have been improved a bit by better emulating TaskController behavior

397. By Daniel d'Andrada on 2016-02-11

Let shell decide the initial surface size

398. By Daniel d'Andrada on 2016-02-11

Surface Size Hints

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-12-07 12:23:29 +0000
3+++ CMakeLists.txt 2016-02-03 11:35:51 +0000
4@@ -20,7 +20,7 @@
5 set(CMAKE_AUTOMOC ON)
6
7 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -Werror")
8-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -fno-strict-aliasing -Werror -Wextra")
9+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wall -fno-strict-aliasing -Werror -Wextra")
10 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
11
12
13
14=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
15--- src/modules/Unity/Application/CMakeLists.txt 2015-10-13 09:00:00 +0000
16+++ src/modules/Unity/Application/CMakeLists.txt 2016-02-03 11:35:51 +0000
17@@ -31,7 +31,6 @@
18 plugin.cpp
19 applicationscreenshotprovider.cpp
20 dbuswindowstack.cpp
21- taskcontroller.cpp
22 mirsurfacemanager.cpp
23 ubuntukeyboardinfo.cpp
24 mirsurface.cpp
25@@ -42,7 +41,9 @@
26 session.cpp
27 sessionmanager.cpp
28 sharedwakelock.cpp
29- upstart/applicationcontroller.cpp
30+ upstart/taskcontroller.cpp
31+ timer.cpp
32+ timesource.cpp
33 tracepoints.c
34 settings.cpp
35 # We need to run moc on these headers
36@@ -53,7 +54,7 @@
37 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
38 # Feed the automoc monster
39 session_interface.h
40- applicationcontroller.h
41+ taskcontroller.h
42 settings_interface.h
43 )
44
45
46=== modified file 'src/modules/Unity/Application/application.cpp'
47--- src/modules/Unity/Application/application.cpp 2016-01-22 16:32:39 +0000
48+++ src/modules/Unity/Application/application.cpp 2016-02-03 11:35:51 +0000
49@@ -20,7 +20,7 @@
50 #include "desktopfilereader.h"
51 #include "session.h"
52 #include "sharedwakelock.h"
53-#include "taskcontroller.h"
54+#include "timer.h"
55
56 // common
57 #include <debughelpers.h>
58@@ -52,7 +52,7 @@
59 , m_session(nullptr)
60 , m_requestedState(RequestedRunning)
61 , m_processState(ProcessUnknown)
62- , m_closeTimer(0)
63+ , m_closeTimer(nullptr)
64 , m_exemptFromLifecycle(false)
65 {
66 qCDebug(QTMIR_APPLICATIONS) << "Application::Application - appId=" << desktopFileReader->appId();
67@@ -66,6 +66,8 @@
68 m_supportedOrientations = m_desktopData->supportedOrientations();
69
70 m_rotatesWindowContents = m_desktopData->rotatesWindowContents();
71+
72+ setCloseTimer(new Timer);
73 }
74
75 Application::~Application()
76@@ -101,6 +103,7 @@
77 delete m_session;
78 }
79 delete m_desktopData;
80+ delete m_closeTimer;
81 }
82
83
84@@ -433,11 +436,11 @@
85
86 void Application::doClose()
87 {
88- Q_ASSERT(m_closeTimer == 0);
89+ Q_ASSERT(!m_closeTimer->isRunning());;
90 Q_ASSERT(m_session != nullptr);
91
92 m_session->close();
93- m_closeTimer = startTimer(3000);
94+ m_closeTimer->start();
95 setInternalState(InternalState::Closing);
96 }
97
98@@ -682,14 +685,6 @@
99 Q_EMIT stopProcessRequested();
100 }
101
102-void Application::timerEvent(QTimerEvent *event)
103-{
104- if (event->timerId() == m_closeTimer) {
105- m_closeTimer = 0;
106- stop();
107- }
108-}
109-
110 bool Application::isTouchApp() const
111 {
112 return m_desktopData->isTouchApp();
113@@ -790,4 +785,30 @@
114 }
115 }
116
117+void Application::setCloseTimer(AbstractTimer *timer)
118+{
119+ delete m_closeTimer;
120+
121+ m_closeTimer = timer;
122+ m_closeTimer->setInterval(3000);
123+ m_closeTimer->setSingleShot(true);
124+ connect(m_closeTimer, &Timer::timeout, this, &Application::stop);
125+}
126+
127+QSize Application::initialSurfaceSize() const
128+{
129+ return m_initialSurfaceSize;
130+}
131+
132+void Application::setInitialSurfaceSize(const QSize &size)
133+{
134+ qCDebug(QTMIR_APPLICATIONS).nospace() << "Application::setInitialSurfaceSize - appId=" << appId()
135+ << " size=" << size;
136+
137+ if (size != m_initialSurfaceSize) {
138+ m_initialSurfaceSize = size;
139+ Q_EMIT initialSurfaceSizeChanged(m_initialSurfaceSize);
140+ }
141+}
142+
143 } // namespace qtmir
144
145=== modified file 'src/modules/Unity/Application/application.h'
146--- src/modules/Unity/Application/application.h 2015-12-07 12:23:29 +0000
147+++ src/modules/Unity/Application/application.h 2016-02-03 11:35:51 +0000
148@@ -43,6 +43,7 @@
149 class DesktopFileReader;
150 class Session;
151 class SharedWakelock;
152+class AbstractTimer;
153
154 class Application : public unity::shell::application::ApplicationInfoInterface
155 {
156@@ -107,6 +108,8 @@
157 bool isTouchApp() const override;
158 bool exemptFromLifecycle() const override;
159 void setExemptFromLifecycle(bool) override;
160+ QSize initialSurfaceSize() const override;
161+ void setInitialSurfaceSize(const QSize &size) override;
162
163 void setStage(Stage stage);
164
165@@ -133,6 +136,7 @@
166
167 // for tests
168 InternalState internalState() const { return m_state; }
169+ void setCloseTimer(AbstractTimer *timer);
170
171 Q_SIGNALS:
172 void fullscreenChanged(bool fullscreen);
173@@ -150,9 +154,6 @@
174
175 void respawn();
176
177-protected:
178- void timerEvent(QTimerEvent *event);
179-
180 private:
181
182 QString longAppId() const;
183@@ -187,8 +188,9 @@
184 SessionInterface *m_session;
185 RequestedState m_requestedState;
186 ProcessState m_processState;
187- int m_closeTimer;
188+ AbstractTimer *m_closeTimer;
189 bool m_exemptFromLifecycle;
190+ QSize m_initialSurfaceSize;
191
192 friend class ApplicationManager;
193 friend class SessionManager;
194
195=== modified file 'src/modules/Unity/Application/application_manager.cpp'
196--- src/modules/Unity/Application/application_manager.cpp 2016-01-22 16:32:39 +0000
197+++ src/modules/Unity/Application/application_manager.cpp 2016-02-03 11:35:51 +0000
198@@ -22,8 +22,7 @@
199 #include "session.h"
200 #include "sharedwakelock.h"
201 #include "proc_info.h"
202-#include "taskcontroller.h"
203-#include "upstart/applicationcontroller.h"
204+#include "upstart/taskcontroller.h"
205 #include "tracepoints.h" // generated from tracepoints.tp
206 #include "settings.h"
207
208@@ -32,8 +31,8 @@
209 #include "nativeinterface.h"
210 #include "sessionlistener.h"
211 #include "sessionauthorizer.h"
212-#include "taskcontroller.h"
213 #include "logging.h"
214+#include <mirwindowmanager.h>
215
216 // mir
217 #include <mir/scene/surface.h>
218@@ -120,13 +119,12 @@
219 return nullptr;
220 }
221
222- auto mirServer = nativeInterface->m_mirServer;
223+ auto mirServer = nativeInterface->m_mirServer.lock();
224
225 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));
226 SessionAuthorizer *sessionAuthorizer = static_cast<SessionAuthorizer*>(nativeInterface->nativeResourceForIntegration("SessionAuthorizer"));
227
228- QSharedPointer<upstart::ApplicationController> appController(new upstart::ApplicationController());
229- QSharedPointer<TaskController> taskController(new TaskController(nullptr, appController));
230+ QSharedPointer<TaskController> taskController(new upstart::TaskController());
231 QSharedPointer<DesktopFileReader::Factory> fileReaderFactory(new DesktopFileReader::Factory());
232 QSharedPointer<ProcInfo> procInfo(new ProcInfo());
233 QSharedPointer<SharedWakelock> sharedWakelock(new SharedWakelock);
234@@ -149,6 +147,9 @@
235 connectToSessionListener(appManager, sessionListener);
236 connectToSessionAuthorizer(appManager, sessionAuthorizer);
237 connectToTaskController(appManager, taskController.data());
238+ connect(mirServer->windowManager(), &MirWindowManager::sessionAboutToCreateSurface,
239+ appManager, &ApplicationManager::onSessionAboutToCreateSurface,
240+ Qt::BlockingQueuedConnection);
241
242 // Emit signal to notify Upstart that Mir is ready to receive client connections
243 // see http://upstart.ubuntu.com/cookbook/#expect-stop
244@@ -461,15 +462,14 @@
245 m_closingApplications.removeAll(application);
246 });
247 m_closingApplications.append(application);
248- application->close();
249 return true;
250 }
251
252-void ApplicationManager::onProcessFailed(const QString &appId, const bool duringStartup)
253+void ApplicationManager::onProcessFailed(const QString &appId, TaskController::Error error)
254 {
255 // Applications fail if they fail to launch, crash or are killed.
256
257- qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::onProcessFailed - appId=" << appId << "duringStartup=" << duringStartup;
258+ qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::onProcessFailed - appId=" << appId;
259
260 Application *application = findApplication(appId);
261 if (!application) {
262@@ -478,7 +478,7 @@
263 return;
264 }
265
266- Q_UNUSED(duringStartup); // FIXME(greyback) upstart reports app that fully started up & crashes as failing during startup??
267+ Q_UNUSED(error); // FIXME(greyback) upstart reports app that fully started up & crashes as failing during startup??
268 application->setProcessState(Application::ProcessFailed);
269 application->setPid(0);
270 }
271@@ -862,4 +862,23 @@
272 return nullptr;
273 }
274
275+void ApplicationManager::onSessionAboutToCreateSurface(
276+ const std::shared_ptr<mir::scene::Session> &session, int type, QSize &size)
277+{
278+ if (type == mir_surface_type_normal) {
279+ Application* application = findApplicationWithSession(session);
280+
281+ if (application) {
282+ qCDebug(QTMIR_APPLICATIONS).nospace() << "ApplicationManager::onSessionAboutToCreateSurface appId="
283+ << application->appId();
284+ size = application->initialSurfaceSize();
285+ } else {
286+ qCDebug(QTMIR_APPLICATIONS).nospace() << "ApplicationManager::onSessionAboutToCreateSurface unknown app";
287+ }
288+ } else {
289+ qCDebug(QTMIR_APPLICATIONS).nospace() << "ApplicationManager::onSessionAboutToCreateSurface type=" << type
290+ << " NOOP";
291+ }
292+}
293+
294 } // namespace qtmir
295
296=== modified file 'src/modules/Unity/Application/application_manager.h'
297--- src/modules/Unity/Application/application_manager.h 2015-12-07 12:23:29 +0000
298+++ src/modules/Unity/Application/application_manager.h 2016-02-03 11:35:51 +0000
299@@ -30,6 +30,7 @@
300 // local
301 #include "application.h"
302 #include "desktopfilereader.h"
303+#include "taskcontroller.h"
304
305 namespace mir {
306 namespace scene {
307@@ -47,7 +48,6 @@
308 class MirSurfaceManager;
309 class ProcInfo;
310 class SharedWakelock;
311-class TaskController;
312 class SettingsInterface;
313
314 class ApplicationManager : public unity::shell::application::ApplicationManagerInterface
315@@ -127,7 +127,7 @@
316 void onProcessStarting(const QString& appId);
317 void onProcessStopped(const QString& appId);
318 void onProcessSuspended(const QString& appId);
319- void onProcessFailed(const QString& appId, const bool duringStartup);
320+ void onProcessFailed(const QString& appId, TaskController::Error error);
321 void onFocusRequested(const QString& appId);
322 void onResumeRequested(const QString& appId);
323
324@@ -137,6 +137,8 @@
325
326 private Q_SLOTS:
327 void onAppDataChanged(const int role);
328+ void onSessionAboutToCreateSurface(const std::shared_ptr<mir::scene::Session> &session,
329+ int type, QSize &size);
330
331 private:
332 void setFocused(Application *application);
333
334=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
335--- src/modules/Unity/Application/mirsurface.cpp 2016-01-22 17:51:40 +0000
336+++ src/modules/Unity/Application/mirsurface.cpp 2016-02-03 11:35:51 +0000
337@@ -171,7 +171,8 @@
338 MirSurface::MirSurface(std::shared_ptr<mir::scene::Surface> surface,
339 SessionInterface* session,
340 mir::shell::Shell* shell,
341- std::shared_ptr<SurfaceObserver> observer)
342+ std::shared_ptr<SurfaceObserver> observer,
343+ const SizeHints &sizeHints)
344 : MirSurfaceInterface()
345 , m_surface(surface)
346 , m_session(session)
347@@ -182,12 +183,25 @@
348 , m_currentFrameNumber(0)
349 , m_live(true)
350 {
351+ m_minimumWidth = sizeHints.minWidth;
352+ m_minimumHeight = sizeHints.minHeight;
353+ m_maximumWidth = sizeHints.maxWidth;
354+ m_maximumHeight = sizeHints.maxHeight;
355+ m_widthIncrement = sizeHints.widthIncrement;
356+ m_heightIncrement = sizeHints.heightIncrement;
357+
358 m_surfaceObserver = observer;
359 if (observer) {
360 connect(observer.get(), &SurfaceObserver::framesPosted, this, &MirSurface::onFramesPostedObserved);
361 connect(observer.get(), &SurfaceObserver::attributeChanged, this, &MirSurface::onAttributeChanged);
362 connect(observer.get(), &SurfaceObserver::nameChanged, this, &MirSurface::nameChanged);
363 connect(observer.get(), &SurfaceObserver::cursorChanged, this, &MirSurface::setCursor);
364+ connect(observer.get(), &SurfaceObserver::minimumWidthChanged, this, &MirSurface::setMinimumWidth);
365+ connect(observer.get(), &SurfaceObserver::minimumHeightChanged, this, &MirSurface::setMinimumHeight);
366+ connect(observer.get(), &SurfaceObserver::maximumWidthChanged, this, &MirSurface::setMaximumWidth);
367+ connect(observer.get(), &SurfaceObserver::maximumHeightChanged, this, &MirSurface::setMaximumHeight);
368+ connect(observer.get(), &SurfaceObserver::widthIncrementChanged, this, &MirSurface::setWidthIncrement);
369+ connect(observer.get(), &SurfaceObserver::heightIncrementChanged, this, &MirSurface::setHeightIncrement);
370 observer->setListener(this);
371 }
372
373@@ -754,3 +768,81 @@
374 m_cursor = cursor;
375 Q_EMIT cursorChanged(m_cursor);
376 }
377+
378+int MirSurface::minimumWidth() const
379+{
380+ return m_minimumWidth;
381+}
382+
383+int MirSurface::minimumHeight() const
384+{
385+ return m_minimumHeight;
386+}
387+
388+int MirSurface::maximumWidth() const
389+{
390+ return m_maximumWidth;
391+}
392+
393+int MirSurface::maximumHeight() const
394+{
395+ return m_maximumHeight;
396+}
397+
398+int MirSurface::widthIncrement() const
399+{
400+ return m_widthIncrement;
401+}
402+
403+int MirSurface::heightIncrement() const
404+{
405+ return m_heightIncrement;
406+}
407+
408+void MirSurface::setMinimumWidth(int value)
409+{
410+ if (value != m_minimumWidth) {
411+ m_minimumWidth = value;
412+ Q_EMIT minimumWidthChanged(value);
413+ }
414+}
415+
416+void MirSurface::setMinimumHeight(int value)
417+{
418+ if (value != m_minimumHeight) {
419+ m_minimumHeight = value;
420+ Q_EMIT minimumHeightChanged(value);
421+ }
422+}
423+
424+void MirSurface::setMaximumWidth(int value)
425+{
426+ if (value != m_maximumWidth) {
427+ m_maximumWidth = value;
428+ Q_EMIT maximumWidthChanged(value);
429+ }
430+}
431+
432+void MirSurface::setMaximumHeight(int value)
433+{
434+ if (value != m_maximumHeight) {
435+ m_maximumHeight = value;
436+ Q_EMIT maximumHeightChanged(value);
437+ }
438+}
439+
440+void MirSurface::setWidthIncrement(int value)
441+{
442+ if (value != m_widthIncrement) {
443+ m_widthIncrement = value;
444+ Q_EMIT widthIncrementChanged(value);
445+ }
446+}
447+
448+void MirSurface::setHeightIncrement(int value)
449+{
450+ if (value != m_heightIncrement) {
451+ m_heightIncrement = value;
452+ Q_EMIT heightIncrementChanged(value);
453+ }
454+}
455
456=== modified file 'src/modules/Unity/Application/mirsurface.h'
457--- src/modules/Unity/Application/mirsurface.h 2015-12-10 13:08:43 +0000
458+++ src/modules/Unity/Application/mirsurface.h 2016-02-03 11:35:51 +0000
459@@ -31,6 +31,9 @@
460 #include "mirbuffersgtexture.h"
461 #include "session.h"
462
463+// mirserver
464+#include "sizehints.h"
465+
466 // mir
467 #include <mir/scene/surface.h>
468 #include <mir_toolkit/common.h>
469@@ -49,7 +52,8 @@
470 MirSurface(std::shared_ptr<mir::scene::Surface> surface,
471 SessionInterface* session,
472 mir::shell::Shell *shell,
473- std::shared_ptr<SurfaceObserver> observer);
474+ std::shared_ptr<SurfaceObserver> observer,
475+ const SizeHints &);
476 virtual ~MirSurface();
477
478 ////
479@@ -73,6 +77,13 @@
480 Mir::OrientationAngle orientationAngle() const override;
481 void setOrientationAngle(Mir::OrientationAngle angle) override;
482
483+ int minimumWidth() const override;
484+ int minimumHeight() const override;
485+ int maximumWidth() const override;
486+ int maximumHeight() const override;
487+ int widthIncrement() const override;
488+ int heightIncrement() const override;
489+
490 ////
491 // qtmir::MirSurfaceInterface
492
493@@ -124,6 +135,13 @@
494 public Q_SLOTS:
495 void onCompositorSwappedBuffers() override;
496
497+ void setMinimumWidth(int) override;
498+ void setMinimumHeight(int) override;
499+ void setMaximumWidth(int) override;
500+ void setMaximumHeight(int) override;
501+ void setWidthIncrement(int) override;
502+ void setHeightIncrement(int) override;
503+
504 private Q_SLOTS:
505 void dropPendingBuffer();
506 void onAttributeChanged(const MirSurfaceAttrib, const int);
507@@ -165,6 +183,13 @@
508 QSize m_size;
509
510 QCursor m_cursor;
511+
512+ int m_minimumWidth{0};
513+ int m_minimumHeight{0};
514+ int m_maximumWidth{0};
515+ int m_maximumHeight{0};
516+ int m_widthIncrement{0};
517+ int m_heightIncrement{0};
518 };
519
520 } // namespace qtmir
521
522=== modified file 'src/modules/Unity/Application/mirsurfaceinterface.h'
523--- src/modules/Unity/Application/mirsurfaceinterface.h 2015-12-10 13:08:43 +0000
524+++ src/modules/Unity/Application/mirsurfaceinterface.h 2016-02-03 11:35:51 +0000
525@@ -92,6 +92,13 @@
526 public Q_SLOTS:
527 virtual void onCompositorSwappedBuffers() = 0;
528
529+ virtual void setMinimumWidth(int) = 0;
530+ virtual void setMinimumHeight(int) = 0;
531+ virtual void setMaximumWidth(int) = 0;
532+ virtual void setMaximumHeight(int) = 0;
533+ virtual void setWidthIncrement(int) = 0;
534+ virtual void setHeightIncrement(int) = 0;
535+
536 Q_SIGNALS:
537 void firstFrameDrawn();
538 void framesPosted();
539
540=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
541--- src/modules/Unity/Application/mirsurfacemanager.cpp 2015-12-07 12:02:48 +0000
542+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2016-02-03 11:35:51 +0000
543@@ -34,6 +34,7 @@
544 #include "mirserver.h"
545 #include "sessionlistener.h"
546 #include "logging.h"
547+#include "sizehints.h"
548
549 Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")
550
551@@ -97,13 +98,14 @@
552
553 void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *mirSession,
554 const std::shared_ptr<mir::scene::Surface> &surface,
555- const std::shared_ptr<SurfaceObserver> &observer)
556+ const std::shared_ptr<SurfaceObserver> &observer,
557+ qtmir::SizeHints sizeHints)
558 {
559 qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionCreatedSurface - mirSession=" << mirSession
560 << "surface=" << surface.get() << "surface.name=" << surface->name().c_str();
561
562 SessionInterface* session = m_sessionManager->findSession(mirSession);
563- auto qmlSurface = new MirSurface(surface, session, m_shell, observer);
564+ auto qmlSurface = new MirSurface(surface, session, m_shell, observer, sizeHints);
565 {
566 QMutexLocker lock(&m_mutex);
567 m_mirSurfaceToQmlSurfaceHash.insert(surface.get(), qmlSurface);
568
569=== modified file 'src/modules/Unity/Application/mirsurfacemanager.h'
570--- src/modules/Unity/Application/mirsurfacemanager.h 2015-08-31 09:51:28 +0000
571+++ src/modules/Unity/Application/mirsurfacemanager.h 2016-02-03 11:35:51 +0000
572@@ -29,6 +29,8 @@
573 // Mir
574 #include <mir_toolkit/common.h>
575
576+// mirserver qpa
577+#include <sizehints.h>
578
579 namespace mir {
580 namespace scene {
581@@ -71,7 +73,8 @@
582 public Q_SLOTS:
583 void onSessionCreatedSurface(const mir::scene::Session *,
584 const std::shared_ptr<mir::scene::Surface> &,
585- std::shared_ptr<SurfaceObserver> const&);
586+ std::shared_ptr<SurfaceObserver> const&,
587+ qtmir::SizeHints);
588 void onSessionDestroyingSurface(const mir::scene::Session *, const std::shared_ptr<mir::scene::Surface> &);
589
590 protected:
591
592=== removed file 'src/modules/Unity/Application/taskcontroller.cpp'
593--- src/modules/Unity/Application/taskcontroller.cpp 2015-10-08 11:20:30 +0000
594+++ src/modules/Unity/Application/taskcontroller.cpp 1970-01-01 00:00:00 +0000
595@@ -1,119 +0,0 @@
596-/*
597- * Copyright (C) 2013-2015 Canonical, Ltd.
598- *
599- * This program is free software: you can redistribute it and/or modify it under
600- * the terms of the GNU Lesser General Public License version 3, as published by
601- * the Free Software Foundation.
602- *
603- * This program is distributed in the hope that it will be useful, but WITHOUT
604- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
605- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
606- * Lesser General Public License for more details.
607- *
608- * You should have received a copy of the GNU Lesser General Public License
609- * along with this program. If not, see <http://www.gnu.org/licenses/>.
610- */
611-
612-// local
613-#include "taskcontroller.h"
614-#include "logging.h"
615-
616-// Qt
617-#include <QStringList>
618-
619-// STL
620-#include <mutex>
621-
622-// std
623-#include <csignal>
624-#include <unistd.h>
625-
626-namespace qtmir
627-{
628-
629-TaskController::TaskController(
630- QObject *parent,
631- const QSharedPointer<ApplicationController> &appController) :
632- QObject(parent),
633- m_appController(appController)
634-{
635- connect(m_appController.data(),
636- &ApplicationController::applicationAboutToBeStarted,
637- this,
638- &TaskController::processStarting);
639-
640- connect(m_appController.data(),
641- &ApplicationController::applicationStopped,
642- this,
643- &TaskController::processStopped);
644-
645- connect(m_appController.data(),
646- &ApplicationController::applicationPaused,
647- this,
648- &TaskController::processSuspended);
649-
650- connect(m_appController.data(),
651- &ApplicationController::applicationFocusRequest,
652- this,
653- &TaskController::focusRequested);
654-
655- connect(m_appController.data(),
656- &ApplicationController::applicationResumeRequested,
657- this,
658- &TaskController::resumeRequested);
659-
660- connect(m_appController.data(),
661- &ApplicationController::applicationError,
662- this,
663- &TaskController::onApplicationError);
664-}
665-
666-TaskController::~TaskController()
667-{
668-}
669-
670-bool TaskController::start(const QString& appId, const QStringList& arguments)
671-{
672- qCDebug(QTMIR_APPLICATIONS) << "TaskController::start - appId=" << appId;
673- return m_appController->startApplicationWithAppIdAndArgs(appId, arguments);
674-}
675-
676-bool TaskController::stop(const QString& appId)
677-{
678- qCDebug(QTMIR_APPLICATIONS) << "TaskController::stop - appId=" << appId;
679- auto result = m_appController->stopApplicationWithAppId(appId);
680- if (!result)
681- qCDebug(QTMIR_APPLICATIONS) << "TaskController::stopApplication - FAILED to stop appId=" << appId;
682-
683- return result;
684-}
685-
686-bool TaskController::appIdHasProcessId(const QString& appId, const pid_t pid) const
687-{
688- qCDebug(QTMIR_APPLICATIONS) << "TaskController::isApplicationPid - appId=" << appId << "pid=" << pid;
689- return m_appController->appIdHasProcessId(pid, appId);
690-}
691-
692-QFileInfo TaskController::findDesktopFileForAppId(const QString &appId) const
693-{
694- return m_appController->findDesktopFileForAppId(appId);
695-}
696-
697-bool TaskController::suspend(const QString &appId)
698-{
699- qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << appId;
700- return m_appController->pauseApplicationWithAppId(appId);
701-}
702-
703-bool TaskController::resume(const QString &appId)
704-{
705- qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << appId;
706- return m_appController->resumeApplicationWithAppId(appId);
707-}
708-
709-void TaskController::onApplicationError(const QString& id, ApplicationController::Error error)
710-{
711- Q_EMIT processFailed(id, (error == ApplicationController::Error::APPLICATION_FAILED_TO_START) );
712-}
713-
714-} // namespace qtmir
715
716=== renamed file 'src/modules/Unity/Application/applicationcontroller.h' => 'src/modules/Unity/Application/taskcontroller.h'
717--- src/modules/Unity/Application/applicationcontroller.h 2015-08-11 12:08:32 +0000
718+++ src/modules/Unity/Application/taskcontroller.h 2016-02-03 11:35:51 +0000
719@@ -15,8 +15,8 @@
720 *
721 */
722
723-#ifndef APPLICATION_CONTROLLER_H
724-#define APPLICATION_CONTROLLER_H
725+#ifndef QTMIR_TASK_CONTROLLER_H
726+#define QTMIR_TASK_CONTROLLER_H
727
728 #include <QObject>
729 #include <QString>
730@@ -26,7 +26,7 @@
731 namespace qtmir
732 {
733
734-class ApplicationController : public QObject
735+class TaskController : public QObject
736 {
737 Q_OBJECT
738
739@@ -37,36 +37,36 @@
740 APPLICATION_FAILED_TO_START
741 };
742
743- ApplicationController(const ApplicationController&) = delete;
744- virtual ~ApplicationController() = default;
745+ TaskController(const TaskController&) = delete;
746+ virtual ~TaskController() = default;
747
748- ApplicationController& operator=(const ApplicationController&) = delete;
749+ TaskController& operator=(const TaskController&) = delete;
750
751 virtual pid_t primaryPidForAppId(const QString &appId) = 0;
752- virtual bool appIdHasProcessId(pid_t pid, const QString &appId) = 0;
753-
754- virtual bool stopApplicationWithAppId(const QString &appId) = 0;
755- virtual bool startApplicationWithAppIdAndArgs(const QString &appId, const QStringList &arguments) = 0;
756-
757- virtual bool pauseApplicationWithAppId(const QString &appId) = 0;
758- virtual bool resumeApplicationWithAppId(const QString &appId) = 0;
759+ virtual bool appIdHasProcessId(const QString &appId, pid_t pid) = 0;
760+
761+ virtual bool stop(const QString &appId) = 0;
762+ virtual bool start(const QString &appId, const QStringList &arguments) = 0;
763+
764+ virtual bool suspend(const QString &appId) = 0;
765+ virtual bool resume(const QString &appId) = 0;
766
767 virtual QFileInfo findDesktopFileForAppId(const QString &appId) const = 0;
768
769 Q_SIGNALS:
770- void applicationAboutToBeStarted(const QString &appId);
771+ void processStarting(const QString &appId);
772 void applicationStarted(const QString &appId);
773- void applicationStopped(const QString &appId);
774- void applicationPaused(const QString &appId);
775- void applicationFocusRequest(const QString &appId);
776- void applicationResumeRequested(const QString &appId);
777+ void processStopped(const QString &appId);
778+ void processSuspended(const QString &appId);
779+ void focusRequested(const QString &appId);
780+ void resumeRequested(const QString &appId);
781
782- void applicationError(const QString &appId, ApplicationController::Error error);
783+ void processFailed(const QString &appId, TaskController::Error error);
784
785 protected:
786- ApplicationController() = default;
787+ TaskController() = default;
788 };
789
790 } // namespace qtmir
791
792-#endif // APPLICATION_CONTROLLER_H
793+#endif // QTMIR_TASK_CONTROLLER_H
794
795=== removed file 'src/modules/Unity/Application/taskcontroller.h'
796--- src/modules/Unity/Application/taskcontroller.h 2015-10-08 11:20:30 +0000
797+++ src/modules/Unity/Application/taskcontroller.h 1970-01-01 00:00:00 +0000
798@@ -1,63 +0,0 @@
799-/*
800- * Copyright (C) 2013-2015 Canonical, Ltd.
801- *
802- * This program is free software: you can redistribute it and/or modify it under
803- * the terms of the GNU Lesser General Public License version 3, as published by
804- * the Free Software Foundation.
805- *
806- * This program is distributed in the hope that it will be useful, but WITHOUT
807- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
808- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
809- * Lesser General Public License for more details.
810- *
811- * You should have received a copy of the GNU Lesser General Public License
812- * along with this program. If not, see <http://www.gnu.org/licenses/>.
813- */
814-
815-#ifndef TASKCONTROLLER_H
816-#define TASKCONTROLLER_H
817-
818-#include <QObject>
819-
820-#include "application.h"
821-#include "applicationcontroller.h"
822-
823-namespace qtmir
824-{
825-
826-class TaskController : public QObject
827-{
828- Q_OBJECT
829-public:
830- TaskController(
831- QObject *parent,
832- const QSharedPointer<ApplicationController> &appController);
833- ~TaskController();
834-
835- bool start(const QString &appId, const QStringList &args);
836- bool stop(const QString &appId);
837-
838- bool suspend(const QString &appId);
839- bool resume(const QString &appId);
840-
841- bool appIdHasProcessId(const QString &appId, const pid_t pid) const;
842- QFileInfo findDesktopFileForAppId(const QString &appId) const;
843-
844-Q_SIGNALS:
845- void processStarting(const QString &appId);
846- void processStopped(const QString &appId);
847- void processSuspended(const QString &appId);
848- void processFailed(const QString &appId, const bool duringStartup);
849- void focusRequested(const QString &appId);
850- void resumeRequested(const QString &appId);
851-
852-private Q_SLOTS:
853- void onApplicationError(const QString &id, ApplicationController::Error error);
854-
855-private:
856- const QSharedPointer<ApplicationController> m_appController;
857-};
858-
859-} // namespace qtmir
860-
861-#endif // TASKCONTROLLER_H
862
863=== added file 'src/modules/Unity/Application/timer.cpp'
864--- src/modules/Unity/Application/timer.cpp 1970-01-01 00:00:00 +0000
865+++ src/modules/Unity/Application/timer.cpp 2016-02-03 11:35:51 +0000
866@@ -0,0 +1,109 @@
867+/*
868+ * Copyright (C) 2015 Canonical, Ltd.
869+ *
870+ * This program is free software; you can redistribute it and/or modify
871+ * it under the terms of the GNU General Public License as published by
872+ * the Free Software Foundation; version 3.
873+ *
874+ * This program is distributed in the hope that it will be useful,
875+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
876+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
877+ * GNU General Public License for more details.
878+ *
879+ * You should have received a copy of the GNU General Public License
880+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
881+ */
882+
883+#include "timer.h"
884+
885+using namespace qtmir;
886+
887+Timer::Timer(QObject *parent) : AbstractTimer(parent)
888+{
889+ m_timer.setSingleShot(false);
890+ connect(&m_timer, &QTimer::timeout, this, &AbstractTimer::timeout);
891+}
892+
893+int Timer::interval() const
894+{
895+ return m_timer.interval();
896+}
897+
898+void Timer::setInterval(int msecs)
899+{
900+ m_timer.setInterval(msecs);
901+}
902+
903+void Timer::start()
904+{
905+ m_timer.start();
906+ AbstractTimer::start();
907+}
908+
909+void Timer::stop()
910+{
911+ m_timer.stop();
912+ AbstractTimer::stop();
913+}
914+
915+bool Timer::isSingleShot() const
916+{
917+ return m_timer.isSingleShot();
918+}
919+
920+void Timer::setSingleShot(bool value)
921+{
922+ m_timer.setSingleShot(value);
923+}
924+
925+/////////////////////////////////// FakeTimer //////////////////////////////////
926+
927+FakeTimer::FakeTimer(const SharedTimeSource &timeSource, QObject *parent)
928+ : qtmir::AbstractTimer(parent)
929+ , m_interval(0)
930+ , m_singleShot(false)
931+ , m_timeSource(timeSource)
932+{
933+}
934+
935+void FakeTimer::update()
936+{
937+ if (!isRunning()) {
938+ return;
939+ }
940+
941+ if (m_nextTimeoutTime <= m_timeSource->msecsSinceReference()) {
942+ if (isSingleShot()) {
943+ stop();
944+ } else {
945+ m_nextTimeoutTime += interval();
946+ }
947+ Q_EMIT timeout();
948+ }
949+}
950+
951+void FakeTimer::start()
952+{
953+ AbstractTimer::start();
954+ m_nextTimeoutTime = m_timeSource->msecsSinceReference() + (qint64)interval();
955+}
956+
957+int FakeTimer::interval() const
958+{
959+ return m_interval;
960+}
961+
962+void FakeTimer::setInterval(int msecs)
963+{
964+ m_interval = msecs;
965+}
966+
967+bool FakeTimer::isSingleShot() const
968+{
969+ return m_singleShot;
970+}
971+
972+void FakeTimer::setSingleShot(bool value)
973+{
974+ m_singleShot = value;
975+}
976
977=== added file 'src/modules/Unity/Application/timer.h'
978--- src/modules/Unity/Application/timer.h 1970-01-01 00:00:00 +0000
979+++ src/modules/Unity/Application/timer.h 2016-02-03 11:35:51 +0000
980@@ -0,0 +1,88 @@
981+/*
982+ * Copyright (C) 2015 Canonical, Ltd.
983+ *
984+ * This program is free software; you can redistribute it and/or modify
985+ * it under the terms of the GNU General Public License as published by
986+ * the Free Software Foundation; version 3.
987+ *
988+ * This program is distributed in the hope that it will be useful,
989+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
990+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
991+ * GNU General Public License for more details.
992+ *
993+ * You should have received a copy of the GNU General Public License
994+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
995+ */
996+
997+#ifndef QTMIR_TIMER_H
998+#define QTMIR_TIMER_H
999+
1000+#include "timesource.h"
1001+
1002+#include <QObject>
1003+#include <QPointer>
1004+#include <QTimer>
1005+
1006+namespace qtmir {
1007+
1008+/* Defines an interface for a Timer. Useful for tests. */
1009+class AbstractTimer : public QObject
1010+{
1011+ Q_OBJECT
1012+public:
1013+ AbstractTimer(QObject *parent) : QObject(parent), m_isRunning(false) {}
1014+ virtual int interval() const = 0;
1015+ virtual void setInterval(int msecs) = 0;
1016+ virtual void start() { m_isRunning = true; }
1017+ virtual void stop() { m_isRunning = false; }
1018+ bool isRunning() const { return m_isRunning; }
1019+ virtual bool isSingleShot() const = 0;
1020+ virtual void setSingleShot(bool value) = 0;
1021+Q_SIGNALS:
1022+ void timeout();
1023+private:
1024+ bool m_isRunning;
1025+};
1026+
1027+/* Essentially a QTimer wrapper */
1028+class Timer : public AbstractTimer
1029+{
1030+ Q_OBJECT
1031+public:
1032+ Timer(QObject *parent = nullptr);
1033+
1034+ int interval() const override;
1035+ void setInterval(int msecs) override;
1036+ void start() override;
1037+ void stop() override;
1038+ bool isSingleShot() const override;
1039+ void setSingleShot(bool value) override;
1040+private:
1041+ QTimer m_timer;
1042+};
1043+
1044+/* For tests */
1045+class FakeTimer : public AbstractTimer
1046+{
1047+ Q_OBJECT
1048+public:
1049+ FakeTimer(const SharedTimeSource &timeSource, QObject *parent = nullptr);
1050+
1051+ void update();
1052+ qint64 nextTimeoutTime() const { return m_nextTimeoutTime; }
1053+
1054+ int interval() const override;
1055+ void setInterval(int msecs) override;
1056+ void start() override;
1057+ bool isSingleShot() const override;
1058+ void setSingleShot(bool value) override;
1059+private:
1060+ int m_interval;
1061+ bool m_singleShot;
1062+ SharedTimeSource m_timeSource;
1063+ qint64 m_nextTimeoutTime;
1064+};
1065+
1066+} // namespace qtmir
1067+
1068+#endif // QTMIR_TIMER_H
1069
1070=== added file 'src/modules/Unity/Application/timesource.cpp'
1071--- src/modules/Unity/Application/timesource.cpp 1970-01-01 00:00:00 +0000
1072+++ src/modules/Unity/Application/timesource.cpp 2016-02-03 11:35:51 +0000
1073@@ -0,0 +1,48 @@
1074+/*
1075+ * Copyright (C) 2015 - Canonical Ltd.
1076+ *
1077+ * This program is free software: you can redistribute it and/or modify it
1078+ * under the terms of the GNU Lesser General Public License, as
1079+ * published by the Free Software Foundation; either version 2.1 or 3.0
1080+ * of the License.
1081+ *
1082+ * This program is distributed in the hope that it will be useful, but
1083+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1084+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
1085+ * PURPOSE. See the applicable version of the GNU Lesser General Public
1086+ * License for more details.
1087+ *
1088+ * You should have received a copy of both the GNU Lesser General Public
1089+ * License along with this program. If not, see <http://www.gnu.org/licenses/>
1090+ *
1091+ */
1092+
1093+#include "timesource.h"
1094+
1095+#include <QElapsedTimer>
1096+
1097+namespace qtmir {
1098+class RealTimeSourcePrivate {
1099+public:
1100+ QElapsedTimer timer;
1101+};
1102+}
1103+
1104+using namespace qtmir;
1105+
1106+RealTimeSource::RealTimeSource()
1107+ : TimeSource()
1108+ , d(new RealTimeSourcePrivate)
1109+{
1110+ d->timer.start();
1111+}
1112+
1113+RealTimeSource::~RealTimeSource()
1114+{
1115+ delete d;
1116+}
1117+
1118+qint64 RealTimeSource::msecsSinceReference()
1119+{
1120+ return d->timer.elapsed();
1121+}
1122
1123=== added file 'src/modules/Unity/Application/timesource.h'
1124--- src/modules/Unity/Application/timesource.h 1970-01-01 00:00:00 +0000
1125+++ src/modules/Unity/Application/timesource.h 2016-02-03 11:35:51 +0000
1126@@ -0,0 +1,61 @@
1127+/*
1128+ * Copyright (C) 2015 Canonical Ltd.
1129+ *
1130+ * This program is free software: you can redistribute it and/or modify it
1131+ * under the terms of the GNU Lesser General Public License, as
1132+ * published by the Free Software Foundation; either version 2.1 or 3.0
1133+ * of the License.
1134+ *
1135+ * This program is distributed in the hope that it will be useful, but
1136+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1137+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
1138+ * PURPOSE. See the applicable version of the GNU Lesser General Public
1139+ * License for more details.
1140+ *
1141+ * You should have received a copy of both the GNU Lesser General Public
1142+ * License along with this program. If not, see <http://www.gnu.org/licenses/>
1143+ */
1144+
1145+#ifndef QTMIR_TIMESOURCE_H
1146+#define QTMIR_TIMESOURCE_H
1147+
1148+#include <QSharedPointer>
1149+
1150+namespace qtmir {
1151+/*
1152+ Interface for a time source.
1153+ */
1154+class TimeSource {
1155+public:
1156+ virtual ~TimeSource() {}
1157+ /* Returns the current time in milliseconds since some reference time in the past. */
1158+ virtual qint64 msecsSinceReference() = 0;
1159+};
1160+typedef QSharedPointer<TimeSource> SharedTimeSource;
1161+
1162+/*
1163+ Implementation of a time source
1164+ */
1165+class RealTimeSourcePrivate;
1166+class RealTimeSource : public TimeSource {
1167+public:
1168+ RealTimeSource();
1169+ virtual ~RealTimeSource();
1170+ qint64 msecsSinceReference() override;
1171+private:
1172+ RealTimeSourcePrivate *d;
1173+};
1174+
1175+/*
1176+ A fake time source, useful for tests
1177+ */
1178+class FakeTimeSource : public TimeSource {
1179+public:
1180+ FakeTimeSource() { m_msecsSinceReference = 0; }
1181+ qint64 msecsSinceReference() override { return m_msecsSinceReference; }
1182+ qint64 m_msecsSinceReference;
1183+};
1184+
1185+} // namespace qtmir
1186+
1187+#endif // QTMIR_TIMESOURCE_H
1188
1189=== renamed file 'src/modules/Unity/Application/upstart/applicationcontroller.cpp' => 'src/modules/Unity/Application/upstart/taskcontroller.cpp'
1190--- src/modules/Unity/Application/upstart/applicationcontroller.cpp 2015-05-27 21:07:45 +0000
1191+++ src/modules/Unity/Application/upstart/taskcontroller.cpp 2016-02-03 11:35:51 +0000
1192@@ -15,7 +15,7 @@
1193 *
1194 */
1195
1196-#include "applicationcontroller.h"
1197+#include "taskcontroller.h"
1198
1199 // qtmir
1200 #include <logging.h>
1201@@ -33,7 +33,7 @@
1202 namespace upstart
1203 {
1204
1205-struct ApplicationController::Private
1206+struct TaskController::Private
1207 {
1208 UbuntuAppLaunchAppObserver preStartCallback = nullptr;
1209 UbuntuAppLaunchAppObserver startedCallback = nullptr;
1210@@ -100,50 +100,50 @@
1211
1212 } // namespace
1213
1214-ApplicationController::ApplicationController()
1215- : qtmir::ApplicationController(),
1216+TaskController::TaskController()
1217+ : qtmir::TaskController(),
1218 impl(new Private())
1219 {
1220 impl->preStartCallback = [](const gchar * appId, gpointer userData) {
1221- auto thiz = static_cast<ApplicationController*>(userData);
1222- Q_EMIT(thiz->applicationAboutToBeStarted(toShortAppIdIfPossible(appId)));
1223+ auto thiz = static_cast<TaskController*>(userData);
1224+ Q_EMIT(thiz->processStarting(toShortAppIdIfPossible(appId)));
1225 };
1226
1227 impl->startedCallback = [](const gchar * appId, gpointer userData) {
1228- auto thiz = static_cast<ApplicationController*>(userData);
1229+ auto thiz = static_cast<TaskController*>(userData);
1230 Q_EMIT(thiz->applicationStarted(toShortAppIdIfPossible(appId)));
1231 };
1232
1233 impl->stopCallback = [](const gchar * appId, gpointer userData) {
1234- auto thiz = static_cast<ApplicationController*>(userData);
1235- Q_EMIT(thiz->applicationStopped(toShortAppIdIfPossible(appId)));
1236+ auto thiz = static_cast<TaskController*>(userData);
1237+ Q_EMIT(thiz->processStopped(toShortAppIdIfPossible(appId)));
1238 };
1239
1240 impl->focusCallback = [](const gchar * appId, gpointer userData) {
1241- auto thiz = static_cast<ApplicationController*>(userData);
1242- Q_EMIT(thiz->applicationFocusRequest(toShortAppIdIfPossible(appId)));
1243+ auto thiz = static_cast<TaskController*>(userData);
1244+ Q_EMIT(thiz->focusRequested(toShortAppIdIfPossible(appId)));
1245 };
1246
1247 impl->resumeCallback = [](const gchar * appId, gpointer userData) {
1248- auto thiz = static_cast<ApplicationController*>(userData);
1249- Q_EMIT(thiz->applicationResumeRequested(toShortAppIdIfPossible(appId)));
1250+ auto thiz = static_cast<TaskController*>(userData);
1251+ Q_EMIT(thiz->resumeRequested(toShortAppIdIfPossible(appId)));
1252 };
1253
1254 impl->pausedCallback = [](const gchar * appId, GPid *, gpointer userData) {
1255- auto thiz = static_cast<ApplicationController*>(userData);
1256- Q_EMIT(thiz->applicationPaused(toShortAppIdIfPossible(appId)));
1257+ auto thiz = static_cast<TaskController*>(userData);
1258+ Q_EMIT(thiz->processSuspended(toShortAppIdIfPossible(appId)));
1259 };
1260
1261 impl->failureCallback = [](const gchar * appId, UbuntuAppLaunchAppFailed failureType, gpointer userData) {
1262- ApplicationController::Error error;
1263+ TaskController::Error error;
1264 switch(failureType)
1265 {
1266- case UBUNTU_APP_LAUNCH_APP_FAILED_CRASH: error = ApplicationController::Error::APPLICATION_CRASHED;
1267- case UBUNTU_APP_LAUNCH_APP_FAILED_START_FAILURE: error = ApplicationController::Error::APPLICATION_FAILED_TO_START;
1268+ case UBUNTU_APP_LAUNCH_APP_FAILED_CRASH: error = TaskController::Error::APPLICATION_CRASHED;
1269+ case UBUNTU_APP_LAUNCH_APP_FAILED_START_FAILURE: error = TaskController::Error::APPLICATION_FAILED_TO_START;
1270 }
1271
1272- auto thiz = static_cast<ApplicationController*>(userData);
1273- Q_EMIT(thiz->applicationError(toShortAppIdIfPossible(appId), error));
1274+ auto thiz = static_cast<TaskController*>(userData);
1275+ Q_EMIT(thiz->processFailed(toShortAppIdIfPossible(appId), error));
1276 };
1277
1278 ubuntu_app_launch_observer_add_app_starting(impl->preStartCallback, this);
1279@@ -155,7 +155,7 @@
1280 ubuntu_app_launch_observer_add_app_failed(impl->failureCallback, this);
1281 }
1282
1283-ApplicationController::~ApplicationController()
1284+TaskController::~TaskController()
1285 {
1286 ubuntu_app_launch_observer_delete_app_starting(impl->preStartCallback, this);
1287 ubuntu_app_launch_observer_delete_app_started(impl->startedCallback, this);
1288@@ -166,30 +166,30 @@
1289 ubuntu_app_launch_observer_delete_app_failed(impl->failureCallback, this);
1290 }
1291
1292-pid_t ApplicationController::primaryPidForAppId(const QString& appId)
1293+pid_t TaskController::primaryPidForAppId(const QString& appId)
1294 {
1295 GPid pid = ubuntu_app_launch_get_primary_pid(toLongAppIdIfPossible(appId).toLatin1().constData());
1296 if (!pid)
1297- qDebug() << "ApplicationController::primaryPidForAppId FAILED to get PID for appId=" << appId;
1298+ qDebug() << "TaskController::primaryPidForAppId FAILED to get PID for appId=" << appId;
1299
1300 return pid;
1301 }
1302
1303-bool ApplicationController::appIdHasProcessId(pid_t pid, const QString& appId)
1304+bool TaskController::appIdHasProcessId(const QString& appId, pid_t pid)
1305 {
1306 return ubuntu_app_launch_pid_in_app_id(pid, toLongAppIdIfPossible(appId).toLatin1().constData());
1307 }
1308
1309-bool ApplicationController::stopApplicationWithAppId(const QString& appId)
1310+bool TaskController::stop(const QString& appId)
1311 {
1312 auto result = ubuntu_app_launch_stop_application(toLongAppIdIfPossible(appId).toLatin1().constData());
1313 if (!result)
1314- qDebug() << "ApplicationController::stopApplication FAILED to stop appId=" << appId;
1315+ qDebug() << "TaskController::stopApplication FAILED to stop appId=" << appId;
1316
1317 return result;
1318 }
1319
1320-bool ApplicationController::startApplicationWithAppIdAndArgs(const QString& appId, const QStringList& arguments)
1321+bool TaskController::start(const QString& appId, const QStringList& arguments)
1322 {
1323 // Convert arguments QStringList into format suitable for ubuntu-app-launch
1324 // The last item should be null, which is done by g_new0, we just don't fill it.
1325@@ -206,33 +206,33 @@
1326 g_strfreev(upstartArgs);
1327
1328 if (!result)
1329- qDebug() << "Application::Controller::startApplicationWithAppIdAndArgs FAILED to start appId" << appId;
1330+ qDebug() << "TaskController::start FAILED to start appId" << appId;
1331
1332 return result;
1333 }
1334
1335-bool ApplicationController::pauseApplicationWithAppId(const QString& appId)
1336+bool TaskController::suspend(const QString& appId)
1337 {
1338 auto result = ubuntu_app_launch_pause_application(toLongAppIdIfPossible(appId).toLatin1().constData());
1339 if (!result)
1340- qDebug() << "ApplicationController::pauseApplication FAILED to pause appId=" << appId;
1341+ qDebug() << "TaskController::pauseApplication FAILED to pause appId=" << appId;
1342
1343 return result;
1344 }
1345
1346-bool ApplicationController::resumeApplicationWithAppId(const QString& appId)
1347+bool TaskController::resume(const QString& appId)
1348 {
1349 auto result = ubuntu_app_launch_resume_application(toLongAppIdIfPossible(appId).toLatin1().constData());
1350 if (!result)
1351- qDebug() << "ApplicationController::resumeApplication FAILED to resume appId=" << appId;
1352+ qDebug() << "TaskController::resumeApplication FAILED to resume appId=" << appId;
1353
1354 return result;
1355 }
1356
1357
1358-QFileInfo ApplicationController::findDesktopFileForAppId(const QString &appId) const
1359+QFileInfo TaskController::findDesktopFileForAppId(const QString &appId) const
1360 {
1361- qCDebug(QTMIR_APPLICATIONS) << "ApplicationController::desktopFilePathForAppId - appId=" << appId;
1362+ qCDebug(QTMIR_APPLICATIONS) << "TaskController::desktopFilePathForAppId - appId=" << appId;
1363
1364 // Search for the correct desktop file using a simple heuristic
1365 int dashPos = -1;
1366
1367=== renamed file 'src/modules/Unity/Application/upstart/applicationcontroller.h' => 'src/modules/Unity/Application/upstart/taskcontroller.h'
1368--- src/modules/Unity/Application/upstart/applicationcontroller.h 2014-09-18 22:03:02 +0000
1369+++ src/modules/Unity/Application/upstart/taskcontroller.h 2016-02-03 11:35:51 +0000
1370@@ -1,5 +1,5 @@
1371 /*
1372- * Copyright (C) 2013 Canonical, Ltd.
1373+ * Copyright (C) 2013,2015 Canonical, Ltd.
1374 *
1375 * This program is free software: you can redistribute it and/or modify it under
1376 * the terms of the GNU Lesser General Public License version 3, as published by
1377@@ -15,30 +15,30 @@
1378 *
1379 */
1380
1381-#ifndef UPSTART_APPLICATION_CONTROLLER_H
1382-#define UPSTART_APPLICATION_CONTROLLER_H
1383+#ifndef QTMIR_UPSTART_TASK_CONTROLLER_H
1384+#define QTMIR_UPSTART_TASK_CONTROLLER_H
1385
1386-#include "../applicationcontroller.h"
1387+#include "../taskcontroller.h"
1388
1389 namespace qtmir
1390 {
1391 namespace upstart
1392 {
1393
1394-class ApplicationController : public qtmir::ApplicationController
1395+class TaskController : public qtmir::TaskController
1396 {
1397 public:
1398- ApplicationController();
1399- ~ApplicationController();
1400+ TaskController();
1401+ ~TaskController();
1402
1403 pid_t primaryPidForAppId(const QString& appId) override;
1404- bool appIdHasProcessId(pid_t pid, const QString& appId) override;
1405-
1406- bool stopApplicationWithAppId(const QString& appId) override;
1407- bool startApplicationWithAppIdAndArgs(const QString& appId, const QStringList& arguments) override;
1408-
1409- bool pauseApplicationWithAppId(const QString& appId) override;
1410- bool resumeApplicationWithAppId(const QString& appId) override;
1411+ bool appIdHasProcessId(const QString& appId, pid_t pid) override;
1412+
1413+ bool stop(const QString& appId) override;
1414+ bool start(const QString& appId, const QStringList& arguments) override;
1415+
1416+ bool suspend(const QString& appId) override;
1417+ bool resume(const QString& appId) override;
1418
1419 QFileInfo findDesktopFileForAppId(const QString &appId) const override;
1420
1421@@ -50,4 +50,4 @@
1422 } // namespace upstart
1423 } // namespace qtmir
1424
1425-#endif // UPSTART_APPLICATION_CONTROLLER_H
1426+#endif // QTMIR_UPSTART_TASK_CONTROLLER_H
1427
1428=== modified file 'src/platforms/mirserver/CMakeLists.txt'
1429--- src/platforms/mirserver/CMakeLists.txt 2015-12-07 10:51:03 +0000
1430+++ src/platforms/mirserver/CMakeLists.txt 2016-02-03 11:35:51 +0000
1431@@ -69,6 +69,7 @@
1432 services.cpp
1433 ubuntutheme.cpp
1434 clipboard.cpp
1435+ sizehints.cpp
1436 tileddisplayconfigurationpolicy.cpp
1437 tracepoints.c
1438 # We need to run moc on these headers
1439
1440=== modified file 'src/platforms/mirserver/mirserver.cpp'
1441--- src/platforms/mirserver/mirserver.cpp 2015-11-10 11:07:23 +0000
1442+++ src/platforms/mirserver/mirserver.cpp 2016-02-03 11:35:51 +0000
1443@@ -104,10 +104,13 @@
1444 return std::make_shared<MirServerStatusListener>();
1445 });
1446
1447- override_the_window_manager_builder([this](mir::shell::FocusController* focus_controller)
1448+ override_the_window_manager_builder([this](mir::shell::FocusController*)
1449 -> std::shared_ptr<mir::shell::WindowManager>
1450 {
1451- return {MirWindowManager::create(focus_controller, the_shell_display_layout())};
1452+ auto windowManager = MirWindowManager::create(the_shell_display_layout(),
1453+ std::static_pointer_cast<::SessionListener>(the_session_listener()));
1454+ m_windowManager = windowManager;
1455+ return windowManager;
1456 });
1457
1458 wrap_display_configuration_policy(
1459@@ -193,3 +196,8 @@
1460 std::weak_ptr<MirShell> m_shell = the_shell();
1461 return m_shell.lock().get();
1462 }
1463+
1464+MirWindowManager *MirServer::windowManager()
1465+{
1466+ return m_windowManager.lock().get();
1467+}
1468
1469=== modified file 'src/platforms/mirserver/mirserver.h'
1470--- src/platforms/mirserver/mirserver.h 2015-08-20 10:16:54 +0000
1471+++ src/platforms/mirserver/mirserver.h 2016-02-03 11:35:51 +0000
1472@@ -27,6 +27,7 @@
1473 using MirShell = mir::shell::Shell;
1474 class PromptSessionListener;
1475 class ScreenController;
1476+class MirWindowManager;
1477
1478 // We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing)
1479 // calling initialization functions before MirServer is constructed.
1480@@ -61,11 +62,12 @@
1481 SessionAuthorizer *sessionAuthorizer();
1482 SessionListener *sessionListener();
1483 PromptSessionListener *promptSessionListener();
1484+ MirWindowManager *windowManager();
1485 MirShell *shell();
1486
1487 private:
1488 std::weak_ptr<MirShell> m_shell;
1489- std::shared_ptr<QtEventFeeder> m_qtEventFeeder;
1490+ std::weak_ptr<MirWindowManager> m_windowManager;
1491 const QSharedPointer<ScreenController> m_screenController;
1492 };
1493
1494
1495=== modified file 'src/platforms/mirserver/mirwindowmanager.cpp'
1496--- src/platforms/mirserver/mirwindowmanager.cpp 2015-12-02 12:27:45 +0000
1497+++ src/platforms/mirserver/mirwindowmanager.cpp 2016-02-03 11:35:51 +0000
1498@@ -16,6 +16,7 @@
1499
1500 #include "mirwindowmanager.h"
1501 #include "logging.h"
1502+#include "surfaceobserver.h"
1503 #include "tracepoints.h" // generated from tracepoints.tp
1504
1505 #include <mir/geometry/rectangle.h>
1506@@ -24,6 +25,8 @@
1507 #include <mir/scene/surface.h>
1508 #include <mir/shell/display_layout.h>
1509
1510+#include <QMutexLocker>
1511+
1512 namespace ms = mir::scene;
1513
1514 namespace
1515@@ -32,7 +35,8 @@
1516 {
1517 public:
1518
1519- MirWindowManagerImpl(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
1520+ MirWindowManagerImpl(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout,
1521+ std::shared_ptr<::SessionListener> sessionListener);
1522
1523 void add_session(std::shared_ptr<mir::scene::Session> const& session) override;
1524
1525@@ -75,12 +79,15 @@
1526
1527 private:
1528 std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
1529+ std::shared_ptr<::SessionListener> m_sessionListener;
1530 };
1531
1532 }
1533
1534-MirWindowManagerImpl::MirWindowManagerImpl(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
1535- m_displayLayout{displayLayout}
1536+MirWindowManagerImpl::MirWindowManagerImpl(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout,
1537+ std::shared_ptr<::SessionListener> sessionListener) :
1538+ m_displayLayout{displayLayout},
1539+ m_sessionListener(sessionListener)
1540 {
1541 qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManagerImpl::MirWindowManagerImpl";
1542 }
1543@@ -100,16 +107,28 @@
1544 {
1545 tracepoint(qtmirserver, surfacePlacementStart);
1546
1547- // TODO: Callback unity8 so that it can make a decision on that.
1548- // unity8 must bear in mind that the called function will be on a Mir thread though.
1549- // The QPA shouldn't be deciding for itself on such things.
1550+ m_sessionListener->surfaceAboutToBeCreated(*session.get(), qtmir::SizeHints(requestParameters));
1551
1552+ QSize initialSize;
1553+ // can be connected to via Qt::BlockingQueuedConnection to alter surface initial size
1554+ {
1555+ int surfaceType = requestParameters.type.is_set() ? requestParameters.type.value() : -1;
1556+ Q_EMIT sessionAboutToCreateSurface(session, surfaceType, initialSize);
1557+ }
1558 ms::SurfaceCreationParameters placedParameters = requestParameters;
1559
1560- // Just make it fullscreen for now
1561- mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
1562- m_displayLayout->size_to_output(rect);
1563- placedParameters.size = rect.size;
1564+ if (initialSize.isValid()) {
1565+ placedParameters.size.width = mir::geometry::Width(initialSize.width());
1566+ placedParameters.size.height = mir::geometry::Height(initialSize.height());
1567+ } else {
1568+ qCWarning(QTMIR_MIR_MESSAGES) << "MirWindowManagerImpl::add_surface(): didn't get a initial surface"
1569+ " size from shell. Falling back to fullscreen placement";
1570+ // This is bad. Fallback to fullscreen
1571+ mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
1572+ m_displayLayout->size_to_output(rect);
1573+ placedParameters.size = rect.size;
1574+ }
1575+
1576
1577 qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManagerImpl::add_surface(): size requested ("
1578 << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("
1579@@ -172,11 +191,17 @@
1580 if (modifications.name.is_set()) {
1581 surface->rename(modifications.name.value());
1582 }
1583+
1584+ QMutexLocker(&SurfaceObserver::mutex);
1585+ SurfaceObserver *observer = SurfaceObserver::observerForSurface(surface.get());
1586+ if (observer) {
1587+ observer->notifySizeHintChanges(modifications);
1588+ }
1589 }
1590
1591-std::unique_ptr<MirWindowManager> MirWindowManager::create(
1592- mir::shell::FocusController* /*focus_controller*/,
1593- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout)
1594+std::shared_ptr<MirWindowManager> MirWindowManager::create(
1595+ const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout,
1596+ std::shared_ptr<::SessionListener> sessionListener)
1597 {
1598- return std::make_unique<MirWindowManagerImpl>(displayLayout);
1599+ return std::make_shared<MirWindowManagerImpl>(displayLayout, sessionListener);
1600 }
1601
1602=== modified file 'src/platforms/mirserver/mirwindowmanager.h'
1603--- src/platforms/mirserver/mirwindowmanager.h 2015-11-19 12:55:57 +0000
1604+++ src/platforms/mirserver/mirwindowmanager.h 2016-02-03 11:35:51 +0000
1605@@ -19,7 +19,10 @@
1606
1607 #include <mir/shell/window_manager.h>
1608
1609+#include "sessionlistener.h"
1610+
1611 #include <QObject>
1612+#include <QSize>
1613
1614 namespace mir {
1615 namespace shell {
1616@@ -33,10 +36,14 @@
1617 Q_OBJECT
1618
1619 public:
1620+ static std::shared_ptr<MirWindowManager> create(
1621+ const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout,
1622+ std::shared_ptr<::SessionListener> sessionListener);
1623
1624- static std::unique_ptr<MirWindowManager> create(
1625- mir::shell::FocusController* focus_controller,
1626- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
1627+Q_SIGNALS:
1628+ // requires Qt::BlockingQueuedConnection!!
1629+ void sessionAboutToCreateSurface(const std::shared_ptr<mir::scene::Session> &session,
1630+ int type, QSize &size);
1631 };
1632
1633 #endif /* QPAMIRSERVER_WINDOW_MANAGER_H */
1634
1635=== modified file 'src/platforms/mirserver/sessionlistener.cpp'
1636--- src/platforms/mirserver/sessionlistener.cpp 2015-08-11 12:08:32 +0000
1637+++ src/platforms/mirserver/sessionlistener.cpp 2016-02-03 11:35:51 +0000
1638@@ -34,6 +34,7 @@
1639 qRegisterMetaType<std::shared_ptr<ms::Session>>("std::shared_ptr<mir::scene::Session>");
1640 qRegisterMetaType<std::shared_ptr<ms::Surface>>("std::shared_ptr<mir::scene::Surface>");
1641 qRegisterMetaType<std::shared_ptr<SurfaceObserver>>("std::shared_ptr<SurfaceObserver>");
1642+ qRegisterMetaType<qtmir::SizeHints>();
1643 }
1644
1645 SessionListener::~SessionListener()
1646@@ -73,8 +74,12 @@
1647 qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::surface_created - this=" << this << "session=" << &session
1648 << "surface=" << surface.get();
1649 std::shared_ptr<SurfaceObserver> surfaceObserver = std::make_shared<SurfaceObserver>();
1650+ SurfaceObserver::registerObserverForSurface(surfaceObserver.get(), surface.get());
1651 surface->add_observer(surfaceObserver);
1652- Q_EMIT sessionCreatedSurface(&session, surface, surfaceObserver);
1653+
1654+ qtmir::SizeHints sizeHints = m_sizeHintsForNewSurface.take(&session);
1655+
1656+ Q_EMIT sessionCreatedSurface(&session, surface, surfaceObserver, sizeHints);
1657 }
1658
1659 void SessionListener::destroying_surface(ms::Session& session, std::shared_ptr<ms::Surface> const& surface)
1660@@ -84,3 +89,8 @@
1661 << "surface=" << surface.get();
1662 Q_EMIT sessionDestroyingSurface(&session, surface);
1663 }
1664+
1665+void SessionListener::surfaceAboutToBeCreated(mir::scene::Session& session, qtmir::SizeHints sizeHints)
1666+{
1667+ m_sizeHintsForNewSurface[&session] = sizeHints;
1668+}
1669
1670=== modified file 'src/platforms/mirserver/sessionlistener.h'
1671--- src/platforms/mirserver/sessionlistener.h 2015-08-31 09:51:28 +0000
1672+++ src/platforms/mirserver/sessionlistener.h 2016-02-03 11:35:51 +0000
1673@@ -18,10 +18,13 @@
1674 #define SESSIONLISTENER_H
1675
1676 #include <QObject>
1677+#include <QMap>
1678
1679 #include "mir/scene/session_listener.h"
1680 #include "mir/scene/session.h"
1681
1682+#include "sizehints.h"
1683+
1684 class SurfaceObserver;
1685
1686 class SessionListener : public QObject, public mir::scene::SessionListener
1687@@ -39,6 +42,8 @@
1688 void surface_created(mir::scene::Session&, std::shared_ptr<mir::scene::Surface> const&) override;
1689 void destroying_surface(mir::scene::Session&, std::shared_ptr<mir::scene::Surface> const&) override;
1690
1691+ void surfaceAboutToBeCreated(mir::scene::Session&, qtmir::SizeHints sizeHints);
1692+
1693 Q_SIGNALS:
1694 void sessionStarting(std::shared_ptr<mir::scene::Session> const& session);
1695 void sessionStopping(std::shared_ptr<mir::scene::Session> const& session);
1696@@ -47,8 +52,12 @@
1697
1698 void sessionCreatedSurface(mir::scene::Session const*,
1699 std::shared_ptr<mir::scene::Surface> const&,
1700- std::shared_ptr<SurfaceObserver> const&);
1701+ std::shared_ptr<SurfaceObserver> const&,
1702+ qtmir::SizeHints);
1703 void sessionDestroyingSurface(mir::scene::Session const*, std::shared_ptr<mir::scene::Surface> const&);
1704+
1705+private:
1706+ QMap<mir::scene::Session*, qtmir::SizeHints> m_sizeHintsForNewSurface;
1707 };
1708
1709 #endif // SESSIONLISTENER_H
1710
1711=== added file 'src/platforms/mirserver/sizehints.cpp'
1712--- src/platforms/mirserver/sizehints.cpp 1970-01-01 00:00:00 +0000
1713+++ src/platforms/mirserver/sizehints.cpp 2016-02-03 11:35:51 +0000
1714@@ -0,0 +1,44 @@
1715+/*
1716+ * Copyright (C) 2015 Canonical, Ltd.
1717+ *
1718+ * This program is free software: you can redistribute it and/or modify it under
1719+ * the terms of the GNU Lesser General Public License version 3, as published by
1720+ * the Free Software Foundation.
1721+ *
1722+ * This program is distributed in the hope that it will be useful, but WITHOUT
1723+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1724+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1725+ * Lesser General Public License for more details.
1726+ *
1727+ * You should have received a copy of the GNU Lesser General Public License
1728+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1729+ */
1730+
1731+#include <mir/scene/surface_creation_parameters.h>
1732+
1733+#include "sizehints.h"
1734+
1735+using namespace qtmir;
1736+
1737+SizeHints::SizeHints(const mir::scene::SurfaceCreationParameters &params)
1738+{
1739+ minWidth = params.min_width.is_set() ? params.min_width.value().as_int() : 0;
1740+ maxWidth = params.max_width.is_set() ? params.max_width.value().as_int() : 0;
1741+
1742+ minHeight = params.min_height.is_set() ? params.min_height.value().as_int() : 0;
1743+ maxHeight = params.max_height.is_set() ? params.max_height.value().as_int() : 0;
1744+
1745+ widthIncrement = params.width_inc.is_set() ? params.width_inc.value().as_int() : 0;
1746+ heightIncrement = params.height_inc.is_set() ? params.height_inc.value().as_int() : 0;
1747+}
1748+
1749+QString SizeHints::toString() const
1750+{
1751+ return QString("SizeHints(minW=%1,minH=%2,maxW=%3,maxH=%4,wIncr=%5,hInc=%6)")
1752+ .arg(minWidth)
1753+ .arg(minHeight)
1754+ .arg(maxWidth)
1755+ .arg(maxHeight)
1756+ .arg(widthIncrement)
1757+ .arg(heightIncrement);
1758+}
1759
1760=== added file 'src/platforms/mirserver/sizehints.h'
1761--- src/platforms/mirserver/sizehints.h 1970-01-01 00:00:00 +0000
1762+++ src/platforms/mirserver/sizehints.h 2016-02-03 11:35:51 +0000
1763@@ -0,0 +1,52 @@
1764+/*
1765+ * Copyright (C) 2015 Canonical, Ltd.
1766+ *
1767+ * This program is free software: you can redistribute it and/or modify it under
1768+ * the terms of the GNU Lesser General Public License version 3, as published by
1769+ * the Free Software Foundation.
1770+ *
1771+ * This program is distributed in the hope that it will be useful, but WITHOUT
1772+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1773+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1774+ * Lesser General Public License for more details.
1775+ *
1776+ * You should have received a copy of the GNU Lesser General Public License
1777+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1778+ */
1779+
1780+#ifndef QTMIR_SIZEHINTS_H
1781+#define QTMIR_SIZEHINTS_H
1782+
1783+#include <QMetaType>
1784+#include <QString>
1785+
1786+namespace mir {
1787+ namespace scene {
1788+ class SurfaceCreationParameters;
1789+ }
1790+}
1791+
1792+namespace qtmir {
1793+
1794+class SizeHints {
1795+public:
1796+ SizeHints() {}
1797+ SizeHints(const mir::scene::SurfaceCreationParameters&);
1798+
1799+ QString toString() const;
1800+
1801+ int minWidth{0};
1802+ int maxWidth{0};
1803+
1804+ int minHeight{0};
1805+ int maxHeight{0};
1806+
1807+ int widthIncrement{0};
1808+ int heightIncrement{0};
1809+};
1810+
1811+} // namespace qtmir
1812+
1813+Q_DECLARE_METATYPE(qtmir::SizeHints)
1814+
1815+#endif // QTMIR_SIZEHINTS_H
1816
1817=== modified file 'src/platforms/mirserver/surfaceobserver.cpp'
1818--- src/platforms/mirserver/surfaceobserver.cpp 2015-12-04 14:02:54 +0000
1819+++ src/platforms/mirserver/surfaceobserver.cpp 2016-02-03 11:35:51 +0000
1820@@ -18,11 +18,17 @@
1821
1822 #include "namedcursor.h"
1823
1824+#include <QImage>
1825 #include <QMetaObject>
1826-#include <QImage>
1827+#include <QMutableMapIterator>
1828+#include <QMutexLocker>
1829 #include <QPixmap>
1830
1831 #include <mir/geometry/size.h>
1832+#include <mir/shell/surface_specification.h>
1833+
1834+QMap<const mir::scene::Surface*, SurfaceObserver*> SurfaceObserver::m_surfaceToObserverMap;
1835+QMutex SurfaceObserver::mutex;
1836
1837 SurfaceObserver::SurfaceObserver()
1838 : m_listener(nullptr)
1839@@ -52,6 +58,19 @@
1840 m_cursorNameToShape["dnd-link"] = Qt::DragLinkCursor;
1841 }
1842
1843+SurfaceObserver::~SurfaceObserver()
1844+{
1845+ QMutexLocker locker(&mutex);
1846+ QMutableMapIterator<const mir::scene::Surface*, SurfaceObserver*> i(m_surfaceToObserverMap);
1847+ while (i.hasNext()) {
1848+ i.next();
1849+ if (i.value() == this) {
1850+ i.remove();
1851+ return;
1852+ }
1853+ }
1854+}
1855+
1856 void SurfaceObserver::setListener(QObject *listener)
1857 {
1858 m_listener = listener;
1859@@ -88,6 +107,44 @@
1860 void SurfaceObserver::resized_to(mir::geometry::Size const&size)
1861 {
1862 Q_EMIT resized(QSize(size.width.as_int(), size.height.as_int()));
1863+
1864+}
1865+
1866+void SurfaceObserver::notifySizeHintChanges(const mir::shell::SurfaceSpecification &modifications)
1867+{
1868+ if (modifications.min_width.is_set()) {
1869+ Q_EMIT minimumWidthChanged(modifications.min_width.value().as_int());
1870+ }
1871+ if (modifications.min_height.is_set()) {
1872+ Q_EMIT minimumHeightChanged(modifications.min_height.value().as_int());
1873+ }
1874+ if (modifications.max_width.is_set()) {
1875+ Q_EMIT maximumWidthChanged(modifications.max_width.value().as_int());
1876+ }
1877+ if (modifications.max_height.is_set()) {
1878+ Q_EMIT maximumHeightChanged(modifications.max_height.value().as_int());
1879+ }
1880+ if (modifications.width_inc.is_set()) {
1881+ Q_EMIT widthIncrementChanged(modifications.width_inc.value().as_int());
1882+ }
1883+ if (modifications.height_inc.is_set()) {
1884+ Q_EMIT heightIncrementChanged(modifications.height_inc.value().as_int());
1885+ }
1886+}
1887+
1888+SurfaceObserver *SurfaceObserver::observerForSurface(const mir::scene::Surface *surface)
1889+{
1890+ if (m_surfaceToObserverMap.contains(surface)) {
1891+ return m_surfaceToObserverMap.value(surface);
1892+ } else {
1893+ return nullptr;
1894+ }
1895+}
1896+
1897+void SurfaceObserver::registerObserverForSurface(SurfaceObserver *observer, const mir::scene::Surface *surface)
1898+{
1899+ QMutexLocker locker(&mutex);
1900+ m_surfaceToObserverMap[surface] = observer;
1901 }
1902
1903 void SurfaceObserver::cursor_image_set_to(const mir::graphics::CursorImage &cursorImage)
1904
1905=== modified file 'src/platforms/mirserver/surfaceobserver.h'
1906--- src/platforms/mirserver/surfaceobserver.h 2016-01-24 02:51:34 +0000
1907+++ src/platforms/mirserver/surfaceobserver.h 2016-02-03 11:35:51 +0000
1908@@ -21,15 +21,26 @@
1909 #include <QCursor>
1910 #include <QObject>
1911 #include <QMap>
1912+#include <QMutex>
1913 #include <QSize>
1914 #include <mir/scene/surface_observer.h>
1915
1916+namespace mir {
1917+ namespace scene {
1918+ class Surface;
1919+ }
1920+ namespace shell {
1921+ class SurfaceSpecification;
1922+ }
1923+}
1924+
1925 class SurfaceObserver : public QObject, public mir::scene::SurfaceObserver
1926 {
1927 Q_OBJECT
1928
1929 public:
1930 SurfaceObserver();
1931+ virtual ~SurfaceObserver();
1932
1933 void setListener(QObject *listener);
1934
1935@@ -52,6 +63,12 @@
1936 void renamed(char const * name) override;
1937 void cursor_image_removed() override;
1938
1939+ void notifySizeHintChanges(const mir::shell::SurfaceSpecification&);
1940+
1941+ static SurfaceObserver *observerForSurface(const mir::scene::Surface *surface);
1942+ static void registerObserverForSurface(SurfaceObserver *observer, const mir::scene::Surface *surface);
1943+ static QMutex mutex;
1944+
1945 Q_SIGNALS:
1946 void attributeChanged(const MirSurfaceAttrib attribute, const int value);
1947 void framesPosted();
1948@@ -59,11 +76,19 @@
1949 void nameChanged(const QString &name);
1950 void cursorChanged(const QCursor &cursor);
1951
1952+ void minimumWidthChanged(int);
1953+ void minimumHeightChanged(int);
1954+ void maximumWidthChanged(int);
1955+ void maximumHeightChanged(int);
1956+ void widthIncrementChanged(int);
1957+ void heightIncrementChanged(int);
1958+
1959 private:
1960 QCursor createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage);
1961 QObject *m_listener;
1962 bool m_framesPosted;
1963 QMap<QByteArray, Qt::CursorShape> m_cursorNameToShape;
1964+ static QMap<const mir::scene::Surface*, SurfaceObserver*> m_surfaceToObserverMap;
1965 };
1966
1967 #endif
1968
1969=== modified file 'tests/CMakeLists.txt'
1970--- tests/CMakeLists.txt 2014-12-03 08:56:35 +0000
1971+++ tests/CMakeLists.txt 2016-02-03 11:35:51 +0000
1972@@ -1,4 +1,5 @@
1973 find_package(GMock)
1974
1975+add_subdirectory(framework)
1976 add_subdirectory(mirserver)
1977 add_subdirectory(modules)
1978
1979=== removed directory 'tests/common'
1980=== renamed directory 'tests/modules/common' => 'tests/framework'
1981=== added file 'tests/framework/CMakeLists.txt'
1982--- tests/framework/CMakeLists.txt 1970-01-01 00:00:00 +0000
1983+++ tests/framework/CMakeLists.txt 2016-02-03 11:35:51 +0000
1984@@ -0,0 +1,45 @@
1985+include_directories(
1986+ ${APPLICATION_API_INCLUDE_DIRS}
1987+ ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
1988+ ${CMAKE_SOURCE_DIR}/src/modules
1989+ ${MIRSERVER_INCLUDE_DIRS}
1990+ ${MIRRENDERERGLDEV_INCLUDE_DIRS}
1991+
1992+ ${Qt5Quick_INCLUDE_DIRS}
1993+ ${Qt5DBus_INCLUDE_DIRS}
1994+)
1995+
1996+set(QTMIR_TEST_PRIVATE_SRC
1997+ fake_desktopfilereader.cpp
1998+ fake_mirsurface.cpp
1999+ fake_session.cpp
2000+ mock_task_controller.cpp
2001+ mock_desktop_file_reader.cpp
2002+ mock_display.cpp
2003+ mock_display_configuration.cpp
2004+ mock_gl_display_buffer.cpp
2005+ mock_main_loop.cpp
2006+ mock_mir_session.cpp
2007+ mock_proc_info.cpp
2008+ mock_prompt_session.cpp
2009+ mock_prompt_session_manager.cpp
2010+ mock_renderable.cpp
2011+ mock_session.cpp
2012+ mock_settings.cpp
2013+ mock_shared_wakelock.cpp
2014+ mock_surface.cpp
2015+ stub_input_channel.cpp
2016+ stub_scene_surface.cpp
2017+ qtmir_test.cpp
2018+)
2019+
2020+add_library(qtmir-test-framework-static STATIC
2021+ ${QTMIR_TEST_PRIVATE_SRC}
2022+)
2023+
2024+target_link_libraries(
2025+ qtmir-test-framework-static
2026+
2027+ ${GTEST_BOTH_LIBRARIES}
2028+ ${GMOCK_LIBRARIES}
2029+)
2030
2031=== added file 'tests/framework/fake_desktopfilereader.cpp'
2032--- tests/framework/fake_desktopfilereader.cpp 1970-01-01 00:00:00 +0000
2033+++ tests/framework/fake_desktopfilereader.cpp 2016-02-03 11:35:51 +0000
2034@@ -0,0 +1,76 @@
2035+/*
2036+ * Copyright (C) 2015 Canonical, Ltd.
2037+ *
2038+ * This program is free software: you can redistribute it and/or modify it under
2039+ * the terms of the GNU Lesser General Public License version 3, as published by
2040+ * the Free Software Foundation.
2041+ *
2042+ * This program is distributed in the hope that it will be useful, but WITHOUT
2043+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2044+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2045+ * Lesser General Public License for more details.
2046+ *
2047+ * You should have received a copy of the GNU Lesser General Public License
2048+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2049+ */
2050+
2051+#include "fake_desktopfilereader.h"
2052+
2053+#include <QDebug>
2054+
2055+namespace qtmir
2056+{
2057+
2058+FakeDesktopFileReader::FakeDesktopFileReader(const QString &appId)
2059+ : DesktopFileReader()
2060+ , m_appId(appId)
2061+{
2062+}
2063+
2064+FakeDesktopFileReader::FakeDesktopFileReader()
2065+ : DesktopFileReader()
2066+ , m_appId("foo-app")
2067+{
2068+}
2069+
2070+FakeDesktopFileReader::~FakeDesktopFileReader()
2071+{
2072+}
2073+
2074+QString FakeDesktopFileReader::file() const { return m_appId + ".desktop"; }
2075+
2076+QString FakeDesktopFileReader::appId() const { return m_appId; }
2077+
2078+QString FakeDesktopFileReader::name() const { return QString(); }
2079+
2080+QString FakeDesktopFileReader::comment() const { return QString(); }
2081+
2082+QString FakeDesktopFileReader::icon() const { return QString(); }
2083+
2084+QString FakeDesktopFileReader::exec() const { return QString(); }
2085+
2086+QString FakeDesktopFileReader::path() const { return QString(); }
2087+
2088+QString FakeDesktopFileReader::stageHint() const { return QString(); }
2089+
2090+QString FakeDesktopFileReader::splashTitle() const { return QString(); }
2091+
2092+QString FakeDesktopFileReader::splashImage() const { return QString(); }
2093+
2094+QString FakeDesktopFileReader::splashShowHeader() const { return QString(); }
2095+
2096+QString FakeDesktopFileReader::splashColor() const { return QString(); }
2097+
2098+QString FakeDesktopFileReader::splashColorHeader() const { return QString(); }
2099+
2100+QString FakeDesktopFileReader::splashColorFooter() const { return QString(); }
2101+
2102+Qt::ScreenOrientations FakeDesktopFileReader::supportedOrientations() const { return Qt::PortraitOrientation; }
2103+
2104+bool FakeDesktopFileReader::rotatesWindowContents() const { return false; }
2105+
2106+bool FakeDesktopFileReader::isTouchApp() const { return true; }
2107+
2108+bool FakeDesktopFileReader::loaded() const { return true; }
2109+
2110+} // namespace qtmir
2111
2112=== modified file 'tests/framework/fake_desktopfilereader.h'
2113--- tests/modules/common/fake_desktopfilereader.h 2015-09-28 20:11:39 +0000
2114+++ tests/framework/fake_desktopfilereader.h 2016-02-03 11:35:51 +0000
2115@@ -17,33 +17,35 @@
2116 #ifndef FAKE_DESKTOPFILEREADER_H
2117 #define FAKE_DESKTOPFILEREADER_H
2118
2119+#include <Unity/Application/desktopfilereader.h>
2120+
2121 namespace qtmir {
2122
2123 class FakeDesktopFileReader : public qtmir::DesktopFileReader
2124 {
2125 public:
2126- FakeDesktopFileReader() : DesktopFileReader()
2127- , m_appId("foo-app")
2128- {}
2129+ FakeDesktopFileReader(const QString &appId);
2130+ FakeDesktopFileReader();
2131+ virtual ~FakeDesktopFileReader();
2132
2133- QString file() const override { return QString(); }
2134- QString appId() const override { return m_appId; }
2135- QString name() const override { return QString(); }
2136- QString comment() const override { return QString(); }
2137- QString icon() const override { return QString(); }
2138- QString exec() const override { return QString(); }
2139- QString path() const override { return QString(); }
2140- QString stageHint() const override { return QString(); }
2141- QString splashTitle() const override { return QString(); }
2142- QString splashImage() const override { return QString(); }
2143- QString splashShowHeader() const override { return QString(); }
2144- QString splashColor() const override { return QString(); }
2145- QString splashColorHeader() const override { return QString(); }
2146- QString splashColorFooter() const override { return QString(); }
2147- Qt::ScreenOrientations supportedOrientations() const override { return Qt::PortraitOrientation; }
2148- bool rotatesWindowContents() const override { return false; }
2149- bool isTouchApp() const override { return true; }
2150- bool loaded() const override { return true; }
2151+ QString file() const override;
2152+ QString appId() const override;
2153+ QString name() const override;
2154+ QString comment() const override;
2155+ QString icon() const override;
2156+ QString exec() const override;
2157+ QString path() const override;
2158+ QString stageHint() const override;
2159+ QString splashTitle() const override;
2160+ QString splashImage() const override;
2161+ QString splashShowHeader() const override;
2162+ QString splashColor() const override;
2163+ QString splashColorHeader() const override;
2164+ QString splashColorFooter() const override;
2165+ Qt::ScreenOrientations supportedOrientations() const override;
2166+ bool rotatesWindowContents() const override;
2167+ bool isTouchApp() const override;
2168+ bool loaded() const override;
2169
2170 QString m_appId;
2171 };
2172
2173=== renamed file 'tests/common/fake_displayconfigurationoutput.h' => 'tests/framework/fake_displayconfigurationoutput.h'
2174=== added file 'tests/framework/fake_mirsurface.cpp'
2175--- tests/framework/fake_mirsurface.cpp 1970-01-01 00:00:00 +0000
2176+++ tests/framework/fake_mirsurface.cpp 2016-02-03 11:35:51 +0000
2177@@ -0,0 +1,212 @@
2178+/*
2179+ * Copyright (C) 2015 Canonical, Ltd.
2180+ *
2181+ * This program is free software: you can redistribute it and/or modify it under
2182+ * the terms of the GNU Lesser General Public License version 3, as published by
2183+ * the Free Software Foundation.
2184+ *
2185+ * This program is distributed in the hope that it will be useful, but WITHOUT
2186+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2187+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2188+ * Lesser General Public License for more details.
2189+ *
2190+ * You should have received a copy of the GNU Lesser General Public License
2191+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2192+ */
2193+
2194+#include "fake_mirsurface.h"
2195+
2196+namespace qtmir
2197+{
2198+
2199+FakeMirSurface::TouchEvent::TouchEvent(Qt::KeyboardModifiers mods,
2200+ const QList<QTouchEvent::TouchPoint> &points,
2201+ Qt::TouchPointStates states,
2202+ ulong timestamp)
2203+ : keyboardModifiers(mods)
2204+ , touchPoints(points)
2205+ , states(states)
2206+ , timestamp(timestamp)
2207+{
2208+}
2209+
2210+FakeMirSurface::TouchEvent::~TouchEvent()
2211+{
2212+}
2213+
2214+FakeMirSurface::FakeMirSurface(QObject *parent)
2215+ : MirSurfaceInterface(parent)
2216+ , m_isFirstFrameDrawn(false)
2217+ , m_isFrameDropperRunning(true)
2218+ , m_live(true)
2219+ , m_state(Mir::RestoredState)
2220+ , m_orientationAngle(Mir::Angle0)
2221+ , m_visible(true)
2222+ , m_focused(false)
2223+{
2224+}
2225+
2226+FakeMirSurface::~FakeMirSurface()
2227+{
2228+}
2229+
2230+Mir::Type FakeMirSurface::type() const { return Mir::NormalType; }
2231+
2232+QString FakeMirSurface::name() const { return QString("Fake MirSurface"); }
2233+
2234+QSize FakeMirSurface::size() const { return m_size; }
2235+
2236+void FakeMirSurface::resize(int width, int height)
2237+{
2238+ if (m_size.width() != width || m_size.height() != height) {
2239+ m_size.setWidth(width);
2240+ m_size.setHeight(height);
2241+ Q_EMIT sizeChanged(m_size);
2242+ }
2243+}
2244+
2245+void FakeMirSurface::resize(const QSize &size) { resize(size.width(), size.height()); }
2246+
2247+Mir::State FakeMirSurface::state() const { return m_state; }
2248+
2249+void FakeMirSurface::setState(Mir::State qmlState)
2250+{
2251+ if (qmlState != m_state) {
2252+ m_state = qmlState;
2253+ Q_EMIT stateChanged(m_state);
2254+ }
2255+}
2256+
2257+bool FakeMirSurface::live() const { return m_live; }
2258+
2259+bool FakeMirSurface::visible() const { return m_visible; }
2260+
2261+Mir::OrientationAngle FakeMirSurface::orientationAngle() const { return m_orientationAngle; }
2262+
2263+void FakeMirSurface::setOrientationAngle(Mir::OrientationAngle angle)
2264+{
2265+ if (m_orientationAngle != angle) {
2266+ m_orientationAngle = angle;
2267+ Q_EMIT orientationAngleChanged(m_orientationAngle);
2268+ }
2269+}
2270+
2271+bool FakeMirSurface::isFirstFrameDrawn() const
2272+{
2273+ return m_isFirstFrameDrawn;
2274+}
2275+
2276+void FakeMirSurface::stopFrameDropper()
2277+{
2278+ m_isFrameDropperRunning = false;
2279+}
2280+
2281+void FakeMirSurface::startFrameDropper()
2282+{
2283+ m_isFrameDropperRunning = true;
2284+}
2285+
2286+void FakeMirSurface::setLive(bool value)
2287+{
2288+ if (m_live != value) {
2289+ m_live = value;
2290+ Q_EMIT liveChanged(m_live);
2291+ }
2292+}
2293+
2294+void FakeMirSurface::setViewVisibility(qintptr viewId, bool visible) {
2295+ if (!m_views.contains(viewId)) return;
2296+
2297+ m_views[viewId] = visible;
2298+ updateVisibility();
2299+}
2300+
2301+bool FakeMirSurface::isBeingDisplayed() const { return !m_views.isEmpty(); }
2302+
2303+void FakeMirSurface::registerView(qintptr viewId)
2304+{
2305+ m_views.insert(viewId, false);
2306+ if (m_views.count() == 1) {
2307+ Q_EMIT isBeingDisplayedChanged();
2308+ }
2309+}
2310+
2311+void FakeMirSurface::unregisterView(qintptr viewId)
2312+{
2313+ m_views.remove(viewId);
2314+ if (m_views.count() == 0) {
2315+ Q_EMIT isBeingDisplayedChanged();
2316+ }
2317+ updateVisibility();
2318+}
2319+
2320+QSharedPointer<QSGTexture> FakeMirSurface::texture() { return QSharedPointer<QSGTexture>(); }
2321+
2322+QSGTexture *FakeMirSurface::weakTexture() const { return nullptr; }
2323+
2324+bool FakeMirSurface::updateTexture() { return true; }
2325+
2326+unsigned int FakeMirSurface::currentFrameNumber() const { return 0; }
2327+
2328+bool FakeMirSurface::numBuffersReadyForCompositor() { return 0; }
2329+
2330+void FakeMirSurface::setFocus(bool focus) { m_focused = focus; }
2331+
2332+void FakeMirSurface::mousePressEvent(QMouseEvent *) {}
2333+
2334+void FakeMirSurface::mouseMoveEvent(QMouseEvent *) {}
2335+
2336+void FakeMirSurface::mouseReleaseEvent(QMouseEvent *) {}
2337+
2338+void FakeMirSurface::hoverEnterEvent(QHoverEvent *) {}
2339+
2340+void FakeMirSurface::hoverLeaveEvent(QHoverEvent *) {}
2341+
2342+void FakeMirSurface::hoverMoveEvent(QHoverEvent *) {}
2343+
2344+void FakeMirSurface::wheelEvent(QWheelEvent *) {}
2345+
2346+void FakeMirSurface::keyPressEvent(QKeyEvent *) {}
2347+
2348+void FakeMirSurface::keyReleaseEvent(QKeyEvent *) {}
2349+
2350+void FakeMirSurface::touchEvent(Qt::KeyboardModifiers mods,
2351+ const QList<QTouchEvent::TouchPoint> &points,
2352+ Qt::TouchPointStates states,
2353+ ulong timestamp)
2354+{
2355+ m_touchesReceived.append(TouchEvent(mods, points, states, timestamp));
2356+}
2357+
2358+QString FakeMirSurface::appId() const { return "foo-app"; }
2359+
2360+void FakeMirSurface::onCompositorSwappedBuffers() {}
2361+
2362+void FakeMirSurface::drawFirstFrame()
2363+{
2364+ if (!m_isFirstFrameDrawn) {
2365+ m_isFirstFrameDrawn = true;
2366+ Q_EMIT firstFrameDrawn();
2367+ }
2368+}
2369+
2370+bool FakeMirSurface::isFrameDropperRunning() const { return m_isFrameDropperRunning; }
2371+
2372+QList<FakeMirSurface::TouchEvent> &FakeMirSurface::touchesReceived() { return m_touchesReceived; }
2373+
2374+void FakeMirSurface::updateVisibility()
2375+{
2376+ bool newVisible = false;
2377+ QHashIterator<int, bool> i(m_views);
2378+ while (i.hasNext()) {
2379+ i.next();
2380+ newVisible |= i.value();
2381+ }
2382+
2383+ if (m_visible != newVisible) {
2384+ m_visible = newVisible;
2385+ Q_EMIT visibleChanged(newVisible);
2386+ }
2387+}
2388+
2389+} // namespace qtmir
2390
2391=== modified file 'tests/framework/fake_mirsurface.h'
2392--- tests/modules/common/fake_mirsurface.h 2015-12-10 13:08:43 +0000
2393+++ tests/framework/fake_mirsurface.h 2016-02-03 11:35:51 +0000
2394@@ -36,11 +36,8 @@
2395 TouchEvent(Qt::KeyboardModifiers mods,
2396 const QList<QTouchEvent::TouchPoint> &points,
2397 Qt::TouchPointStates states,
2398- ulong timestamp)
2399- : keyboardModifiers(mods)
2400- , touchPoints(points)
2401- , states(states)
2402- , timestamp(timestamp) {}
2403+ ulong timestamp);
2404+ virtual ~TouchEvent();
2405
2406 Qt::KeyboardModifiers keyboardModifiers;
2407 QList<QTouchEvent::TouchPoint> touchPoints;
2408@@ -48,129 +45,68 @@
2409 ulong timestamp;
2410 };
2411
2412-
2413- FakeMirSurface(QObject *parent = nullptr)
2414- : MirSurfaceInterface(parent)
2415- , m_isFirstFrameDrawn(false)
2416- , m_isFrameDropperRunning(true)
2417- , m_live(true)
2418- , m_state(Mir::RestoredState)
2419- , m_orientationAngle(Mir::Angle0)
2420- , m_visible(true)
2421- , m_focused(false)
2422- {}
2423+ FakeMirSurface(QObject *parent = nullptr);
2424+ virtual ~FakeMirSurface();
2425
2426 ////
2427 // unity.shell.application.MirSurfaceInterface
2428- Mir::Type type() const override { return Mir::NormalType; }
2429-
2430- QString name() const override { return QString("Fake MirSurface"); }
2431-
2432- QSize size() const override { return m_size; }
2433-
2434- void resize(int width, int height) override {
2435- if (m_size.width() != width || m_size.height() != height) {
2436- m_size.setWidth(width);
2437- m_size.setHeight(height);
2438- Q_EMIT sizeChanged(m_size);
2439- }
2440- }
2441- void resize(const QSize &size) override { resize(size.width(), size.height()); }
2442-
2443- Mir::State state() const override { return m_state; }
2444- void setState(Mir::State qmlState) override {
2445- if (qmlState != m_state) {
2446- m_state = qmlState;
2447- Q_EMIT stateChanged(m_state);
2448- }
2449- }
2450-
2451- bool live() const override { return m_live; }
2452-
2453- bool visible() const override { return m_visible; }
2454-
2455- Mir::OrientationAngle orientationAngle() const override { return m_orientationAngle; }
2456- void setOrientationAngle(Mir::OrientationAngle angle) override {
2457- if (m_orientationAngle != angle) {
2458- m_orientationAngle = angle;
2459- Q_EMIT orientationAngleChanged(m_orientationAngle);
2460- }
2461- }
2462+ Mir::Type type() const override;
2463+ QString name() const override;
2464+ QSize size() const override;
2465+ void resize(int width, int height) override;
2466+ void resize(const QSize &size) override;
2467+ Mir::State state() const override;
2468+ void setState(Mir::State qmlState) override;
2469+ bool live() const override;
2470+ bool visible() const override;
2471+ Mir::OrientationAngle orientationAngle() const override;
2472+ void setOrientationAngle(Mir::OrientationAngle angle) override;
2473+
2474+ int minimumWidth() const override { return 0; }
2475+ int minimumHeight() const override { return 0; }
2476+ int maximumWidth() const override { return 0; }
2477+ int maximumHeight() const override { return 0; }
2478+ int widthIncrement() const override { return 0; }
2479+ int heightIncrement() const override { return 0; }
2480
2481 ////
2482 // qtmir.MirSurfaceInterface
2483
2484- bool isFirstFrameDrawn() const override {
2485- return m_isFirstFrameDrawn;
2486- }
2487-
2488- void stopFrameDropper() override {
2489- m_isFrameDropperRunning = false;
2490- }
2491- void startFrameDropper() override {
2492- m_isFrameDropperRunning = true;
2493- }
2494-
2495- void setLive(bool value) override {
2496- if (m_live != value) {
2497- m_live = value;
2498- Q_EMIT liveChanged(m_live);
2499- }
2500- }
2501-
2502- void setViewVisibility(qintptr viewId, bool visible) override {
2503- if (!m_views.contains(viewId)) return;
2504-
2505- m_views[viewId] = visible;
2506- updateVisibility();
2507- }
2508-
2509- bool isBeingDisplayed() const override { return !m_views.isEmpty(); }
2510-
2511- void registerView(qintptr viewId) override {
2512- m_views.insert(viewId, false);
2513- if (m_views.count() == 1) {
2514- Q_EMIT isBeingDisplayedChanged();
2515- }
2516- }
2517-
2518- void unregisterView(qintptr viewId) override {
2519- m_views.remove(viewId);
2520- if (m_views.count() == 0) {
2521- Q_EMIT isBeingDisplayedChanged();
2522- }
2523- updateVisibility();
2524- }
2525+ bool isFirstFrameDrawn() const override;
2526+ void stopFrameDropper() override;
2527+ void startFrameDropper() override;
2528+ void setLive(bool value) override;
2529+ void setViewVisibility(qintptr viewId, bool visible) override;
2530+ bool isBeingDisplayed() const override;
2531+ void registerView(qintptr viewId) override;
2532+ void unregisterView(qintptr viewId) override;
2533
2534 // methods called from the rendering (scene graph) thread:
2535- QSharedPointer<QSGTexture> texture() override { return QSharedPointer<QSGTexture>(); }
2536- QSGTexture *weakTexture() const override { return nullptr; }
2537- bool updateTexture() override { return true; }
2538- unsigned int currentFrameNumber() const override { return 0; }
2539- bool numBuffersReadyForCompositor() override { return 0; }
2540+ QSharedPointer<QSGTexture> texture() override;
2541+ QSGTexture *weakTexture() const override;
2542+ bool updateTexture() override;
2543+ unsigned int currentFrameNumber() const override;
2544+ bool numBuffersReadyForCompositor() override;
2545 // end of methods called from the rendering (scene graph) thread
2546
2547- void setFocus(bool focus) override { m_focused = focus; }
2548-
2549- void mousePressEvent(QMouseEvent *) override {}
2550- void mouseMoveEvent(QMouseEvent *) override {}
2551- void mouseReleaseEvent(QMouseEvent *) override {}
2552- void hoverEnterEvent(QHoverEvent *) override {}
2553- void hoverLeaveEvent(QHoverEvent *) override {}
2554- void hoverMoveEvent(QHoverEvent *) override {}
2555- void wheelEvent(QWheelEvent *) override {}
2556-
2557- void keyPressEvent(QKeyEvent *) override {}
2558- void keyReleaseEvent(QKeyEvent *) override {}
2559+ void setFocus(bool focus) override;
2560+
2561+ void mousePressEvent(QMouseEvent *) override;
2562+ void mouseMoveEvent(QMouseEvent *) override;
2563+ void mouseReleaseEvent(QMouseEvent *) override;
2564+ void hoverEnterEvent(QHoverEvent *) override;
2565+ void hoverLeaveEvent(QHoverEvent *) override;
2566+ void hoverMoveEvent(QHoverEvent *) override;
2567+ void wheelEvent(QWheelEvent *) override;
2568+ void keyPressEvent(QKeyEvent *) override;
2569+ void keyReleaseEvent(QKeyEvent *) override;
2570
2571 void touchEvent(Qt::KeyboardModifiers mods,
2572 const QList<QTouchEvent::TouchPoint> &points,
2573 Qt::TouchPointStates states,
2574- ulong timestamp) override {
2575- m_touchesReceived.append(TouchEvent(mods, points, states, timestamp));
2576- }
2577+ ulong timestamp) override;
2578
2579- QString appId() const override { return "foo-app"; }
2580+ QString appId() const override;
2581
2582 QCursor cursor() const override { return QCursor(); }
2583
2584@@ -182,40 +118,28 @@
2585 void closeRequested();
2586
2587 public Q_SLOTS:
2588- void onCompositorSwappedBuffers() override {}
2589+ void onCompositorSwappedBuffers() override;
2590+
2591+ void setMinimumWidth(int) {}
2592+ void setMinimumHeight(int) {}
2593+ void setMaximumWidth(int) {}
2594+ void setMaximumHeight(int) {}
2595+ void setWidthIncrement(int) {}
2596+ void setHeightIncrement(int) {}
2597
2598 ////
2599 // Test API from now on
2600
2601 public:
2602
2603- void drawFirstFrame() {
2604- if (!m_isFirstFrameDrawn) {
2605- m_isFirstFrameDrawn = true;
2606- Q_EMIT firstFrameDrawn();
2607- }
2608- }
2609-
2610- bool isFrameDropperRunning() const {
2611- return m_isFrameDropperRunning;
2612- }
2613-
2614- QList<TouchEvent> &touchesReceived() { return m_touchesReceived; }
2615+ void drawFirstFrame();
2616+
2617+ bool isFrameDropperRunning() const;
2618+
2619+ QList<TouchEvent> &touchesReceived();
2620
2621 private:
2622- void updateVisibility() {
2623- bool newVisible = false;
2624- QHashIterator<int, bool> i(m_views);
2625- while (i.hasNext()) {
2626- i.next();
2627- newVisible |= i.value();
2628- }
2629-
2630- if (m_visible != newVisible) {
2631- m_visible = newVisible;
2632- Q_EMIT visibleChanged(newVisible);
2633- }
2634- }
2635+ void updateVisibility();
2636
2637
2638 bool m_isFirstFrameDrawn;
2639
2640=== added file 'tests/framework/fake_session.cpp'
2641--- tests/framework/fake_session.cpp 1970-01-01 00:00:00 +0000
2642+++ tests/framework/fake_session.cpp 2016-02-03 11:35:51 +0000
2643@@ -0,0 +1,119 @@
2644+/*
2645+ * Copyright (C) 2015 Canonical, Ltd.
2646+ *
2647+ * This program is free software: you can redistribute it and/or modify it under
2648+ * the terms of the GNU Lesser General Public License version 3, as published by
2649+ * the Free Software Foundation.
2650+ *
2651+ * This program is distributed in the hope that it will be useful, but WITHOUT
2652+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2653+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2654+ * Lesser General Public License for more details.
2655+ *
2656+ * You should have received a copy of the GNU Lesser General Public License
2657+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2658+ */
2659+
2660+#include "fake_session.h"
2661+
2662+namespace qtmir
2663+{
2664+
2665+FakeSession::FakeSession()
2666+ : SessionInterface(0)
2667+ , m_application(nullptr)
2668+ , m_state(Starting)
2669+{
2670+}
2671+
2672+FakeSession::~FakeSession()
2673+{
2674+}
2675+
2676+void FakeSession::release() {}
2677+
2678+QString FakeSession::name() const { return QString("foo-session"); }
2679+
2680+unity::shell::application::ApplicationInfoInterface *FakeSession::application() const { return m_application; }
2681+
2682+MirSurfaceInterface *FakeSession::lastSurface() const { return nullptr; }
2683+
2684+const ObjectListModel<MirSurfaceInterface> *FakeSession::surfaces() const { return nullptr; }
2685+
2686+SessionInterface *FakeSession::parentSession() const { return nullptr; }
2687+
2688+SessionModel *FakeSession::childSessions() const { return nullptr; }
2689+
2690+SessionInterface::State FakeSession::state() const { return m_state; }
2691+
2692+bool FakeSession::fullscreen() const { return false; }
2693+
2694+bool FakeSession::live() const { return true; }
2695+
2696+std::shared_ptr<mir::scene::Session> FakeSession::session() const { return nullptr; }
2697+
2698+void FakeSession::registerSurface(MirSurfaceInterface *) {}
2699+
2700+void FakeSession::removeSurface(MirSurfaceInterface *) {}
2701+
2702+void FakeSession::setApplication(unity::shell::application::ApplicationInfoInterface *app)
2703+{
2704+ if (m_application != app) {
2705+ m_application = app;
2706+ Q_EMIT applicationChanged(m_application);
2707+ }
2708+}
2709+
2710+void FakeSession::suspend()
2711+{
2712+ if (m_state == Running) {
2713+ setState(Suspending);
2714+ }
2715+}
2716+
2717+void FakeSession::resume()
2718+{
2719+ if (m_state == Suspending || m_state == Suspended) {
2720+ setState(Running);
2721+ }
2722+}
2723+
2724+void FakeSession::stop()
2725+{
2726+ setState(Stopped);
2727+}
2728+
2729+void FakeSession::close() {}
2730+
2731+void FakeSession::addChildSession(SessionInterface *) {}
2732+
2733+void FakeSession::insertChildSession(uint, SessionInterface *) {}
2734+
2735+void FakeSession::removeChildSession(SessionInterface *) {}
2736+
2737+void FakeSession::foreachChildSession(std::function<void (SessionInterface *)>) const {}
2738+
2739+std::shared_ptr<mir::scene::PromptSession> FakeSession::activePromptSession() const
2740+{
2741+ return std::shared_ptr<mir::scene::PromptSession>();
2742+}
2743+
2744+void FakeSession::foreachPromptSession(std::function<void (const std::shared_ptr<mir::scene::PromptSession> &)>) const {}
2745+
2746+void FakeSession::setFullscreen(bool) {}
2747+
2748+void FakeSession::setLive(const bool) {}
2749+
2750+void FakeSession::appendPromptSession(const std::shared_ptr<mir::scene::PromptSession> &) {}
2751+
2752+void FakeSession::removePromptSession(const std::shared_ptr<mir::scene::PromptSession> &) {}
2753+
2754+void FakeSession::setState(SessionInterface::State state)
2755+{
2756+ if (m_state != state) {
2757+ m_state = state;
2758+ Q_EMIT stateChanged(m_state);
2759+ }
2760+}
2761+
2762+} // namespace qtmir
2763
2764=== modified file 'tests/framework/fake_session.h'
2765--- tests/modules/common/fake_session.h 2015-12-07 12:02:48 +0000
2766+++ tests/framework/fake_session.h 2016-02-03 11:35:51 +0000
2767@@ -27,83 +27,56 @@
2768 Q_OBJECT
2769
2770 public:
2771- FakeSession()
2772- : SessionInterface(0)
2773- , m_application(nullptr)
2774- , m_state(Starting)
2775- {
2776- }
2777+ FakeSession();
2778+ virtual ~FakeSession();
2779
2780 // For QML use
2781- void release() override {}
2782-
2783- QString name() const override { return QString("foo-session"); }
2784- unity::shell::application::ApplicationInfoInterface* application() const override { return m_application; }
2785- MirSurfaceInterface* lastSurface() const override { return nullptr; }
2786- const ObjectListModel<MirSurfaceInterface>* surfaces() const override { return nullptr; }
2787- SessionInterface* parentSession() const override { return nullptr; }
2788- SessionModel* childSessions() const override { return nullptr; }
2789- State state() const override { return m_state; }
2790- bool fullscreen() const override { return false; }
2791- bool live() const override { return true; }
2792-
2793- std::shared_ptr<mir::scene::Session> session() const override { return nullptr; }
2794+ void release() override;
2795+
2796+ QString name() const override;
2797+ unity::shell::application::ApplicationInfoInterface* application() const override;
2798+ MirSurfaceInterface* lastSurface() const override;
2799+ const ObjectListModel<MirSurfaceInterface>* surfaces() const override;
2800+ SessionInterface* parentSession() const override;
2801+ SessionModel* childSessions() const override;
2802+ State state() const override;
2803+ bool fullscreen() const override;
2804+ bool live() const override;
2805+
2806+ std::shared_ptr<mir::scene::Session> session() const override;
2807
2808 // For MirSurfaceItem and MirSurfaceManager use
2809
2810- void registerSurface(MirSurfaceInterface*) override {}
2811- void removeSurface(MirSurfaceInterface*) override {}
2812+ void registerSurface(MirSurfaceInterface*) override;
2813+ void removeSurface(MirSurfaceInterface*) override;
2814
2815 // For Application use
2816
2817- void setApplication(unity::shell::application::ApplicationInfoInterface* app) override {
2818- if (m_application != app) {
2819- m_application = app;
2820- Q_EMIT applicationChanged(m_application);
2821- }
2822- }
2823- void suspend() override {
2824- if (m_state == Running) {
2825- setState(Suspending);
2826- }
2827- }
2828- void resume() override {
2829- if (m_state == Suspending || m_state == Suspended) {
2830- setState(Running);
2831- }
2832- }
2833- void stop() override {
2834- setState(Stopped);
2835- }
2836+ void setApplication(unity::shell::application::ApplicationInfoInterface* app) override;
2837+ void suspend() override;
2838+ void resume() override;
2839+ void stop() override;
2840
2841- void close() override {
2842- }
2843+ void close() override;
2844
2845 // For SessionManager use
2846
2847- void addChildSession(SessionInterface*) override {}
2848- void insertChildSession(uint, SessionInterface*) override {}
2849- void removeChildSession(SessionInterface*) override {}
2850- void foreachChildSession(std::function<void(SessionInterface* session)>) const override {}
2851-
2852- std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override {
2853- return std::shared_ptr<mir::scene::PromptSession>();
2854- }
2855- void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)>) const override {}
2856-
2857- void setFullscreen(bool) override {}
2858- void setLive(const bool) override {}
2859- void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override {}
2860- void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override {}
2861+ void addChildSession(SessionInterface*) override;
2862+ void insertChildSession(uint, SessionInterface*) override;
2863+ void removeChildSession(SessionInterface*) override;
2864+ void foreachChildSession(std::function<void(SessionInterface* session)>) const override;
2865+
2866+ std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override;
2867+ void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)>) const override;
2868+
2869+ void setFullscreen(bool) override;
2870+ void setLive(const bool) override;
2871+ void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override;
2872+ void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override;
2873
2874 // For tests
2875
2876- void setState(State state) {
2877- if (m_state != state) {
2878- m_state = state;
2879- Q_EMIT stateChanged(m_state);
2880- }
2881- }
2882+ void setState(State state);
2883
2884 private:
2885 unity::shell::application::ApplicationInfoInterface* m_application;
2886
2887=== renamed file 'tests/common/gmock_fixes.h' => 'tests/framework/gmock_fixes.h'
2888=== added file 'tests/framework/mock_desktop_file_reader.cpp'
2889--- tests/framework/mock_desktop_file_reader.cpp 1970-01-01 00:00:00 +0000
2890+++ tests/framework/mock_desktop_file_reader.cpp 2016-02-03 11:35:51 +0000
2891@@ -0,0 +1,117 @@
2892+/*
2893+ * Copyright (C) 2015 Canonical, Ltd.
2894+ *
2895+ * This program is free software: you can redistribute it and/or modify it under
2896+ * the terms of the GNU Lesser General Public License version 3, as published by
2897+ * the Free Software Foundation.
2898+ *
2899+ * This program is distributed in the hope that it will be useful, but WITHOUT
2900+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2901+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2902+ * Lesser General Public License for more details.
2903+ *
2904+ * You should have received a copy of the GNU Lesser General Public License
2905+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2906+ */
2907+
2908+#include "mock_desktop_file_reader.h"
2909+
2910+namespace qtmir
2911+{
2912+
2913+MockDesktopFileReader::MockDesktopFileReader(const QString &appId, const QFileInfo &fileInfo)
2914+ : DesktopFileReader(appId, fileInfo)
2915+{
2916+ using namespace ::testing;
2917+
2918+ ON_CALL(*this, file()).WillByDefault(Invoke(this, &MockDesktopFileReader::doFile));
2919+ ON_CALL(*this, appId()).WillByDefault(Invoke(this, &MockDesktopFileReader::doAppId));
2920+ ON_CALL(*this, name()).WillByDefault(Invoke(this, &MockDesktopFileReader::doName));
2921+ ON_CALL(*this, comment()).WillByDefault(Invoke(this, &MockDesktopFileReader::doComment));
2922+ ON_CALL(*this, icon()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIcon));
2923+ ON_CALL(*this, exec()).WillByDefault(Invoke(this, &MockDesktopFileReader::doExec));
2924+ ON_CALL(*this, path()).WillByDefault(Invoke(this, &MockDesktopFileReader::doPath));
2925+ ON_CALL(*this, stageHint()).WillByDefault(Invoke(this, &MockDesktopFileReader::doStageHint));
2926+ ON_CALL(*this, isTouchApp()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIsTouchApp));
2927+ ON_CALL(*this, loaded()).WillByDefault(Invoke(this, &MockDesktopFileReader::doLoaded));
2928+}
2929+
2930+MockDesktopFileReader::~MockDesktopFileReader()
2931+{
2932+}
2933+
2934+QString MockDesktopFileReader::doFile() const
2935+{
2936+ return DesktopFileReader::file();
2937+}
2938+
2939+QString MockDesktopFileReader::doAppId() const
2940+{
2941+ return DesktopFileReader::appId();
2942+}
2943+
2944+QString MockDesktopFileReader::doName() const
2945+{
2946+ return DesktopFileReader::name();
2947+}
2948+
2949+QString MockDesktopFileReader::doComment() const
2950+{
2951+ return DesktopFileReader::comment();
2952+}
2953+
2954+QString MockDesktopFileReader::doIcon() const
2955+{
2956+ return DesktopFileReader::icon();
2957+}
2958+
2959+QString MockDesktopFileReader::doExec() const
2960+{
2961+ return DesktopFileReader::exec();
2962+}
2963+
2964+QString MockDesktopFileReader::doPath() const
2965+{
2966+ return DesktopFileReader::path();
2967+}
2968+
2969+QString MockDesktopFileReader::doStageHint() const
2970+{
2971+ return DesktopFileReader::stageHint();
2972+}
2973+
2974+bool MockDesktopFileReader::doIsTouchApp() const
2975+{
2976+ return DesktopFileReader::isTouchApp();
2977+}
2978+
2979+bool MockDesktopFileReader::doLoaded() const
2980+{
2981+ return DesktopFileReader::loaded();
2982+}
2983+
2984+
2985+MockDesktopFileReaderFactory::MockDesktopFileReaderFactory()
2986+{
2987+ using namespace ::testing;
2988+ ON_CALL(*this, createInstance(_, _))
2989+ .WillByDefault(
2990+ Invoke(
2991+ this,
2992+ &MockDesktopFileReaderFactory::doCreateInstance));
2993+}
2994+
2995+MockDesktopFileReaderFactory::~MockDesktopFileReaderFactory()
2996+{
2997+}
2998+
2999+qtmir::DesktopFileReader *MockDesktopFileReaderFactory::doCreateInstance(const QString &appId, const QFileInfo &fi)
3000+{
3001+ using namespace ::testing;
3002+ auto instance = new NiceMock<MockDesktopFileReader>(appId, fi);
3003+ ON_CALL(*instance, loaded()).WillByDefault(Return(true));
3004+
3005+ return instance;
3006+}
3007+
3008+} // namespace qtmir
3009
3010=== modified file 'tests/framework/mock_desktop_file_reader.h'
3011--- tests/modules/common/mock_desktop_file_reader.h 2015-09-29 18:27:27 +0000
3012+++ tests/framework/mock_desktop_file_reader.h 2016-02-03 11:35:51 +0000
3013@@ -21,26 +21,13 @@
3014
3015 #include <gmock/gmock.h>
3016
3017-namespace testing
3018+namespace qtmir
3019 {
3020+
3021 struct MockDesktopFileReader : public qtmir::DesktopFileReader
3022 {
3023- MockDesktopFileReader(const QString &appId, const QFileInfo& fileInfo)
3024- : DesktopFileReader(appId, fileInfo)
3025- {
3026- using namespace ::testing;
3027-
3028- ON_CALL(*this, file()).WillByDefault(Invoke(this, &MockDesktopFileReader::doFile));
3029- ON_CALL(*this, appId()).WillByDefault(Invoke(this, &MockDesktopFileReader::doAppId));
3030- ON_CALL(*this, name()).WillByDefault(Invoke(this, &MockDesktopFileReader::doName));
3031- ON_CALL(*this, comment()).WillByDefault(Invoke(this, &MockDesktopFileReader::doComment));
3032- ON_CALL(*this, icon()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIcon));
3033- ON_CALL(*this, exec()).WillByDefault(Invoke(this, &MockDesktopFileReader::doExec));
3034- ON_CALL(*this, path()).WillByDefault(Invoke(this, &MockDesktopFileReader::doPath));
3035- ON_CALL(*this, stageHint()).WillByDefault(Invoke(this, &MockDesktopFileReader::doStageHint));
3036- ON_CALL(*this, isTouchApp()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIsTouchApp));
3037- ON_CALL(*this, loaded()).WillByDefault(Invoke(this, &MockDesktopFileReader::doLoaded));
3038- }
3039+ MockDesktopFileReader(const QString &appId, const QFileInfo& fileInfo);
3040+ virtual ~MockDesktopFileReader();
3041
3042 MOCK_CONST_METHOD0(file, QString());
3043 MOCK_CONST_METHOD0(appId, QString ());
3044@@ -53,80 +40,28 @@
3045 MOCK_CONST_METHOD0(isTouchApp, bool());
3046 MOCK_CONST_METHOD0(loaded, bool());
3047
3048- QString doFile() const
3049- {
3050- return DesktopFileReader::file();
3051- }
3052-
3053- QString doAppId() const
3054- {
3055- return DesktopFileReader::appId();
3056- }
3057-
3058- QString doName() const
3059- {
3060- return DesktopFileReader::name();
3061- }
3062-
3063- QString doComment() const
3064- {
3065- return DesktopFileReader::comment();
3066- }
3067-
3068- QString doIcon() const
3069- {
3070- return DesktopFileReader::icon();
3071- }
3072-
3073- QString doExec() const
3074- {
3075- return DesktopFileReader::exec();
3076- }
3077-
3078- QString doPath() const
3079- {
3080- return DesktopFileReader::path();
3081- }
3082-
3083- QString doStageHint() const
3084- {
3085- return DesktopFileReader::stageHint();
3086- }
3087-
3088- bool doIsTouchApp() const
3089- {
3090- return DesktopFileReader::isTouchApp();
3091- }
3092-
3093- bool doLoaded() const
3094- {
3095- return DesktopFileReader::loaded();
3096- }
3097+ QString doFile() const;
3098+ QString doAppId() const;
3099+ QString doName() const;
3100+ QString doComment() const;
3101+ QString doIcon() const;
3102+ QString doExec() const;
3103+ QString doPath() const;
3104+ QString doStageHint() const;
3105+ bool doIsTouchApp() const;
3106+ bool doLoaded() const;
3107 };
3108
3109 struct MockDesktopFileReaderFactory : public qtmir::DesktopFileReader::Factory
3110 {
3111- MockDesktopFileReaderFactory()
3112- {
3113- using namespace ::testing;
3114- ON_CALL(*this, createInstance(_, _))
3115- .WillByDefault(
3116- Invoke(
3117- this,
3118- &MockDesktopFileReaderFactory::doCreateInstance));
3119- }
3120-
3121- virtual qtmir::DesktopFileReader* doCreateInstance(const QString &appId, const QFileInfo &fi)
3122- {
3123- using namespace ::testing;
3124- auto instance = new NiceMock<MockDesktopFileReader>(appId, fi);
3125- ON_CALL(*instance, loaded()).WillByDefault(Return(true));
3126-
3127- return instance;
3128- }
3129+ MockDesktopFileReaderFactory();
3130+ virtual ~MockDesktopFileReaderFactory();
3131+
3132+ virtual qtmir::DesktopFileReader* doCreateInstance(const QString &appId, const QFileInfo &fi);
3133
3134 MOCK_METHOD2(createInstance, qtmir::DesktopFileReader*(const QString &appId, const QFileInfo &fi));
3135 };
3136-}
3137+
3138+} // namespace qtmir
3139
3140 #endif // MOCK_DESKTOP_FILE_READER_H
3141
3142=== added file 'tests/framework/mock_display.cpp'
3143--- tests/framework/mock_display.cpp 1970-01-01 00:00:00 +0000
3144+++ tests/framework/mock_display.cpp 2016-02-03 11:35:51 +0000
3145@@ -0,0 +1,35 @@
3146+/*
3147+ * Copyright (C) 2015 Canonical, Ltd.
3148+ *
3149+ * This program is free software: you can redistribute it and/or modify it under
3150+ * the terms of the GNU Lesser General Public License version 3, as published by
3151+ * the Free Software Foundation.
3152+ *
3153+ * This program is distributed in the hope that it will be useful, but WITHOUT
3154+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3155+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3156+ * Lesser General Public License for more details.
3157+ *
3158+ * You should have received a copy of the GNU Lesser General Public License
3159+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3160+ */
3161+
3162+#include "mock_display.h"
3163+#include <mir/graphics/event_handler_register.h>
3164+#include <mir/graphics/display_configuration.h>
3165+
3166+MockDisplaySyncGroup::MockDisplaySyncGroup()
3167+{
3168+}
3169+
3170+MockDisplaySyncGroup::~MockDisplaySyncGroup()
3171+{
3172+}
3173+
3174+MockDisplay::MockDisplay()
3175+{
3176+}
3177+
3178+MockDisplay::~MockDisplay()
3179+{
3180+}
3181
3182=== renamed file 'tests/common/mock_display.h' => 'tests/framework/mock_display.h'
3183--- tests/common/mock_display.h 2015-08-20 10:16:54 +0000
3184+++ tests/framework/mock_display.h 2016-02-03 11:35:51 +0000
3185@@ -26,6 +26,9 @@
3186 class MockDisplaySyncGroup : public mir::graphics::DisplaySyncGroup
3187 {
3188 public:
3189+ MockDisplaySyncGroup();
3190+ virtual ~MockDisplaySyncGroup();
3191+
3192 MOCK_METHOD1(for_each_display_buffer, void(std::function<void(mir::graphics::DisplayBuffer&)> const& f));
3193 MOCK_METHOD0(post, void());
3194 };
3195@@ -33,6 +36,9 @@
3196 struct MockDisplay : public mir::graphics::Display
3197 {
3198 public:
3199+ MockDisplay();
3200+ virtual ~MockDisplay();
3201+
3202 MOCK_METHOD1(for_each_display_sync_group, void(std::function<void(mir::graphics::DisplaySyncGroup&)> const&));
3203 MOCK_CONST_METHOD0(configuration, std::unique_ptr<mir::graphics::DisplayConfiguration>());
3204 MOCK_METHOD1(configure, void(mir::graphics::DisplayConfiguration const&));
3205@@ -48,6 +54,4 @@
3206 MOCK_METHOD0(create_gl_context, std::unique_ptr<mir::graphics::GLContext>());
3207 };
3208
3209-
3210-
3211 #endif // MOCKDISPLAY_H
3212
3213=== added file 'tests/framework/mock_display_configuration.cpp'
3214--- tests/framework/mock_display_configuration.cpp 1970-01-01 00:00:00 +0000
3215+++ tests/framework/mock_display_configuration.cpp 2016-02-03 11:35:51 +0000
3216@@ -0,0 +1,25 @@
3217+/*
3218+ * Copyright (C) 2015 Canonical, Ltd.
3219+ *
3220+ * This program is free software: you can redistribute it and/or modify it under
3221+ * the terms of the GNU Lesser General Public License version 3, as published by
3222+ * the Free Software Foundation.
3223+ *
3224+ * This program is distributed in the hope that it will be useful, but WITHOUT
3225+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3226+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3227+ * Lesser General Public License for more details.
3228+ *
3229+ * You should have received a copy of the GNU Lesser General Public License
3230+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3231+ */
3232+
3233+#include "mock_display_configuration.h"
3234+
3235+MockDisplayConfiguration::MockDisplayConfiguration()
3236+{
3237+}
3238+
3239+MockDisplayConfiguration::~MockDisplayConfiguration()
3240+{
3241+}
3242
3243=== renamed file 'tests/common/mock_display_configuration.h' => 'tests/framework/mock_display_configuration.h'
3244--- tests/common/mock_display_configuration.h 2015-12-04 15:44:11 +0000
3245+++ tests/framework/mock_display_configuration.h 2016-02-03 11:35:51 +0000
3246@@ -25,6 +25,9 @@
3247 class MockDisplayConfiguration : public mir::graphics::DisplayConfiguration
3248 {
3249 public:
3250+ MockDisplayConfiguration();
3251+ virtual ~MockDisplayConfiguration();
3252+
3253 MOCK_CONST_METHOD1(for_each_card, void(std::function<void(mir::graphics::DisplayConfigurationCard const&)>));
3254
3255 MOCK_CONST_METHOD1(for_each_output, void(std::function<void(mir::graphics::DisplayConfigurationOutput const&)>));
3256@@ -33,4 +36,5 @@
3257
3258 MOCK_CONST_METHOD0(valid, bool());
3259 };
3260+
3261 #endif // MOCK_DISPLAY_CONFIGURATION_H
3262
3263=== added file 'tests/framework/mock_gl_display_buffer.cpp'
3264--- tests/framework/mock_gl_display_buffer.cpp 1970-01-01 00:00:00 +0000
3265+++ tests/framework/mock_gl_display_buffer.cpp 2016-02-03 11:35:51 +0000
3266@@ -0,0 +1,30 @@
3267+/*
3268+ * Copyright (C) 2015 Canonical, Ltd.
3269+ *
3270+ * This program is free software: you can redistribute it and/or modify it under
3271+ * the terms of the GNU Lesser General Public License version 3, as published by
3272+ * the Free Software Foundation.
3273+ *
3274+ * This program is distributed in the hope that it will be useful, but WITHOUT
3275+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3276+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3277+ * Lesser General Public License for more details.
3278+ *
3279+ * You should have received a copy of the GNU Lesser General Public License
3280+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3281+ */
3282+
3283+#include "mock_gl_display_buffer.h"
3284+
3285+MockGLDisplayBuffer::MockGLDisplayBuffer()
3286+{
3287+ using namespace testing;
3288+ ON_CALL(*this, view_area())
3289+ .WillByDefault(Return(mir::geometry::Rectangle{{0,0},{0,0}}));
3290+ ON_CALL(*this, native_display_buffer())
3291+ .WillByDefault(Return(dynamic_cast<mir::graphics::NativeDisplayBuffer*>(this)));
3292+}
3293+
3294+MockGLDisplayBuffer::~MockGLDisplayBuffer()
3295+{
3296+}
3297
3298=== renamed file 'tests/common/mock_gl_display_buffer.h' => 'tests/framework/mock_gl_display_buffer.h'
3299--- tests/common/mock_gl_display_buffer.h 2015-10-14 23:14:48 +0000
3300+++ tests/framework/mock_gl_display_buffer.h 2016-02-03 11:35:51 +0000
3301@@ -27,14 +27,9 @@
3302 public mir::graphics::NativeDisplayBuffer
3303 {
3304 public:
3305- MockGLDisplayBuffer()
3306- {
3307- using namespace testing;
3308- ON_CALL(*this, view_area())
3309- .WillByDefault(Return(mir::geometry::Rectangle{{0,0},{0,0}}));
3310- ON_CALL(*this, native_display_buffer())
3311- .WillByDefault(Return(dynamic_cast<mir::graphics::NativeDisplayBuffer*>(this)));
3312- }
3313+ MockGLDisplayBuffer();
3314+ virtual ~MockGLDisplayBuffer();
3315+
3316 MOCK_CONST_METHOD0(view_area, mir::geometry::Rectangle());
3317 MOCK_METHOD1(post_renderables_if_optimizable, bool(mir::graphics::RenderableList const&));
3318 MOCK_CONST_METHOD0(orientation, MirOrientation());
3319@@ -45,5 +40,4 @@
3320 MOCK_METHOD0(swap_buffers, void());
3321 };
3322
3323-
3324 #endif // MOCK_GL_DISPLAY_BUFFER_H
3325
3326=== added file 'tests/framework/mock_main_loop.cpp'
3327--- tests/framework/mock_main_loop.cpp 1970-01-01 00:00:00 +0000
3328+++ tests/framework/mock_main_loop.cpp 2016-02-03 11:35:51 +0000
3329@@ -0,0 +1,28 @@
3330+/*
3331+ * Copyright (C) 2015 Canonical, Ltd.
3332+ *
3333+ * This program is free software: you can redistribute it and/or modify it under
3334+ * the terms of the GNU Lesser General Public License version 3, as published by
3335+ * the Free Software Foundation.
3336+ *
3337+ * This program is distributed in the hope that it will be useful, but WITHOUT
3338+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3339+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3340+ * Lesser General Public License for more details.
3341+ *
3342+ * You should have received a copy of the GNU Lesser General Public License
3343+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3344+ */
3345+
3346+#include "mock_main_loop.h"
3347+
3348+MockMainLoop::MockMainLoop()
3349+{
3350+}
3351+
3352+MockMainLoop::~MockMainLoop()
3353+{
3354+}
3355+
3356+void MockMainLoop::run() {}
3357+void MockMainLoop::stop() {}
3358\ No newline at end of file
3359
3360=== renamed file 'tests/common/mock_main_loop.h' => 'tests/framework/mock_main_loop.h'
3361--- tests/common/mock_main_loop.h 2015-08-20 10:16:54 +0000
3362+++ tests/framework/mock_main_loop.h 2016-02-03 11:35:51 +0000
3363@@ -17,19 +17,17 @@
3364 #ifndef MOCKMAINLOOP_H
3365 #define MOCKMAINLOOP_H
3366
3367-#include <gmock/gmock.h>
3368-
3369 #include <mir/main_loop.h>
3370-
3371-#include <memory>
3372+#include "gmock_fixes.h"
3373
3374 class MockMainLoop : public mir::MainLoop
3375 {
3376 public:
3377- ~MockMainLoop() noexcept {}
3378+ MockMainLoop();
3379+ ~MockMainLoop() noexcept;
3380
3381- void run() override {}
3382- void stop() override {}
3383+ void run() override;
3384+ void stop() override;
3385
3386 MOCK_METHOD2(register_signal_handler,
3387 void(std::initializer_list<int>,
3388@@ -49,5 +47,4 @@
3389 MOCK_METHOD1(create_alarm, std::unique_ptr<mir::time::Alarm>(std::shared_ptr<mir::LockableCallback> const& callback));
3390 };
3391
3392-
3393 #endif // MOCKMAINLOOP_H
3394
3395=== added file 'tests/framework/mock_mir_session.cpp'
3396--- tests/framework/mock_mir_session.cpp 1970-01-01 00:00:00 +0000
3397+++ tests/framework/mock_mir_session.cpp 2016-02-03 11:35:51 +0000
3398@@ -0,0 +1,63 @@
3399+/*
3400+ * Copyright (C) 2015 Canonical, Ltd.
3401+ *
3402+ * This program is free software: you can redistribute it and/or modify it under
3403+ * the terms of the GNU Lesser General Public License version 3, as published by
3404+ * the Free Software Foundation.
3405+ *
3406+ * This program is distributed in the hope that it will be useful, but WITHOUT
3407+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3408+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3409+ * Lesser General Public License for more details.
3410+ *
3411+ * You should have received a copy of the GNU Lesser General Public License
3412+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3413+ */
3414+
3415+#include "mock_mir_session.h"
3416+
3417+namespace mir
3418+{
3419+namespace scene
3420+{
3421+
3422+MockSession::MockSession()
3423+{
3424+}
3425+
3426+MockSession::MockSession(const std::string &sessionName, pid_t processId)
3427+ : m_sessionName(sessionName), m_sessionId(processId)
3428+{
3429+}
3430+
3431+MockSession::~MockSession()
3432+{
3433+}
3434+
3435+std::string MockSession::name() const
3436+{
3437+ return m_sessionName;
3438+}
3439+
3440+pid_t MockSession::process_id() const
3441+{
3442+ return m_sessionId;
3443+}
3444+
3445+void MockSession::resume_prompt_session() {}
3446+
3447+void MockSession::suspend_prompt_session() {}
3448+
3449+void MockSession::stop_prompt_session() {}
3450+
3451+void MockSession::start_prompt_session() {}
3452+
3453+std::shared_ptr<scene::Surface> MockSession::surface_after(const std::shared_ptr<scene::Surface> &) const
3454+{
3455+ return {};
3456+}
3457+
3458+void MockSession::configure_streams(scene::Surface &, const std::vector<mir::shell::StreamSpecification> &) {}
3459+
3460+} // namespace scene
3461+} // namespace mir
3462
3463=== modified file 'tests/framework/mock_mir_session.h'
3464--- tests/modules/common/mock_mir_session.h 2016-01-20 20:01:54 +0000
3465+++ tests/framework/mock_mir_session.h 2016-02-03 11:35:51 +0000
3466@@ -29,20 +29,13 @@
3467
3468 struct MockSession : public Session
3469 {
3470- MockSession() {}
3471- MockSession(std::string const& sessionName, pid_t processId)
3472- : m_sessionName(sessionName), m_sessionId(processId)
3473- {}
3474-
3475- std::string name() const override
3476- {
3477- return m_sessionName;
3478- }
3479-
3480- pid_t process_id() const override
3481- {
3482- return m_sessionId;
3483- }
3484+ MockSession();
3485+ MockSession(std::string const& sessionName, pid_t processId);
3486+ virtual ~MockSession();
3487+
3488+ std::string name() const override;
3489+
3490+ pid_t process_id() const override;
3491
3492 MOCK_METHOD0(force_requests_to_complete, void());
3493
3494@@ -63,16 +56,16 @@
3495 MOCK_METHOD1(send_display_config, void(graphics::DisplayConfiguration const&));
3496 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
3497
3498- void start_prompt_session() override {};
3499- void stop_prompt_session() override {};
3500- void suspend_prompt_session() override {};
3501- void resume_prompt_session() override {};
3502- std::shared_ptr<Surface> surface_after(std::shared_ptr<Surface> const&) const override { return {}; }
3503+ void start_prompt_session() override;
3504+ void stop_prompt_session() override;
3505+ void suspend_prompt_session() override;
3506+ void resume_prompt_session() override;
3507+ std::shared_ptr<Surface> surface_after(std::shared_ptr<Surface> const&) const override;
3508
3509 MOCK_CONST_METHOD1(get_buffer_stream, std::shared_ptr<frontend::BufferStream>(frontend::BufferStreamId));
3510 MOCK_METHOD1(destroy_buffer_stream, void(frontend::BufferStreamId));
3511 MOCK_METHOD1(create_buffer_stream, frontend::BufferStreamId(graphics::BufferProperties const&));
3512- void configure_streams(Surface&, std::vector<shell::StreamSpecification> const&) override {};
3513+ void configure_streams(Surface&, std::vector<shell::StreamSpecification> const&) override;;
3514
3515 MOCK_METHOD1(send_input_device_change, void(std::vector<std::shared_ptr<mir::input::Device>> const&));
3516 //void send_input_device_change(std::vector<std::shared_ptr<input::Device>> const& devices) = 0;
3517
3518=== added file 'tests/framework/mock_proc_info.cpp'
3519--- tests/framework/mock_proc_info.cpp 1970-01-01 00:00:00 +0000
3520+++ tests/framework/mock_proc_info.cpp 2016-02-03 11:35:51 +0000
3521@@ -0,0 +1,35 @@
3522+/*
3523+ * Copyright (C) 2015 Canonical, Ltd.
3524+ *
3525+ * This program is free software: you can redistribute it and/or modify it under
3526+ * the terms of the GNU Lesser General Public License version 3, as published by
3527+ * the Free Software Foundation.
3528+ *
3529+ * This program is distributed in the hope that it will be useful, but WITHOUT
3530+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3531+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3532+ * Lesser General Public License for more details.
3533+ *
3534+ * You should have received a copy of the GNU Lesser General Public License
3535+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3536+ */
3537+
3538+#include "mock_proc_info.h"
3539+
3540+namespace qtmir
3541+{
3542+
3543+MockProcInfo::MockProcInfo()
3544+{
3545+}
3546+
3547+MockProcInfo::~MockProcInfo()
3548+{
3549+}
3550+
3551+std::unique_ptr<qtmir::ProcInfo::CommandLine> MockProcInfo::commandLine(pid_t pid)
3552+{
3553+ return std::unique_ptr<CommandLine>(new CommandLine{command_line(pid)});
3554+}
3555+
3556+} // namespace qtmir
3557
3558=== modified file 'tests/framework/mock_proc_info.h'
3559--- tests/modules/common/mock_proc_info.h 2015-10-08 11:20:30 +0000
3560+++ tests/framework/mock_proc_info.h 2016-02-03 11:35:51 +0000
3561@@ -21,16 +21,17 @@
3562
3563 #include <gmock/gmock.h>
3564
3565-namespace testing
3566-{
3567+namespace qtmir {
3568+
3569 struct MockProcInfo : public qtmir::ProcInfo
3570 {
3571+ MockProcInfo();
3572+ virtual ~MockProcInfo();
3573+
3574 MOCK_METHOD1(command_line, QByteArray(pid_t));
3575- std::unique_ptr<CommandLine> commandLine(pid_t pid)
3576- {
3577- return std::unique_ptr<CommandLine>(new CommandLine{command_line(pid)});
3578- }
3579+ std::unique_ptr<CommandLine> commandLine(pid_t pid);
3580 };
3581-}
3582+
3583+} // namespace qtmir
3584
3585 #endif // MOCK_PROC_INFO_H
3586
3587=== added file 'tests/framework/mock_prompt_session.cpp'
3588--- tests/framework/mock_prompt_session.cpp 1970-01-01 00:00:00 +0000
3589+++ tests/framework/mock_prompt_session.cpp 2016-02-03 11:35:51 +0000
3590@@ -0,0 +1,33 @@
3591+/*
3592+ * Copyright (C) 2015 Canonical, Ltd.
3593+ *
3594+ * This program is free software: you can redistribute it and/or modify it under
3595+ * the terms of the GNU Lesser General Public License version 3, as published by
3596+ * the Free Software Foundation.
3597+ *
3598+ * This program is distributed in the hope that it will be useful, but WITHOUT
3599+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3600+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3601+ * Lesser General Public License for more details.
3602+ *
3603+ * You should have received a copy of the GNU Lesser General Public License
3604+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3605+ */
3606+
3607+#include "mock_prompt_session.h"
3608+
3609+namespace mir
3610+{
3611+namespace scene
3612+{
3613+
3614+MockPromptSession::MockPromptSession()
3615+{
3616+}
3617+
3618+MockPromptSession::~MockPromptSession()
3619+{
3620+}
3621+
3622+} // namespace scene
3623+} // namespace mir
3624
3625=== modified file 'tests/framework/mock_prompt_session.h'
3626--- tests/modules/common/mock_prompt_session.h 2015-08-11 12:08:32 +0000
3627+++ tests/framework/mock_prompt_session.h 2016-02-03 11:35:51 +0000
3628@@ -26,6 +26,9 @@
3629 struct MockPromptSession : public PromptSession
3630 {
3631 public:
3632+ MockPromptSession();
3633+ virtual ~MockPromptSession();
3634+
3635 MOCK_METHOD1(start, void(std::shared_ptr<Session> const&));
3636 MOCK_METHOD1(stop, void(std::shared_ptr<Session> const&));
3637 MOCK_METHOD1(suspend, void(std::shared_ptr<Session> const&));
3638
3639=== added file 'tests/framework/mock_prompt_session_manager.cpp'
3640--- tests/framework/mock_prompt_session_manager.cpp 1970-01-01 00:00:00 +0000
3641+++ tests/framework/mock_prompt_session_manager.cpp 2016-02-03 11:35:51 +0000
3642@@ -0,0 +1,33 @@
3643+/*
3644+ * Copyright (C) 2015 Canonical, Ltd.
3645+ *
3646+ * This program is free software: you can redistribute it and/or modify it under
3647+ * the terms of the GNU Lesser General Public License version 3, as published by
3648+ * the Free Software Foundation.
3649+ *
3650+ * This program is distributed in the hope that it will be useful, but WITHOUT
3651+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3652+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3653+ * Lesser General Public License for more details.
3654+ *
3655+ * You should have received a copy of the GNU Lesser General Public License
3656+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3657+ */
3658+
3659+#include "mock_prompt_session_manager.h"
3660+
3661+namespace mir
3662+{
3663+namespace scene
3664+{
3665+
3666+MockPromptSessionManager::MockPromptSessionManager()
3667+{
3668+}
3669+
3670+MockPromptSessionManager::~MockPromptSessionManager()
3671+{
3672+}
3673+
3674+} // namespace scene
3675+} // namespace mir
3676
3677=== modified file 'tests/framework/mock_prompt_session_manager.h'
3678--- tests/modules/common/mock_prompt_session_manager.h 2015-08-11 12:08:32 +0000
3679+++ tests/framework/mock_prompt_session_manager.h 2016-02-03 11:35:51 +0000
3680@@ -28,6 +28,9 @@
3681 class MockPromptSessionManager: public PromptSessionManager
3682 {
3683 public:
3684+ MockPromptSessionManager();
3685+ virtual ~MockPromptSessionManager();
3686+
3687 MOCK_CONST_METHOD2(start_prompt_session_for, std::shared_ptr<PromptSession>(std::shared_ptr<mir::scene::Session> const&,
3688 mir::scene::PromptSessionCreationParameters const&));
3689
3690
3691=== added file 'tests/framework/mock_renderable.cpp'
3692--- tests/framework/mock_renderable.cpp 1970-01-01 00:00:00 +0000
3693+++ tests/framework/mock_renderable.cpp 2016-02-03 11:35:51 +0000
3694@@ -0,0 +1,33 @@
3695+/*
3696+ * Copyright (C) 2015 Canonical, Ltd.
3697+ *
3698+ * This program is free software: you can redistribute it and/or modify it under
3699+ * the terms of the GNU Lesser General Public License version 3, as published by
3700+ * the Free Software Foundation.
3701+ *
3702+ * This program is distributed in the hope that it will be useful, but WITHOUT
3703+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3704+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3705+ * Lesser General Public License for more details.
3706+ *
3707+ * You should have received a copy of the GNU Lesser General Public License
3708+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3709+ */
3710+
3711+#include "mock_renderable.h"
3712+
3713+namespace mir
3714+{
3715+namespace graphics
3716+{
3717+
3718+MockRenderable::MockRenderable()
3719+{
3720+}
3721+
3722+MockRenderable::~MockRenderable()
3723+{
3724+}
3725+
3726+} // namespace graphics
3727+} // namespace mir
3728
3729=== modified file 'tests/framework/mock_renderable.h'
3730--- tests/modules/common/mock_renderable.h 2015-08-11 12:08:32 +0000
3731+++ tests/framework/mock_renderable.h 2016-02-03 11:35:51 +0000
3732@@ -25,7 +25,8 @@
3733
3734 struct MockRenderable : public Renderable
3735 {
3736- MockRenderable() {};
3737+ MockRenderable();
3738+ virtual ~MockRenderable();
3739
3740 MOCK_CONST_METHOD0(id, ID());
3741 MOCK_CONST_METHOD0(buffer, std::shared_ptr<Buffer>());
3742
3743=== added file 'tests/framework/mock_session.cpp'
3744--- tests/framework/mock_session.cpp 1970-01-01 00:00:00 +0000
3745+++ tests/framework/mock_session.cpp 2016-02-03 11:35:51 +0000
3746@@ -0,0 +1,69 @@
3747+/*
3748+ * Copyright (C) 2015 Canonical, Ltd.
3749+ *
3750+ * This program is free software: you can redistribute it and/or modify it under
3751+ * the terms of the GNU Lesser General Public License version 3, as published by
3752+ * the Free Software Foundation.
3753+ *
3754+ * This program is distributed in the hope that it will be useful, but WITHOUT
3755+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3756+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3757+ * Lesser General Public License for more details.
3758+ *
3759+ * You should have received a copy of the GNU Lesser General Public License
3760+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3761+ */
3762+
3763+#include "mock_session.h"
3764+
3765+namespace qtmir
3766+{
3767+
3768+MockSession::MockSession()
3769+ : SessionInterface(0)
3770+{
3771+ m_state = Starting;
3772+ ON_CALL(*this, suspend()).WillByDefault(::testing::Invoke(this, &MockSession::doSuspend));
3773+ ON_CALL(*this, resume()).WillByDefault(::testing::Invoke(this, &MockSession::doResume));
3774+ ON_CALL(*this, stop()).WillByDefault(::testing::Invoke(this, &MockSession::doStop));
3775+ ON_CALL(*this, state()).WillByDefault(::testing::Invoke(this, &MockSession::doState));
3776+}
3777+
3778+MockSession::~MockSession()
3779+{
3780+
3781+}
3782+
3783+SessionInterface::State MockSession::doState() const
3784+{
3785+ return m_state;
3786+}
3787+
3788+void MockSession::doStop()
3789+{
3790+ setState(Stopped);
3791+}
3792+
3793+void MockSession::doResume()
3794+{
3795+ if (m_state == Suspending || m_state == Suspended) {
3796+ setState(Running);
3797+ }
3798+}
3799+
3800+void MockSession::doSuspend()
3801+{
3802+ if (m_state == Running) {
3803+ setState(Suspending);
3804+ }
3805+}
3806+
3807+void MockSession::setState(SessionInterface::State state)
3808+{
3809+ if (m_state != state) {
3810+ m_state = state;
3811+ Q_EMIT stateChanged(m_state);
3812+ }
3813+}
3814+
3815+} // namespace qtmir
3816
3817=== modified file 'tests/framework/mock_session.h'
3818--- tests/modules/common/mock_session.h 2015-12-07 12:02:48 +0000
3819+++ tests/framework/mock_session.h 2016-02-03 11:35:51 +0000
3820@@ -24,13 +24,8 @@
3821
3822 class MockSession : public SessionInterface {
3823 public:
3824- MockSession() : SessionInterface(0) {
3825- m_state = Starting;
3826- ON_CALL(*this, suspend()).WillByDefault(::testing::Invoke(this, &MockSession::doSuspend));
3827- ON_CALL(*this, resume()).WillByDefault(::testing::Invoke(this, &MockSession::doResume));
3828- ON_CALL(*this, stop()).WillByDefault(::testing::Invoke(this, &MockSession::doStop));
3829- ON_CALL(*this, state()).WillByDefault(::testing::Invoke(this, &MockSession::doState));
3830- }
3831+ MockSession();
3832+ virtual ~MockSession();
3833
3834 MOCK_METHOD0(release, void());
3835
3836@@ -66,29 +61,12 @@
3837 MOCK_CONST_METHOD0(activePromptSession, std::shared_ptr<mir::scene::PromptSession>());
3838 MOCK_CONST_METHOD1(foreachPromptSession, void(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> f));
3839
3840- void setState(State state) {
3841- if (m_state != state) {
3842- m_state = state;
3843- Q_EMIT stateChanged(m_state);
3844- }
3845- }
3846+ void setState(State state);
3847
3848- void doSuspend() {
3849- if (m_state == Running) {
3850- setState(Suspending);
3851- }
3852- }
3853- void doResume() {
3854- if (m_state == Suspending || m_state == Suspended) {
3855- setState(Running);
3856- }
3857- }
3858- void doStop() {
3859- setState(Stopped);
3860- }
3861- State doState() const {
3862- return m_state;
3863- }
3864+ void doSuspend();
3865+ void doResume();
3866+ void doStop();
3867+ State doState() const;
3868
3869 protected:
3870 MOCK_METHOD1(setFullscreen, void(bool fullscreen));
3871@@ -97,7 +75,6 @@
3872 MOCK_METHOD1(removePromptSession, void(const std::shared_ptr<mir::scene::PromptSession>& session));
3873
3874 private:
3875-
3876 State m_state;
3877 };
3878
3879
3880=== added file 'tests/framework/mock_settings.cpp'
3881--- tests/framework/mock_settings.cpp 1970-01-01 00:00:00 +0000
3882+++ tests/framework/mock_settings.cpp 2016-02-03 11:35:51 +0000
3883@@ -0,0 +1,40 @@
3884+/*
3885+ * Copyright (C) 2015 Canonical, Ltd.
3886+ *
3887+ * This program is free software: you can redistribute it and/or modify it under
3888+ * the terms of the GNU Lesser General Public License version 3, as published by
3889+ * the Free Software Foundation.
3890+ *
3891+ * This program is distributed in the hope that it will be useful, but WITHOUT
3892+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3893+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3894+ * Lesser General Public License for more details.
3895+ *
3896+ * You should have received a copy of the GNU Lesser General Public License
3897+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3898+ */
3899+
3900+#include "mock_settings.h"
3901+
3902+namespace qtmir
3903+{
3904+
3905+MockSettings::MockSettings()
3906+{
3907+ using namespace ::testing;
3908+
3909+ QVariantList lifecycleExemptAppIds;
3910+ lifecycleExemptAppIds << "com.ubuntu.music";
3911+ ON_CALL(*this, get(_))
3912+ .WillByDefault(
3913+ Return(lifecycleExemptAppIds));
3914+
3915+}
3916+
3917+MockSettings::~MockSettings()
3918+{
3919+
3920+}
3921+
3922+} // namespace qtmir
3923+
3924
3925=== modified file 'tests/framework/mock_settings.h'
3926--- tests/modules/common/mock_settings.h 2015-03-24 23:38:33 +0000
3927+++ tests/framework/mock_settings.h 2016-02-03 11:35:51 +0000
3928@@ -18,24 +18,20 @@
3929 #define MOCK_SETTINGS_H
3930
3931 #include <Unity/Application/settings_interface.h>
3932-
3933+#include <QVariant>
3934+
3935 #include <gmock/gmock.h>
3936
3937-namespace testing
3938+namespace qtmir
3939 {
3940 struct MockSettings : public qtmir::SettingsInterface
3941 {
3942- MockSettings()
3943- {
3944- QVariantList lifecycleExemptAppIds;
3945- lifecycleExemptAppIds << "com.ubuntu.music";
3946- ON_CALL(*this, get(_))
3947- .WillByDefault(
3948- Return(lifecycleExemptAppIds));
3949+ MockSettings();
3950+ virtual ~MockSettings();
3951
3952- }
3953 MOCK_CONST_METHOD1(get, QVariant(const QString &));
3954 };
3955
3956-} // namespace testing
3957+} // namespace qtmir
3958+
3959 #endif // MOCK_SETTINGS_H
3960
3961=== added file 'tests/framework/mock_shared_wakelock.cpp'
3962--- tests/framework/mock_shared_wakelock.cpp 1970-01-01 00:00:00 +0000
3963+++ tests/framework/mock_shared_wakelock.cpp 2016-02-03 11:35:51 +0000
3964@@ -0,0 +1,61 @@
3965+/*
3966+ * Copyright (C) 2015 Canonical, Ltd.
3967+ *
3968+ * This program is free software: you can redistribute it and/or modify it under
3969+ * the terms of the GNU Lesser General Public License version 3, as published by
3970+ * the Free Software Foundation.
3971+ *
3972+ * This program is distributed in the hope that it will be useful, but WITHOUT
3973+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3974+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3975+ * Lesser General Public License for more details.
3976+ *
3977+ * You should have received a copy of the GNU Lesser General Public License
3978+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3979+ */
3980+
3981+#include "mock_shared_wakelock.h"
3982+
3983+namespace qtmir
3984+{
3985+
3986+MockSharedWakelock::MockSharedWakelock(const QDBusConnection &)
3987+{
3988+ using namespace ::testing;
3989+
3990+ ON_CALL(*this, enabled()).WillByDefault(Invoke(this, &MockSharedWakelock::doEnabled));
3991+ ON_CALL(*this, acquire(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doAcquire));
3992+ ON_CALL(*this, release(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doRelease));
3993+}
3994+
3995+MockSharedWakelock::~MockSharedWakelock()
3996+{
3997+}
3998+
3999+void MockSharedWakelock::doRelease(const QObject *object)
4000+{
4001+ if (!m_owners.remove(object)) {
4002+ return;
4003+ }
4004+ if (m_owners.isEmpty()) {
4005+ Q_EMIT enabledChanged(false);
4006+ }
4007+}
4008+
4009+void MockSharedWakelock::doAcquire(const QObject *object)
4010+{
4011+ if (m_owners.contains(object)) {
4012+ return;
4013+ }
4014+ m_owners.insert(object);
4015+ if (m_owners.size() == 1) {
4016+ Q_EMIT enabledChanged(true);
4017+ }
4018+}
4019+
4020+bool MockSharedWakelock::doEnabled()
4021+{
4022+ return !m_owners.isEmpty();
4023+}
4024+
4025+} // namespace qtmir
4026
4027=== modified file 'tests/framework/mock_shared_wakelock.h'
4028--- tests/modules/common/mock_shared_wakelock.h 2015-03-05 09:36:02 +0000
4029+++ tests/framework/mock_shared_wakelock.h 2016-02-03 11:35:51 +0000
4030@@ -21,51 +21,26 @@
4031
4032 #include <gmock/gmock.h>
4033
4034-namespace testing
4035+namespace qtmir
4036 {
4037 class MockSharedWakelock : public qtmir::SharedWakelock
4038 {
4039 public:
4040- MockSharedWakelock(const QDBusConnection& /*connection*/= QDBusConnection::systemBus())
4041- {
4042- ON_CALL(*this, enabled()).WillByDefault(Invoke(this, &MockSharedWakelock::doEnabled));
4043- ON_CALL(*this, acquire(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doAcquire));
4044- ON_CALL(*this, release(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doRelease));
4045- }
4046+ MockSharedWakelock(const QDBusConnection& /*connection*/= QDBusConnection::systemBus());
4047+ virtual ~MockSharedWakelock();
4048
4049 MOCK_CONST_METHOD0(enabled, bool());
4050 MOCK_METHOD1(acquire, void(const QObject *));
4051 MOCK_METHOD1(release, void(const QObject *));
4052
4053- bool doEnabled()
4054- {
4055- return !m_owners.isEmpty();
4056- }
4057-
4058- void doAcquire(const QObject *object)
4059- {
4060- if (m_owners.contains(object)) {
4061- return;
4062- }
4063- m_owners.insert(object);
4064- if (m_owners.size() == 1) {
4065- Q_EMIT enabledChanged(true);
4066- }
4067- }
4068-
4069- void doRelease(const QObject *object)
4070- {
4071- if (!m_owners.remove(object)) {
4072- return;
4073- }
4074- if (m_owners.isEmpty()) {
4075- Q_EMIT enabledChanged(false);
4076- }
4077- }
4078+ bool doEnabled();
4079+ void doAcquire(const QObject *object);
4080+ void doRelease(const QObject *object);
4081
4082 private:
4083 QSet<const QObject *> m_owners;
4084 };
4085
4086-} // namespace testing
4087+} // namespace qtmir
4088+
4089 #endif // MOCK_SHARED_WAKELOCK_H
4090
4091=== added file 'tests/framework/mock_surface.cpp'
4092--- tests/framework/mock_surface.cpp 1970-01-01 00:00:00 +0000
4093+++ tests/framework/mock_surface.cpp 2016-02-03 11:35:51 +0000
4094@@ -0,0 +1,45 @@
4095+/*
4096+ * Copyright (C) 2015 Canonical, Ltd.
4097+ *
4098+ * This program is free software: you can redistribute it and/or modify it under
4099+ * the terms of the GNU Lesser General Public License version 3, as published by
4100+ * the Free Software Foundation.
4101+ *
4102+ * This program is distributed in the hope that it will be useful, but WITHOUT
4103+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
4104+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4105+ * Lesser General Public License for more details.
4106+ *
4107+ * You should have received a copy of the GNU Lesser General Public License
4108+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4109+ */
4110+
4111+#include "mock_surface.h"
4112+
4113+namespace mir
4114+{
4115+namespace scene
4116+{
4117+
4118+MockSurface::MockSurface()
4119+{
4120+}
4121+
4122+MockSurface::~MockSurface()
4123+{
4124+}
4125+
4126+void MockSurface::rename(const std::string &) {}
4127+
4128+void MockSurface::set_keymap(MirInputDeviceId,
4129+ std::string const&,
4130+ std::string const&,
4131+ std::string const&,
4132+ std::string const&)
4133+{
4134+}
4135+
4136+// void MockSurface::consume(const MirEvent &event) { consume(&event); }
4137+
4138+} // namespace scene
4139+} // namespace mir
4140
4141=== modified file 'tests/framework/mock_surface.h'
4142--- tests/modules/common/mock_surface.h 2016-01-24 02:51:34 +0000
4143+++ tests/framework/mock_surface.h 2016-02-03 11:35:51 +0000
4144@@ -28,7 +28,8 @@
4145
4146 struct MockSurface : public mir::scene::Surface
4147 {
4148- MockSurface() {}
4149+ MockSurface();
4150+ virtual ~MockSurface();
4151
4152 MOCK_CONST_METHOD0(name, std::string());
4153 MOCK_CONST_METHOD0(client_size, geometry::Size());
4154@@ -63,15 +64,15 @@
4155 MOCK_METHOD0(request_client_surface_close, void());
4156 MOCK_CONST_METHOD1(buffers_ready_for_compositor, int(void const*));
4157 void set_keymap(MirInputDeviceId, std::string const&, std::string const&,
4158- std::string const&, std::string const&) override {}
4159- void rename(std::string const&) override {}
4160+ std::string const&, std::string const&) override;
4161+ void rename(std::string const&) override;
4162 MOCK_METHOD1(set_streams, void(std::list<StreamInfo> const&));
4163
4164 // from mir::input::surface
4165 MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point));
4166 MOCK_CONST_METHOD0(reception_mode, input::InputReceptionMode());
4167 MOCK_METHOD1(consume, void(MirEvent const* event));
4168- //void consume(MirEvent const* event) override { consume(event); }
4169+ //void consume(MirEvent const* event) override;
4170
4171 // from mir::frontend::surface
4172 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
4173
4174=== added file 'tests/framework/mock_task_controller.cpp'
4175--- tests/framework/mock_task_controller.cpp 1970-01-01 00:00:00 +0000
4176+++ tests/framework/mock_task_controller.cpp 2016-02-03 11:35:51 +0000
4177@@ -0,0 +1,129 @@
4178+/*
4179+ * Copyright (C) 2015 Canonical, Ltd.
4180+ *
4181+ * This program is free software: you can redistribute it and/or modify it under
4182+ * the terms of the GNU Lesser General Public License version 3, as published by
4183+ * the Free Software Foundation.
4184+ *
4185+ * This program is distributed in the hope that it will be useful, but WITHOUT
4186+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
4187+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4188+ * Lesser General Public License for more details.
4189+ *
4190+ * You should have received a copy of the GNU Lesser General Public License
4191+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4192+ */
4193+
4194+#include "mock_task_controller.h"
4195+
4196+namespace qtmir
4197+{
4198+
4199+MockTaskController::MockTaskController()
4200+{
4201+ using namespace ::testing;
4202+ ON_CALL(*this, primaryPidForAppId(_))
4203+ .WillByDefault(
4204+ Invoke(this, &MockTaskController::doPrimaryPidForAppId));
4205+
4206+ ON_CALL(*this, appIdHasProcessId(_, _))
4207+ .WillByDefault(
4208+ Invoke(this, &MockTaskController::doAppIdHasProcessId));
4209+
4210+ ON_CALL(*this, findDesktopFileForAppId(_))
4211+ .WillByDefault(
4212+ Invoke(this, &MockTaskController::doFindDesktopFileForAppId));
4213+
4214+ ON_CALL(*this, stop(_))
4215+ .WillByDefault(
4216+ Invoke(this, &MockTaskController::doStop));
4217+
4218+ ON_CALL(*this, start(_, _))
4219+ .WillByDefault(
4220+ Invoke(this, &MockTaskController::doStart));
4221+
4222+ ON_CALL(*this, suspend(_))
4223+ .WillByDefault(
4224+ Invoke(this, &MockTaskController::doSuspend));
4225+
4226+ ON_CALL(*this, resume(_))
4227+ .WillByDefault(
4228+ Invoke(this, &MockTaskController::doResume));
4229+}
4230+
4231+MockTaskController::~MockTaskController()
4232+{
4233+
4234+}
4235+
4236+pid_t MockTaskController::doPrimaryPidForAppId(const QString &appId)
4237+{
4238+ auto it = children.find(appId);
4239+ if (it == children.end())
4240+ return -1;
4241+
4242+ return it->pid();
4243+}
4244+
4245+
4246+bool MockTaskController::doAppIdHasProcessId(const QString &appId, pid_t pid)
4247+{
4248+ auto it = children.find(appId);
4249+ if (it == children.end())
4250+ return -1;
4251+
4252+ return it->pid() == pid;
4253+}
4254+
4255+
4256+QFileInfo MockTaskController::doFindDesktopFileForAppId(const QString &appId) const
4257+{
4258+ QString path = QString("/usr/share/applications/%1.desktop").arg(appId);
4259+ return QFileInfo(path);
4260+}
4261+
4262+
4263+bool MockTaskController::doStop(const QString &appId)
4264+{
4265+ Q_UNUSED(appId);
4266+
4267+ return false;
4268+}
4269+
4270+
4271+bool MockTaskController::doStart(const QString &appId, const QStringList &args)
4272+{
4273+ Q_UNUSED(args);
4274+
4275+ auto child = core::posix::fork([]()
4276+ {
4277+ while (true);
4278+
4279+ return core::posix::exit::Status::success;
4280+ }, core::posix::StandardStream::empty);
4281+
4282+ if (child.pid() > 0)
4283+ {
4284+ children.insert(appId, child);
4285+ return true;
4286+ }
4287+
4288+ return false;
4289+}
4290+
4291+
4292+bool MockTaskController::doSuspend(const QString &appId)
4293+{
4294+ Q_UNUSED(appId);
4295+
4296+ return false;
4297+}
4298+
4299+bool MockTaskController::doResume(const QString &appId)
4300+{
4301+ Q_UNUSED(appId);
4302+
4303+ return false;
4304+}
4305+
4306+} // namespace qtmir
4307
4308=== renamed file 'tests/modules/common/mock_application_controller.h' => 'tests/framework/mock_task_controller.h'
4309--- tests/modules/common/mock_application_controller.h 2015-08-11 12:08:32 +0000
4310+++ tests/framework/mock_task_controller.h 2016-02-03 11:35:51 +0000
4311@@ -14,127 +14,50 @@
4312 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4313 */
4314
4315-#ifndef MOCK_APPLICATION_CONTROLLER_H
4316-#define MOCK_APPLICATION_CONTROLLER_H
4317+#ifndef MOCK_TASK_CONTROLLER_H
4318+#define MOCK_TASK_CONTROLLER_H
4319
4320-#include <Unity/Application/applicationcontroller.h>
4321+#include <Unity/Application/taskcontroller.h>
4322+#include <QMap>
4323
4324 #include <core/posix/fork.h>
4325
4326 #include <gmock/gmock.h>
4327
4328-namespace testing
4329-{
4330-struct MockApplicationController : public qtmir::ApplicationController
4331-{
4332+namespace qtmir
4333+{
4334+struct MockTaskController : public qtmir::TaskController
4335+{
4336+ MockTaskController();
4337+ virtual ~MockTaskController();
4338+
4339 MOCK_METHOD1(primaryPidForAppId, pid_t(const QString& appId));
4340- MOCK_METHOD2(appIdHasProcessId, bool(pid_t, const QString&));
4341+ MOCK_METHOD2(appIdHasProcessId, bool(const QString&, pid_t));
4342 MOCK_CONST_METHOD1(findDesktopFileForAppId, QFileInfo(const QString &appId));
4343
4344- MOCK_METHOD1(stopApplicationWithAppId, bool(const QString&));
4345- MOCK_METHOD2(startApplicationWithAppIdAndArgs, bool(const QString&, const QStringList&));
4346- MOCK_METHOD1(pauseApplicationWithAppId, bool(const QString&));
4347- MOCK_METHOD1(resumeApplicationWithAppId, bool(const QString&));
4348-
4349- MockApplicationController()
4350- {
4351- using namespace ::testing;
4352- ON_CALL(*this, primaryPidForAppId(_))
4353- .WillByDefault(
4354- Invoke(this, &MockApplicationController::doPrimaryPidForAppId));
4355-
4356- ON_CALL(*this, appIdHasProcessId(_, _))
4357- .WillByDefault(
4358- Invoke(this, &MockApplicationController::doAppIdHasProcessId));
4359-
4360- ON_CALL(*this, findDesktopFileForAppId(_))
4361- .WillByDefault(
4362- Invoke(this, &MockApplicationController::doFindDesktopFileForAppId));
4363-
4364- ON_CALL(*this, stopApplicationWithAppId(_))
4365- .WillByDefault(
4366- Invoke(this, &MockApplicationController::doStopApplicationWithAppId));
4367-
4368- ON_CALL(*this, startApplicationWithAppIdAndArgs(_, _))
4369- .WillByDefault(
4370- Invoke(this, &MockApplicationController::doStartApplicationWithAppIdAndArgs));
4371-
4372- ON_CALL(*this, pauseApplicationWithAppId(_))
4373- .WillByDefault(
4374- Invoke(this, &MockApplicationController::doPauseApplicationWithAppId));
4375-
4376- ON_CALL(*this, resumeApplicationWithAppId(_))
4377- .WillByDefault(
4378- Invoke(this, &MockApplicationController::doResumeApplicationWithAppId));
4379- }
4380-
4381- pid_t doPrimaryPidForAppId(const QString& appId)
4382- {
4383- auto it = children.find(appId);
4384- if (it == children.end())
4385- return -1;
4386-
4387- return it->pid();
4388- }
4389-
4390- bool doAppIdHasProcessId(pid_t pid, const QString& appId)
4391- {
4392- auto it = children.find(appId);
4393- if (it == children.end())
4394- return -1;
4395-
4396- return it->pid() == pid;
4397- }
4398-
4399- QFileInfo doFindDesktopFileForAppId(const QString& appId) const
4400- {
4401- QString path = QString("/usr/share/applications/%1.desktop").arg(appId);
4402- return QFileInfo(path);
4403- }
4404-
4405- bool doStopApplicationWithAppId(const QString& appId)
4406- {
4407- Q_UNUSED(appId);
4408-
4409- return false;
4410- }
4411-
4412- bool doStartApplicationWithAppIdAndArgs(const QString& appId, const QStringList& args)
4413- {
4414- Q_UNUSED(args);
4415-
4416- auto child = core::posix::fork([]()
4417- {
4418- while (true);
4419-
4420- return core::posix::exit::Status::success;
4421- }, core::posix::StandardStream::empty);
4422-
4423- if (child.pid() > 0)
4424- {
4425- children.insert(appId, child);
4426- return true;
4427- }
4428-
4429- return false;
4430- }
4431-
4432- bool doPauseApplicationWithAppId(const QString& appId)
4433- {
4434- Q_UNUSED(appId);
4435-
4436- return false;
4437- }
4438-
4439- bool doResumeApplicationWithAppId(const QString& appId)
4440- {
4441- Q_UNUSED(appId);
4442-
4443- return false;
4444- }
4445-
4446+ MOCK_METHOD1(stop, bool(const QString&));
4447+ MOCK_METHOD2(start, bool(const QString&, const QStringList&));
4448+ MOCK_METHOD1(suspend, bool(const QString&));
4449+ MOCK_METHOD1(resume, bool(const QString&));
4450+
4451+ pid_t doPrimaryPidForAppId(const QString& appId);
4452+
4453+ bool doAppIdHasProcessId(const QString& appId, pid_t pid);
4454+
4455+ QFileInfo doFindDesktopFileForAppId(const QString& appId) const;
4456+
4457+ bool doStop(const QString& appId);
4458+
4459+ bool doStart(const QString& appId, const QStringList& args);
4460+
4461+ bool doSuspend(const QString& appId);
4462+
4463+ bool doResume(const QString& appId);
4464+
4465+private:
4466 QMap<QString, core::posix::ChildProcess> children;
4467 };
4468-} // namespace testing
4469-
4470-#endif // MOCK_APPLICATION_CONTROLLER_H
4471+
4472+} // namespace qtmir
4473+
4474+#endif // MOCK_TASK_CONTROLLER_H
4475
4476=== modified file 'tests/framework/qtmir_test.cpp'
4477--- tests/modules/common/qtmir_test.cpp 2016-01-22 16:32:39 +0000
4478+++ tests/framework/qtmir_test.cpp 2016-02-03 11:35:51 +0000
4479@@ -18,7 +18,8 @@
4480
4481 namespace qtmir {
4482
4483-void PrintTo(const Application::InternalState& state, ::std::ostream* os) {
4484+void PrintTo(const Application::InternalState& state, ::std::ostream* os)
4485+{
4486 switch (state) {
4487 case Application::InternalState::Starting:
4488 *os << "Starting";
4489@@ -77,4 +78,97 @@
4490 }
4491 }
4492
4493+// Initialization of mir::Server needed for by tests
4494+class TestMirServerInit : public virtual mir::Server
4495+{
4496+public:
4497+ TestMirServerInit(std::shared_ptr<StubPromptSessionManager> const& promptSessionManager)
4498+ : mock_prompt_session_manager(promptSessionManager)
4499+ {
4500+ override_the_prompt_session_manager(
4501+ [this]{ return the_mock_prompt_session_manager(); });
4502+ }
4503+
4504+ std::shared_ptr<mir::scene::MockPromptSessionManager> the_mock_prompt_session_manager()
4505+ {
4506+ return mock_prompt_session_manager;
4507+ }
4508+
4509+private:
4510+ std::shared_ptr<StubPromptSessionManager> const mock_prompt_session_manager;
4511+};
4512+
4513+
4514+namespace { char const* argv[] = { nullptr }; }
4515+
4516+class FakeMirServer: private TestMirServerInit, public MirServer
4517+{
4518+public:
4519+ FakeMirServer(std::shared_ptr<StubPromptSessionManager> const& promptSessionManager)
4520+ : TestMirServerInit(promptSessionManager), MirServer(0, argv, QSharedPointer<ScreenController>())
4521+ {
4522+ }
4523+
4524+ using TestMirServerInit::the_mock_prompt_session_manager;
4525+};
4526+
4527 } // namespace qtmir
4528+
4529+namespace testing
4530+{
4531+
4532+QtMirTest::QtMirTest()
4533+ : promptSessionManager(std::make_shared<StubPromptSessionManager>())
4534+ , mirServer(QSharedPointer<MirServer>(new FakeMirServer(promptSessionManager)))
4535+ , applicationManager(mirServer,
4536+ taskControllerSharedPointer,
4537+ QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}),
4538+ QSharedPointer<DesktopFileReader::Factory>(&desktopFileReaderFactory,[](DesktopFileReader::Factory*){}),
4539+ QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}),
4540+ QSharedPointer<MockSettings>(&settings,[](MockSettings *){}))
4541+ , sessionManager(mirServer, &applicationManager)
4542+ , surfaceManager(mirServer, mirShell, &sessionManager)
4543+{
4544+}
4545+
4546+QtMirTest::~QtMirTest()
4547+{
4548+
4549+}
4550+
4551+Application *QtMirTest::startApplication(pid_t procId, const QString &appId)
4552+{
4553+ using namespace testing;
4554+
4555+ ON_CALL(*taskController,appIdHasProcessId(appId, procId)).WillByDefault(Return(true));
4556+
4557+ // Set up Mocks & signal watcher
4558+ auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
4559+ ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
4560+ ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
4561+
4562+ EXPECT_CALL(desktopFileReaderFactory, createInstance(appId, _))
4563+ .Times(1)
4564+ .WillOnce(Return(mockDesktopFileReader));
4565+
4566+ EXPECT_CALL(*taskController, start(appId, _))
4567+ .Times(1)
4568+ .WillOnce(Return(true));
4569+
4570+ auto application = applicationManager.startApplication(appId, ApplicationManager::NoFlag);
4571+ applicationManager.onProcessStarting(appId);
4572+
4573+ bool authed = false;
4574+ applicationManager.authorizeSession(procId, authed);
4575+ EXPECT_EQ(authed, true);
4576+
4577+ auto appSession = std::make_shared<mir::scene::MockSession>(appId.toStdString(), procId);
4578+ applicationManager.onSessionStarting(appSession);
4579+ sessionManager.onSessionStarting(appSession);
4580+
4581+ Mock::VerifyAndClearExpectations(taskController);
4582+ Mock::VerifyAndClearExpectations(&desktopFileReaderFactory);
4583+ return application;
4584+}
4585+
4586+} // namespace testing
4587
4588=== modified file 'tests/framework/qtmir_test.h'
4589--- tests/modules/common/qtmir_test.h 2015-12-07 10:51:03 +0000
4590+++ tests/framework/qtmir_test.h 2016-02-03 11:35:51 +0000
4591@@ -21,18 +21,17 @@
4592
4593 #include <gtest/gtest.h>
4594
4595+#include <QSharedPointer>
4596+
4597 #include <Unity/Application/application.h>
4598 #include <Unity/Application/application_manager.h>
4599-#include <Unity/Application/applicationcontroller.h>
4600 #include <Unity/Application/mirsurfacemanager.h>
4601 #include <Unity/Application/sessionmanager.h>
4602 #include <Unity/Application/session_interface.h>
4603 #include <Unity/Application/sharedwakelock.h>
4604-#include <Unity/Application/taskcontroller.h>
4605 #include <Unity/Application/proc_info.h>
4606 #include <mirserver.h>
4607
4608-#include "mock_application_controller.h"
4609 #include "mock_desktop_file_reader.h"
4610 #include "mock_proc_info.h"
4611 #include "mock_mir_session.h"
4612@@ -40,51 +39,19 @@
4613 #include "mock_prompt_session.h"
4614 #include "mock_shared_wakelock.h"
4615 #include "mock_settings.h"
4616+#include "mock_task_controller.h"
4617
4618 namespace ms = mir::scene;
4619 using namespace qtmir;
4620
4621 namespace qtmir {
4622
4623+typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;
4624+
4625 // For better output in ASSERT_* and EXPECT_* error messages
4626 void PrintTo(const Application::InternalState& state, ::std::ostream* os);
4627 void PrintTo(const SessionInterface::State& state, ::std::ostream* os);
4628
4629-// Initialization of mir::Server needed for by tests
4630-class TestMirServerInit : public virtual mir::Server
4631-{
4632-public:
4633- TestMirServerInit()
4634- {
4635- override_the_prompt_session_manager(
4636- [this]{ return the_mock_prompt_session_manager(); });
4637- }
4638-
4639- std::shared_ptr<mir::scene::MockPromptSessionManager> the_mock_prompt_session_manager()
4640- {
4641- return mock_prompt_session_manager;
4642- }
4643-
4644-private:
4645- typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;
4646- std::shared_ptr<StubPromptSessionManager> const mock_prompt_session_manager
4647- {std::make_shared<StubPromptSessionManager>()};
4648-};
4649-
4650-
4651-namespace { char const* argv[] = { nullptr }; }
4652-
4653-class FakeMirServer: private TestMirServerInit, public MirServer
4654-{
4655-public:
4656- FakeMirServer()
4657- : MirServer(0, argv, QSharedPointer<ScreenController>())
4658- {
4659- }
4660-
4661- using TestMirServerInit::the_mock_prompt_session_manager;
4662-};
4663-
4664 } // namespace qtmir
4665
4666 namespace testing {
4667@@ -92,85 +59,21 @@
4668 class QtMirTest : public ::testing::Test
4669 {
4670 public:
4671- QtMirTest()
4672- : mirServer{
4673- QSharedPointer<FakeMirServer> (new FakeMirServer)
4674- }
4675- , taskController{
4676- QSharedPointer<TaskController> (
4677- new TaskController(
4678- nullptr,
4679- QSharedPointer<ApplicationController>(
4680- &appController,
4681- [](ApplicationController*){})
4682- )
4683- )
4684- }
4685- , applicationManager{
4686- mirServer,
4687- taskController,
4688- QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}),
4689- QSharedPointer<DesktopFileReader::Factory>(
4690- &desktopFileReaderFactory,
4691- [](DesktopFileReader::Factory*){}),
4692- QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}),
4693- QSharedPointer<MockSettings>(&settings,[](MockSettings *){})
4694- }
4695- , sessionManager{
4696- mirServer,
4697- &applicationManager,
4698- }
4699- , surfaceManager{
4700- mirServer,
4701- mirShell,
4702- &sessionManager
4703- }
4704- {
4705- }
4706-
4707- Application* startApplication(pid_t procId, QString const& appId)
4708- {
4709- using namespace testing;
4710-
4711- ON_CALL(appController,appIdHasProcessId(procId, appId)).WillByDefault(Return(true));
4712-
4713- // Set up Mocks & signal watcher
4714- auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
4715- ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
4716- ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
4717-
4718- EXPECT_CALL(desktopFileReaderFactory, createInstance(appId, _))
4719- .Times(1)
4720- .WillOnce(Return(mockDesktopFileReader));
4721-
4722- EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(appId, _))
4723- .Times(1)
4724- .WillOnce(Return(true));
4725-
4726- auto application = applicationManager.startApplication(appId, ApplicationManager::NoFlag);
4727- applicationManager.onProcessStarting(appId);
4728-
4729- bool authed = false;
4730- applicationManager.authorizeSession(procId, authed);
4731- EXPECT_EQ(authed, true);
4732-
4733- auto appSession = std::make_shared<mir::scene::MockSession>(appId.toStdString(), procId);
4734- applicationManager.onSessionStarting(appSession);
4735- sessionManager.onSessionStarting(appSession);
4736-
4737- Mock::VerifyAndClearExpectations(&appController);
4738- Mock::VerifyAndClearExpectations(&desktopFileReaderFactory);
4739- return application;
4740- }
4741-
4742- testing::NiceMock<testing::MockApplicationController> appController;
4743- testing::NiceMock<testing::MockProcInfo> procInfo;
4744- testing::NiceMock<testing::MockDesktopFileReaderFactory> desktopFileReaderFactory;
4745- testing::NiceMock<testing::MockSharedWakelock> sharedWakelock;
4746- testing::NiceMock<testing::MockSettings> settings;
4747- QSharedPointer<FakeMirServer> mirServer;
4748+ QtMirTest();
4749+ virtual ~QtMirTest();
4750+
4751+ Application* startApplication(pid_t procId, QString const& appId);
4752+
4753+ QSharedPointer<qtmir::TaskController> taskControllerSharedPointer{new testing::NiceMock<qtmir::MockTaskController>};
4754+ testing::NiceMock<qtmir::MockTaskController> *taskController{static_cast<testing::NiceMock<qtmir::MockTaskController>*>(taskControllerSharedPointer.data())};
4755+ testing::NiceMock<MockProcInfo> procInfo;
4756+ testing::NiceMock<MockDesktopFileReaderFactory> desktopFileReaderFactory;
4757+ testing::NiceMock<MockSharedWakelock> sharedWakelock;
4758+ testing::NiceMock<MockSettings> settings;
4759+ std::shared_ptr<StubPromptSessionManager> promptSessionManager;
4760+ QSharedPointer<MirServer> mirServer;
4761+
4762 MirShell *mirShell{nullptr};
4763- QSharedPointer<TaskController> taskController;
4764 ApplicationManager applicationManager;
4765 SessionManager sessionManager;
4766 MirSurfaceManager surfaceManager;
4767
4768=== added file 'tests/framework/stub_input_channel.cpp'
4769--- tests/framework/stub_input_channel.cpp 1970-01-01 00:00:00 +0000
4770+++ tests/framework/stub_input_channel.cpp 2016-02-03 11:35:51 +0000
4771@@ -0,0 +1,52 @@
4772+/*
4773+ * Copyright (C) 2015 Canonical, Ltd.
4774+ *
4775+ * This program is free software: you can redistribute it and/or modify it under
4776+ * the terms of the GNU Lesser General Public License version 3, as published by
4777+ * the Free Software Foundation.
4778+ *
4779+ * This program is distributed in the hope that it will be useful, but WITHOUT
4780+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
4781+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4782+ * Lesser General Public License for more details.
4783+ *
4784+ * You should have received a copy of the GNU Lesser General Public License
4785+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4786+ */
4787+
4788+#include "stub_input_channel.h"
4789+
4790+namespace mir
4791+{
4792+namespace test
4793+{
4794+namespace doubles
4795+{
4796+
4797+StubInputChannel::StubInputChannel(int fd)
4798+ : input_fd(fd)
4799+{
4800+}
4801+
4802+StubInputChannel::StubInputChannel()
4803+ : StubInputChannel(0)
4804+{
4805+}
4806+
4807+StubInputChannel::~StubInputChannel()
4808+{
4809+}
4810+
4811+int StubInputChannel::client_fd() const
4812+{
4813+ return input_fd;
4814+}
4815+
4816+int StubInputChannel::server_fd() const
4817+{
4818+ return input_fd;
4819+}
4820+
4821+} // namespace doubles
4822+} // namespace test
4823+} // namespace mir
4824
4825=== modified file 'tests/framework/stub_input_channel.h'
4826--- tests/modules/common/stub_input_channel.h 2015-08-11 12:08:32 +0000
4827+++ tests/framework/stub_input_channel.h 2016-02-03 11:35:51 +0000
4828@@ -28,24 +28,14 @@
4829
4830 struct StubInputChannel : public input::InputChannel
4831 {
4832- StubInputChannel(int fd)
4833- : input_fd(fd)
4834- {
4835- }
4836-
4837- StubInputChannel()
4838- : StubInputChannel(0)
4839- {
4840- }
4841-
4842- int client_fd() const override
4843- {
4844- return input_fd;
4845- }
4846- int server_fd() const override
4847- {
4848- return input_fd;
4849- }
4850+ StubInputChannel(int fd);
4851+
4852+ StubInputChannel();
4853+
4854+ virtual ~StubInputChannel();
4855+
4856+ int client_fd() const override;
4857+ int server_fd() const override;
4858 int input_fd;
4859 };
4860
4861
4862=== added file 'tests/framework/stub_scene_surface.cpp'
4863--- tests/framework/stub_scene_surface.cpp 1970-01-01 00:00:00 +0000
4864+++ tests/framework/stub_scene_surface.cpp 2016-02-03 11:35:51 +0000
4865@@ -0,0 +1,103 @@
4866+/*
4867+ * Copyright (C) 2015 Canonical, Ltd.
4868+ *
4869+ * This program is free software: you can redistribute it and/or modify it under
4870+ * the terms of the GNU Lesser General Public License version 3, as published by
4871+ * the Free Software Foundation.
4872+ *
4873+ * This program is distributed in the hope that it will be useful, but WITHOUT
4874+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
4875+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4876+ * Lesser General Public License for more details.
4877+ *
4878+ * You should have received a copy of the GNU Lesser General Public License
4879+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4880+ */
4881+
4882+#include "stub_scene_surface.h"
4883+
4884+namespace mir
4885+{
4886+namespace test
4887+{
4888+namespace doubles
4889+{
4890+
4891+StubSceneSurface::StubSceneSurface(int fd)
4892+ : channel(std::make_shared<StubInputChannel>(fd)), fd(fd)
4893+{
4894+}
4895+
4896+StubSceneSurface::~StubSceneSurface()
4897+{
4898+}
4899+
4900+std::shared_ptr<mir::input::InputChannel> StubSceneSurface::input_channel() const
4901+{
4902+ return channel;
4903+}
4904+
4905+mir::input::InputReceptionMode StubSceneSurface::reception_mode() const
4906+{
4907+ return input_mode;
4908+}
4909+
4910+std::string StubSceneSurface::name() const { return {}; }
4911+
4912+mir::geometry::Point StubSceneSurface::top_left() const { return {}; }
4913+
4914+mir::geometry::Size StubSceneSurface::client_size() const { return {};}
4915+
4916+mir::geometry::Size StubSceneSurface::size() const { return {}; }
4917+
4918+mir::geometry::Rectangle StubSceneSurface::input_bounds() const { return {{},{}}; }
4919+
4920+bool StubSceneSurface::input_area_contains(mir::geometry::Point const&) const { return false; }
4921+
4922+mir::graphics::RenderableList StubSceneSurface::generate_renderables(mir::compositor::CompositorID) const { return {};}
4923+
4924+float StubSceneSurface::alpha() const { return 0.0f; }
4925+
4926+MirSurfaceType StubSceneSurface::type() const { return mir_surface_type_normal; }
4927+
4928+MirSurfaceState StubSceneSurface::state() const { return mir_surface_state_unknown; }
4929+
4930+void StubSceneSurface::hide() {}
4931+
4932+void StubSceneSurface::show() {}
4933+
4934+void StubSceneSurface::move_to(const mir::geometry::Point &) {}
4935+
4936+void StubSceneSurface::set_input_region(const std::vector<mir::geometry::Rectangle> &) {}
4937+
4938+void StubSceneSurface::resize(const mir::geometry::Size &) {}
4939+
4940+void StubSceneSurface::set_transformation(const glm::mat4 &) {}
4941+
4942+void StubSceneSurface::set_alpha(float) {}
4943+
4944+void StubSceneSurface::set_orientation(MirOrientation) {}
4945+
4946+void StubSceneSurface::add_observer(const std::shared_ptr<mir::scene::SurfaceObserver> &) {}
4947+
4948+void StubSceneSurface::remove_observer(const std::weak_ptr<mir::scene::SurfaceObserver> &) {}
4949+
4950+void StubSceneSurface::set_reception_mode(mir::input::InputReceptionMode mode) { input_mode = mode; }
4951+
4952+void StubSceneSurface::consume(const MirEvent *) {}
4953+
4954+void StubSceneSurface::set_cursor_image(const std::shared_ptr<mir::graphics::CursorImage> &) {}
4955+
4956+std::shared_ptr<mir::graphics::CursorImage> StubSceneSurface::cursor_image() const { return {}; }
4957+
4958+bool StubSceneSurface::supports_input() const { return true; }
4959+
4960+int StubSceneSurface::client_input_fd() const { return fd;}
4961+
4962+int StubSceneSurface::configure(MirSurfaceAttrib, int) { return 0; }
4963+
4964+int StubSceneSurface::query(MirSurfaceAttrib) const { return 0; }
4965+
4966+} // namespace doubles
4967+} // namespace test
4968+} // namespace mir
4969
4970=== modified file 'tests/framework/stub_scene_surface.h'
4971--- tests/modules/common/stub_scene_surface.h 2016-01-20 20:01:54 +0000
4972+++ tests/framework/stub_scene_surface.h 2016-02-03 11:35:51 +0000
4973@@ -38,55 +38,47 @@
4974 int fd;
4975 mir::input::InputReceptionMode input_mode{mir::input::InputReceptionMode::normal};
4976
4977- StubSceneSurface(int fd)
4978- : channel(std::make_shared<StubInputChannel>(fd)), fd(fd)
4979- {
4980- }
4981-
4982- std::shared_ptr<mir::input::InputChannel> input_channel() const override
4983- {
4984- return channel;
4985- }
4986-
4987- mir::input::InputReceptionMode reception_mode() const override
4988- {
4989- return input_mode;
4990- }
4991-
4992- std::string name() const override { return {}; }
4993- geometry::Point top_left() const override { return {}; }
4994- geometry::Size client_size() const override { return {};}
4995- geometry::Size size() const override { return {}; }
4996- geometry::Rectangle input_bounds() const override { return {{},{}}; }
4997- bool input_area_contains(mir::geometry::Point const&) const override { return false; }
4998-
4999- graphics::RenderableList generate_renderables(compositor::CompositorID) const override { return {};}
5000- float alpha() const override { return 0.0f;}
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches