blob: 9ff72e2d4946db1c7bf4a89b1d29b8f2730e38e1 [file] [log] [blame]
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +02001#pragma once
2
3#include "interfaces/sensor.hpp"
4#include "utils/generate_unique_mock_id.hpp"
5
6#include <gmock/gmock.h>
7
8class SensorMock : public interfaces::Sensor
9{
10 public:
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010011 explicit SensorMock()
12 {
13 initialize();
14 }
15
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020016 explicit SensorMock(Id sensorId) : mockSensorId(sensorId)
17 {
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010018 initialize();
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020019 }
20
21 static Id makeId(std::string_view service, std::string_view path)
22 {
23 return Id("SensorMock", service, path);
24 }
25
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020026 MOCK_METHOD(Id, id, (), (const, override));
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010027 MOCK_METHOD(std::string, metadata, (), (const, override));
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020028 MOCK_METHOD(void, registerForUpdates,
29 (const std::weak_ptr<interfaces::SensorListener>&), (override));
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020030 MOCK_METHOD(void, unregisterFromUpdates,
31 (const std::weak_ptr<interfaces::SensorListener>&), (override));
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020032
33 const uint64_t mockId = generateUniqueMockId();
34
35 Id mockSensorId = Id("SensorMock", "", "");
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010036
37 private:
38 void initialize()
39 {
40 ON_CALL(*this, id()).WillByDefault(testing::Invoke([this] {
41 return this->mockSensorId;
42 }));
43 }
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020044};