blob: d71d77eca35accf6f29ee65e8e80113af4188348 [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));
27 MOCK_METHOD(void, registerForUpdates,
28 (const std::weak_ptr<interfaces::SensorListener>&), (override));
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020029
30 const uint64_t mockId = generateUniqueMockId();
31
32 Id mockSensorId = Id("SensorMock", "", "");
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010033
34 private:
35 void initialize()
36 {
37 ON_CALL(*this, id()).WillByDefault(testing::Invoke([this] {
38 return this->mockSensorId;
39 }));
40 }
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020041};