Merge lp:~nick-dedekind/qtmir/qtmir-test-build into lp:qtmir

Proposed by Nick Dedekind on 2015-09-30
Status: Merged
Approved by: Gerry Boland on 2015-12-16
Approved revision: 393
Merged at revision: 441
Proposed branch: lp:~nick-dedekind/qtmir/qtmir-test-build
Merge into: lp:qtmir
Diff against target: 3404 lines (+1807/-752)
57 files modified
CMakeLists.txt (+1/-1)
tests/CMakeLists.txt (+1/-0)
tests/framework/CMakeLists.txt (+45/-0)
tests/framework/fake_desktopfilereader.cpp (+68/-0)
tests/framework/fake_desktopfilereader.h (+22/-21)
tests/framework/fake_mirsurface.cpp (+212/-0)
tests/framework/fake_mirsurface.h (+48/-138)
tests/framework/fake_session.cpp (+119/-0)
tests/framework/fake_session.h (+35/-62)
tests/framework/mock_application_controller.cpp (+129/-0)
tests/framework/mock_application_controller.h (+22/-99)
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/qtmir_test.cpp (+99/-1)
tests/framework/qtmir_test.h (+15/-112)
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/modules/Application/CMakeLists.txt (+7/-6)
tests/modules/ApplicationManager/CMakeLists.txt (+7/-5)
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/mirsurfaceitem_test.cpp (+1/-1)
tests/modules/TaskController/CMakeLists.txt (+6/-2)
To merge this branch: bzr merge lp:~nick-dedekind/qtmir/qtmir-test-build
Reviewer Review Type Date Requested Status
MichaƂ Sawicz Abstain on 2016-02-11
Gerry Boland 2015-09-30 Approve on 2015-12-16
PS Jenkins bot continuous-integration Needs Fixing on 2015-12-16
Review via email: mp+272932@code.launchpad.net

Commit Message

Moved test framework into a static library for quicker recompilation.

Description of the Change

Moved test framework into a static library for quicker recompilation.

To post a comment you must log in.
382. By Nick Dedekind on 2015-09-30

Move test framework to library

383. By Nick Dedekind on 2015-10-01

undo new line removal

384. By Nick Dedekind on 2015-10-01

undo new line removal

Gerry Boland (gerboland) wrote :

Code style nit:
+void qtmir::FakeMirSurface::resize(int width, int height) {
should be changed to be:
+void qtmir::FakeMirSurface::resize(int width, int height)
+{
These slipped in sometime before this, but would you mind fixing them please?

The exception is for 1 liners, those are fine as they are:
+Mir::Type qtmir::FakeMirSurface::type() const { return Mir::NormalType; }

=== modified file 'CMakeLists.txt'
I think your editor dropped the newline at the file end, can you restore it please.

=== added file 'tests/framework/CMakeLists.txt'
these includes are not necessary:
+ ${CMAKE_SOURCE_DIR}/tests/modules/common
+ ${LTTNG_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}

=== added file 'tests/framework/fake_mirsurface.cpp'
=== added file 'tests/framework/fake_session.cpp'
Why not wrap everything in "namespace qtmir {" instead of using "qtmir::" everywhere?

=== added file 'tests/framework/stub_input_channel.cpp'
=== added file 'tests/framework/stub_scene_surface.cpp'
so::many::namespaces. Could use "namespace mtd = mir::test::doubles"
Are these taken from Mir? There's no copyright header.

This improves builds measurably, thank you so much. Phone OOM killer isn't striking while compiling appManTest any more!

Gerry Boland (gerboland) :
review: Needs Fixing
385. By Nick Dedekind on 2015-10-02

namespace rework

386. By Nick Dedekind on 2015-10-02

moved qtmir_test impl to cpp

387. By Nick Dedekind on 2015-10-02

removed unnecessary const

388. By Nick Dedekind on 2015-10-05

merge trunk

Nick Dedekind (nick-dedekind) wrote :

> Code style nit:
> +void qtmir::FakeMirSurface::resize(int width, int height) {
> should be changed to be:
> +void qtmir::FakeMirSurface::resize(int width, int height)
> +{
> These slipped in sometime before this, but would you mind fixing them please?
>
> The exception is for 1 liners, those are fine as they are:
> +Mir::Type qtmir::FakeMirSurface::type() const { return Mir::NormalType; }
>
>
>
> === modified file 'CMakeLists.txt'
> I think your editor dropped the newline at the file end, can you restore it
> please.
>
>
> === added file 'tests/framework/CMakeLists.txt'
> these includes are not necessary:
> + ${CMAKE_SOURCE_DIR}/tests/modules/common
> + ${LTTNG_INCLUDE_DIRS}
> + ${Qt5Gui_INCLUDE_DIRS}
>
>
> === added file 'tests/framework/fake_mirsurface.cpp'
> === added file 'tests/framework/fake_session.cpp'
> Why not wrap everything in "namespace qtmir {" instead of using "qtmir::"
> everywhere?
>
>
> === added file 'tests/framework/stub_input_channel.cpp'
> === added file 'tests/framework/stub_scene_surface.cpp'
> so::many::namespaces. Could use "namespace mtd = mir::test::doubles"
> Are these taken from Mir? There's no copyright header.
>
> This improves builds measurably, thank you so much. Phone OOM killer isn't
> striking while compiling appManTest any more!

Think I got everything.

Gerry Boland (gerboland) wrote :

Thanks for cleaning up the namespaces in the tests. qtmir everywhere is simpler.

=== added file 'tests/framework/fake_desktopfilereader.cpp'
=== added file 'tests/framework/fake_mirsurface.cpp'
=== added file 'tests/framework/fake_session.cpp'
=== added file 'tests/framework/mock_application_controller.cpp'
=== added file 'tests/framework/mock_desktop_file_reader.cpp'
=== added file 'tests/framework/mock_mir_session.cpp'
=== added file 'tests/framework/mock_proc_info.cpp'
=== added file 'tests/framework/mock_prompt_session.cpp'
=== added file 'tests/framework/mock_prompt_session_manager.cpp'
=== added file 'tests/framework/mock_renderable.cpp'
=== added file 'tests/framework/mock_session.cpp'
=== added file 'tests/framework/mock_settings.cpp'
=== added file 'tests/framework/mock_shared_wakelock.cpp'
=== added file 'tests/framework/mock_surface.cpp'
=== added file 'tests/framework/stub_input_channel.cpp'
=== added file 'tests/framework/stub_scene_surface.cpp'
all missing licence headers.

That's my only complaint tho. But I do anticipate merge conflicts appearing when the multimonitor silo lands. Hopefully not many

review: Needs Fixing
389. By Nick Dedekind on 2015-10-19

added copywrite

Nick Dedekind (nick-dedekind) wrote :

> Thanks for cleaning up the namespaces in the tests. qtmir everywhere is
> simpler.
>
> === added file 'tests/framework/fake_desktopfilereader.cpp'
> === added file 'tests/framework/fake_mirsurface.cpp'
> === added file 'tests/framework/fake_session.cpp'
> === added file 'tests/framework/mock_application_controller.cpp'
> === added file 'tests/framework/mock_desktop_file_reader.cpp'
> === added file 'tests/framework/mock_mir_session.cpp'
> === added file 'tests/framework/mock_proc_info.cpp'
> === added file 'tests/framework/mock_prompt_session.cpp'
> === added file 'tests/framework/mock_prompt_session_manager.cpp'
> === added file 'tests/framework/mock_renderable.cpp'
> === added file 'tests/framework/mock_session.cpp'
> === added file 'tests/framework/mock_settings.cpp'
> === added file 'tests/framework/mock_shared_wakelock.cpp'
> === added file 'tests/framework/mock_surface.cpp'
> === added file 'tests/framework/stub_input_channel.cpp'
> === added file 'tests/framework/stub_scene_surface.cpp'
> all missing licence headers.
>
> That's my only complaint tho. But I do anticipate merge conflicts appearing
> when the multimonitor silo lands. Hopefully not many

Fixed

Gerry Boland (gerboland) wrote :

Conflicts with trunk :(

390. By Nick Dedekind on 2015-11-11

merged with trunk

Nick Dedekind (nick-dedekind) wrote :

> Conflicts with trunk :(

Merged.

391. By Nick Dedekind on 2015-11-20

merged with trunk

392. By Nick Dedekind on 2015-12-15

merged with trunk

Gerry Boland (gerboland) wrote :

Am getting cmake warnings: http://pastebin.ubuntu.com/1404950/

393. By Nick Dedekind on 2015-12-16

removed dep loop

Gerry Boland (gerboland) wrote :

Works great, thanks!

review: Approve
394. By Nick Dedekind on 2016-02-01

merged with trunk

395. By Nick Dedekind on 2016-02-10

merged with trunk

MichaƂ Sawicz (saviq) wrote :

/«BUILDDIR»/qtmir-0.4.7+16.04.20160210/tests/modules/ApplicationManager/application_manager_test.cpp: In member function 'virtual void ApplicationManagerTests_CloseWhenSuspendedProcessFailed_Test::TestBody()':
/«BUILDDIR»/qtmir-0.4.7+16.04.20160210/tests/modules/ApplicationManager/application_manager_test.cpp:2305:51: error: no matching function for call to 'qtmir::ApplicationManager::onProcessFailed(const QString&, bool)'

review: Needs Fixing
MichaƂ Sawicz (saviq) wrote :

Oops, wrong branch.

review: Abstain

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-10 16:36:17 +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 'tests/CMakeLists.txt'
15--- tests/CMakeLists.txt 2014-12-03 08:56:35 +0000
16+++ tests/CMakeLists.txt 2016-02-10 16:36:17 +0000
17@@ -1,4 +1,5 @@
18 find_package(GMock)
19
20+add_subdirectory(framework)
21 add_subdirectory(mirserver)
22 add_subdirectory(modules)
23
24=== removed directory 'tests/common'
25=== renamed directory 'tests/modules/common' => 'tests/framework'
26=== added file 'tests/framework/CMakeLists.txt'
27--- tests/framework/CMakeLists.txt 1970-01-01 00:00:00 +0000
28+++ tests/framework/CMakeLists.txt 2016-02-10 16:36:17 +0000
29@@ -0,0 +1,45 @@
30+include_directories(
31+ ${APPLICATION_API_INCLUDE_DIRS}
32+ ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
33+ ${CMAKE_SOURCE_DIR}/src/modules
34+ ${MIRSERVER_INCLUDE_DIRS}
35+ ${MIRRENDERERGLDEV_INCLUDE_DIRS}
36+
37+ ${Qt5Quick_INCLUDE_DIRS}
38+ ${Qt5DBus_INCLUDE_DIRS}
39+)
40+
41+set(QTMIR_TEST_PRIVATE_SRC
42+ fake_desktopfilereader.cpp
43+ fake_mirsurface.cpp
44+ fake_session.cpp
45+ mock_application_controller.cpp
46+ mock_desktop_file_reader.cpp
47+ mock_display.cpp
48+ mock_display_configuration.cpp
49+ mock_gl_display_buffer.cpp
50+ mock_main_loop.cpp
51+ mock_mir_session.cpp
52+ mock_proc_info.cpp
53+ mock_prompt_session.cpp
54+ mock_prompt_session_manager.cpp
55+ mock_renderable.cpp
56+ mock_session.cpp
57+ mock_settings.cpp
58+ mock_shared_wakelock.cpp
59+ mock_surface.cpp
60+ stub_input_channel.cpp
61+ stub_scene_surface.cpp
62+ qtmir_test.cpp
63+)
64+
65+add_library(qtmir-test-framework-static STATIC
66+ ${QTMIR_TEST_PRIVATE_SRC}
67+)
68+
69+target_link_libraries(
70+ qtmir-test-framework-static
71+
72+ ${GTEST_BOTH_LIBRARIES}
73+ ${GMOCK_LIBRARIES}
74+)
75
76=== added file 'tests/framework/fake_desktopfilereader.cpp'
77--- tests/framework/fake_desktopfilereader.cpp 1970-01-01 00:00:00 +0000
78+++ tests/framework/fake_desktopfilereader.cpp 2016-02-10 16:36:17 +0000
79@@ -0,0 +1,68 @@
80+/*
81+ * Copyright (C) 2015 Canonical, Ltd.
82+ *
83+ * This program is free software: you can redistribute it and/or modify it under
84+ * the terms of the GNU Lesser General Public License version 3, as published by
85+ * the Free Software Foundation.
86+ *
87+ * This program is distributed in the hope that it will be useful, but WITHOUT
88+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
89+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
90+ * Lesser General Public License for more details.
91+ *
92+ * You should have received a copy of the GNU Lesser General Public License
93+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
94+ */
95+
96+#include "fake_desktopfilereader.h"
97+
98+namespace qtmir
99+{
100+
101+FakeDesktopFileReader::FakeDesktopFileReader()
102+ : DesktopFileReader()
103+ , m_appId("foo-app")
104+{
105+}
106+
107+FakeDesktopFileReader::~FakeDesktopFileReader()
108+{
109+}
110+
111+QString FakeDesktopFileReader::file() const { return QString(); }
112+
113+QString FakeDesktopFileReader::appId() const { return m_appId; }
114+
115+QString FakeDesktopFileReader::name() const { return QString(); }
116+
117+QString FakeDesktopFileReader::comment() const { return QString(); }
118+
119+QString FakeDesktopFileReader::icon() const { return QString(); }
120+
121+QString FakeDesktopFileReader::exec() const { return QString(); }
122+
123+QString FakeDesktopFileReader::path() const { return QString(); }
124+
125+QString FakeDesktopFileReader::stageHint() const { return QString(); }
126+
127+QString FakeDesktopFileReader::splashTitle() const { return QString(); }
128+
129+QString FakeDesktopFileReader::splashImage() const { return QString(); }
130+
131+QString FakeDesktopFileReader::splashShowHeader() const { return QString(); }
132+
133+QString FakeDesktopFileReader::splashColor() const { return QString(); }
134+
135+QString FakeDesktopFileReader::splashColorHeader() const { return QString(); }
136+
137+QString FakeDesktopFileReader::splashColorFooter() const { return QString(); }
138+
139+Qt::ScreenOrientations FakeDesktopFileReader::supportedOrientations() const { return Qt::PortraitOrientation; }
140+
141+bool FakeDesktopFileReader::rotatesWindowContents() const { return false; }
142+
143+bool FakeDesktopFileReader::isTouchApp() const { return true; }
144+
145+bool FakeDesktopFileReader::loaded() const { return true; }
146+
147+} // namespace qtmir
148
149=== modified file 'tests/framework/fake_desktopfilereader.h'
150--- tests/modules/common/fake_desktopfilereader.h 2015-09-28 20:11:39 +0000
151+++ tests/framework/fake_desktopfilereader.h 2016-02-10 16:36:17 +0000
152@@ -17,33 +17,34 @@
153 #ifndef FAKE_DESKTOPFILEREADER_H
154 #define FAKE_DESKTOPFILEREADER_H
155
156+#include <Unity/Application/desktopfilereader.h>
157+
158 namespace qtmir {
159
160 class FakeDesktopFileReader : public qtmir::DesktopFileReader
161 {
162 public:
163- FakeDesktopFileReader() : DesktopFileReader()
164- , m_appId("foo-app")
165- {}
166+ FakeDesktopFileReader();
167+ virtual ~FakeDesktopFileReader();
168
169- QString file() const override { return QString(); }
170- QString appId() const override { return m_appId; }
171- QString name() const override { return QString(); }
172- QString comment() const override { return QString(); }
173- QString icon() const override { return QString(); }
174- QString exec() const override { return QString(); }
175- QString path() const override { return QString(); }
176- QString stageHint() const override { return QString(); }
177- QString splashTitle() const override { return QString(); }
178- QString splashImage() const override { return QString(); }
179- QString splashShowHeader() const override { return QString(); }
180- QString splashColor() const override { return QString(); }
181- QString splashColorHeader() const override { return QString(); }
182- QString splashColorFooter() const override { return QString(); }
183- Qt::ScreenOrientations supportedOrientations() const override { return Qt::PortraitOrientation; }
184- bool rotatesWindowContents() const override { return false; }
185- bool isTouchApp() const override { return true; }
186- bool loaded() const override { return true; }
187+ QString file() const override;
188+ QString appId() const override;
189+ QString name() const override;
190+ QString comment() const override;
191+ QString icon() const override;
192+ QString exec() const override;
193+ QString path() const override;
194+ QString stageHint() const override;
195+ QString splashTitle() const override;
196+ QString splashImage() const override;
197+ QString splashShowHeader() const override;
198+ QString splashColor() const override;
199+ QString splashColorHeader() const override;
200+ QString splashColorFooter() const override;
201+ Qt::ScreenOrientations supportedOrientations() const override;
202+ bool rotatesWindowContents() const override;
203+ bool isTouchApp() const override;
204+ bool loaded() const override;
205
206 QString m_appId;
207 };
208
209=== renamed file 'tests/common/fake_displayconfigurationoutput.h' => 'tests/framework/fake_displayconfigurationoutput.h'
210=== added file 'tests/framework/fake_mirsurface.cpp'
211--- tests/framework/fake_mirsurface.cpp 1970-01-01 00:00:00 +0000
212+++ tests/framework/fake_mirsurface.cpp 2016-02-10 16:36:17 +0000
213@@ -0,0 +1,212 @@
214+/*
215+ * Copyright (C) 2015 Canonical, Ltd.
216+ *
217+ * This program is free software: you can redistribute it and/or modify it under
218+ * the terms of the GNU Lesser General Public License version 3, as published by
219+ * the Free Software Foundation.
220+ *
221+ * This program is distributed in the hope that it will be useful, but WITHOUT
222+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
223+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
224+ * Lesser General Public License for more details.
225+ *
226+ * You should have received a copy of the GNU Lesser General Public License
227+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
228+ */
229+
230+#include "fake_mirsurface.h"
231+
232+namespace qtmir
233+{
234+
235+FakeMirSurface::TouchEvent::TouchEvent(Qt::KeyboardModifiers mods,
236+ const QList<QTouchEvent::TouchPoint> &points,
237+ Qt::TouchPointStates states,
238+ ulong timestamp)
239+ : keyboardModifiers(mods)
240+ , touchPoints(points)
241+ , states(states)
242+ , timestamp(timestamp)
243+{
244+}
245+
246+FakeMirSurface::TouchEvent::~TouchEvent()
247+{
248+}
249+
250+FakeMirSurface::FakeMirSurface(QObject *parent)
251+ : MirSurfaceInterface(parent)
252+ , m_isFirstFrameDrawn(false)
253+ , m_isFrameDropperRunning(true)
254+ , m_live(true)
255+ , m_state(Mir::RestoredState)
256+ , m_orientationAngle(Mir::Angle0)
257+ , m_visible(true)
258+ , m_focused(false)
259+{
260+}
261+
262+FakeMirSurface::~FakeMirSurface()
263+{
264+}
265+
266+Mir::Type FakeMirSurface::type() const { return Mir::NormalType; }
267+
268+QString FakeMirSurface::name() const { return QString("Fake MirSurface"); }
269+
270+QSize FakeMirSurface::size() const { return m_size; }
271+
272+void FakeMirSurface::resize(int width, int height)
273+{
274+ if (m_size.width() != width || m_size.height() != height) {
275+ m_size.setWidth(width);
276+ m_size.setHeight(height);
277+ Q_EMIT sizeChanged(m_size);
278+ }
279+}
280+
281+void FakeMirSurface::resize(const QSize &size) { resize(size.width(), size.height()); }
282+
283+Mir::State FakeMirSurface::state() const { return m_state; }
284+
285+void FakeMirSurface::setState(Mir::State qmlState)
286+{
287+ if (qmlState != m_state) {
288+ m_state = qmlState;
289+ Q_EMIT stateChanged(m_state);
290+ }
291+}
292+
293+bool FakeMirSurface::live() const { return m_live; }
294+
295+bool FakeMirSurface::visible() const { return m_visible; }
296+
297+Mir::OrientationAngle FakeMirSurface::orientationAngle() const { return m_orientationAngle; }
298+
299+void FakeMirSurface::setOrientationAngle(Mir::OrientationAngle angle)
300+{
301+ if (m_orientationAngle != angle) {
302+ m_orientationAngle = angle;
303+ Q_EMIT orientationAngleChanged(m_orientationAngle);
304+ }
305+}
306+
307+bool FakeMirSurface::isFirstFrameDrawn() const
308+{
309+ return m_isFirstFrameDrawn;
310+}
311+
312+void FakeMirSurface::stopFrameDropper()
313+{
314+ m_isFrameDropperRunning = false;
315+}
316+
317+void FakeMirSurface::startFrameDropper()
318+{
319+ m_isFrameDropperRunning = true;
320+}
321+
322+void FakeMirSurface::setLive(bool value)
323+{
324+ if (m_live != value) {
325+ m_live = value;
326+ Q_EMIT liveChanged(m_live);
327+ }
328+}
329+
330+void FakeMirSurface::setViewVisibility(qintptr viewId, bool visible) {
331+ if (!m_views.contains(viewId)) return;
332+
333+ m_views[viewId] = visible;
334+ updateVisibility();
335+}
336+
337+bool FakeMirSurface::isBeingDisplayed() const { return !m_views.isEmpty(); }
338+
339+void FakeMirSurface::registerView(qintptr viewId)
340+{
341+ m_views.insert(viewId, false);
342+ if (m_views.count() == 1) {
343+ Q_EMIT isBeingDisplayedChanged();
344+ }
345+}
346+
347+void FakeMirSurface::unregisterView(qintptr viewId)
348+{
349+ m_views.remove(viewId);
350+ if (m_views.count() == 0) {
351+ Q_EMIT isBeingDisplayedChanged();
352+ }
353+ updateVisibility();
354+}
355+
356+QSharedPointer<QSGTexture> FakeMirSurface::texture() { return QSharedPointer<QSGTexture>(); }
357+
358+QSGTexture *FakeMirSurface::weakTexture() const { return nullptr; }
359+
360+bool FakeMirSurface::updateTexture() { return true; }
361+
362+unsigned int FakeMirSurface::currentFrameNumber() const { return 0; }
363+
364+bool FakeMirSurface::numBuffersReadyForCompositor() { return 0; }
365+
366+void FakeMirSurface::setFocus(bool focus) { m_focused = focus; }
367+
368+void FakeMirSurface::mousePressEvent(QMouseEvent *) {}
369+
370+void FakeMirSurface::mouseMoveEvent(QMouseEvent *) {}
371+
372+void FakeMirSurface::mouseReleaseEvent(QMouseEvent *) {}
373+
374+void FakeMirSurface::hoverEnterEvent(QHoverEvent *) {}
375+
376+void FakeMirSurface::hoverLeaveEvent(QHoverEvent *) {}
377+
378+void FakeMirSurface::hoverMoveEvent(QHoverEvent *) {}
379+
380+void FakeMirSurface::wheelEvent(QWheelEvent *) {}
381+
382+void FakeMirSurface::keyPressEvent(QKeyEvent *) {}
383+
384+void FakeMirSurface::keyReleaseEvent(QKeyEvent *) {}
385+
386+void FakeMirSurface::touchEvent(Qt::KeyboardModifiers mods,
387+ const QList<QTouchEvent::TouchPoint> &points,
388+ Qt::TouchPointStates states,
389+ ulong timestamp)
390+{
391+ m_touchesReceived.append(TouchEvent(mods, points, states, timestamp));
392+}
393+
394+QString FakeMirSurface::appId() const { return "foo-app"; }
395+
396+void FakeMirSurface::onCompositorSwappedBuffers() {}
397+
398+void FakeMirSurface::drawFirstFrame()
399+{
400+ if (!m_isFirstFrameDrawn) {
401+ m_isFirstFrameDrawn = true;
402+ Q_EMIT firstFrameDrawn();
403+ }
404+}
405+
406+bool FakeMirSurface::isFrameDropperRunning() const { return m_isFrameDropperRunning; }
407+
408+QList<FakeMirSurface::TouchEvent> &FakeMirSurface::touchesReceived() { return m_touchesReceived; }
409+
410+void FakeMirSurface::updateVisibility()
411+{
412+ bool newVisible = false;
413+ QHashIterator<int, bool> i(m_views);
414+ while (i.hasNext()) {
415+ i.next();
416+ newVisible |= i.value();
417+ }
418+
419+ if (m_visible != newVisible) {
420+ m_visible = newVisible;
421+ Q_EMIT visibleChanged(newVisible);
422+ }
423+}
424+
425+} // namespace qtmir
426
427=== modified file 'tests/framework/fake_mirsurface.h'
428--- tests/modules/common/fake_mirsurface.h 2015-12-10 13:08:43 +0000
429+++ tests/framework/fake_mirsurface.h 2016-02-10 16:36:17 +0000
430@@ -36,11 +36,8 @@
431 TouchEvent(Qt::KeyboardModifiers mods,
432 const QList<QTouchEvent::TouchPoint> &points,
433 Qt::TouchPointStates states,
434- ulong timestamp)
435- : keyboardModifiers(mods)
436- , touchPoints(points)
437- , states(states)
438- , timestamp(timestamp) {}
439+ ulong timestamp);
440+ virtual ~TouchEvent();
441
442 Qt::KeyboardModifiers keyboardModifiers;
443 QList<QTouchEvent::TouchPoint> touchPoints;
444@@ -48,129 +45,61 @@
445 ulong timestamp;
446 };
447
448-
449- FakeMirSurface(QObject *parent = nullptr)
450- : MirSurfaceInterface(parent)
451- , m_isFirstFrameDrawn(false)
452- , m_isFrameDropperRunning(true)
453- , m_live(true)
454- , m_state(Mir::RestoredState)
455- , m_orientationAngle(Mir::Angle0)
456- , m_visible(true)
457- , m_focused(false)
458- {}
459+ FakeMirSurface(QObject *parent = nullptr);
460+ virtual ~FakeMirSurface();
461
462 ////
463 // unity.shell.application.MirSurfaceInterface
464- Mir::Type type() const override { return Mir::NormalType; }
465-
466- QString name() const override { return QString("Fake MirSurface"); }
467-
468- QSize size() const override { return m_size; }
469-
470- void resize(int width, int height) override {
471- if (m_size.width() != width || m_size.height() != height) {
472- m_size.setWidth(width);
473- m_size.setHeight(height);
474- Q_EMIT sizeChanged(m_size);
475- }
476- }
477- void resize(const QSize &size) override { resize(size.width(), size.height()); }
478-
479- Mir::State state() const override { return m_state; }
480- void setState(Mir::State qmlState) override {
481- if (qmlState != m_state) {
482- m_state = qmlState;
483- Q_EMIT stateChanged(m_state);
484- }
485- }
486-
487- bool live() const override { return m_live; }
488-
489- bool visible() const override { return m_visible; }
490-
491- Mir::OrientationAngle orientationAngle() const override { return m_orientationAngle; }
492- void setOrientationAngle(Mir::OrientationAngle angle) override {
493- if (m_orientationAngle != angle) {
494- m_orientationAngle = angle;
495- Q_EMIT orientationAngleChanged(m_orientationAngle);
496- }
497- }
498+ Mir::Type type() const override;
499+ QString name() const override;
500+ QSize size() const override;
501+ void resize(int width, int height) override;
502+ void resize(const QSize &size) override;
503+ Mir::State state() const override;
504+ void setState(Mir::State qmlState) override;
505+ bool live() const override;
506+ bool visible() const override;
507+ Mir::OrientationAngle orientationAngle() const override;
508+ void setOrientationAngle(Mir::OrientationAngle angle) override;
509
510 ////
511 // qtmir.MirSurfaceInterface
512
513- bool isFirstFrameDrawn() const override {
514- return m_isFirstFrameDrawn;
515- }
516-
517- void stopFrameDropper() override {
518- m_isFrameDropperRunning = false;
519- }
520- void startFrameDropper() override {
521- m_isFrameDropperRunning = true;
522- }
523-
524- void setLive(bool value) override {
525- if (m_live != value) {
526- m_live = value;
527- Q_EMIT liveChanged(m_live);
528- }
529- }
530-
531- void setViewVisibility(qintptr viewId, bool visible) override {
532- if (!m_views.contains(viewId)) return;
533-
534- m_views[viewId] = visible;
535- updateVisibility();
536- }
537-
538- bool isBeingDisplayed() const override { return !m_views.isEmpty(); }
539-
540- void registerView(qintptr viewId) override {
541- m_views.insert(viewId, false);
542- if (m_views.count() == 1) {
543- Q_EMIT isBeingDisplayedChanged();
544- }
545- }
546-
547- void unregisterView(qintptr viewId) override {
548- m_views.remove(viewId);
549- if (m_views.count() == 0) {
550- Q_EMIT isBeingDisplayedChanged();
551- }
552- updateVisibility();
553- }
554+ bool isFirstFrameDrawn() const override;
555+ void stopFrameDropper() override;
556+ void startFrameDropper() override;
557+ void setLive(bool value) override;
558+ void setViewVisibility(qintptr viewId, bool visible) override;
559+ bool isBeingDisplayed() const override;
560+ void registerView(qintptr viewId) override;
561+ void unregisterView(qintptr viewId) override;
562
563 // methods called from the rendering (scene graph) thread:
564- QSharedPointer<QSGTexture> texture() override { return QSharedPointer<QSGTexture>(); }
565- QSGTexture *weakTexture() const override { return nullptr; }
566- bool updateTexture() override { return true; }
567- unsigned int currentFrameNumber() const override { return 0; }
568- bool numBuffersReadyForCompositor() override { return 0; }
569+ QSharedPointer<QSGTexture> texture() override;
570+ QSGTexture *weakTexture() const override;
571+ bool updateTexture() override;
572+ unsigned int currentFrameNumber() const override;
573+ bool numBuffersReadyForCompositor() override;
574 // end of methods called from the rendering (scene graph) thread
575
576- void setFocus(bool focus) override { m_focused = focus; }
577-
578- void mousePressEvent(QMouseEvent *) override {}
579- void mouseMoveEvent(QMouseEvent *) override {}
580- void mouseReleaseEvent(QMouseEvent *) override {}
581- void hoverEnterEvent(QHoverEvent *) override {}
582- void hoverLeaveEvent(QHoverEvent *) override {}
583- void hoverMoveEvent(QHoverEvent *) override {}
584- void wheelEvent(QWheelEvent *) override {}
585-
586- void keyPressEvent(QKeyEvent *) override {}
587- void keyReleaseEvent(QKeyEvent *) override {}
588+ void setFocus(bool focus) override;
589+
590+ void mousePressEvent(QMouseEvent *) override;
591+ void mouseMoveEvent(QMouseEvent *) override;
592+ void mouseReleaseEvent(QMouseEvent *) override;
593+ void hoverEnterEvent(QHoverEvent *) override;
594+ void hoverLeaveEvent(QHoverEvent *) override;
595+ void hoverMoveEvent(QHoverEvent *) override;
596+ void wheelEvent(QWheelEvent *) override;
597+ void keyPressEvent(QKeyEvent *) override;
598+ void keyReleaseEvent(QKeyEvent *) override;
599
600 void touchEvent(Qt::KeyboardModifiers mods,
601 const QList<QTouchEvent::TouchPoint> &points,
602 Qt::TouchPointStates states,
603- ulong timestamp) override {
604- m_touchesReceived.append(TouchEvent(mods, points, states, timestamp));
605- }
606+ ulong timestamp) override;
607
608- QString appId() const override { return "foo-app"; }
609+ QString appId() const override;
610
611 QCursor cursor() const override { return QCursor(); }
612
613@@ -182,40 +111,21 @@
614 void closeRequested();
615
616 public Q_SLOTS:
617- void onCompositorSwappedBuffers() override {}
618+ void onCompositorSwappedBuffers() override;
619
620 ////
621 // Test API from now on
622
623 public:
624
625- void drawFirstFrame() {
626- if (!m_isFirstFrameDrawn) {
627- m_isFirstFrameDrawn = true;
628- Q_EMIT firstFrameDrawn();
629- }
630- }
631-
632- bool isFrameDropperRunning() const {
633- return m_isFrameDropperRunning;
634- }
635-
636- QList<TouchEvent> &touchesReceived() { return m_touchesReceived; }
637+ void drawFirstFrame();
638+
639+ bool isFrameDropperRunning() const;
640+
641+ QList<TouchEvent> &touchesReceived();
642
643 private:
644- void updateVisibility() {
645- bool newVisible = false;
646- QHashIterator<int, bool> i(m_views);
647- while (i.hasNext()) {
648- i.next();
649- newVisible |= i.value();
650- }
651-
652- if (m_visible != newVisible) {
653- m_visible = newVisible;
654- Q_EMIT visibleChanged(newVisible);
655- }
656- }
657+ void updateVisibility();
658
659
660 bool m_isFirstFrameDrawn;
661
662=== added file 'tests/framework/fake_session.cpp'
663--- tests/framework/fake_session.cpp 1970-01-01 00:00:00 +0000
664+++ tests/framework/fake_session.cpp 2016-02-10 16:36:17 +0000
665@@ -0,0 +1,119 @@
666+/*
667+ * Copyright (C) 2015 Canonical, Ltd.
668+ *
669+ * This program is free software: you can redistribute it and/or modify it under
670+ * the terms of the GNU Lesser General Public License version 3, as published by
671+ * the Free Software Foundation.
672+ *
673+ * This program is distributed in the hope that it will be useful, but WITHOUT
674+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
675+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
676+ * Lesser General Public License for more details.
677+ *
678+ * You should have received a copy of the GNU Lesser General Public License
679+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
680+ */
681+
682+#include "fake_session.h"
683+
684+namespace qtmir
685+{
686+
687+FakeSession::FakeSession()
688+ : SessionInterface(0)
689+ , m_application(nullptr)
690+ , m_state(Starting)
691+{
692+}
693+
694+FakeSession::~FakeSession()
695+{
696+}
697+
698+void FakeSession::release() {}
699+
700+QString FakeSession::name() const { return QString("foo-session"); }
701+
702+unity::shell::application::ApplicationInfoInterface *FakeSession::application() const { return m_application; }
703+
704+MirSurfaceInterface *FakeSession::lastSurface() const { return nullptr; }
705+
706+const ObjectListModel<MirSurfaceInterface> *FakeSession::surfaces() const { return nullptr; }
707+
708+SessionInterface *FakeSession::parentSession() const { return nullptr; }
709+
710+SessionModel *FakeSession::childSessions() const { return nullptr; }
711+
712+SessionInterface::State FakeSession::state() const { return m_state; }
713+
714+bool FakeSession::fullscreen() const { return false; }
715+
716+bool FakeSession::live() const { return true; }
717+
718+std::shared_ptr<mir::scene::Session> FakeSession::session() const { return nullptr; }
719+
720+void FakeSession::registerSurface(MirSurfaceInterface *) {}
721+
722+void FakeSession::removeSurface(MirSurfaceInterface *) {}
723+
724+void FakeSession::setApplication(unity::shell::application::ApplicationInfoInterface *app)
725+{
726+ if (m_application != app) {
727+ m_application = app;
728+ Q_EMIT applicationChanged(m_application);
729+ }
730+}
731+
732+void FakeSession::suspend()
733+{
734+ if (m_state == Running) {
735+ setState(Suspending);
736+ }
737+}
738+
739+void FakeSession::resume()
740+{
741+ if (m_state == Suspending || m_state == Suspended) {
742+ setState(Running);
743+ }
744+}
745+
746+void FakeSession::stop()
747+{
748+ setState(Stopped);
749+}
750+
751+void FakeSession::close() {}
752+
753+void FakeSession::addChildSession(SessionInterface *) {}
754+
755+void FakeSession::insertChildSession(uint, SessionInterface *) {}
756+
757+void FakeSession::removeChildSession(SessionInterface *) {}
758+
759+void FakeSession::foreachChildSession(std::function<void (SessionInterface *)>) const {}
760+
761+std::shared_ptr<mir::scene::PromptSession> FakeSession::activePromptSession() const
762+{
763+ return std::shared_ptr<mir::scene::PromptSession>();
764+}
765+
766+void FakeSession::foreachPromptSession(std::function<void (const std::shared_ptr<mir::scene::PromptSession> &)>) const {}
767+
768+void FakeSession::setFullscreen(bool) {}
769+
770+void FakeSession::setLive(const bool) {}
771+
772+void FakeSession::appendPromptSession(const std::shared_ptr<mir::scene::PromptSession> &) {}
773+
774+void FakeSession::removePromptSession(const std::shared_ptr<mir::scene::PromptSession> &) {}
775+
776+void FakeSession::setState(SessionInterface::State state)
777+{
778+ if (m_state != state) {
779+ m_state = state;
780+ Q_EMIT stateChanged(m_state);
781+ }
782+}
783+
784+} // namespace qtmir
785
786=== modified file 'tests/framework/fake_session.h'
787--- tests/modules/common/fake_session.h 2015-12-07 12:02:48 +0000
788+++ tests/framework/fake_session.h 2016-02-10 16:36:17 +0000
789@@ -27,83 +27,56 @@
790 Q_OBJECT
791
792 public:
793- FakeSession()
794- : SessionInterface(0)
795- , m_application(nullptr)
796- , m_state(Starting)
797- {
798- }
799+ FakeSession();
800+ virtual ~FakeSession();
801
802 // For QML use
803- void release() override {}
804-
805- QString name() const override { return QString("foo-session"); }
806- unity::shell::application::ApplicationInfoInterface* application() const override { return m_application; }
807- MirSurfaceInterface* lastSurface() const override { return nullptr; }
808- const ObjectListModel<MirSurfaceInterface>* surfaces() const override { return nullptr; }
809- SessionInterface* parentSession() const override { return nullptr; }
810- SessionModel* childSessions() const override { return nullptr; }
811- State state() const override { return m_state; }
812- bool fullscreen() const override { return false; }
813- bool live() const override { return true; }
814-
815- std::shared_ptr<mir::scene::Session> session() const override { return nullptr; }
816+ void release() override;
817+
818+ QString name() const override;
819+ unity::shell::application::ApplicationInfoInterface* application() const override;
820+ MirSurfaceInterface* lastSurface() const override;
821+ const ObjectListModel<MirSurfaceInterface>* surfaces() const override;
822+ SessionInterface* parentSession() const override;
823+ SessionModel* childSessions() const override;
824+ State state() const override;
825+ bool fullscreen() const override;
826+ bool live() const override;
827+
828+ std::shared_ptr<mir::scene::Session> session() const override;
829
830 // For MirSurfaceItem and MirSurfaceManager use
831
832- void registerSurface(MirSurfaceInterface*) override {}
833- void removeSurface(MirSurfaceInterface*) override {}
834+ void registerSurface(MirSurfaceInterface*) override;
835+ void removeSurface(MirSurfaceInterface*) override;
836
837 // For Application use
838
839- void setApplication(unity::shell::application::ApplicationInfoInterface* app) override {
840- if (m_application != app) {
841- m_application = app;
842- Q_EMIT applicationChanged(m_application);
843- }
844- }
845- void suspend() override {
846- if (m_state == Running) {
847- setState(Suspending);
848- }
849- }
850- void resume() override {
851- if (m_state == Suspending || m_state == Suspended) {
852- setState(Running);
853- }
854- }
855- void stop() override {
856- setState(Stopped);
857- }
858+ void setApplication(unity::shell::application::ApplicationInfoInterface* app) override;
859+ void suspend() override;
860+ void resume() override;
861+ void stop() override;
862
863- void close() override {
864- }
865+ void close() override;
866
867 // For SessionManager use
868
869- void addChildSession(SessionInterface*) override {}
870- void insertChildSession(uint, SessionInterface*) override {}
871- void removeChildSession(SessionInterface*) override {}
872- void foreachChildSession(std::function<void(SessionInterface* session)>) const override {}
873-
874- std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override {
875- return std::shared_ptr<mir::scene::PromptSession>();
876- }
877- void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)>) const override {}
878-
879- void setFullscreen(bool) override {}
880- void setLive(const bool) override {}
881- void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override {}
882- void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override {}
883+ void addChildSession(SessionInterface*) override;
884+ void insertChildSession(uint, SessionInterface*) override;
885+ void removeChildSession(SessionInterface*) override;
886+ void foreachChildSession(std::function<void(SessionInterface* session)>) const override;
887+
888+ std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override;
889+ void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)>) const override;
890+
891+ void setFullscreen(bool) override;
892+ void setLive(const bool) override;
893+ void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override;
894+ void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override;
895
896 // For tests
897
898- void setState(State state) {
899- if (m_state != state) {
900- m_state = state;
901- Q_EMIT stateChanged(m_state);
902- }
903- }
904+ void setState(State state);
905
906 private:
907 unity::shell::application::ApplicationInfoInterface* m_application;
908
909=== renamed file 'tests/common/gmock_fixes.h' => 'tests/framework/gmock_fixes.h'
910=== added file 'tests/framework/mock_application_controller.cpp'
911--- tests/framework/mock_application_controller.cpp 1970-01-01 00:00:00 +0000
912+++ tests/framework/mock_application_controller.cpp 2016-02-10 16:36:17 +0000
913@@ -0,0 +1,129 @@
914+/*
915+ * Copyright (C) 2015 Canonical, Ltd.
916+ *
917+ * This program is free software: you can redistribute it and/or modify it under
918+ * the terms of the GNU Lesser General Public License version 3, as published by
919+ * the Free Software Foundation.
920+ *
921+ * This program is distributed in the hope that it will be useful, but WITHOUT
922+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
923+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
924+ * Lesser General Public License for more details.
925+ *
926+ * You should have received a copy of the GNU Lesser General Public License
927+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
928+ */
929+
930+#include "mock_application_controller.h"
931+
932+namespace qtmir
933+{
934+
935+MockApplicationController::MockApplicationController()
936+{
937+ using namespace ::testing;
938+ ON_CALL(*this, primaryPidForAppId(_))
939+ .WillByDefault(
940+ Invoke(this, &MockApplicationController::doPrimaryPidForAppId));
941+
942+ ON_CALL(*this, appIdHasProcessId(_, _))
943+ .WillByDefault(
944+ Invoke(this, &MockApplicationController::doAppIdHasProcessId));
945+
946+ ON_CALL(*this, findDesktopFileForAppId(_))
947+ .WillByDefault(
948+ Invoke(this, &MockApplicationController::doFindDesktopFileForAppId));
949+
950+ ON_CALL(*this, stopApplicationWithAppId(_))
951+ .WillByDefault(
952+ Invoke(this, &MockApplicationController::doStopApplicationWithAppId));
953+
954+ ON_CALL(*this, startApplicationWithAppIdAndArgs(_, _))
955+ .WillByDefault(
956+ Invoke(this, &MockApplicationController::doStartApplicationWithAppIdAndArgs));
957+
958+ ON_CALL(*this, pauseApplicationWithAppId(_))
959+ .WillByDefault(
960+ Invoke(this, &MockApplicationController::doPauseApplicationWithAppId));
961+
962+ ON_CALL(*this, resumeApplicationWithAppId(_))
963+ .WillByDefault(
964+ Invoke(this, &MockApplicationController::doResumeApplicationWithAppId));
965+}
966+
967+MockApplicationController::~MockApplicationController()
968+{
969+
970+}
971+
972+pid_t MockApplicationController::doPrimaryPidForAppId(const QString &appId)
973+{
974+ auto it = children.find(appId);
975+ if (it == children.end())
976+ return -1;
977+
978+ return it->pid();
979+}
980+
981+
982+bool MockApplicationController::doAppIdHasProcessId(pid_t pid, const QString &appId)
983+{
984+ auto it = children.find(appId);
985+ if (it == children.end())
986+ return -1;
987+
988+ return it->pid() == pid;
989+}
990+
991+
992+QFileInfo MockApplicationController::doFindDesktopFileForAppId(const QString &appId) const
993+{
994+ QString path = QString("/usr/share/applications/%1.desktop").arg(appId);
995+ return QFileInfo(path);
996+}
997+
998+
999+bool MockApplicationController::doStopApplicationWithAppId(const QString &appId)
1000+{
1001+ Q_UNUSED(appId);
1002+
1003+ return false;
1004+}
1005+
1006+
1007+bool MockApplicationController::doStartApplicationWithAppIdAndArgs(const QString &appId, const QStringList &args)
1008+{
1009+ Q_UNUSED(args);
1010+
1011+ auto child = core::posix::fork([]()
1012+ {
1013+ while (true);
1014+
1015+ return core::posix::exit::Status::success;
1016+ }, core::posix::StandardStream::empty);
1017+
1018+ if (child.pid() > 0)
1019+ {
1020+ children.insert(appId, child);
1021+ return true;
1022+ }
1023+
1024+ return false;
1025+}
1026+
1027+
1028+bool MockApplicationController::doPauseApplicationWithAppId(const QString &appId)
1029+{
1030+ Q_UNUSED(appId);
1031+
1032+ return false;
1033+}
1034+
1035+bool MockApplicationController::doResumeApplicationWithAppId(const QString &appId)
1036+{
1037+ Q_UNUSED(appId);
1038+
1039+ return false;
1040+}
1041+
1042+} // namespace qtmir
1043
1044=== modified file 'tests/framework/mock_application_controller.h'
1045--- tests/modules/common/mock_application_controller.h 2015-08-11 12:08:32 +0000
1046+++ tests/framework/mock_application_controller.h 2016-02-10 16:36:17 +0000
1047@@ -18,15 +18,19 @@
1048 #define MOCK_APPLICATION_CONTROLLER_H
1049
1050 #include <Unity/Application/applicationcontroller.h>
1051+#include <QMap>
1052
1053 #include <core/posix/fork.h>
1054
1055 #include <gmock/gmock.h>
1056
1057-namespace testing
1058+namespace qtmir
1059 {
1060 struct MockApplicationController : public qtmir::ApplicationController
1061 {
1062+ MockApplicationController();
1063+ virtual ~MockApplicationController();
1064+
1065 MOCK_METHOD1(primaryPidForAppId, pid_t(const QString& appId));
1066 MOCK_METHOD2(appIdHasProcessId, bool(pid_t, const QString&));
1067 MOCK_CONST_METHOD1(findDesktopFileForAppId, QFileInfo(const QString &appId));
1068@@ -36,105 +40,24 @@
1069 MOCK_METHOD1(pauseApplicationWithAppId, bool(const QString&));
1070 MOCK_METHOD1(resumeApplicationWithAppId, bool(const QString&));
1071
1072- MockApplicationController()
1073- {
1074- using namespace ::testing;
1075- ON_CALL(*this, primaryPidForAppId(_))
1076- .WillByDefault(
1077- Invoke(this, &MockApplicationController::doPrimaryPidForAppId));
1078-
1079- ON_CALL(*this, appIdHasProcessId(_, _))
1080- .WillByDefault(
1081- Invoke(this, &MockApplicationController::doAppIdHasProcessId));
1082-
1083- ON_CALL(*this, findDesktopFileForAppId(_))
1084- .WillByDefault(
1085- Invoke(this, &MockApplicationController::doFindDesktopFileForAppId));
1086-
1087- ON_CALL(*this, stopApplicationWithAppId(_))
1088- .WillByDefault(
1089- Invoke(this, &MockApplicationController::doStopApplicationWithAppId));
1090-
1091- ON_CALL(*this, startApplicationWithAppIdAndArgs(_, _))
1092- .WillByDefault(
1093- Invoke(this, &MockApplicationController::doStartApplicationWithAppIdAndArgs));
1094-
1095- ON_CALL(*this, pauseApplicationWithAppId(_))
1096- .WillByDefault(
1097- Invoke(this, &MockApplicationController::doPauseApplicationWithAppId));
1098-
1099- ON_CALL(*this, resumeApplicationWithAppId(_))
1100- .WillByDefault(
1101- Invoke(this, &MockApplicationController::doResumeApplicationWithAppId));
1102- }
1103-
1104- pid_t doPrimaryPidForAppId(const QString& appId)
1105- {
1106- auto it = children.find(appId);
1107- if (it == children.end())
1108- return -1;
1109-
1110- return it->pid();
1111- }
1112-
1113- bool doAppIdHasProcessId(pid_t pid, const QString& appId)
1114- {
1115- auto it = children.find(appId);
1116- if (it == children.end())
1117- return -1;
1118-
1119- return it->pid() == pid;
1120- }
1121-
1122- QFileInfo doFindDesktopFileForAppId(const QString& appId) const
1123- {
1124- QString path = QString("/usr/share/applications/%1.desktop").arg(appId);
1125- return QFileInfo(path);
1126- }
1127-
1128- bool doStopApplicationWithAppId(const QString& appId)
1129- {
1130- Q_UNUSED(appId);
1131-
1132- return false;
1133- }
1134-
1135- bool doStartApplicationWithAppIdAndArgs(const QString& appId, const QStringList& args)
1136- {
1137- Q_UNUSED(args);
1138-
1139- auto child = core::posix::fork([]()
1140- {
1141- while (true);
1142-
1143- return core::posix::exit::Status::success;
1144- }, core::posix::StandardStream::empty);
1145-
1146- if (child.pid() > 0)
1147- {
1148- children.insert(appId, child);
1149- return true;
1150- }
1151-
1152- return false;
1153- }
1154-
1155- bool doPauseApplicationWithAppId(const QString& appId)
1156- {
1157- Q_UNUSED(appId);
1158-
1159- return false;
1160- }
1161-
1162- bool doResumeApplicationWithAppId(const QString& appId)
1163- {
1164- Q_UNUSED(appId);
1165-
1166- return false;
1167- }
1168-
1169+ pid_t doPrimaryPidForAppId(const QString& appId);
1170+
1171+ bool doAppIdHasProcessId(pid_t pid, const QString& appId);
1172+
1173+ QFileInfo doFindDesktopFileForAppId(const QString& appId) const;
1174+
1175+ bool doStopApplicationWithAppId(const QString& appId);
1176+
1177+ bool doStartApplicationWithAppIdAndArgs(const QString& appId, const QStringList& args);
1178+
1179+ bool doPauseApplicationWithAppId(const QString& appId);
1180+
1181+ bool doResumeApplicationWithAppId(const QString& appId);
1182+
1183+private:
1184 QMap<QString, core::posix::ChildProcess> children;
1185 };
1186-} // namespace testing
1187+
1188+} // namespace qtmir
1189
1190 #endif // MOCK_APPLICATION_CONTROLLER_H
1191
1192=== added file 'tests/framework/mock_desktop_file_reader.cpp'
1193--- tests/framework/mock_desktop_file_reader.cpp 1970-01-01 00:00:00 +0000
1194+++ tests/framework/mock_desktop_file_reader.cpp 2016-02-10 16:36:17 +0000
1195@@ -0,0 +1,117 @@
1196+/*
1197+ * Copyright (C) 2015 Canonical, Ltd.
1198+ *
1199+ * This program is free software: you can redistribute it and/or modify it under
1200+ * the terms of the GNU Lesser General Public License version 3, as published by
1201+ * the Free Software Foundation.
1202+ *
1203+ * This program is distributed in the hope that it will be useful, but WITHOUT
1204+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1205+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1206+ * Lesser General Public License for more details.
1207+ *
1208+ * You should have received a copy of the GNU Lesser General Public License
1209+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1210+ */
1211+
1212+#include "mock_desktop_file_reader.h"
1213+
1214+namespace qtmir
1215+{
1216+
1217+MockDesktopFileReader::MockDesktopFileReader(const QString &appId, const QFileInfo &fileInfo)
1218+ : DesktopFileReader(appId, fileInfo)
1219+{
1220+ using namespace ::testing;
1221+
1222+ ON_CALL(*this, file()).WillByDefault(Invoke(this, &MockDesktopFileReader::doFile));
1223+ ON_CALL(*this, appId()).WillByDefault(Invoke(this, &MockDesktopFileReader::doAppId));
1224+ ON_CALL(*this, name()).WillByDefault(Invoke(this, &MockDesktopFileReader::doName));
1225+ ON_CALL(*this, comment()).WillByDefault(Invoke(this, &MockDesktopFileReader::doComment));
1226+ ON_CALL(*this, icon()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIcon));
1227+ ON_CALL(*this, exec()).WillByDefault(Invoke(this, &MockDesktopFileReader::doExec));
1228+ ON_CALL(*this, path()).WillByDefault(Invoke(this, &MockDesktopFileReader::doPath));
1229+ ON_CALL(*this, stageHint()).WillByDefault(Invoke(this, &MockDesktopFileReader::doStageHint));
1230+ ON_CALL(*this, isTouchApp()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIsTouchApp));
1231+ ON_CALL(*this, loaded()).WillByDefault(Invoke(this, &MockDesktopFileReader::doLoaded));
1232+}
1233+
1234+MockDesktopFileReader::~MockDesktopFileReader()
1235+{
1236+}
1237+
1238+QString MockDesktopFileReader::doFile() const
1239+{
1240+ return DesktopFileReader::file();
1241+}
1242+
1243+QString MockDesktopFileReader::doAppId() const
1244+{
1245+ return DesktopFileReader::appId();
1246+}
1247+
1248+QString MockDesktopFileReader::doName() const
1249+{
1250+ return DesktopFileReader::name();
1251+}
1252+
1253+QString MockDesktopFileReader::doComment() const
1254+{
1255+ return DesktopFileReader::comment();
1256+}
1257+
1258+QString MockDesktopFileReader::doIcon() const
1259+{
1260+ return DesktopFileReader::icon();
1261+}
1262+
1263+QString MockDesktopFileReader::doExec() const
1264+{
1265+ return DesktopFileReader::exec();
1266+}
1267+
1268+QString MockDesktopFileReader::doPath() const
1269+{
1270+ return DesktopFileReader::path();
1271+}
1272+
1273+QString MockDesktopFileReader::doStageHint() const
1274+{
1275+ return DesktopFileReader::stageHint();
1276+}
1277+
1278+bool MockDesktopFileReader::doIsTouchApp() const
1279+{
1280+ return DesktopFileReader::isTouchApp();
1281+}
1282+
1283+bool MockDesktopFileReader::doLoaded() const
1284+{
1285+ return DesktopFileReader::loaded();
1286+}
1287+
1288+
1289+MockDesktopFileReaderFactory::MockDesktopFileReaderFactory()
1290+{
1291+ using namespace ::testing;
1292+ ON_CALL(*this, createInstance(_, _))
1293+ .WillByDefault(
1294+ Invoke(
1295+ this,
1296+ &MockDesktopFileReaderFactory::doCreateInstance));
1297+}
1298+
1299+MockDesktopFileReaderFactory::~MockDesktopFileReaderFactory()
1300+{
1301+}
1302+
1303+qtmir::DesktopFileReader *MockDesktopFileReaderFactory::doCreateInstance(const QString &appId, const QFileInfo &fi)
1304+{
1305+ using namespace ::testing;
1306+ auto instance = new NiceMock<MockDesktopFileReader>(appId, fi);
1307+ ON_CALL(*instance, loaded()).WillByDefault(Return(true));
1308+
1309+ return instance;
1310+}
1311+
1312+} // namespace qtmir
1313
1314=== modified file 'tests/framework/mock_desktop_file_reader.h'
1315--- tests/modules/common/mock_desktop_file_reader.h 2015-09-29 18:27:27 +0000
1316+++ tests/framework/mock_desktop_file_reader.h 2016-02-10 16:36:17 +0000
1317@@ -21,26 +21,13 @@
1318
1319 #include <gmock/gmock.h>
1320
1321-namespace testing
1322+namespace qtmir
1323 {
1324+
1325 struct MockDesktopFileReader : public qtmir::DesktopFileReader
1326 {
1327- MockDesktopFileReader(const QString &appId, const QFileInfo& fileInfo)
1328- : DesktopFileReader(appId, fileInfo)
1329- {
1330- using namespace ::testing;
1331-
1332- ON_CALL(*this, file()).WillByDefault(Invoke(this, &MockDesktopFileReader::doFile));
1333- ON_CALL(*this, appId()).WillByDefault(Invoke(this, &MockDesktopFileReader::doAppId));
1334- ON_CALL(*this, name()).WillByDefault(Invoke(this, &MockDesktopFileReader::doName));
1335- ON_CALL(*this, comment()).WillByDefault(Invoke(this, &MockDesktopFileReader::doComment));
1336- ON_CALL(*this, icon()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIcon));
1337- ON_CALL(*this, exec()).WillByDefault(Invoke(this, &MockDesktopFileReader::doExec));
1338- ON_CALL(*this, path()).WillByDefault(Invoke(this, &MockDesktopFileReader::doPath));
1339- ON_CALL(*this, stageHint()).WillByDefault(Invoke(this, &MockDesktopFileReader::doStageHint));
1340- ON_CALL(*this, isTouchApp()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIsTouchApp));
1341- ON_CALL(*this, loaded()).WillByDefault(Invoke(this, &MockDesktopFileReader::doLoaded));
1342- }
1343+ MockDesktopFileReader(const QString &appId, const QFileInfo& fileInfo);
1344+ virtual ~MockDesktopFileReader();
1345
1346 MOCK_CONST_METHOD0(file, QString());
1347 MOCK_CONST_METHOD0(appId, QString ());
1348@@ -53,80 +40,28 @@
1349 MOCK_CONST_METHOD0(isTouchApp, bool());
1350 MOCK_CONST_METHOD0(loaded, bool());
1351
1352- QString doFile() const
1353- {
1354- return DesktopFileReader::file();
1355- }
1356-
1357- QString doAppId() const
1358- {
1359- return DesktopFileReader::appId();
1360- }
1361-
1362- QString doName() const
1363- {
1364- return DesktopFileReader::name();
1365- }
1366-
1367- QString doComment() const
1368- {
1369- return DesktopFileReader::comment();
1370- }
1371-
1372- QString doIcon() const
1373- {
1374- return DesktopFileReader::icon();
1375- }
1376-
1377- QString doExec() const
1378- {
1379- return DesktopFileReader::exec();
1380- }
1381-
1382- QString doPath() const
1383- {
1384- return DesktopFileReader::path();
1385- }
1386-
1387- QString doStageHint() const
1388- {
1389- return DesktopFileReader::stageHint();
1390- }
1391-
1392- bool doIsTouchApp() const
1393- {
1394- return DesktopFileReader::isTouchApp();
1395- }
1396-
1397- bool doLoaded() const
1398- {
1399- return DesktopFileReader::loaded();
1400- }
1401+ QString doFile() const;
1402+ QString doAppId() const;
1403+ QString doName() const;
1404+ QString doComment() const;
1405+ QString doIcon() const;
1406+ QString doExec() const;
1407+ QString doPath() const;
1408+ QString doStageHint() const;
1409+ bool doIsTouchApp() const;
1410+ bool doLoaded() const;
1411 };
1412
1413 struct MockDesktopFileReaderFactory : public qtmir::DesktopFileReader::Factory
1414 {
1415- MockDesktopFileReaderFactory()
1416- {
1417- using namespace ::testing;
1418- ON_CALL(*this, createInstance(_, _))
1419- .WillByDefault(
1420- Invoke(
1421- this,
1422- &MockDesktopFileReaderFactory::doCreateInstance));
1423- }
1424-
1425- virtual qtmir::DesktopFileReader* doCreateInstance(const QString &appId, const QFileInfo &fi)
1426- {
1427- using namespace ::testing;
1428- auto instance = new NiceMock<MockDesktopFileReader>(appId, fi);
1429- ON_CALL(*instance, loaded()).WillByDefault(Return(true));
1430-
1431- return instance;
1432- }
1433+ MockDesktopFileReaderFactory();
1434+ virtual ~MockDesktopFileReaderFactory();
1435+
1436+ virtual qtmir::DesktopFileReader* doCreateInstance(const QString &appId, const QFileInfo &fi);
1437
1438 MOCK_METHOD2(createInstance, qtmir::DesktopFileReader*(const QString &appId, const QFileInfo &fi));
1439 };
1440-}
1441+
1442+} // namespace qtmir
1443
1444 #endif // MOCK_DESKTOP_FILE_READER_H
1445
1446=== added file 'tests/framework/mock_display.cpp'
1447--- tests/framework/mock_display.cpp 1970-01-01 00:00:00 +0000
1448+++ tests/framework/mock_display.cpp 2016-02-10 16:36:17 +0000
1449@@ -0,0 +1,35 @@
1450+/*
1451+ * Copyright (C) 2015 Canonical, Ltd.
1452+ *
1453+ * This program is free software: you can redistribute it and/or modify it under
1454+ * the terms of the GNU Lesser General Public License version 3, as published by
1455+ * the Free Software Foundation.
1456+ *
1457+ * This program is distributed in the hope that it will be useful, but WITHOUT
1458+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1459+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1460+ * Lesser General Public License for more details.
1461+ *
1462+ * You should have received a copy of the GNU Lesser General Public License
1463+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1464+ */
1465+
1466+#include "mock_display.h"
1467+#include <mir/graphics/event_handler_register.h>
1468+#include <mir/graphics/display_configuration.h>
1469+
1470+MockDisplaySyncGroup::MockDisplaySyncGroup()
1471+{
1472+}
1473+
1474+MockDisplaySyncGroup::~MockDisplaySyncGroup()
1475+{
1476+}
1477+
1478+MockDisplay::MockDisplay()
1479+{
1480+}
1481+
1482+MockDisplay::~MockDisplay()
1483+{
1484+}
1485
1486=== renamed file 'tests/common/mock_display.h' => 'tests/framework/mock_display.h'
1487--- tests/common/mock_display.h 2015-08-20 10:16:54 +0000
1488+++ tests/framework/mock_display.h 2016-02-10 16:36:17 +0000
1489@@ -26,6 +26,9 @@
1490 class MockDisplaySyncGroup : public mir::graphics::DisplaySyncGroup
1491 {
1492 public:
1493+ MockDisplaySyncGroup();
1494+ virtual ~MockDisplaySyncGroup();
1495+
1496 MOCK_METHOD1(for_each_display_buffer, void(std::function<void(mir::graphics::DisplayBuffer&)> const& f));
1497 MOCK_METHOD0(post, void());
1498 };
1499@@ -33,6 +36,9 @@
1500 struct MockDisplay : public mir::graphics::Display
1501 {
1502 public:
1503+ MockDisplay();
1504+ virtual ~MockDisplay();
1505+
1506 MOCK_METHOD1(for_each_display_sync_group, void(std::function<void(mir::graphics::DisplaySyncGroup&)> const&));
1507 MOCK_CONST_METHOD0(configuration, std::unique_ptr<mir::graphics::DisplayConfiguration>());
1508 MOCK_METHOD1(configure, void(mir::graphics::DisplayConfiguration const&));
1509@@ -48,6 +54,4 @@
1510 MOCK_METHOD0(create_gl_context, std::unique_ptr<mir::graphics::GLContext>());
1511 };
1512
1513-
1514-
1515 #endif // MOCKDISPLAY_H
1516
1517=== added file 'tests/framework/mock_display_configuration.cpp'
1518--- tests/framework/mock_display_configuration.cpp 1970-01-01 00:00:00 +0000
1519+++ tests/framework/mock_display_configuration.cpp 2016-02-10 16:36:17 +0000
1520@@ -0,0 +1,25 @@
1521+/*
1522+ * Copyright (C) 2015 Canonical, Ltd.
1523+ *
1524+ * This program is free software: you can redistribute it and/or modify it under
1525+ * the terms of the GNU Lesser General Public License version 3, as published by
1526+ * the Free Software Foundation.
1527+ *
1528+ * This program is distributed in the hope that it will be useful, but WITHOUT
1529+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1530+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1531+ * Lesser General Public License for more details.
1532+ *
1533+ * You should have received a copy of the GNU Lesser General Public License
1534+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1535+ */
1536+
1537+#include "mock_display_configuration.h"
1538+
1539+MockDisplayConfiguration::MockDisplayConfiguration()
1540+{
1541+}
1542+
1543+MockDisplayConfiguration::~MockDisplayConfiguration()
1544+{
1545+}
1546
1547=== renamed file 'tests/common/mock_display_configuration.h' => 'tests/framework/mock_display_configuration.h'
1548--- tests/common/mock_display_configuration.h 2015-12-04 15:44:11 +0000
1549+++ tests/framework/mock_display_configuration.h 2016-02-10 16:36:17 +0000
1550@@ -25,6 +25,9 @@
1551 class MockDisplayConfiguration : public mir::graphics::DisplayConfiguration
1552 {
1553 public:
1554+ MockDisplayConfiguration();
1555+ virtual ~MockDisplayConfiguration();
1556+
1557 MOCK_CONST_METHOD1(for_each_card, void(std::function<void(mir::graphics::DisplayConfigurationCard const&)>));
1558
1559 MOCK_CONST_METHOD1(for_each_output, void(std::function<void(mir::graphics::DisplayConfigurationOutput const&)>));
1560@@ -33,4 +36,5 @@
1561
1562 MOCK_CONST_METHOD0(valid, bool());
1563 };
1564+
1565 #endif // MOCK_DISPLAY_CONFIGURATION_H
1566
1567=== added file 'tests/framework/mock_gl_display_buffer.cpp'
1568--- tests/framework/mock_gl_display_buffer.cpp 1970-01-01 00:00:00 +0000
1569+++ tests/framework/mock_gl_display_buffer.cpp 2016-02-10 16:36:17 +0000
1570@@ -0,0 +1,30 @@
1571+/*
1572+ * Copyright (C) 2015 Canonical, Ltd.
1573+ *
1574+ * This program is free software: you can redistribute it and/or modify it under
1575+ * the terms of the GNU Lesser General Public License version 3, as published by
1576+ * the Free Software Foundation.
1577+ *
1578+ * This program is distributed in the hope that it will be useful, but WITHOUT
1579+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1580+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1581+ * Lesser General Public License for more details.
1582+ *
1583+ * You should have received a copy of the GNU Lesser General Public License
1584+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1585+ */
1586+
1587+#include "mock_gl_display_buffer.h"
1588+
1589+MockGLDisplayBuffer::MockGLDisplayBuffer()
1590+{
1591+ using namespace testing;
1592+ ON_CALL(*this, view_area())
1593+ .WillByDefault(Return(mir::geometry::Rectangle{{0,0},{0,0}}));
1594+ ON_CALL(*this, native_display_buffer())
1595+ .WillByDefault(Return(dynamic_cast<mir::graphics::NativeDisplayBuffer*>(this)));
1596+}
1597+
1598+MockGLDisplayBuffer::~MockGLDisplayBuffer()
1599+{
1600+}
1601
1602=== renamed file 'tests/common/mock_gl_display_buffer.h' => 'tests/framework/mock_gl_display_buffer.h'
1603--- tests/common/mock_gl_display_buffer.h 2015-10-14 23:14:48 +0000
1604+++ tests/framework/mock_gl_display_buffer.h 2016-02-10 16:36:17 +0000
1605@@ -27,14 +27,9 @@
1606 public mir::graphics::NativeDisplayBuffer
1607 {
1608 public:
1609- MockGLDisplayBuffer()
1610- {
1611- using namespace testing;
1612- ON_CALL(*this, view_area())
1613- .WillByDefault(Return(mir::geometry::Rectangle{{0,0},{0,0}}));
1614- ON_CALL(*this, native_display_buffer())
1615- .WillByDefault(Return(dynamic_cast<mir::graphics::NativeDisplayBuffer*>(this)));
1616- }
1617+ MockGLDisplayBuffer();
1618+ virtual ~MockGLDisplayBuffer();
1619+
1620 MOCK_CONST_METHOD0(view_area, mir::geometry::Rectangle());
1621 MOCK_METHOD1(post_renderables_if_optimizable, bool(mir::graphics::RenderableList const&));
1622 MOCK_CONST_METHOD0(orientation, MirOrientation());
1623@@ -45,5 +40,4 @@
1624 MOCK_METHOD0(swap_buffers, void());
1625 };
1626
1627-
1628 #endif // MOCK_GL_DISPLAY_BUFFER_H
1629
1630=== added file 'tests/framework/mock_main_loop.cpp'
1631--- tests/framework/mock_main_loop.cpp 1970-01-01 00:00:00 +0000
1632+++ tests/framework/mock_main_loop.cpp 2016-02-10 16:36:17 +0000
1633@@ -0,0 +1,28 @@
1634+/*
1635+ * Copyright (C) 2015 Canonical, Ltd.
1636+ *
1637+ * This program is free software: you can redistribute it and/or modify it under
1638+ * the terms of the GNU Lesser General Public License version 3, as published by
1639+ * the Free Software Foundation.
1640+ *
1641+ * This program is distributed in the hope that it will be useful, but WITHOUT
1642+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1643+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1644+ * Lesser General Public License for more details.
1645+ *
1646+ * You should have received a copy of the GNU Lesser General Public License
1647+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1648+ */
1649+
1650+#include "mock_main_loop.h"
1651+
1652+MockMainLoop::MockMainLoop()
1653+{
1654+}
1655+
1656+MockMainLoop::~MockMainLoop()
1657+{
1658+}
1659+
1660+void MockMainLoop::run() {}
1661+void MockMainLoop::stop() {}
1662\ No newline at end of file
1663
1664=== renamed file 'tests/common/mock_main_loop.h' => 'tests/framework/mock_main_loop.h'
1665--- tests/common/mock_main_loop.h 2015-08-20 10:16:54 +0000
1666+++ tests/framework/mock_main_loop.h 2016-02-10 16:36:17 +0000
1667@@ -17,19 +17,17 @@
1668 #ifndef MOCKMAINLOOP_H
1669 #define MOCKMAINLOOP_H
1670
1671-#include <gmock/gmock.h>
1672-
1673 #include <mir/main_loop.h>
1674-
1675-#include <memory>
1676+#include "gmock_fixes.h"
1677
1678 class MockMainLoop : public mir::MainLoop
1679 {
1680 public:
1681- ~MockMainLoop() noexcept {}
1682+ MockMainLoop();
1683+ ~MockMainLoop() noexcept;
1684
1685- void run() override {}
1686- void stop() override {}
1687+ void run() override;
1688+ void stop() override;
1689
1690 MOCK_METHOD2(register_signal_handler,
1691 void(std::initializer_list<int>,
1692@@ -49,5 +47,4 @@
1693 MOCK_METHOD1(create_alarm, std::unique_ptr<mir::time::Alarm>(std::shared_ptr<mir::LockableCallback> const& callback));
1694 };
1695
1696-
1697 #endif // MOCKMAINLOOP_H
1698
1699=== added file 'tests/framework/mock_mir_session.cpp'
1700--- tests/framework/mock_mir_session.cpp 1970-01-01 00:00:00 +0000
1701+++ tests/framework/mock_mir_session.cpp 2016-02-10 16:36:17 +0000
1702@@ -0,0 +1,63 @@
1703+/*
1704+ * Copyright (C) 2015 Canonical, Ltd.
1705+ *
1706+ * This program is free software: you can redistribute it and/or modify it under
1707+ * the terms of the GNU Lesser General Public License version 3, as published by
1708+ * the Free Software Foundation.
1709+ *
1710+ * This program is distributed in the hope that it will be useful, but WITHOUT
1711+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1712+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1713+ * Lesser General Public License for more details.
1714+ *
1715+ * You should have received a copy of the GNU Lesser General Public License
1716+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1717+ */
1718+
1719+#include "mock_mir_session.h"
1720+
1721+namespace mir
1722+{
1723+namespace scene
1724+{
1725+
1726+MockSession::MockSession()
1727+{
1728+}
1729+
1730+MockSession::MockSession(const std::string &sessionName, pid_t processId)
1731+ : m_sessionName(sessionName), m_sessionId(processId)
1732+{
1733+}
1734+
1735+MockSession::~MockSession()
1736+{
1737+}
1738+
1739+std::string MockSession::name() const
1740+{
1741+ return m_sessionName;
1742+}
1743+
1744+pid_t MockSession::process_id() const
1745+{
1746+ return m_sessionId;
1747+}
1748+
1749+void MockSession::resume_prompt_session() {}
1750+
1751+void MockSession::suspend_prompt_session() {}
1752+
1753+void MockSession::stop_prompt_session() {}
1754+
1755+void MockSession::start_prompt_session() {}
1756+
1757+std::shared_ptr<scene::Surface> MockSession::surface_after(const std::shared_ptr<scene::Surface> &) const
1758+{
1759+ return {};
1760+}
1761+
1762+void MockSession::configure_streams(scene::Surface &, const std::vector<mir::shell::StreamSpecification> &) {}
1763+
1764+} // namespace scene
1765+} // namespace mir
1766
1767=== modified file 'tests/framework/mock_mir_session.h'
1768--- tests/modules/common/mock_mir_session.h 2016-01-20 20:01:54 +0000
1769+++ tests/framework/mock_mir_session.h 2016-02-10 16:36:17 +0000
1770@@ -29,20 +29,13 @@
1771
1772 struct MockSession : public Session
1773 {
1774- MockSession() {}
1775- MockSession(std::string const& sessionName, pid_t processId)
1776- : m_sessionName(sessionName), m_sessionId(processId)
1777- {}
1778-
1779- std::string name() const override
1780- {
1781- return m_sessionName;
1782- }
1783-
1784- pid_t process_id() const override
1785- {
1786- return m_sessionId;
1787- }
1788+ MockSession();
1789+ MockSession(std::string const& sessionName, pid_t processId);
1790+ virtual ~MockSession();
1791+
1792+ std::string name() const override;
1793+
1794+ pid_t process_id() const override;
1795
1796 MOCK_METHOD0(force_requests_to_complete, void());
1797
1798@@ -63,16 +56,16 @@
1799 MOCK_METHOD1(send_display_config, void(graphics::DisplayConfiguration const&));
1800 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
1801
1802- void start_prompt_session() override {};
1803- void stop_prompt_session() override {};
1804- void suspend_prompt_session() override {};
1805- void resume_prompt_session() override {};
1806- std::shared_ptr<Surface> surface_after(std::shared_ptr<Surface> const&) const override { return {}; }
1807+ void start_prompt_session() override;
1808+ void stop_prompt_session() override;
1809+ void suspend_prompt_session() override;
1810+ void resume_prompt_session() override;
1811+ std::shared_ptr<Surface> surface_after(std::shared_ptr<Surface> const&) const override;
1812
1813 MOCK_CONST_METHOD1(get_buffer_stream, std::shared_ptr<frontend::BufferStream>(frontend::BufferStreamId));
1814 MOCK_METHOD1(destroy_buffer_stream, void(frontend::BufferStreamId));
1815 MOCK_METHOD1(create_buffer_stream, frontend::BufferStreamId(graphics::BufferProperties const&));
1816- void configure_streams(Surface&, std::vector<shell::StreamSpecification> const&) override {};
1817+ void configure_streams(Surface&, std::vector<shell::StreamSpecification> const&) override;;
1818
1819 MOCK_METHOD1(send_input_device_change, void(std::vector<std::shared_ptr<mir::input::Device>> const&));
1820 //void send_input_device_change(std::vector<std::shared_ptr<input::Device>> const& devices) = 0;
1821
1822=== added file 'tests/framework/mock_proc_info.cpp'
1823--- tests/framework/mock_proc_info.cpp 1970-01-01 00:00:00 +0000
1824+++ tests/framework/mock_proc_info.cpp 2016-02-10 16:36:17 +0000
1825@@ -0,0 +1,35 @@
1826+/*
1827+ * Copyright (C) 2015 Canonical, Ltd.
1828+ *
1829+ * This program is free software: you can redistribute it and/or modify it under
1830+ * the terms of the GNU Lesser General Public License version 3, as published by
1831+ * the Free Software Foundation.
1832+ *
1833+ * This program is distributed in the hope that it will be useful, but WITHOUT
1834+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1835+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1836+ * Lesser General Public License for more details.
1837+ *
1838+ * You should have received a copy of the GNU Lesser General Public License
1839+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1840+ */
1841+
1842+#include "mock_proc_info.h"
1843+
1844+namespace qtmir
1845+{
1846+
1847+MockProcInfo::MockProcInfo()
1848+{
1849+}
1850+
1851+MockProcInfo::~MockProcInfo()
1852+{
1853+}
1854+
1855+std::unique_ptr<qtmir::ProcInfo::CommandLine> MockProcInfo::commandLine(pid_t pid)
1856+{
1857+ return std::unique_ptr<CommandLine>(new CommandLine{command_line(pid)});
1858+}
1859+
1860+} // namespace qtmir
1861
1862=== modified file 'tests/framework/mock_proc_info.h'
1863--- tests/modules/common/mock_proc_info.h 2015-10-08 11:20:30 +0000
1864+++ tests/framework/mock_proc_info.h 2016-02-10 16:36:17 +0000
1865@@ -21,16 +21,17 @@
1866
1867 #include <gmock/gmock.h>
1868
1869-namespace testing
1870-{
1871+namespace qtmir {
1872+
1873 struct MockProcInfo : public qtmir::ProcInfo
1874 {
1875+ MockProcInfo();
1876+ virtual ~MockProcInfo();
1877+
1878 MOCK_METHOD1(command_line, QByteArray(pid_t));
1879- std::unique_ptr<CommandLine> commandLine(pid_t pid)
1880- {
1881- return std::unique_ptr<CommandLine>(new CommandLine{command_line(pid)});
1882- }
1883+ std::unique_ptr<CommandLine> commandLine(pid_t pid);
1884 };
1885-}
1886+
1887+} // namespace qtmir
1888
1889 #endif // MOCK_PROC_INFO_H
1890
1891=== added file 'tests/framework/mock_prompt_session.cpp'
1892--- tests/framework/mock_prompt_session.cpp 1970-01-01 00:00:00 +0000
1893+++ tests/framework/mock_prompt_session.cpp 2016-02-10 16:36:17 +0000
1894@@ -0,0 +1,33 @@
1895+/*
1896+ * Copyright (C) 2015 Canonical, Ltd.
1897+ *
1898+ * This program is free software: you can redistribute it and/or modify it under
1899+ * the terms of the GNU Lesser General Public License version 3, as published by
1900+ * the Free Software Foundation.
1901+ *
1902+ * This program is distributed in the hope that it will be useful, but WITHOUT
1903+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1904+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1905+ * Lesser General Public License for more details.
1906+ *
1907+ * You should have received a copy of the GNU Lesser General Public License
1908+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1909+ */
1910+
1911+#include "mock_prompt_session.h"
1912+
1913+namespace mir
1914+{
1915+namespace scene
1916+{
1917+
1918+MockPromptSession::MockPromptSession()
1919+{
1920+}
1921+
1922+MockPromptSession::~MockPromptSession()
1923+{
1924+}
1925+
1926+} // namespace scene
1927+} // namespace mir
1928
1929=== modified file 'tests/framework/mock_prompt_session.h'
1930--- tests/modules/common/mock_prompt_session.h 2015-08-11 12:08:32 +0000
1931+++ tests/framework/mock_prompt_session.h 2016-02-10 16:36:17 +0000
1932@@ -26,6 +26,9 @@
1933 struct MockPromptSession : public PromptSession
1934 {
1935 public:
1936+ MockPromptSession();
1937+ virtual ~MockPromptSession();
1938+
1939 MOCK_METHOD1(start, void(std::shared_ptr<Session> const&));
1940 MOCK_METHOD1(stop, void(std::shared_ptr<Session> const&));
1941 MOCK_METHOD1(suspend, void(std::shared_ptr<Session> const&));
1942
1943=== added file 'tests/framework/mock_prompt_session_manager.cpp'
1944--- tests/framework/mock_prompt_session_manager.cpp 1970-01-01 00:00:00 +0000
1945+++ tests/framework/mock_prompt_session_manager.cpp 2016-02-10 16:36:17 +0000
1946@@ -0,0 +1,33 @@
1947+/*
1948+ * Copyright (C) 2015 Canonical, Ltd.
1949+ *
1950+ * This program is free software: you can redistribute it and/or modify it under
1951+ * the terms of the GNU Lesser General Public License version 3, as published by
1952+ * the Free Software Foundation.
1953+ *
1954+ * This program is distributed in the hope that it will be useful, but WITHOUT
1955+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1956+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1957+ * Lesser General Public License for more details.
1958+ *
1959+ * You should have received a copy of the GNU Lesser General Public License
1960+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1961+ */
1962+
1963+#include "mock_prompt_session_manager.h"
1964+
1965+namespace mir
1966+{
1967+namespace scene
1968+{
1969+
1970+MockPromptSessionManager::MockPromptSessionManager()
1971+{
1972+}
1973+
1974+MockPromptSessionManager::~MockPromptSessionManager()
1975+{
1976+}
1977+
1978+} // namespace scene
1979+} // namespace mir
1980
1981=== modified file 'tests/framework/mock_prompt_session_manager.h'
1982--- tests/modules/common/mock_prompt_session_manager.h 2015-08-11 12:08:32 +0000
1983+++ tests/framework/mock_prompt_session_manager.h 2016-02-10 16:36:17 +0000
1984@@ -28,6 +28,9 @@
1985 class MockPromptSessionManager: public PromptSessionManager
1986 {
1987 public:
1988+ MockPromptSessionManager();
1989+ virtual ~MockPromptSessionManager();
1990+
1991 MOCK_CONST_METHOD2(start_prompt_session_for, std::shared_ptr<PromptSession>(std::shared_ptr<mir::scene::Session> const&,
1992 mir::scene::PromptSessionCreationParameters const&));
1993
1994
1995=== added file 'tests/framework/mock_renderable.cpp'
1996--- tests/framework/mock_renderable.cpp 1970-01-01 00:00:00 +0000
1997+++ tests/framework/mock_renderable.cpp 2016-02-10 16:36:17 +0000
1998@@ -0,0 +1,33 @@
1999+/*
2000+ * Copyright (C) 2015 Canonical, Ltd.
2001+ *
2002+ * This program is free software: you can redistribute it and/or modify it under
2003+ * the terms of the GNU Lesser General Public License version 3, as published by
2004+ * the Free Software Foundation.
2005+ *
2006+ * This program is distributed in the hope that it will be useful, but WITHOUT
2007+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2008+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2009+ * Lesser General Public License for more details.
2010+ *
2011+ * You should have received a copy of the GNU Lesser General Public License
2012+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2013+ */
2014+
2015+#include "mock_renderable.h"
2016+
2017+namespace mir
2018+{
2019+namespace graphics
2020+{
2021+
2022+MockRenderable::MockRenderable()
2023+{
2024+}
2025+
2026+MockRenderable::~MockRenderable()
2027+{
2028+}
2029+
2030+} // namespace graphics
2031+} // namespace mir
2032
2033=== modified file 'tests/framework/mock_renderable.h'
2034--- tests/modules/common/mock_renderable.h 2015-08-11 12:08:32 +0000
2035+++ tests/framework/mock_renderable.h 2016-02-10 16:36:17 +0000
2036@@ -25,7 +25,8 @@
2037
2038 struct MockRenderable : public Renderable
2039 {
2040- MockRenderable() {};
2041+ MockRenderable();
2042+ virtual ~MockRenderable();
2043
2044 MOCK_CONST_METHOD0(id, ID());
2045 MOCK_CONST_METHOD0(buffer, std::shared_ptr<Buffer>());
2046
2047=== added file 'tests/framework/mock_session.cpp'
2048--- tests/framework/mock_session.cpp 1970-01-01 00:00:00 +0000
2049+++ tests/framework/mock_session.cpp 2016-02-10 16:36:17 +0000
2050@@ -0,0 +1,69 @@
2051+/*
2052+ * Copyright (C) 2015 Canonical, Ltd.
2053+ *
2054+ * This program is free software: you can redistribute it and/or modify it under
2055+ * the terms of the GNU Lesser General Public License version 3, as published by
2056+ * the Free Software Foundation.
2057+ *
2058+ * This program is distributed in the hope that it will be useful, but WITHOUT
2059+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2060+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2061+ * Lesser General Public License for more details.
2062+ *
2063+ * You should have received a copy of the GNU Lesser General Public License
2064+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2065+ */
2066+
2067+#include "mock_session.h"
2068+
2069+namespace qtmir
2070+{
2071+
2072+MockSession::MockSession()
2073+ : SessionInterface(0)
2074+{
2075+ m_state = Starting;
2076+ ON_CALL(*this, suspend()).WillByDefault(::testing::Invoke(this, &MockSession::doSuspend));
2077+ ON_CALL(*this, resume()).WillByDefault(::testing::Invoke(this, &MockSession::doResume));
2078+ ON_CALL(*this, stop()).WillByDefault(::testing::Invoke(this, &MockSession::doStop));
2079+ ON_CALL(*this, state()).WillByDefault(::testing::Invoke(this, &MockSession::doState));
2080+}
2081+
2082+MockSession::~MockSession()
2083+{
2084+
2085+}
2086+
2087+SessionInterface::State MockSession::doState() const
2088+{
2089+ return m_state;
2090+}
2091+
2092+void MockSession::doStop()
2093+{
2094+ setState(Stopped);
2095+}
2096+
2097+void MockSession::doResume()
2098+{
2099+ if (m_state == Suspending || m_state == Suspended) {
2100+ setState(Running);
2101+ }
2102+}
2103+
2104+void MockSession::doSuspend()
2105+{
2106+ if (m_state == Running) {
2107+ setState(Suspending);
2108+ }
2109+}
2110+
2111+void MockSession::setState(SessionInterface::State state)
2112+{
2113+ if (m_state != state) {
2114+ m_state = state;
2115+ Q_EMIT stateChanged(m_state);
2116+ }
2117+}
2118+
2119+} // namespace qtmir
2120
2121=== modified file 'tests/framework/mock_session.h'
2122--- tests/modules/common/mock_session.h 2015-12-07 12:02:48 +0000
2123+++ tests/framework/mock_session.h 2016-02-10 16:36:17 +0000
2124@@ -24,13 +24,8 @@
2125
2126 class MockSession : public SessionInterface {
2127 public:
2128- MockSession() : SessionInterface(0) {
2129- m_state = Starting;
2130- ON_CALL(*this, suspend()).WillByDefault(::testing::Invoke(this, &MockSession::doSuspend));
2131- ON_CALL(*this, resume()).WillByDefault(::testing::Invoke(this, &MockSession::doResume));
2132- ON_CALL(*this, stop()).WillByDefault(::testing::Invoke(this, &MockSession::doStop));
2133- ON_CALL(*this, state()).WillByDefault(::testing::Invoke(this, &MockSession::doState));
2134- }
2135+ MockSession();
2136+ virtual ~MockSession();
2137
2138 MOCK_METHOD0(release, void());
2139
2140@@ -66,29 +61,12 @@
2141 MOCK_CONST_METHOD0(activePromptSession, std::shared_ptr<mir::scene::PromptSession>());
2142 MOCK_CONST_METHOD1(foreachPromptSession, void(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> f));
2143
2144- void setState(State state) {
2145- if (m_state != state) {
2146- m_state = state;
2147- Q_EMIT stateChanged(m_state);
2148- }
2149- }
2150+ void setState(State state);
2151
2152- void doSuspend() {
2153- if (m_state == Running) {
2154- setState(Suspending);
2155- }
2156- }
2157- void doResume() {
2158- if (m_state == Suspending || m_state == Suspended) {
2159- setState(Running);
2160- }
2161- }
2162- void doStop() {
2163- setState(Stopped);
2164- }
2165- State doState() const {
2166- return m_state;
2167- }
2168+ void doSuspend();
2169+ void doResume();
2170+ void doStop();
2171+ State doState() const;
2172
2173 protected:
2174 MOCK_METHOD1(setFullscreen, void(bool fullscreen));
2175@@ -97,7 +75,6 @@
2176 MOCK_METHOD1(removePromptSession, void(const std::shared_ptr<mir::scene::PromptSession>& session));
2177
2178 private:
2179-
2180 State m_state;
2181 };
2182
2183
2184=== added file 'tests/framework/mock_settings.cpp'
2185--- tests/framework/mock_settings.cpp 1970-01-01 00:00:00 +0000
2186+++ tests/framework/mock_settings.cpp 2016-02-10 16:36:17 +0000
2187@@ -0,0 +1,40 @@
2188+/*
2189+ * Copyright (C) 2015 Canonical, Ltd.
2190+ *
2191+ * This program is free software: you can redistribute it and/or modify it under
2192+ * the terms of the GNU Lesser General Public License version 3, as published by
2193+ * the Free Software Foundation.
2194+ *
2195+ * This program is distributed in the hope that it will be useful, but WITHOUT
2196+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2197+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2198+ * Lesser General Public License for more details.
2199+ *
2200+ * You should have received a copy of the GNU Lesser General Public License
2201+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2202+ */
2203+
2204+#include "mock_settings.h"
2205+
2206+namespace qtmir
2207+{
2208+
2209+MockSettings::MockSettings()
2210+{
2211+ using namespace ::testing;
2212+
2213+ QVariantList lifecycleExemptAppIds;
2214+ lifecycleExemptAppIds << "com.ubuntu.music";
2215+ ON_CALL(*this, get(_))
2216+ .WillByDefault(
2217+ Return(lifecycleExemptAppIds));
2218+
2219+}
2220+
2221+MockSettings::~MockSettings()
2222+{
2223+
2224+}
2225+
2226+} // namespace qtmir
2227+
2228
2229=== modified file 'tests/framework/mock_settings.h'
2230--- tests/modules/common/mock_settings.h 2015-03-24 23:38:33 +0000
2231+++ tests/framework/mock_settings.h 2016-02-10 16:36:17 +0000
2232@@ -18,24 +18,20 @@
2233 #define MOCK_SETTINGS_H
2234
2235 #include <Unity/Application/settings_interface.h>
2236-
2237+#include <QVariant>
2238+
2239 #include <gmock/gmock.h>
2240
2241-namespace testing
2242+namespace qtmir
2243 {
2244 struct MockSettings : public qtmir::SettingsInterface
2245 {
2246- MockSettings()
2247- {
2248- QVariantList lifecycleExemptAppIds;
2249- lifecycleExemptAppIds << "com.ubuntu.music";
2250- ON_CALL(*this, get(_))
2251- .WillByDefault(
2252- Return(lifecycleExemptAppIds));
2253+ MockSettings();
2254+ virtual ~MockSettings();
2255
2256- }
2257 MOCK_CONST_METHOD1(get, QVariant(const QString &));
2258 };
2259
2260-} // namespace testing
2261+} // namespace qtmir
2262+
2263 #endif // MOCK_SETTINGS_H
2264
2265=== added file 'tests/framework/mock_shared_wakelock.cpp'
2266--- tests/framework/mock_shared_wakelock.cpp 1970-01-01 00:00:00 +0000
2267+++ tests/framework/mock_shared_wakelock.cpp 2016-02-10 16:36:17 +0000
2268@@ -0,0 +1,61 @@
2269+/*
2270+ * Copyright (C) 2015 Canonical, Ltd.
2271+ *
2272+ * This program is free software: you can redistribute it and/or modify it under
2273+ * the terms of the GNU Lesser General Public License version 3, as published by
2274+ * the Free Software Foundation.
2275+ *
2276+ * This program is distributed in the hope that it will be useful, but WITHOUT
2277+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2278+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2279+ * Lesser General Public License for more details.
2280+ *
2281+ * You should have received a copy of the GNU Lesser General Public License
2282+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2283+ */
2284+
2285+#include "mock_shared_wakelock.h"
2286+
2287+namespace qtmir
2288+{
2289+
2290+MockSharedWakelock::MockSharedWakelock(const QDBusConnection &)
2291+{
2292+ using namespace ::testing;
2293+
2294+ ON_CALL(*this, enabled()).WillByDefault(Invoke(this, &MockSharedWakelock::doEnabled));
2295+ ON_CALL(*this, acquire(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doAcquire));
2296+ ON_CALL(*this, release(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doRelease));
2297+}
2298+
2299+MockSharedWakelock::~MockSharedWakelock()
2300+{
2301+}
2302+
2303+void MockSharedWakelock::doRelease(const QObject *object)
2304+{
2305+ if (!m_owners.remove(object)) {
2306+ return;
2307+ }
2308+ if (m_owners.isEmpty()) {
2309+ Q_EMIT enabledChanged(false);
2310+ }
2311+}
2312+
2313+void MockSharedWakelock::doAcquire(const QObject *object)
2314+{
2315+ if (m_owners.contains(object)) {
2316+ return;
2317+ }
2318+ m_owners.insert(object);
2319+ if (m_owners.size() == 1) {
2320+ Q_EMIT enabledChanged(true);
2321+ }
2322+}
2323+
2324+bool MockSharedWakelock::doEnabled()
2325+{
2326+ return !m_owners.isEmpty();
2327+}
2328+
2329+} // namespace qtmir
2330
2331=== modified file 'tests/framework/mock_shared_wakelock.h'
2332--- tests/modules/common/mock_shared_wakelock.h 2015-03-05 09:36:02 +0000
2333+++ tests/framework/mock_shared_wakelock.h 2016-02-10 16:36:17 +0000
2334@@ -21,51 +21,26 @@
2335
2336 #include <gmock/gmock.h>
2337
2338-namespace testing
2339+namespace qtmir
2340 {
2341 class MockSharedWakelock : public qtmir::SharedWakelock
2342 {
2343 public:
2344- MockSharedWakelock(const QDBusConnection& /*connection*/= QDBusConnection::systemBus())
2345- {
2346- ON_CALL(*this, enabled()).WillByDefault(Invoke(this, &MockSharedWakelock::doEnabled));
2347- ON_CALL(*this, acquire(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doAcquire));
2348- ON_CALL(*this, release(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doRelease));
2349- }
2350+ MockSharedWakelock(const QDBusConnection& /*connection*/= QDBusConnection::systemBus());
2351+ virtual ~MockSharedWakelock();
2352
2353 MOCK_CONST_METHOD0(enabled, bool());
2354 MOCK_METHOD1(acquire, void(const QObject *));
2355 MOCK_METHOD1(release, void(const QObject *));
2356
2357- bool doEnabled()
2358- {
2359- return !m_owners.isEmpty();
2360- }
2361-
2362- void doAcquire(const QObject *object)
2363- {
2364- if (m_owners.contains(object)) {
2365- return;
2366- }
2367- m_owners.insert(object);
2368- if (m_owners.size() == 1) {
2369- Q_EMIT enabledChanged(true);
2370- }
2371- }
2372-
2373- void doRelease(const QObject *object)
2374- {
2375- if (!m_owners.remove(object)) {
2376- return;
2377- }
2378- if (m_owners.isEmpty()) {
2379- Q_EMIT enabledChanged(false);
2380- }
2381- }
2382+ bool doEnabled();
2383+ void doAcquire(const QObject *object);
2384+ void doRelease(const QObject *object);
2385
2386 private:
2387 QSet<const QObject *> m_owners;
2388 };
2389
2390-} // namespace testing
2391+} // namespace qtmir
2392+
2393 #endif // MOCK_SHARED_WAKELOCK_H
2394
2395=== added file 'tests/framework/mock_surface.cpp'
2396--- tests/framework/mock_surface.cpp 1970-01-01 00:00:00 +0000
2397+++ tests/framework/mock_surface.cpp 2016-02-10 16:36:17 +0000
2398@@ -0,0 +1,45 @@
2399+/*
2400+ * Copyright (C) 2015 Canonical, Ltd.
2401+ *
2402+ * This program is free software: you can redistribute it and/or modify it under
2403+ * the terms of the GNU Lesser General Public License version 3, as published by
2404+ * the Free Software Foundation.
2405+ *
2406+ * This program is distributed in the hope that it will be useful, but WITHOUT
2407+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2408+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2409+ * Lesser General Public License for more details.
2410+ *
2411+ * You should have received a copy of the GNU Lesser General Public License
2412+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2413+ */
2414+
2415+#include "mock_surface.h"
2416+
2417+namespace mir
2418+{
2419+namespace scene
2420+{
2421+
2422+MockSurface::MockSurface()
2423+{
2424+}
2425+
2426+MockSurface::~MockSurface()
2427+{
2428+}
2429+
2430+void MockSurface::rename(const std::string &) {}
2431+
2432+void MockSurface::set_keymap(MirInputDeviceId,
2433+ std::string const&,
2434+ std::string const&,
2435+ std::string const&,
2436+ std::string const&)
2437+{
2438+}
2439+
2440+// void MockSurface::consume(const MirEvent &event) { consume(&event); }
2441+
2442+} // namespace scene
2443+} // namespace mir
2444
2445=== modified file 'tests/framework/mock_surface.h'
2446--- tests/modules/common/mock_surface.h 2016-01-24 02:51:34 +0000
2447+++ tests/framework/mock_surface.h 2016-02-10 16:36:17 +0000
2448@@ -28,7 +28,8 @@
2449
2450 struct MockSurface : public mir::scene::Surface
2451 {
2452- MockSurface() {}
2453+ MockSurface();
2454+ virtual ~MockSurface();
2455
2456 MOCK_CONST_METHOD0(name, std::string());
2457 MOCK_CONST_METHOD0(client_size, geometry::Size());
2458@@ -63,15 +64,15 @@
2459 MOCK_METHOD0(request_client_surface_close, void());
2460 MOCK_CONST_METHOD1(buffers_ready_for_compositor, int(void const*));
2461 void set_keymap(MirInputDeviceId, std::string const&, std::string const&,
2462- std::string const&, std::string const&) override {}
2463- void rename(std::string const&) override {}
2464+ std::string const&, std::string const&) override;
2465+ void rename(std::string const&) override;
2466 MOCK_METHOD1(set_streams, void(std::list<StreamInfo> const&));
2467
2468 // from mir::input::surface
2469 MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point));
2470 MOCK_CONST_METHOD0(reception_mode, input::InputReceptionMode());
2471 MOCK_METHOD1(consume, void(MirEvent const* event));
2472- //void consume(MirEvent const* event) override { consume(event); }
2473+ //void consume(MirEvent const* event) override;
2474
2475 // from mir::frontend::surface
2476 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
2477
2478=== modified file 'tests/framework/qtmir_test.cpp'
2479--- tests/modules/common/qtmir_test.cpp 2016-01-22 16:32:39 +0000
2480+++ tests/framework/qtmir_test.cpp 2016-02-10 16:36:17 +0000
2481@@ -18,7 +18,8 @@
2482
2483 namespace qtmir {
2484
2485-void PrintTo(const Application::InternalState& state, ::std::ostream* os) {
2486+void PrintTo(const Application::InternalState& state, ::std::ostream* os)
2487+{
2488 switch (state) {
2489 case Application::InternalState::Starting:
2490 *os << "Starting";
2491@@ -77,4 +78,101 @@
2492 }
2493 }
2494
2495+// Initialization of mir::Server needed for by tests
2496+class TestMirServerInit : public virtual mir::Server
2497+{
2498+public:
2499+ TestMirServerInit(std::shared_ptr<StubPromptSessionManager> const& promptSessionManager)
2500+ : mock_prompt_session_manager(promptSessionManager)
2501+ {
2502+ override_the_prompt_session_manager(
2503+ [this]{ return the_mock_prompt_session_manager(); });
2504+ }
2505+
2506+ std::shared_ptr<mir::scene::MockPromptSessionManager> the_mock_prompt_session_manager()
2507+ {
2508+ return mock_prompt_session_manager;
2509+ }
2510+
2511+private:
2512+ std::shared_ptr<StubPromptSessionManager> const mock_prompt_session_manager;
2513+};
2514+
2515+
2516+namespace { char const* argv[] = { nullptr }; }
2517+
2518+class FakeMirServer: private TestMirServerInit, public MirServer
2519+{
2520+public:
2521+ FakeMirServer(std::shared_ptr<StubPromptSessionManager> const& promptSessionManager)
2522+ : TestMirServerInit(promptSessionManager), MirServer(0, argv, QSharedPointer<ScreenController>())
2523+ {
2524+ }
2525+
2526+ using TestMirServerInit::the_mock_prompt_session_manager;
2527+};
2528+
2529 } // namespace qtmir
2530+
2531+namespace testing
2532+{
2533+
2534+QtMirTest::QtMirTest()
2535+ : promptSessionManager(std::make_shared<StubPromptSessionManager>())
2536+ , mirServer(QSharedPointer<MirServer>(new FakeMirServer(promptSessionManager)))
2537+ , taskController(QSharedPointer<TaskController>(
2538+ new TaskController(
2539+ nullptr,
2540+ QSharedPointer<ApplicationController>(&appController, [](ApplicationController*){}))))
2541+ , applicationManager(mirServer,
2542+ taskController,
2543+ QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}),
2544+ QSharedPointer<DesktopFileReader::Factory>(&desktopFileReaderFactory,[](DesktopFileReader::Factory*){}),
2545+ QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}),
2546+ QSharedPointer<MockSettings>(&settings,[](MockSettings *){}))
2547+ , sessionManager(mirServer, &applicationManager)
2548+ , surfaceManager(mirServer, mirShell, &sessionManager)
2549+{
2550+}
2551+
2552+QtMirTest::~QtMirTest()
2553+{
2554+
2555+}
2556+
2557+Application *QtMirTest::startApplication(pid_t procId, const QString &appId)
2558+{
2559+ using namespace testing;
2560+
2561+ ON_CALL(appController,appIdHasProcessId(procId, appId)).WillByDefault(Return(true));
2562+
2563+ // Set up Mocks & signal watcher
2564+ auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
2565+ ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
2566+ ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
2567+
2568+ EXPECT_CALL(desktopFileReaderFactory, createInstance(appId, _))
2569+ .Times(1)
2570+ .WillOnce(Return(mockDesktopFileReader));
2571+
2572+ EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(appId, _))
2573+ .Times(1)
2574+ .WillOnce(Return(true));
2575+
2576+ auto application = applicationManager.startApplication(appId, ApplicationManager::NoFlag);
2577+ applicationManager.onProcessStarting(appId);
2578+
2579+ bool authed = false;
2580+ applicationManager.authorizeSession(procId, authed);
2581+ EXPECT_EQ(authed, true);
2582+
2583+ auto appSession = std::make_shared<mir::scene::MockSession>(appId.toStdString(), procId);
2584+ applicationManager.onSessionStarting(appSession);
2585+ sessionManager.onSessionStarting(appSession);
2586+
2587+ Mock::VerifyAndClearExpectations(&appController);
2588+ Mock::VerifyAndClearExpectations(&desktopFileReaderFactory);
2589+ return application;
2590+}
2591+
2592+} // namespace testing
2593
2594=== modified file 'tests/framework/qtmir_test.h'
2595--- tests/modules/common/qtmir_test.h 2015-12-07 10:51:03 +0000
2596+++ tests/framework/qtmir_test.h 2016-02-10 16:36:17 +0000
2597@@ -46,45 +46,12 @@
2598
2599 namespace qtmir {
2600
2601+typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;
2602+
2603 // For better output in ASSERT_* and EXPECT_* error messages
2604 void PrintTo(const Application::InternalState& state, ::std::ostream* os);
2605 void PrintTo(const SessionInterface::State& state, ::std::ostream* os);
2606
2607-// Initialization of mir::Server needed for by tests
2608-class TestMirServerInit : public virtual mir::Server
2609-{
2610-public:
2611- TestMirServerInit()
2612- {
2613- override_the_prompt_session_manager(
2614- [this]{ return the_mock_prompt_session_manager(); });
2615- }
2616-
2617- std::shared_ptr<mir::scene::MockPromptSessionManager> the_mock_prompt_session_manager()
2618- {
2619- return mock_prompt_session_manager;
2620- }
2621-
2622-private:
2623- typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;
2624- std::shared_ptr<StubPromptSessionManager> const mock_prompt_session_manager
2625- {std::make_shared<StubPromptSessionManager>()};
2626-};
2627-
2628-
2629-namespace { char const* argv[] = { nullptr }; }
2630-
2631-class FakeMirServer: private TestMirServerInit, public MirServer
2632-{
2633-public:
2634- FakeMirServer()
2635- : MirServer(0, argv, QSharedPointer<ScreenController>())
2636- {
2637- }
2638-
2639- using TestMirServerInit::the_mock_prompt_session_manager;
2640-};
2641-
2642 } // namespace qtmir
2643
2644 namespace testing {
2645@@ -92,83 +59,19 @@
2646 class QtMirTest : public ::testing::Test
2647 {
2648 public:
2649- QtMirTest()
2650- : mirServer{
2651- QSharedPointer<FakeMirServer> (new FakeMirServer)
2652- }
2653- , taskController{
2654- QSharedPointer<TaskController> (
2655- new TaskController(
2656- nullptr,
2657- QSharedPointer<ApplicationController>(
2658- &appController,
2659- [](ApplicationController*){})
2660- )
2661- )
2662- }
2663- , applicationManager{
2664- mirServer,
2665- taskController,
2666- QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}),
2667- QSharedPointer<DesktopFileReader::Factory>(
2668- &desktopFileReaderFactory,
2669- [](DesktopFileReader::Factory*){}),
2670- QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}),
2671- QSharedPointer<MockSettings>(&settings,[](MockSettings *){})
2672- }
2673- , sessionManager{
2674- mirServer,
2675- &applicationManager,
2676- }
2677- , surfaceManager{
2678- mirServer,
2679- mirShell,
2680- &sessionManager
2681- }
2682- {
2683- }
2684-
2685- Application* startApplication(pid_t procId, QString const& appId)
2686- {
2687- using namespace testing;
2688-
2689- ON_CALL(appController,appIdHasProcessId(procId, appId)).WillByDefault(Return(true));
2690-
2691- // Set up Mocks & signal watcher
2692- auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
2693- ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
2694- ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
2695-
2696- EXPECT_CALL(desktopFileReaderFactory, createInstance(appId, _))
2697- .Times(1)
2698- .WillOnce(Return(mockDesktopFileReader));
2699-
2700- EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(appId, _))
2701- .Times(1)
2702- .WillOnce(Return(true));
2703-
2704- auto application = applicationManager.startApplication(appId, ApplicationManager::NoFlag);
2705- applicationManager.onProcessStarting(appId);
2706-
2707- bool authed = false;
2708- applicationManager.authorizeSession(procId, authed);
2709- EXPECT_EQ(authed, true);
2710-
2711- auto appSession = std::make_shared<mir::scene::MockSession>(appId.toStdString(), procId);
2712- applicationManager.onSessionStarting(appSession);
2713- sessionManager.onSessionStarting(appSession);
2714-
2715- Mock::VerifyAndClearExpectations(&appController);
2716- Mock::VerifyAndClearExpectations(&desktopFileReaderFactory);
2717- return application;
2718- }
2719-
2720- testing::NiceMock<testing::MockApplicationController> appController;
2721- testing::NiceMock<testing::MockProcInfo> procInfo;
2722- testing::NiceMock<testing::MockDesktopFileReaderFactory> desktopFileReaderFactory;
2723- testing::NiceMock<testing::MockSharedWakelock> sharedWakelock;
2724- testing::NiceMock<testing::MockSettings> settings;
2725- QSharedPointer<FakeMirServer> mirServer;
2726+ QtMirTest();
2727+ virtual ~QtMirTest();
2728+
2729+ Application* startApplication(pid_t procId, QString const& appId);
2730+
2731+ testing::NiceMock<MockApplicationController> appController;
2732+ testing::NiceMock<MockProcInfo> procInfo;
2733+ testing::NiceMock<MockDesktopFileReaderFactory> desktopFileReaderFactory;
2734+ testing::NiceMock<MockSharedWakelock> sharedWakelock;
2735+ testing::NiceMock<MockSettings> settings;
2736+ std::shared_ptr<StubPromptSessionManager> promptSessionManager;
2737+ QSharedPointer<MirServer> mirServer;
2738+
2739 MirShell *mirShell{nullptr};
2740 QSharedPointer<TaskController> taskController;
2741 ApplicationManager applicationManager;
2742
2743=== added file 'tests/framework/stub_input_channel.cpp'
2744--- tests/framework/stub_input_channel.cpp 1970-01-01 00:00:00 +0000
2745+++ tests/framework/stub_input_channel.cpp 2016-02-10 16:36:17 +0000
2746@@ -0,0 +1,52 @@
2747+/*
2748+ * Copyright (C) 2015 Canonical, Ltd.
2749+ *
2750+ * This program is free software: you can redistribute it and/or modify it under
2751+ * the terms of the GNU Lesser General Public License version 3, as published by
2752+ * the Free Software Foundation.
2753+ *
2754+ * This program is distributed in the hope that it will be useful, but WITHOUT
2755+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2756+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2757+ * Lesser General Public License for more details.
2758+ *
2759+ * You should have received a copy of the GNU Lesser General Public License
2760+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2761+ */
2762+
2763+#include "stub_input_channel.h"
2764+
2765+namespace mir
2766+{
2767+namespace test
2768+{
2769+namespace doubles
2770+{
2771+
2772+StubInputChannel::StubInputChannel(int fd)
2773+ : input_fd(fd)
2774+{
2775+}
2776+
2777+StubInputChannel::StubInputChannel()
2778+ : StubInputChannel(0)
2779+{
2780+}
2781+
2782+StubInputChannel::~StubInputChannel()
2783+{
2784+}
2785+
2786+int StubInputChannel::client_fd() const
2787+{
2788+ return input_fd;
2789+}
2790+
2791+int StubInputChannel::server_fd() const
2792+{
2793+ return input_fd;
2794+}
2795+
2796+} // namespace doubles
2797+} // namespace test
2798+} // namespace mir
2799
2800=== modified file 'tests/framework/stub_input_channel.h'
2801--- tests/modules/common/stub_input_channel.h 2015-08-11 12:08:32 +0000
2802+++ tests/framework/stub_input_channel.h 2016-02-10 16:36:17 +0000
2803@@ -28,24 +28,14 @@
2804
2805 struct StubInputChannel : public input::InputChannel
2806 {
2807- StubInputChannel(int fd)
2808- : input_fd(fd)
2809- {
2810- }
2811-
2812- StubInputChannel()
2813- : StubInputChannel(0)
2814- {
2815- }
2816-
2817- int client_fd() const override
2818- {
2819- return input_fd;
2820- }
2821- int server_fd() const override
2822- {
2823- return input_fd;
2824- }
2825+ StubInputChannel(int fd);
2826+
2827+ StubInputChannel();
2828+
2829+ virtual ~StubInputChannel();
2830+
2831+ int client_fd() const override;
2832+ int server_fd() const override;
2833 int input_fd;
2834 };
2835
2836
2837=== added file 'tests/framework/stub_scene_surface.cpp'
2838--- tests/framework/stub_scene_surface.cpp 1970-01-01 00:00:00 +0000
2839+++ tests/framework/stub_scene_surface.cpp 2016-02-10 16:36:17 +0000
2840@@ -0,0 +1,103 @@
2841+/*
2842+ * Copyright (C) 2015 Canonical, Ltd.
2843+ *
2844+ * This program is free software: you can redistribute it and/or modify it under
2845+ * the terms of the GNU Lesser General Public License version 3, as published by
2846+ * the Free Software Foundation.
2847+ *
2848+ * This program is distributed in the hope that it will be useful, but WITHOUT
2849+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2850+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2851+ * Lesser General Public License for more details.
2852+ *
2853+ * You should have received a copy of the GNU Lesser General Public License
2854+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2855+ */
2856+
2857+#include "stub_scene_surface.h"
2858+
2859+namespace mir
2860+{
2861+namespace test
2862+{
2863+namespace doubles
2864+{
2865+
2866+StubSceneSurface::StubSceneSurface(int fd)
2867+ : channel(std::make_shared<StubInputChannel>(fd)), fd(fd)
2868+{
2869+}
2870+
2871+StubSceneSurface::~StubSceneSurface()
2872+{
2873+}
2874+
2875+std::shared_ptr<mir::input::InputChannel> StubSceneSurface::input_channel() const
2876+{
2877+ return channel;
2878+}
2879+
2880+mir::input::InputReceptionMode StubSceneSurface::reception_mode() const
2881+{
2882+ return input_mode;
2883+}
2884+
2885+std::string StubSceneSurface::name() const { return {}; }
2886+
2887+mir::geometry::Point StubSceneSurface::top_left() const { return {}; }
2888+
2889+mir::geometry::Size StubSceneSurface::client_size() const { return {};}
2890+
2891+mir::geometry::Size StubSceneSurface::size() const { return {}; }
2892+
2893+mir::geometry::Rectangle StubSceneSurface::input_bounds() const { return {{},{}}; }
2894+
2895+bool StubSceneSurface::input_area_contains(mir::geometry::Point const&) const { return false; }
2896+
2897+mir::graphics::RenderableList StubSceneSurface::generate_renderables(mir::compositor::CompositorID) const { return {};}
2898+
2899+float StubSceneSurface::alpha() const { return 0.0f; }
2900+
2901+MirSurfaceType StubSceneSurface::type() const { return mir_surface_type_normal; }
2902+
2903+MirSurfaceState StubSceneSurface::state() const { return mir_surface_state_unknown; }
2904+
2905+void StubSceneSurface::hide() {}
2906+
2907+void StubSceneSurface::show() {}
2908+
2909+void StubSceneSurface::move_to(const mir::geometry::Point &) {}
2910+
2911+void StubSceneSurface::set_input_region(const std::vector<mir::geometry::Rectangle> &) {}
2912+
2913+void StubSceneSurface::resize(const mir::geometry::Size &) {}
2914+
2915+void StubSceneSurface::set_transformation(const glm::mat4 &) {}
2916+
2917+void StubSceneSurface::set_alpha(float) {}
2918+
2919+void StubSceneSurface::set_orientation(MirOrientation) {}
2920+
2921+void StubSceneSurface::add_observer(const std::shared_ptr<mir::scene::SurfaceObserver> &) {}
2922+
2923+void StubSceneSurface::remove_observer(const std::weak_ptr<mir::scene::SurfaceObserver> &) {}
2924+
2925+void StubSceneSurface::set_reception_mode(mir::input::InputReceptionMode mode) { input_mode = mode; }
2926+
2927+void StubSceneSurface::consume(const MirEvent *) {}
2928+
2929+void StubSceneSurface::set_cursor_image(const std::shared_ptr<mir::graphics::CursorImage> &) {}
2930+
2931+std::shared_ptr<mir::graphics::CursorImage> StubSceneSurface::cursor_image() const { return {}; }
2932+
2933+bool StubSceneSurface::supports_input() const { return true; }
2934+
2935+int StubSceneSurface::client_input_fd() const { return fd;}
2936+
2937+int StubSceneSurface::configure(MirSurfaceAttrib, int) { return 0; }
2938+
2939+int StubSceneSurface::query(MirSurfaceAttrib) const { return 0; }
2940+
2941+} // namespace doubles
2942+} // namespace test
2943+} // namespace mir
2944
2945=== modified file 'tests/framework/stub_scene_surface.h'
2946--- tests/modules/common/stub_scene_surface.h 2016-01-20 20:01:54 +0000
2947+++ tests/framework/stub_scene_surface.h 2016-02-10 16:36:17 +0000
2948@@ -38,55 +38,47 @@
2949 int fd;
2950 mir::input::InputReceptionMode input_mode{mir::input::InputReceptionMode::normal};
2951
2952- StubSceneSurface(int fd)
2953- : channel(std::make_shared<StubInputChannel>(fd)), fd(fd)
2954- {
2955- }
2956-
2957- std::shared_ptr<mir::input::InputChannel> input_channel() const override
2958- {
2959- return channel;
2960- }
2961-
2962- mir::input::InputReceptionMode reception_mode() const override
2963- {
2964- return input_mode;
2965- }
2966-
2967- std::string name() const override { return {}; }
2968- geometry::Point top_left() const override { return {}; }
2969- geometry::Size client_size() const override { return {};}
2970- geometry::Size size() const override { return {}; }
2971- geometry::Rectangle input_bounds() const override { return {{},{}}; }
2972- bool input_area_contains(mir::geometry::Point const&) const override { return false; }
2973-
2974- graphics::RenderableList generate_renderables(compositor::CompositorID) const override { return {};}
2975- float alpha() const override { return 0.0f;}
2976- MirSurfaceType type() const override { return mir_surface_type_normal; }
2977- MirSurfaceState state() const override { return mir_surface_state_unknown; }
2978-
2979- void hide() override {}
2980- void show() override {}
2981- void move_to(geometry::Point const&) override {}
2982- void set_input_region(std::vector<geometry::Rectangle> const&) override {}
2983- void resize(geometry::Size const&) override {}
2984- void set_transformation(glm::mat4 const&) override {}
2985- void set_alpha(float) override {}
2986- void set_orientation(MirOrientation) override {}
2987-
2988- void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override {}
2989- void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override {}
2990-
2991- void set_reception_mode(input::InputReceptionMode mode) override { input_mode = mode; }
2992- void consume(MirEvent const*) override {}
2993-
2994- void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& /* image */) override {}
2995- std::shared_ptr<graphics::CursorImage> cursor_image() const override { return {}; }
2996-
2997- bool supports_input() const override { return true;}
2998- int client_input_fd() const override { return fd;}
2999- int configure(MirSurfaceAttrib, int) override { return 0; }
3000- int query(MirSurfaceAttrib) const override { return 0; }
3001+ StubSceneSurface(int fd);
3002+ virtual ~StubSceneSurface();
3003+
3004+ std::shared_ptr<mir::input::InputChannel> input_channel() const override;
3005+
3006+ mir::input::InputReceptionMode reception_mode() const override;
3007+
3008+ std::string name() const override;
3009+ geometry::Point top_left() const override;
3010+ geometry::Size client_size() const override;
3011+ geometry::Size size() const override;
3012+ geometry::Rectangle input_bounds() const override;
3013+ bool input_area_contains(mir::geometry::Point const&) const override;
3014+
3015+ graphics::RenderableList generate_renderables(compositor::CompositorID) const override;
3016+ float alpha() const override;
3017+ MirSurfaceType type() const override;
3018+ MirSurfaceState state() const override;
3019+
3020+ void hide() override;
3021+ void show() override;
3022+ void move_to(geometry::Point const&) override;
3023+ void set_input_region(std::vector<geometry::Rectangle> const&) override;
3024+ void resize(geometry::Size const&) override;
3025+ void set_transformation(glm::mat4 const&) override;
3026+ void set_alpha(float) override;
3027+ void set_orientation(MirOrientation) override;
3028+
3029+ void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override;
3030+ void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override;
3031+
3032+ void set_reception_mode(input::InputReceptionMode mode) override;
3033+ void consume(MirEvent const*) override;
3034+
3035+ void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& /* image */) override;
3036+ std::shared_ptr<graphics::CursorImage> cursor_image() const override;
3037+
3038+ bool supports_input() const override;
3039+ int client_input_fd() const override;
3040+ int configure(MirSurfaceAttrib, int) override;
3041+ int query(MirSurfaceAttrib) const override;
3042 };
3043
3044 }
3045
3046=== modified file 'tests/mirserver/Screen/CMakeLists.txt'
3047--- tests/mirserver/Screen/CMakeLists.txt 2015-08-20 10:16:54 +0000
3048+++ tests/mirserver/Screen/CMakeLists.txt 2016-02-10 16:36:17 +0000
3049@@ -5,7 +5,7 @@
3050 )
3051
3052 include_directories(
3053- ${CMAKE_SOURCE_DIR}/tests/common
3054+ ${CMAKE_SOURCE_DIR}/tests/framework
3055 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3056 ${CMAKE_SOURCE_DIR}/src/common
3057 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
3058
3059=== modified file 'tests/mirserver/ScreenController/CMakeLists.txt'
3060--- tests/mirserver/ScreenController/CMakeLists.txt 2015-10-14 22:59:04 +0000
3061+++ tests/mirserver/ScreenController/CMakeLists.txt 2016-02-10 16:36:17 +0000
3062@@ -8,7 +8,7 @@
3063 )
3064
3065 include_directories(
3066- ${CMAKE_SOURCE_DIR}/tests/common
3067+ ${CMAKE_SOURCE_DIR}/tests/framework
3068 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3069 ${CMAKE_SOURCE_DIR}/src/common
3070 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
3071@@ -22,6 +22,9 @@
3072 ScreenControllerTest
3073 qpa-mirserver
3074
3075+ -L${CMAKE_BINARY_DIR}/tests/framework
3076+ qtmir-test-framework-static
3077+
3078 ${GTEST_BOTH_LIBRARIES}
3079 ${GMOCK_LIBRARIES}
3080 )
3081
3082=== modified file 'tests/modules/Application/CMakeLists.txt'
3083--- tests/modules/Application/CMakeLists.txt 2015-11-02 10:07:17 +0000
3084+++ tests/modules/Application/CMakeLists.txt 2016-02-10 16:36:17 +0000
3085@@ -1,15 +1,12 @@
3086 set(
3087 APPLICATION_TEST_SOURCES
3088 application_test.cpp
3089- ${CMAKE_SOURCE_DIR}/tests/modules/common/fake_session.h
3090- ${CMAKE_SOURCE_DIR}/tests/modules/common/qtmir_test.cpp
3091 )
3092
3093 include_directories(
3094- ${APPLICATION_API_INCLUDE_DIRS}
3095 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3096 ${CMAKE_SOURCE_DIR}/src/modules
3097- ${CMAKE_SOURCE_DIR}/tests/modules/common
3098+ ${CMAKE_SOURCE_DIR}/tests/framework
3099 ${MIRSERVER_INCLUDE_DIRS}
3100
3101 ${Qt5Core_INCLUDE_DIRS}
3102@@ -20,13 +17,17 @@
3103
3104 add_executable(application_test ${APPLICATION_TEST_SOURCES})
3105
3106+add_dependencies(application_test qtmir-test-framework-static)
3107+
3108 target_link_libraries(
3109 application_test
3110
3111+ Qt5::Test
3112+
3113 unityapplicationplugin
3114- qpa-mirserver
3115
3116- Qt5::Test
3117+ -L${CMAKE_BINARY_DIR}/tests/framework
3118+ qtmir-test-framework-static
3119
3120 ${GTEST_BOTH_LIBRARIES}
3121 ${GMOCK_LIBRARIES}
3122
3123=== modified file 'tests/modules/ApplicationManager/CMakeLists.txt'
3124--- tests/modules/ApplicationManager/CMakeLists.txt 2015-08-31 09:51:28 +0000
3125+++ tests/modules/ApplicationManager/CMakeLists.txt 2016-02-10 16:36:17 +0000
3126@@ -2,27 +2,29 @@
3127 APPLICATION_MANAGER_TEST_SOURCES
3128 application_manager_test.cpp
3129 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
3130- ${CMAKE_SOURCE_DIR}/tests/modules/common/qtmir_test.cpp
3131- ../common/fake_mirsurface.h
3132 )
3133
3134 include_directories(
3135 ${APPLICATION_API_INCLUDE_DIRS}
3136 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3137 ${CMAKE_SOURCE_DIR}/src/modules
3138- ${CMAKE_SOURCE_DIR}/tests/modules/common
3139+ ${CMAKE_SOURCE_DIR}/tests/framework
3140 ${MIRSERVER_INCLUDE_DIRS}
3141 )
3142
3143 add_executable(applicationmanager_test ${APPLICATION_MANAGER_TEST_SOURCES})
3144
3145+add_dependencies(applicationmanager_test qtmir-test-framework-static)
3146+
3147 target_link_libraries(
3148 applicationmanager_test
3149
3150- qpa-mirserver
3151+ Qt5::Test
3152+
3153 unityapplicationplugin
3154
3155- Qt5::Test
3156+ -L${CMAKE_BINARY_DIR}/tests/framework
3157+ qtmir-test-framework-static
3158
3159 ${GTEST_BOTH_LIBRARIES}
3160 ${GMOCK_LIBRARIES}
3161
3162=== modified file 'tests/modules/DesktopFileReader/CMakeLists.txt'
3163--- tests/modules/DesktopFileReader/CMakeLists.txt 2014-12-03 08:56:35 +0000
3164+++ tests/modules/DesktopFileReader/CMakeLists.txt 2016-02-10 16:36:17 +0000
3165@@ -7,8 +7,6 @@
3166
3167 include_directories(
3168 ${CMAKE_SOURCE_DIR}/src/modules
3169- ${CMAKE_SOURCE_DIR}/tests/modules/common
3170- ${MIRSERVER_INCLUDE_DIRS}
3171 )
3172
3173 add_executable(desktop_file_reader_test ${DESKTOP_FILE_READER_TEST_SOURCES})
3174@@ -16,13 +14,9 @@
3175 target_link_libraries(
3176 desktop_file_reader_test
3177
3178- qpa-mirserver
3179 unityapplicationplugin
3180
3181- Qt5::Gui
3182-
3183 ${GTEST_BOTH_LIBRARIES}
3184- ${GMOCK_LIBRARIES}
3185 )
3186
3187 add_test(DesktopFileReader desktop_file_reader_test)
3188
3189=== modified file 'tests/modules/SessionManager/CMakeLists.txt'
3190--- tests/modules/SessionManager/CMakeLists.txt 2015-08-31 09:51:28 +0000
3191+++ tests/modules/SessionManager/CMakeLists.txt 2016-02-10 16:36:17 +0000
3192@@ -3,28 +3,30 @@
3193 session_manager_test.cpp
3194 session_test.cpp
3195 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
3196- ${CMAKE_SOURCE_DIR}/tests/modules/common/qtmir_test.cpp
3197- ${CMAKE_SOURCE_DIR}/tests/modules/common/fake_mirsurface.h
3198 )
3199
3200 include_directories(
3201 ${APPLICATION_API_INCLUDE_DIRS}
3202 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3203 ${CMAKE_SOURCE_DIR}/src/modules
3204- ${CMAKE_SOURCE_DIR}/tests/modules/common
3205+ ${CMAKE_SOURCE_DIR}/tests/framework
3206 ${MIRSERVER_INCLUDE_DIRS}
3207 )
3208
3209 add_executable(sessionmanager_test ${SESSION_MANAGER_TEST_SOURCES})
3210
3211+add_dependencies(sessionmanager_test qtmir-test-framework-static)
3212+
3213 target_link_libraries(
3214 sessionmanager_test
3215
3216- qpa-mirserver
3217 unityapplicationplugin
3218
3219 Qt5::Test
3220
3221+ -L${CMAKE_BINARY_DIR}/tests/framework
3222+ qtmir-test-framework-static
3223+
3224 ${GTEST_BOTH_LIBRARIES}
3225 ${GMOCK_LIBRARIES}
3226 )
3227
3228=== modified file 'tests/modules/SessionManager/session_manager_test.cpp'
3229--- tests/modules/SessionManager/session_manager_test.cpp 2015-08-11 12:08:32 +0000
3230+++ tests/modules/SessionManager/session_manager_test.cpp 2016-02-10 16:36:17 +0000
3231@@ -60,7 +60,7 @@
3232 EXPECT_TRUE(qtmirAppSession != nullptr);
3233
3234 auto promptSession = std::make_shared<ms::MockPromptSession>();
3235- ON_CALL(*mirServer->the_mock_prompt_session_manager(), application_for(_)).WillByDefault(Return(mirAppSession));
3236+ ON_CALL(*promptSessionManager, application_for(_)).WillByDefault(Return(mirAppSession));
3237
3238 sessionManager.onPromptSessionStarting(promptSession);
3239
3240@@ -83,8 +83,8 @@
3241 SessionInterface* qtmirAppSession = sessionManager.findSession(mirAppSession.get());
3242 EXPECT_TRUE(qtmirAppSession != nullptr);
3243
3244- EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), application_for(_)).WillRepeatedly(Return(mirAppSession));
3245- EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), helper_for(_)).WillRepeatedly(Return(nullptr));
3246+ EXPECT_CALL(*promptSessionManager, application_for(_)).WillRepeatedly(Return(mirAppSession));
3247+ EXPECT_CALL(*promptSessionManager, helper_for(_)).WillRepeatedly(Return(nullptr));
3248
3249 std::shared_ptr<ms::PromptSession> mirPromptSession = std::make_shared<ms::MockPromptSession>();
3250
3251@@ -93,7 +93,7 @@
3252 sessionManager.onSessionStarting(mirProviderSession);
3253 SessionInterface* qtmirProviderSession = sessionManager.findSession(mirProviderSession.get());
3254
3255- EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), for_each_provider_in(mirPromptSession,_)).WillRepeatedly(WithArgs<1>(Invoke(
3256+ EXPECT_CALL(*promptSessionManager, for_each_provider_in(mirPromptSession,_)).WillRepeatedly(WithArgs<1>(Invoke(
3257 [&](std::function<void(std::shared_ptr<ms::Session> const& prompt_provider)> const& f) {
3258 f(mirProviderSession);
3259 })));
3260@@ -109,7 +109,7 @@
3261
3262 EXPECT_THAT(listChildSessions(qtmirAppSession), ElementsAre(qtmirProviderSession));
3263
3264- EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), for_each_provider_in(mirPromptSession,_)).WillRepeatedly(InvokeWithoutArgs([]{}));
3265+ EXPECT_CALL(*promptSessionManager, for_each_provider_in(mirPromptSession,_)).WillRepeatedly(InvokeWithoutArgs([]{}));
3266
3267 EXPECT_EQ(qtmirProviderSession->live(), true);
3268 sessionManager.onPromptProviderRemoved(mirPromptSession.get(), mirProviderSession);
3269
3270=== modified file 'tests/modules/SessionManager/session_test.cpp'
3271--- tests/modules/SessionManager/session_test.cpp 2016-01-22 16:32:39 +0000
3272+++ tests/modules/SessionManager/session_test.cpp 2016-02-10 16:36:17 +0000
3273@@ -236,7 +236,7 @@
3274 auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
3275 session->appendPromptSession(mirPromptSession);
3276
3277- EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), suspend_prompt_session(_)).Times(1);
3278+ EXPECT_CALL(*promptSessionManager, suspend_prompt_session(_)).Times(1);
3279
3280 EXPECT_CALL(*mirSession, set_lifecycle_state(mir_lifecycle_state_will_suspend));
3281 session->suspend();
3282@@ -244,7 +244,7 @@
3283 session->doSuspend();
3284 EXPECT_EQ(Session::Suspended, session->state());
3285
3286- Mock::VerifyAndClear(mirServer->the_mock_prompt_session_manager().get());
3287+ Mock::VerifyAndClear(promptSessionManager.get());
3288 }
3289
3290 TEST_F(SessionTests, ResumePromptSessionWhenSessionResumes)
3291@@ -256,7 +256,7 @@
3292
3293 auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
3294
3295- auto session = std::make_shared<qtmir::Session>(mirSession, mirServer->the_prompt_session_manager());
3296+ auto session = std::make_shared<qtmir::Session>(mirSession, promptSessionManager);
3297 {
3298 FakeMirSurface *surface = new FakeMirSurface;
3299 session->registerSurface(surface);
3300@@ -273,13 +273,13 @@
3301 auto mirPromptSession = std::make_shared<ms::MockPromptSession>();
3302 session->appendPromptSession(mirPromptSession);
3303
3304- EXPECT_CALL(*mirServer->the_mock_prompt_session_manager(), resume_prompt_session(_)).Times(1);
3305+ EXPECT_CALL(*promptSessionManager, resume_prompt_session(_)).Times(1);
3306
3307 EXPECT_CALL(*mirSession, set_lifecycle_state(mir_lifecycle_state_resumed));
3308 session->resume();
3309 EXPECT_EQ(Session::Running, session->state());
3310
3311- Mock::VerifyAndClear(mirServer->the_mock_prompt_session_manager().get());
3312+ Mock::VerifyAndClear(promptSessionManager.get());
3313 }
3314
3315 TEST_F(SessionTests, SessionStopsWhileSuspendingDoesntSuspend)
3316
3317=== modified file 'tests/modules/SharedWakelock/CMakeLists.txt'
3318--- tests/modules/SharedWakelock/CMakeLists.txt 2015-03-04 23:32:28 +0000
3319+++ tests/modules/SharedWakelock/CMakeLists.txt 2016-02-10 16:36:17 +0000
3320@@ -5,7 +5,6 @@
3321
3322 include_directories(
3323 ${CMAKE_SOURCE_DIR}/src/modules
3324- ${CMAKE_SOURCE_DIR}/tests/modules/common
3325 ${QTDBUSTEST_INCLUDE_DIRS}
3326 ${QTDBUSMOCK_INCLUDE_DIRS}
3327 )
3328
3329=== modified file 'tests/modules/SurfaceManager/CMakeLists.txt'
3330--- tests/modules/SurfaceManager/CMakeLists.txt 2015-11-17 14:47:38 +0000
3331+++ tests/modules/SurfaceManager/CMakeLists.txt 2016-02-10 16:36:17 +0000
3332@@ -3,14 +3,12 @@
3333 mirsurfaceitem_test.cpp
3334 mirsurface_test.cpp
3335 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
3336- ${CMAKE_SOURCE_DIR}/tests/modules/common/fake_mirsurface.h
3337- ${CMAKE_SOURCE_DIR}/tests/modules/common/fake_session.h
3338 )
3339
3340 include_directories(
3341 ${CMAKE_SOURCE_DIR}/src/modules
3342 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3343- ${CMAKE_SOURCE_DIR}/tests/modules/common
3344+ ${CMAKE_SOURCE_DIR}/tests/framework
3345 ${MIRSERVER_INCLUDE_DIRS}
3346 )
3347
3348@@ -19,11 +17,13 @@
3349 target_link_libraries(
3350 surfacemanager_test
3351
3352- qpa-mirserver
3353 unityapplicationplugin
3354
3355 Qt5::Test
3356
3357+ -L${CMAKE_BINARY_DIR}/tests/framework
3358+ qtmir-test-framework-static
3359+
3360 ${GTEST_BOTH_LIBRARIES}
3361 ${GMOCK_LIBRARIES}
3362 )
3363
3364=== modified file 'tests/modules/SurfaceManager/mirsurfaceitem_test.cpp'
3365--- tests/modules/SurfaceManager/mirsurfaceitem_test.cpp 2015-11-25 15:38:39 +0000
3366+++ tests/modules/SurfaceManager/mirsurfaceitem_test.cpp 2016-02-10 16:36:17 +0000
3367@@ -24,7 +24,7 @@
3368 // the test subject
3369 #include <Unity/Application/mirsurfaceitem.h>
3370
3371-// tests/modules/common
3372+// tests/framework
3373 #include <fake_mirsurface.h>
3374
3375 using namespace qtmir;
3376
3377=== modified file 'tests/modules/TaskController/CMakeLists.txt'
3378--- tests/modules/TaskController/CMakeLists.txt 2015-06-15 17:01:28 +0000
3379+++ tests/modules/TaskController/CMakeLists.txt 2016-02-10 16:36:17 +0000
3380@@ -7,18 +7,22 @@
3381 include_directories(
3382 ${APPLICATION_API_INCLUDE_DIRS}
3383 ${CMAKE_SOURCE_DIR}/src/modules
3384- ${CMAKE_SOURCE_DIR}/tests/modules/common
3385+ ${CMAKE_SOURCE_DIR}/tests/framework
3386 ${MIRSERVER_INCLUDE_DIRS}
3387 )
3388
3389 add_executable(taskcontroller_test ${TASK_CONTROLLER_TEST_SOURCES})
3390
3391+add_dependencies(taskcontroller_test qtmir-test-framework-static)
3392+
3393 target_link_libraries(
3394 taskcontroller_test
3395
3396- qpa-mirserver
3397 unityapplicationplugin
3398
3399+ -L${CMAKE_BINARY_DIR}/tests/framework
3400+ qtmir-test-framework-static
3401+
3402 ${GTEST_BOTH_LIBRARIES}
3403 ${GMOCK_LIBRARIES}
3404 )

Subscribers

People subscribed via source and target branches