extract test preparation into prepareToScheduleOverdwellSparkDown function #6373

This commit is contained in:
kifir 2024-05-05 18:22:55 +03:00
parent 666507f804
commit 3ce993f324
1 changed files with 19 additions and 9 deletions

View File

@ -8,19 +8,19 @@ using ::testing::_;
extern WarningCodeState unitTestWarningCodeState;
TEST(coil, testOverdwellProtection) {
printf("*************************************************** testOverdwellProtection\r\n");
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
// Magic below is the simpliest way to schedule overdwell sparkDown that I found in
// testAssertWeAreNotMissingASpark299.
//
// eth.smartFireFall(20);
//
// after this method will schedule over fire spark.
// P.S. May be later we will be able to simplify this spell.
static void prepareToScheduleOverdwellSparkDown(EngineTestHelper& eth) {
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
setupSimpleTestEngineWithMafAndTT_ONE_trigger(&eth);
engineConfiguration->isIgnitionEnabled = true;
engineConfiguration->isInjectionEnabled = false;
engine->onScheduleOverFireSparkAndPrepareNextSchedule = [&](const IgnitionEvent&, efitick_t) -> void {
FAIL() << "Unexpected scheduling of overFireSparkAndPrepareNextSchedule";
};
ASSERT_EQ( 0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#0";
eth.smartFireRise(20);
@ -47,6 +47,17 @@ TEST(coil, testOverdwellProtection) {
eth.engine.periodicFastCallback();
eth.smartFireRise(20);
}
TEST(coil, testOverdwellProtection) {
printf("*************************************************** testOverdwellProtection\r\n");
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
engine->onScheduleOverFireSparkAndPrepareNextSchedule = [&](const IgnitionEvent&, efitick_t) -> void {
FAIL() << "Unexpected scheduling of overFireSparkAndPrepareNextSchedule";
};
prepareToScheduleOverdwellSparkDown(eth);
printf("*************************************************** testOverdwellProtection start\r\n");
@ -135,4 +146,3 @@ TEST(coil, testOverdwellProtection) {
ASSERT_TRUE(testIgnitionEventState.has_value()) << "Missed ignition event";
EXPECT_FALSE(testIgnitionEventState.value()) << "Unexpected state in ignition event";
}