2020-11-18 16:34:09 -08:00
|
|
|
/*
|
|
|
|
* @file test_start_stop.cpp
|
|
|
|
*
|
|
|
|
* @date Nov 18, 2020
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2020-11-18 16:34:09 -08:00
|
|
|
|
2020-11-18 17:12:58 -08:00
|
|
|
TEST(start, startStop) {
|
2020-11-26 16:21:42 -08:00
|
|
|
std::unordered_map<SensorType, float> sensorVals = {{ SensorType::AcceleratorPedal, 0 }};
|
2021-11-16 13:52:11 -08:00
|
|
|
EngineTestHelper eth(PROTEUS_BMW_M73, sensorVals);
|
2021-03-11 21:43:48 -08:00
|
|
|
eth.moveTimeForwardAndInvokeEventsSec(1); // '0' time has special meaning for implementation so let's move forward
|
2020-11-18 20:54:30 -08:00
|
|
|
|
2020-11-18 17:12:58 -08:00
|
|
|
// this is a pull-up, so 'true' on start-up
|
2020-11-18 19:47:40 -08:00
|
|
|
setMockState(engineConfiguration->startStopButtonPin, true);
|
2020-11-18 17:53:03 -08:00
|
|
|
|
2020-11-18 20:06:44 -08:00
|
|
|
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
|
2020-11-18 17:53:03 -08:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
slowStartStopButtonCallback();
|
2020-11-18 20:06:44 -08:00
|
|
|
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
|
2020-11-18 19:47:40 -08:00
|
|
|
|
2020-11-19 14:15:28 -08:00
|
|
|
// startup 'timeout' duration of time is a special case so let's sleep a bit
|
2021-03-11 21:43:48 -08:00
|
|
|
eth.moveTimeForwardAndInvokeEventsSec(10);
|
2021-11-16 01:15:29 -08:00
|
|
|
slowStartStopButtonCallback();
|
2020-11-19 14:15:28 -08:00
|
|
|
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
|
|
|
|
|
|
|
|
|
2020-11-18 19:47:40 -08:00
|
|
|
|
2021-03-11 21:43:48 -08:00
|
|
|
eth.moveTimeForwardAndInvokeEventsSec(10);
|
2020-11-18 20:06:44 -08:00
|
|
|
// hit 'start' button! inverted since pull-up
|
2020-11-18 19:47:40 -08:00
|
|
|
setMockState(engineConfiguration->startStopButtonPin, false);
|
2021-11-16 01:15:29 -08:00
|
|
|
slowStartStopButtonCallback();
|
2020-11-18 20:06:44 -08:00
|
|
|
ASSERT_TRUE(efiReadPin(engineConfiguration->starterControlPin));
|
2020-11-18 19:47:40 -08:00
|
|
|
|
2021-03-11 21:43:48 -08:00
|
|
|
eth.moveTimeForwardAndInvokeEventsSec(5);
|
2021-11-16 01:15:29 -08:00
|
|
|
slowStartStopButtonCallback();
|
2020-11-18 19:56:05 -08:00
|
|
|
|
2021-03-11 21:43:48 -08:00
|
|
|
eth.moveTimeForwardAndInvokeEventsSec(5);
|
2021-11-16 01:15:29 -08:00
|
|
|
slowStartStopButtonCallback();
|
2020-11-18 19:56:05 -08:00
|
|
|
|
2021-03-11 21:43:48 -08:00
|
|
|
eth.moveTimeForwardAndInvokeEventsSec(5);
|
2021-11-16 01:15:29 -08:00
|
|
|
slowStartStopButtonCallback();
|
2020-11-18 20:54:30 -08:00
|
|
|
// starter is now OFF due to timeout
|
|
|
|
ASSERT_FALSE(efiReadPin(engineConfiguration->starterControlPin));
|
2020-11-18 17:12:58 -08:00
|
|
|
}
|