~alan-griffiths/miral/fix-1645284

« back to all changes in this revision

Viewing changes to miral-qt/tests/framework/qtmir_test.cpp

  • Committer: Alan Griffiths
  • Date: 2016-11-07 17:59:19 UTC
  • mfrom: (436.1.1 miral2)
  • Revision ID: alan@octopull.co.uk-20161107175919-stbb64i7j1htgog2
[miral-qt] delete all as qtmir work on MirAL has shifted to lp:~unity-team/qtmir/miral-qt-integration and this is a needless distration

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2015-2016 Canonical, Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>.
15
 
 */
16
 
 
17
 
#include "qtmir_test.h"
18
 
 
19
 
namespace qtmir {
20
 
 
21
 
void PrintTo(const Application::InternalState& state, ::std::ostream* os)
22
 
{
23
 
    switch (state) {
24
 
    case Application::InternalState::Starting:
25
 
        *os << "Starting";
26
 
        break;
27
 
    case Application::InternalState::Running:
28
 
        *os << "Running";
29
 
        break;
30
 
    case Application::InternalState::RunningInBackground:
31
 
        *os << "RunningInBackground";
32
 
        break;
33
 
    case Application::InternalState::SuspendingWaitSession:
34
 
        *os << "SuspendingWaitSession";
35
 
        break;
36
 
    case Application::InternalState::SuspendingWaitProcess:
37
 
        *os << "SuspendingWaitProcess";
38
 
        break;
39
 
    case Application::InternalState::Suspended:
40
 
        *os << "Suspended";
41
 
        break;
42
 
    case Application::InternalState::StoppedResumable:
43
 
        *os << "StoppedResumable";
44
 
        break;
45
 
    case Application::InternalState::Closing:
46
 
        *os << "Closing";
47
 
        break;
48
 
    case Application::InternalState::Stopped:
49
 
        *os << "Stopped";
50
 
        break;
51
 
    default:
52
 
        *os << "???";
53
 
        break;
54
 
    }
55
 
}
56
 
 
57
 
void PrintTo(const Session::State& state, ::std::ostream* os)
58
 
{
59
 
    switch (state) {
60
 
    case SessionInterface::Starting:
61
 
        *os << "Starting";
62
 
        break;
63
 
    case SessionInterface::Running:
64
 
        *os << "Running";
65
 
        break;
66
 
    case SessionInterface::Suspending:
67
 
        *os << "Suspending";
68
 
        break;
69
 
    case SessionInterface::Suspended:
70
 
        *os << "Suspended";
71
 
        break;
72
 
    case SessionInterface::Stopped:
73
 
        *os << "Stopped";
74
 
        break;
75
 
    default:
76
 
        *os << "???";
77
 
        break;
78
 
    }
79
 
}
80
 
} // namespace qtmir
81
 
 
82
 
void PrintTo(const QString &text, ::std::ostream *os)
83
 
{
84
 
    *os << text.toUtf8().constData();
85
 
}
86
 
 
87
 
void PrintTo(const QSize &size, ::std::ostream *os)
88
 
{
89
 
    QString output;
90
 
    QDebug debug(&output);
91
 
 
92
 
    debug << size;
93
 
 
94
 
    *os << output.toUtf8().constData();
95
 
}
96
 
 
97
 
void PrintTo(const QPoint &point, ::std::ostream *os)
98
 
{
99
 
    QString output;
100
 
    QDebug debug(&output);
101
 
 
102
 
    debug << point;
103
 
 
104
 
    *os << output.toUtf8().constData();
105
 
}
106
 
 
107
 
namespace testing
108
 
{
109
 
 
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)
117
 
{
118
 
}
119
 
 
120
 
QtMirTest::~QtMirTest()
121
 
{
122
 
 
123
 
}
124
 
 
125
 
Application *QtMirTest::startApplication(pid_t procId, const QString &appId)
126
 
{
127
 
    using namespace testing;
128
 
 
129
 
    ON_CALL(*taskController,appIdHasProcessId(appId, procId)).WillByDefault(Return(true));
130
 
 
131
 
    // Set up Mocks & signal watcher
132
 
    EXPECT_CALL(*taskController, start(appId, _))
133
 
            .Times(1)
134
 
            .WillOnce(Return(true));
135
 
 
136
 
    auto application = applicationManager.startApplication(appId);
137
 
    applicationManager.onProcessStarting(appId);
138
 
 
139
 
    bool authed = false;
140
 
    applicationManager.authorizeSession(procId, authed);
141
 
    EXPECT_EQ(authed, true);
142
 
 
143
 
    auto appSession = std::make_shared<mir::scene::MockSession>(appId.toStdString(), procId);
144
 
    miral::ApplicationInfo appInfo(appSession);
145
 
    sessionManager.onSessionStarting(appInfo);
146
 
 
147
 
    Mock::VerifyAndClearExpectations(taskController);
148
 
    return application;
149
 
}
150
 
 
151
 
} // namespace testing