| 1 |
/* |
| 2 |
* Copyright (C) 2021 UBports foundation. |
| 3 |
* Author(s): Marius Gripsgard <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify it under |
| 6 |
* the terms of the GNU General Public License version 3, as published by |
| 7 |
* the Free Software Foundation. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 |
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
| 11 |
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
#include <gmock/gmock.h> |
| 20 |
#include "platform/platform.h" |
| 21 |
|
| 22 |
class MockPlatform : public Platform |
| 23 |
{ |
| 24 |
public: |
| 25 |
MOCK_METHOD0(name, std::string()); |
| 26 |
MOCK_METHOD0(prettyName, std::string()); |
| 27 |
MOCK_METHOD0(deviceType, DeviceInfo::DeviceType()); |
| 28 |
MOCK_METHOD0(driverType, DeviceInfo::DriverType()); |
| 29 |
|
| 30 |
MOCK_METHOD0(hasValidName, bool()); |
| 31 |
MOCK_METHOD0(hasValidPrettyName, bool()); |
| 32 |
MOCK_METHOD0(hasValidDeviceType, bool()); |
| 33 |
}; |
| 34 |
|
| 35 |
class DummyPlatform : public Platform |
| 36 |
{ |
| 37 |
public: |
| 38 |
DummyPlatform() {}; |
| 39 |
|
| 40 |
DummyPlatform(std::string name, std::string pName) : |
| 41 |
m_name(name), |
| 42 |
m_pName(pName) {}; |
| 43 |
|
| 44 |
DummyPlatform(std::string name, std::string pName, |
| 45 |
std::string buildId, std::string deviceIdentifier, |
| 46 |
DeviceInfo::DeviceType deType, |
| 47 |
DeviceInfo::DriverType drType) : |
| 48 |
m_name(name), |
| 49 |
m_pName(pName), |
| 50 |
m_buildId(buildId), |
| 51 |
m_deviceIdentifier(deviceIdentifier), |
| 52 |
m_deType(deType), |
| 53 |
m_drType(drType) {}; |
| 54 |
|
| 55 |
std::string name() override { return m_name; }; |
| 56 |
std::string prettyName() override { return m_pName; }; |
| 57 |
std::string buildId() override { return m_buildId; }; |
| 58 |
std::string deviceIdentifier() override { return m_deviceIdentifier; }; |
| 59 |
DeviceInfo::DeviceType deviceType() override { return m_deType; }; |
| 60 |
DeviceInfo::DriverType driverType() override { return m_drType; }; |
| 61 |
|
| 62 |
bool hasValidName() override { return !m_name.empty(); }; |
| 63 |
bool hasValidPrettyName() override { return !m_pName.empty(); }; |
| 64 |
bool hasValidDeviceType() override { return m_deType != DeviceInfo::DeviceType::Unknown; }; |
| 65 |
|
| 66 |
private: |
| 67 |
std::string m_name; |
| 68 |
std::string m_pName; |
| 69 |
std::string m_buildId; |
| 70 |
std::string m_deviceIdentifier; |
| 71 |
DeviceInfo::DeviceType m_deType; |
| 72 |
DeviceInfo::DriverType m_drType; |
| 73 |
}; |