blob: b86a26e7f4219295c4c506a45144babac9a03573 [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));
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020029 MOCK_METHOD(void, unregisterFromUpdates,
30 (const std::weak_ptr<interfaces::SensorListener>&), (override));
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020031
32 const uint64_t mockId = generateUniqueMockId();
33
34 Id mockSensorId = Id("SensorMock", "", "");
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010035
36 private:
37 void initialize()
38 {
39 ON_CALL(*this, id()).WillByDefault(testing::Invoke([this] {
40 return this->mockSensorId;
41 }));
42 }
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020043};