2
* Copyright (C) 2014-2015 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
#ifndef QT_MIR_TEST_FRAMEWORK_H
18
#define QT_MIR_TEST_FRAMEWORK_H
22
#include <gtest/gtest.h>
24
#include <QSharedPointer>
26
#include <Unity/Application/application.h>
27
#include <Unity/Application/application_manager.h>
28
#include <Unity/Application/sessionmanager.h>
29
#include <Unity/Application/session_interface.h>
30
#include <Unity/Application/sharedwakelock.h>
31
#include <Unity/Application/proc_info.h>
32
#include "promptsessionmanager.h"
34
#include "mock_proc_info.h"
35
#include "mock_mir_session.h"
36
#include "mock_prompt_session_manager.h"
37
#include "mock_prompt_session.h"
38
#include "mock_shared_wakelock.h"
39
#include "mock_settings.h"
40
#include "mock_task_controller.h"
41
#include "mock_persistent_surface_store.h"
43
namespace ms = mir::scene;
44
using namespace qtmir;
48
typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;
49
typedef testing::NiceMock<mir::shell::MockPersistentSurfaceStore> StubPersistentSurfaceStore;
51
// For better output in ASSERT_* and EXPECT_* error messages
52
void PrintTo(const Application::InternalState& state, ::std::ostream* os);
53
void PrintTo(const SessionInterface::State& state, ::std::ostream* os);
56
void PrintTo(const QString &string, ::std::ostream* os);
57
void PrintTo(const QSize &size, ::std::ostream *os);
58
void PrintTo(const QPoint &point, ::std::ostream *os);
62
class QtMirTest : public ::testing::Test
68
Application* startApplication(pid_t procId, QString const& appId);
71
QSharedPointer<qtmir::TaskController> taskControllerSharedPointer{new testing::NiceMock<qtmir::MockTaskController>};
72
testing::NiceMock<qtmir::MockTaskController> *taskController{static_cast<testing::NiceMock<qtmir::MockTaskController>*>(taskControllerSharedPointer.data())};
73
testing::NiceMock<MockProcInfo> procInfo;
74
testing::NiceMock<MockSharedWakelock> sharedWakelock;
75
testing::NiceMock<MockSettings> settings;
76
std::shared_ptr<StubPromptSessionManager> stubPromptSessionManager{std::make_shared<StubPromptSessionManager>()};
77
std::shared_ptr<qtmir::PromptSessionManager> promptSessionManager{std::make_shared<qtmir::PromptSessionManager>(stubPromptSessionManager)};
78
std::shared_ptr<StubPersistentSurfaceStore> persistentSurfaceStore;
80
ApplicationManager applicationManager;
81
SessionManager sessionManager;
83
} // namespace testing
85
#endif // QT_MIR_TEST_FRAMEWORK_H