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

FAILED: Continuous integration, rev:393 jenkins. qa.ubuntu. com/job/ qtmir-ci/ 541/ jenkins. qa.ubuntu. com/job/ qtmir-vivid- amd64-ci/ 237/console jenkins. qa.ubuntu. com/job/ qtmir-vivid- armhf-ci/ 237/console jenkins. qa.ubuntu. com/job/ qtmir-vivid- i386-ci/ 119/console jenkins. qa.ubuntu. com/job/ qtmir-wily- amd64-ci/ 274/console jenkins. qa.ubuntu. com/job/ qtmir-wily- armhf-ci/ 274/console jenkins. qa.ubuntu. com/job/ qtmir-wily- i386-ci/ 119/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtmir- ci/541/ rebuild
http://