Skip to content

Commit

Permalink
Create SystemInfo.h
Browse files Browse the repository at this point in the history
  • Loading branch information
parvathika authored Sep 2, 2024
1 parent 968556a commit 23a1492
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions Tests/mocks/thunder/SystemInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once

#include <gmock/gmock.h>

#include "Module.h"

class SystemInfo : public WPEFramework::PluginHost::ISubSystem {
private:
SystemInfo(const SystemInfo&) = delete;
SystemInfo& operator=(const SystemInfo&) = delete;

public:
SystemInfo()
: _flags(0)
{
// Defaults:
ON_CALL(*this, Set(::testing::_, ::testing::_))
.WillByDefault(::testing::Invoke(
[&](const subsystem type, WPEFramework::Core::IUnknown* information) {
_subsystems.emplace(type, information);

if (type >= NEGATIVE_START) {
_flags &= ~(1 << (type - NEGATIVE_START));
} else {
_flags |= (1 << type);
}
}));
ON_CALL(*this, Get(::testing::_))
.WillByDefault(::testing::Invoke(
[&](const subsystem type) -> const WPEFramework::Core::IUnknown* {
const WPEFramework::Core::IUnknown* result(nullptr);

auto it = _subsystems.find(type);
if (it != _subsystems.end()) {
result = it->second;
}

return result;
}));
ON_CALL(*this, IsActive(::testing::_))
.WillByDefault(::testing::Invoke(
[&](const subsystem type) -> bool {
return ((type < END_LIST) && ((_flags & (1 << type)) != 0));
}));
}
virtual ~SystemInfo() = default;

public:
MOCK_METHOD(void, Register, (WPEFramework::PluginHost::ISubSystem::INotification * notification), (override));
MOCK_METHOD(void, Unregister, (WPEFramework::PluginHost::ISubSystem::INotification * notification), (override));
MOCK_METHOD(string, BuildTreeHash, (), (const, override));
MOCK_METHOD(void, Set, (const subsystem type, WPEFramework::Core::IUnknown* information), (override));
MOCK_METHOD(const WPEFramework::Core::IUnknown*, Get, (const subsystem type), (const, override));
MOCK_METHOD(bool, IsActive, (const subsystem type), (const, override));

BEGIN_INTERFACE_MAP(SystemInfo)
INTERFACE_ENTRY(WPEFramework::PluginHost::ISubSystem)
END_INTERFACE_MAP

private:
std::map<subsystem, WPEFramework::Core::IUnknown*> _subsystems;
uint32_t _flags;
};

0 comments on commit 23a1492

Please sign in to comment.