forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_start_stop.cpp
46 lines (34 loc) · 1.46 KB
/
test_start_stop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* @file test_start_stop.cpp
*
* @date Nov 18, 2020
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
TEST(start, startStop) {
std::unordered_map<SensorType, float> sensorVals = {{ SensorType::AcceleratorPedal, 0 }};
EngineTestHelper eth(PROTEUS_BMW_M73, sensorVals);
eth.moveTimeForwardAndInvokeEventsSec(1); // '0' time has special meaning for implementation so let's move forward
// this is a pull-up, so 'true' on start-up
setMockState(engineConfiguration->startStopButtonPin, true);
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
slowStartStopButtonCallback();
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
// startup 'timeout' duration of time is a special case so let's sleep a bit
eth.moveTimeForwardAndInvokeEventsSec(10);
slowStartStopButtonCallback();
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
eth.moveTimeForwardAndInvokeEventsSec(10);
// hit 'start' button! inverted since pull-up
setMockState(engineConfiguration->startStopButtonPin, false);
slowStartStopButtonCallback();
ASSERT_TRUE(efiReadPin(engineConfiguration->starterControlPin));
eth.moveTimeForwardAndInvokeEventsSec(5);
slowStartStopButtonCallback();
eth.moveTimeForwardAndInvokeEventsSec(5);
slowStartStopButtonCallback();
eth.moveTimeForwardAndInvokeEventsSec(5);
slowStartStopButtonCallback();
// starter is now OFF due to timeout
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
}