2
* Copyright (C) 2016 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
* In addition, as a special exception, the copyright holders give
17
* permission to link the code of portions of this program with the
18
* OpenSSL library under certain conditions as described in each
19
* individual source file, and distribute linked combinations
21
* You must obey the GNU General Public License in all respects
22
* for all of the code used other than OpenSSL. If you modify
23
* file(s) with this exception, you may extend this exception to your
24
* version of the file(s), but you are not obligated to do so. If you
25
* do not wish to do so, delete this exception statement from your
26
* version. If you delete this exception statement from all source
27
* files in the program, then also delete it here.
30
#include <ubuntu-app-launch/registry.h>
32
namespace ual = ubuntu::app_launch;
34
#include <gtest/gtest.h>
35
#include <gmock/gmock.h>
37
using namespace ::testing;
42
class MockUALRegistry : public ual::Registry {
48
MOCK_METHOD1(installedApps, std::list<std::shared_ptr<ual::Application>>(std::shared_ptr<ual::Registry>));
51
class MockUALApplication : public ual::Application {
56
MockUALApplication(const ual::AppID& app_id,
57
const std::shared_ptr<MockInfo>& info = {})
68
std::shared_ptr<ual::Application::Info> info()
73
static std::shared_ptr<MockUALApplication> create(ual::AppID app_id,
74
std::shared_ptr<MockInfo> info = {})
76
std::shared_ptr<MockUALApplication> result{new MockUALApplication(app_id, info)};
80
class MockInfo : public ual::Application::Info
83
MockInfo(const std::string& title,
84
const std::string& description,
85
const std::string& iconPath)
86
: m_name(ual::Application::Info::Name::from_raw(title)),
87
m_description(ual::Application::Info::Description::from_raw(description)),
88
m_iconPath(ual::Application::Info::IconPath::from_raw(iconPath)),
89
m_defaultDept(ual::Application::Info::DefaultDepartment::from_raw("")),
90
m_ssPath(ual::Application::Info::IconPath::from_raw("")),
91
m_keywords(ual::Application::Info::Keywords::from_raw(std::vector<std::string>{}))
93
DefaultValue<const ual::Application::Info::DefaultDepartment&>::Set(m_defaultDept);
94
DefaultValue<const ual::Application::Info::IconPath&>::Set(m_ssPath);
95
DefaultValue<const ual::Application::Info::Keywords&>::Set(m_keywords);
98
const ual::Application::Info::Name& name()
103
const ual::Application::Info::Description& description()
105
return m_description;
108
const ual::Application::Info::IconPath& iconPath()
113
MOCK_METHOD0(defaultDepartment, const ual::Application::Info::DefaultDepartment&());
114
MOCK_METHOD0(screenshotPath, const ual::Application::Info::IconPath&());
115
MOCK_METHOD0(keywords, const ual::Application::Info::Keywords&());
117
MOCK_METHOD0(splash, ual::Application::Info::Splash());
118
MOCK_METHOD0(supportedOrientations, ual::Application::Info::Orientations());
119
MOCK_METHOD0(rotatesWindowContents, ual::Application::Info::RotatesWindow());
120
MOCK_METHOD0(supportsUbuntuLifecycle, ual::Application::Info::UbuntuLifecycle());
123
ual::Application::Info::Name m_name;
124
ual::Application::Info::Description m_description;
125
ual::Application::Info::IconPath m_iconPath;
126
ual::Application::Info::DefaultDepartment m_defaultDept;
127
ual::Application::Info::IconPath m_ssPath;
128
ual::Application::Info::Keywords m_keywords;
131
class MockInstance : public ual::Application::Instance
134
MOCK_METHOD0(isRunning, bool());
135
MOCK_METHOD0(logPath, std::string());
136
MOCK_METHOD0(primaryPid, pid_t());
137
MOCK_METHOD1(hasPid, bool(pid_t));
138
MOCK_METHOD0(pids, std::vector<pid_t>());
139
MOCK_METHOD0(pause, void());
140
MOCK_METHOD0(resume, void());
141
MOCK_METHOD0(stop, void());
144
MOCK_METHOD0(hasInstances, bool());
145
MOCK_METHOD0(instances, std::vector<std::shared_ptr<ual::Application::Instance>>());
146
MOCK_METHOD1(launch, std::shared_ptr<ual::Application::Instance>(const std::vector<ual::Application::URL>&));
147
MOCK_METHOD1(launchTest, std::shared_ptr<ual::Application::Instance>(const std::vector<ual::Application::URL>&));
151
std::shared_ptr<MockInfo> m_info;