2
* Copyright (C) 2015-2016 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#include "qtmir_test.h"
21
void PrintTo(const Application::InternalState& state, ::std::ostream* os)
24
case Application::InternalState::Starting:
27
case Application::InternalState::Running:
30
case Application::InternalState::RunningInBackground:
31
*os << "RunningInBackground";
33
case Application::InternalState::SuspendingWaitSession:
34
*os << "SuspendingWaitSession";
36
case Application::InternalState::SuspendingWaitProcess:
37
*os << "SuspendingWaitProcess";
39
case Application::InternalState::Suspended:
42
case Application::InternalState::StoppedResumable:
43
*os << "StoppedResumable";
45
case Application::InternalState::Closing:
48
case Application::InternalState::Stopped:
57
void PrintTo(const Session::State& state, ::std::ostream* os)
60
case SessionInterface::Starting:
63
case SessionInterface::Running:
66
case SessionInterface::Suspending:
69
case SessionInterface::Suspended:
72
case SessionInterface::Stopped:
82
void PrintTo(const QString &text, ::std::ostream *os)
84
*os << text.toUtf8().constData();
87
void PrintTo(const QSize &size, ::std::ostream *os)
90
QDebug debug(&output);
94
*os << output.toUtf8().constData();
97
void PrintTo(const QPoint &point, ::std::ostream *os)
100
QDebug debug(&output);
104
*os << output.toUtf8().constData();
110
QtMirTest::QtMirTest()
111
: persistentSurfaceStore(std::make_shared<StubPersistentSurfaceStore>())
112
, applicationManager(taskControllerSharedPointer,
113
QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}),
114
QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}),
115
QSharedPointer<MockSettings>(&settings,[](MockSettings *){}))
116
, sessionManager(promptSessionManager, &applicationManager)
120
QtMirTest::~QtMirTest()
125
Application *QtMirTest::startApplication(pid_t procId, const QString &appId)
127
using namespace testing;
129
ON_CALL(*taskController,appIdHasProcessId(appId, procId)).WillByDefault(Return(true));
131
// Set up Mocks & signal watcher
132
EXPECT_CALL(*taskController, start(appId, _))
134
.WillOnce(Return(true));
136
auto application = applicationManager.startApplication(appId);
137
applicationManager.onProcessStarting(appId);
140
applicationManager.authorizeSession(procId, authed);
141
EXPECT_EQ(authed, true);
143
auto appSession = std::make_shared<mir::scene::MockSession>(appId.toStdString(), procId);
144
miral::ApplicationInfo appInfo(appSession);
145
sessionManager.onSessionStarting(appInfo);
147
Mock::VerifyAndClearExpectations(taskController);
151
} // namespace testing