2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2020-05-14 04:44:32 -07:00
|
|
|
#include "main_trigger_callback.h"
|
2021-03-03 04:30:56 -08:00
|
|
|
#include "injector_model.h"
|
2020-05-14 04:44:32 -07:00
|
|
|
|
|
|
|
using ::testing::_;
|
|
|
|
using ::testing::StrictMock;
|
|
|
|
using ::testing::InSequence;
|
|
|
|
|
|
|
|
TEST(injectionScheduling, NormalDutyCycle) {
|
|
|
|
StrictMock<MockExecutor> mockExec;
|
|
|
|
|
2021-11-16 13:52:11 -08:00
|
|
|
EngineTestHelper eth(TEST_ENGINE);
|
2020-05-14 04:44:32 -07:00
|
|
|
engine->executor.setMockExecutor(&mockExec);
|
|
|
|
|
|
|
|
efitick_t nowNt = 1000000;
|
|
|
|
|
|
|
|
InjectionEvent event;
|
|
|
|
InjectorOutputPin pin;
|
|
|
|
pin.injectorIndex = 0;
|
|
|
|
event.outputs[0] = &pin;
|
|
|
|
|
|
|
|
// Injection duration of 20ms
|
2021-03-03 04:30:56 -08:00
|
|
|
MockInjectorModel2 im;
|
|
|
|
EXPECT_CALL(im, getInjectionDuration(_)).WillOnce(Return(20.0f));
|
2021-11-17 18:50:00 -08:00
|
|
|
engine->module<InjectorModel>().set(&im);
|
2020-05-14 04:44:32 -07:00
|
|
|
|
|
|
|
{
|
|
|
|
InSequence is;
|
|
|
|
|
|
|
|
// Should schedule one normal injection:
|
|
|
|
// rising edge now
|
2021-07-14 13:47:55 -07:00
|
|
|
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.signalTimerUp, nowNt + 0, _));
|
2020-05-14 04:44:32 -07:00
|
|
|
// falling edge 10ms later
|
2021-07-14 13:47:55 -07:00
|
|
|
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.endOfInjectionEvent, nowNt + MS2NT(20), _));
|
2020-05-14 04:44:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
engine->rpmCalculator.oneDegreeUs = 100;
|
|
|
|
|
2020-07-24 18:26:24 -07:00
|
|
|
event.onTriggerTooth(0, 1000, nowNt);
|
2020-05-14 04:44:32 -07:00
|
|
|
}
|