2
* Copyright (C) 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
#include "mock_application_info.h"
18
#include "mock_task_controller.h"
23
MockTaskController::MockTaskController()
25
using namespace ::testing;
27
ON_CALL(*this, appIdHasProcessId(_, _))
29
Invoke(this, &MockTaskController::doAppIdHasProcessId));
31
ON_CALL(*this, getInfoForApp(_))
33
Invoke(this, &MockTaskController::doGetInfoForApp));
35
ON_CALL(*this, stop(_))
37
Invoke(this, &MockTaskController::doStop));
39
ON_CALL(*this, start(_, _))
41
Invoke(this, &MockTaskController::doStart));
43
ON_CALL(*this, suspend(_))
45
Invoke(this, &MockTaskController::doSuspend));
47
ON_CALL(*this, resume(_))
49
Invoke(this, &MockTaskController::doResume));
52
MockTaskController::~MockTaskController()
58
bool MockTaskController::doAppIdHasProcessId(const QString &appId, pid_t pid)
60
auto it = children.find(appId);
61
if (it == children.end())
64
return it->pid() == pid;
68
QSharedPointer<qtmir::ApplicationInfo> MockTaskController::doGetInfoForApp(const QString& appId) const
70
return QSharedPointer<qtmir::ApplicationInfo>(new testing::NiceMock<MockApplicationInfo>(appId));
74
bool MockTaskController::doStop(const QString &appId)
82
bool MockTaskController::doStart(const QString &appId, const QStringList &args)
86
auto child = core::posix::fork([]()
90
return core::posix::exit::Status::success;
91
}, core::posix::StandardStream::empty);
95
children.insert(appId, child);
103
bool MockTaskController::doSuspend(const QString &appId)
110
bool MockTaskController::doResume(const QString &appId)