blob: 69ad0de75bc6f99756b5e6b26d97589d2ac2f2d5 [file] [log] [blame]
Wludzik, Jozef1477fe62021-01-02 11:56:10 +01001#include "dbus_environment.hpp"
2#include "helpers.hpp"
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +02003#include "mocks/clock_mock.hpp"
Wludzik, Jozef1477fe62021-01-02 11:56:10 +01004#include "mocks/sensor_mock.hpp"
5#include "mocks/trigger_action_mock.hpp"
6#include "numeric_threshold.hpp"
7#include "utils/conv_container.hpp"
8
9#include <gmock/gmock.h>
10
11using namespace testing;
12using namespace std::chrono_literals;
13
14class TestNumericThreshold : public Test
15{
16 public:
17 std::vector<std::shared_ptr<SensorMock>> sensorMocks = {
18 std::make_shared<NiceMock<SensorMock>>(),
19 std::make_shared<NiceMock<SensorMock>>()};
20 std::vector<std::string> sensorNames = {"Sensor1", "Sensor2"};
21 std::unique_ptr<TriggerActionMock> actionMockPtr =
22 std::make_unique<StrictMock<TriggerActionMock>>();
23 TriggerActionMock& actionMock = *actionMockPtr;
24 std::shared_ptr<NumericThreshold> sut;
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020025 std::string triggerId = "MyTrigger";
26 std::unique_ptr<NiceMock<ClockMock>> clockMockPtr =
27 std::make_unique<NiceMock<ClockMock>>();
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010028
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000029 void makeThreshold(Milliseconds dwellTime, numeric::Direction direction,
Szymon Dompke94f71c52021-12-10 07:16:33 +010030 double thresholdValue,
31 numeric::Type type = numeric::Type::lowerWarning)
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010032 {
33 std::vector<std::unique_ptr<interfaces::TriggerAction>> actions;
34 actions.push_back(std::move(actionMockPtr));
35
36 sut = std::make_shared<NumericThreshold>(
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020037 DbusEnvironment::getIoc(), triggerId,
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010038 utils::convContainer<std::shared_ptr<interfaces::Sensor>>(
39 sensorMocks),
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020040 std::move(actions), dwellTime, direction, thresholdValue, type,
41 std::move(clockMockPtr));
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010042 }
43
44 void SetUp() override
45 {
Szymon Dompke94f71c52021-12-10 07:16:33 +010046 for (size_t idx = 0; idx < sensorMocks.size(); idx++)
47 {
48 ON_CALL(*sensorMocks.at(idx), getName())
49 .WillByDefault(Return(sensorNames[idx]));
50 }
51
52 makeThreshold(0ms, numeric::Direction::increasing, 90.0,
53 numeric::Type::upperCritical);
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010054 }
55};
56
57TEST_F(TestNumericThreshold, initializeThresholdExpectAllSensorsAreRegistered)
58{
59 for (auto& sensor : sensorMocks)
60 {
61 EXPECT_CALL(*sensor,
62 registerForUpdates(Truly([sut = sut.get()](const auto& x) {
63 return x.lock().get() == sut;
64 })));
65 }
66
67 sut->initialize();
68}
69
70TEST_F(TestNumericThreshold, thresholdIsNotInitializeExpectNoActionCommit)
71{
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020072 EXPECT_CALL(actionMock, commit(_, _, _, _, _)).Times(0);
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010073}
74
Szymon Dompke94f71c52021-12-10 07:16:33 +010075TEST_F(TestNumericThreshold, getLabeledParamsReturnsCorrectly)
76{
77 LabeledThresholdParam expected = numeric::LabeledThresholdParam(
78 numeric::Type::upperCritical, 0, numeric::Direction::increasing, 90.0);
79 EXPECT_EQ(sut->getThresholdParam(), expected);
80}
81
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010082struct NumericParams
83{
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020084 struct UpdateParams
85 {
86 size_t sensor;
87 double value;
88 Milliseconds sleepAfter;
89
90 UpdateParams(size_t sensor, double value,
91 Milliseconds sleepAfter = 0ms) :
92 sensor(sensor),
93 value(value), sleepAfter(sleepAfter)
94 {}
95 };
96
97 struct ExpectedParams
98 {
99 size_t sensor;
100 double value;
101 Milliseconds waitMin;
102
103 ExpectedParams(size_t sensor, double value,
104 Milliseconds waitMin = 0ms) :
105 sensor(sensor),
106 value(value), waitMin(waitMin)
107 {}
108 };
109
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100110 NumericParams& Direction(numeric::Direction val)
111 {
112 direction = val;
113 return *this;
114 }
115
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200116 NumericParams& Updates(std::vector<UpdateParams> val)
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100117 {
118 updates = std::move(val);
119 return *this;
120 }
121
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200122 NumericParams& Expected(std::vector<ExpectedParams> val)
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100123 {
124 expected = std::move(val);
125 return *this;
126 }
127
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200128 NumericParams& ThresholdValue(double val)
129 {
130 thresholdValue = val;
131 return *this;
132 }
133
134 NumericParams& DwellTime(Milliseconds val)
135 {
136 dwellTime = std::move(val);
137 return *this;
138 }
139
140 NumericParams& InitialValues(std::vector<double> val)
141 {
142 initialValues = std::move(val);
143 return *this;
144 }
145
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100146 friend void PrintTo(const NumericParams& o, std::ostream* os)
147 {
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200148 *os << "{ DwellTime: " << o.dwellTime.count() << "ms ";
149 *os << ", ThresholdValue: " << o.thresholdValue;
150 *os << ", Direction: " << static_cast<int>(o.direction);
151 *os << ", InitialValues: [ ";
152 size_t idx = 0;
153 for (const double value : o.initialValues)
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100154 {
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200155 *os << "{ SensorIndex: " << idx << ", Value: " << value << " }, ";
156 idx++;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100157 }
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200158 *os << " ], Updates: [ ";
159 for (const auto& [index, value, sleepAfter] : o.updates)
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100160 {
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200161 *os << "{ SensorIndex: " << index << ", Value: " << value
162 << ", SleepAfter: " << sleepAfter.count() << "ms }, ";
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100163 }
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200164 *os << " ], Expected: [ ";
165 for (const auto& [index, value, waitMin] : o.expected)
166 {
167 *os << "{ SensorIndex: " << index << ", Value: " << value
168 << ", waitMin: " << waitMin.count() << "ms }, ";
169 }
170 *os << " ] }";
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100171 }
172
173 numeric::Direction direction;
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200174 double thresholdValue = 0.0;
175 Milliseconds dwellTime = 0ms;
176 std::vector<UpdateParams> updates;
177 std::vector<ExpectedParams> expected;
178 std::vector<double> initialValues;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100179};
180
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200181class TestNumericThresholdCommon :
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100182 public TestNumericThreshold,
183 public WithParamInterface<NumericParams>
184{
185 public:
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200186 void sleep(Milliseconds duration)
187 {
188 if (duration != 0ms)
189 {
190 DbusEnvironment::sleepFor(duration);
191 }
192 }
193
194 void testBodySensorIsUpdatedMultipleTimes()
195 {
196 std::vector<std::chrono::time_point<std::chrono::high_resolution_clock>>
197 timestamps(sensorMocks.size());
198
199 sut->initialize();
200
201 InSequence seq;
202
203 for (const auto& [index, value, waitMin] : GetParam().expected)
204 {
205 EXPECT_CALL(actionMock,
206 commit(triggerId, Eq(std::nullopt), sensorNames[index],
207 _, TriggerValue(value)))
208 .WillOnce(DoAll(
209 InvokeWithoutArgs([idx = index, &timestamps] {
210 timestamps[idx] =
211 std::chrono::high_resolution_clock::now();
212 }),
213 InvokeWithoutArgs(DbusEnvironment::setPromise("commit"))));
214 }
215
216 auto start = std::chrono::high_resolution_clock::now();
217
218 size_t idx = 0;
219 for (const double value : GetParam().initialValues)
220 {
221 sut->sensorUpdated(*sensorMocks[idx], 0ms, value);
222 idx++;
223 }
224
225 for (const auto& [index, value, sleepAfter] : GetParam().updates)
226 {
227 ASSERT_LT(index, GetParam().initialValues.size())
228 << "Initial value was not specified for sensor with index: "
229 << index;
230 sut->sensorUpdated(*sensorMocks[index], 42ms, value);
231 sleep(sleepAfter);
232 }
233
234 EXPECT_THAT(DbusEnvironment::waitForFutures("commit"), true);
235 for (const auto& [index, value, waitMin] : GetParam().expected)
236 {
237 EXPECT_THAT(timestamps[index] - start, Ge(waitMin));
238 }
239 }
240};
241
242class TestNumericThresholdNoDwellTime : public TestNumericThresholdCommon
243{
244 public:
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100245 void SetUp() override
246 {
Szymon Dompke94f71c52021-12-10 07:16:33 +0100247 for (size_t idx = 0; idx < sensorMocks.size(); idx++)
248 {
249 ON_CALL(*sensorMocks.at(idx), getName())
250 .WillByDefault(Return(sensorNames[idx]));
251 }
252
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200253 makeThreshold(0ms, GetParam().direction, GetParam().thresholdValue);
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100254 }
255};
256
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100257INSTANTIATE_TEST_SUITE_P(_, TestNumericThresholdNoDwellTime,
258 Values(NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200259 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100260 .Direction(numeric::Direction::increasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200261 .InitialValues({80.0})
262 .Updates({{0, 89.0}})
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100263 .Expected({}),
264 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200265 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100266 .Direction(numeric::Direction::increasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200267 .InitialValues({80.0})
268 .Updates({{0, 91.0}})
269 .Expected({{0, 91.0}}),
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100270 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200271 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100272 .Direction(numeric::Direction::increasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200273 .InitialValues({80.0})
274 .Updates({{0, 99.0}, {0, 80.0}, {0, 98.0}})
275 .Expected({{0, 99.0}, {0, 98.0}}),
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100276 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200277 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100278 .Direction(numeric::Direction::increasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200279 .InitialValues({80.0, 100.0})
280 .Updates({{0, 99.0}, {1, 98.0}})
281 .Expected({{0, 99.0}}),
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100282 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200283 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100284 .Direction(numeric::Direction::decreasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200285 .InitialValues({100.0})
286 .Updates({{0, 91.0}})
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100287 .Expected({}),
288 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200289 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100290 .Direction(numeric::Direction::decreasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200291 .InitialValues({100.0})
292 .Updates({{0, 80.0}})
293 .Expected({{0, 80.0}}),
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100294 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200295 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100296 .Direction(numeric::Direction::decreasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200297 .InitialValues({100.0})
298 .Updates({{0, 80.0}, {0, 99.0}, {0, 85.0}})
299 .Expected({{0, 80.0}, {0, 85.0}}),
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100300 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200301 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100302 .Direction(numeric::Direction::decreasing)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200303 .InitialValues({100.0, 99.0})
304 .Updates({{0, 80.0}, {1, 88.0}})
305 .Expected({{0, 80.0}, {1, 88.0}}),
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100306 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200307 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100308 .Direction(numeric::Direction::either)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200309 .InitialValues({98.0})
310 .Updates({{0, 91.0}})
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100311 .Expected({}),
312 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200313 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100314 .Direction(numeric::Direction::either)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200315 .InitialValues({100.0})
316 .Updates({{0, 80.0}, {0, 85.0}, {0, 91.0}})
317 .Expected({{0, 80.0}, {0, 91.0}}),
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100318 NumericParams()
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200319 .ThresholdValue(90.0)
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +0100320 .Direction(numeric::Direction::either)
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200321 .InitialValues({100.0, 80.0})
322 .Updates({{0, 85.0}, {1, 91.0}})
323 .Expected({{0, 85.0}, {1, 91.0}})));
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100324
325TEST_P(TestNumericThresholdNoDwellTime, senorsIsUpdatedMultipleTimes)
326{
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200327 testBodySensorIsUpdatedMultipleTimes();
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100328}
329
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200330class TestNumericThresholdWithDwellTime : public TestNumericThresholdCommon
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100331{
332 public:
333 void SetUp() override
334 {
Szymon Dompke94f71c52021-12-10 07:16:33 +0100335 for (size_t idx = 0; idx < sensorMocks.size(); idx++)
336 {
337 ON_CALL(*sensorMocks.at(idx), getName())
338 .WillByDefault(Return(sensorNames[idx]));
339 }
340
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200341 makeThreshold(GetParam().dwellTime, GetParam().direction,
342 GetParam().thresholdValue);
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100343 }
344};
345
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200346INSTANTIATE_TEST_SUITE_P(
347 SleepAfterEveryUpdate, TestNumericThresholdWithDwellTime,
348 Values(NumericParams()
349 .DwellTime(200ms)
350 .ThresholdValue(90.0)
351 .Direction(numeric::Direction::increasing)
352 .InitialValues({80.0})
353 .Updates({{0, 89.0, 200ms}})
354 .Expected({}),
355 NumericParams()
356 .DwellTime(200ms)
357 .ThresholdValue(90.0)
358 .Direction(numeric::Direction::increasing)
359 .InitialValues({80.0})
360 .Updates({{0, 91.0, 200ms}})
361 .Expected({{0, 91.0, 200ms}}),
362 NumericParams()
363 .DwellTime(200ms)
364 .ThresholdValue(90.0)
365 .Direction(numeric::Direction::increasing)
366 .InitialValues({80.0})
367 .Updates({{0, 99.0, 200ms}, {0, 80.0, 100ms}, {0, 98.0, 200ms}})
368 .Expected({{0, 99.0, 200ms}, {0, 98.0, 500ms}}),
369 NumericParams()
370 .DwellTime(200ms)
371 .ThresholdValue(90.0)
372 .Direction(numeric::Direction::increasing)
373 .InitialValues({80.0, 99.0})
374 .Updates({{0, 100.0, 100ms}, {1, 86.0, 100ms}})
375 .Expected({{0, 100.0, 200ms}}),
376 NumericParams()
377 .DwellTime(200ms)
378 .ThresholdValue(90.0)
379 .Direction(numeric::Direction::decreasing)
380 .InitialValues({100.0})
381 .Updates({{0, 91.0, 200ms}})
382 .Expected({}),
383 NumericParams()
384 .DwellTime(200ms)
385 .ThresholdValue(90.0)
386 .Direction(numeric::Direction::decreasing)
387 .InitialValues({100.0})
388 .Updates({{0, 80.0, 200ms}})
389 .Expected({{0, 80.0, 200ms}}),
390 NumericParams()
391 .DwellTime(200ms)
392 .ThresholdValue(90.0)
393 .Direction(numeric::Direction::decreasing)
394 .InitialValues({100.0})
395 .Updates({{0, 80.0, 200ms}, {0, 99.0, 100ms}, {0, 85.0, 200ms}})
396 .Expected({{0, 80.0, 200ms}, {0, 85.0, 500ms}}),
397 NumericParams()
398 .DwellTime(200ms)
399 .ThresholdValue(90.0)
400 .Direction(numeric::Direction::decreasing)
401 .InitialValues({100.0, 99.0})
402 .Updates({{0, 80.0, 200ms}, {1, 88.0, 200ms}})
403 .Expected({{0, 80.0, 200ms}, {1, 88.0, 400ms}}),
404 NumericParams()
405 .DwellTime(200ms)
406 .ThresholdValue(90.0)
407 .Direction(numeric::Direction::either)
408 .InitialValues({98.0})
409 .Updates({{0, 91.0, 200ms}})
410 .Expected({}),
411 NumericParams()
412 .DwellTime(200ms)
413 .ThresholdValue(90.0)
414 .Direction(numeric::Direction::either)
415 .InitialValues({100.0})
416 .Updates({{0, 80.0, 100ms}, {0, 85.0, 100ms}, {0, 91.0, 200ms}})
417 .Expected({{0, 80.0, 200ms}, {0, 91.0, 400ms}}),
418 NumericParams()
419 .DwellTime(200ms)
420 .ThresholdValue(90.0)
421 .Direction(numeric::Direction::either)
422 .InitialValues({100.0, 80.0})
423 .Updates({{0, 85.0, 100ms}, {1, 91.0, 200ms}})
424 .Expected({{0, 85.0, 200ms}, {1, 91.0, 300ms}})));
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100425
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200426INSTANTIATE_TEST_SUITE_P(
427 SleepAfterLastUpdate, TestNumericThresholdWithDwellTime,
428 Values(NumericParams()
429 .DwellTime(200ms)
430 .ThresholdValue(90.0)
431 .Direction(numeric::Direction::increasing)
432 .InitialValues({80.0})
433 .Updates({{0, 89.0, 300ms}})
434 .Expected({}),
435 NumericParams()
436 .DwellTime(200ms)
437 .ThresholdValue(90.0)
438 .Direction(numeric::Direction::increasing)
439 .InitialValues({80.0})
440 .Updates({{0, 91.0, 300ms}})
441 .Expected({{0, 91.0, 200ms}}),
442 NumericParams()
443 .DwellTime(200ms)
444 .ThresholdValue(90.0)
445 .Direction(numeric::Direction::increasing)
446 .InitialValues({80.0})
447 .Updates({{0, 99.0}, {0, 80.0}, {0, 98.0, 300ms}})
448 .Expected({{0, 98.0, 200ms}}),
449 NumericParams()
450 .DwellTime(200ms)
451 .ThresholdValue(90.0)
452 .Direction(numeric::Direction::increasing)
453 .InitialValues({80.0, 99.0})
454 .Updates({{0, 100.0}, {1, 98.0, 300ms}})
455 .Expected({{0, 100.0, 200ms}}),
456 NumericParams()
457 .DwellTime(200ms)
458 .ThresholdValue(90.0)
459 .Direction(numeric::Direction::decreasing)
460 .InitialValues({100.0})
461 .Updates({{0, 91.0, 300ms}})
462 .Expected({}),
463 NumericParams()
464 .DwellTime(200ms)
465 .ThresholdValue(90.0)
466 .Direction(numeric::Direction::decreasing)
467 .InitialValues({100.0})
468 .Updates({{0, 80.0, 300ms}})
469 .Expected({{0, 80.0, 200ms}}),
470 NumericParams()
471 .DwellTime(200ms)
472 .ThresholdValue(90.0)
473 .Direction(numeric::Direction::decreasing)
474 .InitialValues({100.0})
475 .Updates({{0, 80.0}, {0, 99.0}, {0, 85.0, 300ms}})
476 .Expected({{0, 85.0, 200ms}}),
477 NumericParams()
478 .DwellTime(200ms)
479 .ThresholdValue(90.0)
480 .Direction(numeric::Direction::decreasing)
481 .InitialValues({100.0, 99.0})
482 .Updates({{0, 80.0}, {1, 88.0, 300ms}})
483 .Expected({{0, 80.0, 200ms}, {1, 88.0, 200ms}}),
484 NumericParams()
485 .DwellTime(200ms)
486 .ThresholdValue(90.0)
487 .Direction(numeric::Direction::either)
488 .InitialValues({98.0})
489 .Updates({{0, 91.0, 300ms}})
490 .Expected({}),
491 NumericParams()
492 .DwellTime(200ms)
493 .ThresholdValue(90.0)
494 .Direction(numeric::Direction::either)
495 .InitialValues({100.0})
496 .Updates({{0, 80.0}, {0, 85.0}, {0, 91.0, 300ms}})
497 .Expected({{0, 91.0, 200ms}}),
498 NumericParams()
499 .DwellTime(200ms)
500 .ThresholdValue(90.0)
501 .Direction(numeric::Direction::either)
502 .InitialValues({100.0, 80.0})
503 .Updates({{0, 85.0}, {1, 91.0, 300ms}})
504 .Expected({{0, 85.0, 200ms}, {1, 91.0, 200ms}})));
505
506TEST_P(TestNumericThresholdWithDwellTime, senorsIsUpdatedMultipleTimes)
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100507{
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200508 testBodySensorIsUpdatedMultipleTimes();
Wludzik, Jozef1477fe62021-01-02 11:56:10 +0100509}