2020-07-28 12:11:56 -07:00
|
|
|
#pragma once
|
|
|
|
|
2020-04-20 13:26:35 -07:00
|
|
|
#include "electronic_throttle.h"
|
|
|
|
#include "dc_motor.h"
|
|
|
|
#include "table_helper.h"
|
2020-04-26 11:06:28 -07:00
|
|
|
#include "pwm_generator_logic.h"
|
2020-07-28 12:11:56 -07:00
|
|
|
#include "airmass.h"
|
2021-03-03 04:30:56 -08:00
|
|
|
#include "injector_model.h"
|
2021-08-02 04:03:57 -07:00
|
|
|
#include "stepper.h"
|
2021-11-10 04:29:40 -08:00
|
|
|
#include "tunerstudio_io.h"
|
2022-01-20 11:08:54 -08:00
|
|
|
#include "idle_thread.h"
|
2024-04-30 13:05:13 -07:00
|
|
|
#include "test_executor.h"
|
2020-04-20 13:26:35 -07:00
|
|
|
|
|
|
|
#include "gmock/gmock.h"
|
|
|
|
|
|
|
|
class MockEtb : public IEtbController {
|
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockEtb();
|
|
|
|
virtual ~MockEtb();
|
|
|
|
|
2020-04-20 13:26:35 -07:00
|
|
|
// IEtbController mocks
|
2020-12-11 07:33:00 -08:00
|
|
|
MOCK_METHOD(void, reset, (), (override));
|
2024-05-04 09:08:16 -07:00
|
|
|
MOCK_METHOD(bool, isEtbMode, (), (const, override));
|
2020-09-18 10:47:49 -07:00
|
|
|
MOCK_METHOD(void, update, (), (override));
|
2024-11-11 17:44:11 -08:00
|
|
|
MOCK_METHOD(bool, init, (dc_function_e function, DcMotor* motor, pid_s* pidParameters, const ValueProvider3D* pedalMap), (override));
|
2020-04-20 13:26:35 -07:00
|
|
|
MOCK_METHOD(void, setIdlePosition, (percent_t pos), (override));
|
2020-10-18 18:57:04 -07:00
|
|
|
MOCK_METHOD(void, setWastegatePosition, (percent_t pos), (override));
|
2020-04-28 16:31:41 -07:00
|
|
|
MOCK_METHOD(void, autoCalibrateTps, (), (override));
|
2023-01-10 12:31:04 -08:00
|
|
|
MOCK_METHOD(const pid_state_s&, getPidState, (), (const, override));
|
2024-06-17 18:46:56 -07:00
|
|
|
MOCK_METHOD(float, getCurrentTarget, (), (const, override));
|
2022-07-09 19:46:28 -07:00
|
|
|
MOCK_METHOD(void, setLuaAdjustment, (percent_t adjustment), (override));
|
|
|
|
|
2020-04-20 13:26:35 -07:00
|
|
|
|
|
|
|
// ClosedLoopController mocks
|
2021-11-23 12:52:43 -08:00
|
|
|
MOCK_METHOD(expected<percent_t>, getSetpoint, (), (override));
|
2023-10-19 18:06:09 -07:00
|
|
|
MOCK_METHOD(expected<percent_t>, observePlant, (), (override));
|
2021-11-23 12:52:43 -08:00
|
|
|
MOCK_METHOD(expected<percent_t>, getOpenLoop, (percent_t setpoint), (override));
|
2020-04-20 13:26:35 -07:00
|
|
|
MOCK_METHOD(expected<percent_t>, getClosedLoop, (percent_t setpoint, percent_t observation), (override));
|
|
|
|
MOCK_METHOD(void, setOutput, (expected<percent_t> outputValue), (override));
|
|
|
|
};
|
|
|
|
|
|
|
|
class MockMotor : public DcMotor {
|
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockMotor();
|
|
|
|
virtual ~MockMotor();
|
|
|
|
|
2020-04-20 13:26:35 -07:00
|
|
|
MOCK_METHOD(bool, set, (float duty), (override));
|
|
|
|
MOCK_METHOD(float, get, (), (const, override));
|
|
|
|
MOCK_METHOD(void, enable, (), (override));
|
2023-01-17 23:12:34 -08:00
|
|
|
MOCK_METHOD(void, disable, (const char *msg), (override));
|
2020-04-20 13:26:35 -07:00
|
|
|
MOCK_METHOD(bool, isOpenDirection, (), (const, override));
|
|
|
|
};
|
|
|
|
|
|
|
|
class MockVp3d : public ValueProvider3D {
|
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockVp3d();
|
|
|
|
virtual ~MockVp3d();
|
|
|
|
|
2021-05-20 12:31:16 -07:00
|
|
|
MOCK_METHOD(float, getValue, (float xColumn, float yRow), (const, override));
|
2020-04-20 13:26:35 -07:00
|
|
|
};
|
2020-04-26 11:06:28 -07:00
|
|
|
|
2021-07-01 06:21:18 -07:00
|
|
|
class MockPwm : public IPwm {
|
2020-04-26 11:06:28 -07:00
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockPwm();
|
|
|
|
virtual ~MockPwm();
|
|
|
|
|
2020-04-26 11:06:28 -07:00
|
|
|
MOCK_METHOD(void, setSimplePwmDutyCycle, (float dutyCycle), (override));
|
|
|
|
};
|
2020-05-14 04:44:32 -07:00
|
|
|
|
2020-06-11 17:43:26 -07:00
|
|
|
class MockOutputPin : public OutputPin {
|
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockOutputPin();
|
|
|
|
virtual ~MockOutputPin();
|
|
|
|
|
2023-08-28 21:24:46 -07:00
|
|
|
MOCK_METHOD(void, setValue, (int value, bool isForce), (override));
|
2020-06-11 17:43:26 -07:00
|
|
|
};
|
|
|
|
|
2020-05-14 04:44:32 -07:00
|
|
|
class MockExecutor : public TestExecutor {
|
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockExecutor();
|
|
|
|
virtual ~MockExecutor();
|
|
|
|
|
2024-07-11 17:03:13 -07:00
|
|
|
MOCK_METHOD(void, schedule, (const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action), (override));
|
2021-08-27 01:30:06 -07:00
|
|
|
MOCK_METHOD(void, cancel, (scheduling_s*), (override));
|
2020-05-14 04:44:32 -07:00
|
|
|
};
|
2020-07-26 20:35:36 -07:00
|
|
|
|
2021-05-14 04:17:22 -07:00
|
|
|
class MockAirmass : public AirmassVeModelBase {
|
2020-07-26 20:35:36 -07:00
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockAirmass();
|
|
|
|
virtual ~MockAirmass();
|
2020-07-28 12:11:56 -07:00
|
|
|
|
|
|
|
MockVp3d veTable;
|
|
|
|
|
2024-09-24 23:21:39 -07:00
|
|
|
MOCK_METHOD(AirmassResult, getAirmass, (float rpm, bool postState), (override));
|
2020-07-26 20:35:36 -07:00
|
|
|
};
|
2021-03-03 04:30:56 -08:00
|
|
|
|
|
|
|
class MockInjectorModel2 : public IInjectorModel {
|
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockInjectorModel2();
|
|
|
|
virtual ~MockInjectorModel2();
|
|
|
|
|
2021-03-03 04:30:56 -08:00
|
|
|
MOCK_METHOD(void, prepare, (), (override));
|
|
|
|
MOCK_METHOD(floatms_t, getInjectionDuration, (float fuelMassGram), (const, override));
|
|
|
|
MOCK_METHOD(float, getFuelMassForDuration, (floatms_t duration), (const, override));
|
2022-09-01 07:58:16 -07:00
|
|
|
MOCK_METHOD(floatms_t, getDeadtime, (), (const, override));
|
2021-03-03 04:30:56 -08:00
|
|
|
};
|
2021-08-02 04:03:57 -07:00
|
|
|
|
|
|
|
class MockStepperHardware : public StepperHw {
|
|
|
|
public:
|
2021-10-30 17:31:09 -07:00
|
|
|
MockStepperHardware();
|
|
|
|
virtual ~MockStepperHardware();
|
|
|
|
|
2021-08-02 04:03:57 -07:00
|
|
|
MOCK_METHOD(bool, step, (bool positive), (override));
|
|
|
|
};
|
2021-11-10 04:29:40 -08:00
|
|
|
|
|
|
|
class MockTsChannel : public TsChannelBase {
|
|
|
|
public:
|
|
|
|
MockTsChannel();
|
|
|
|
virtual ~MockTsChannel();
|
|
|
|
|
|
|
|
MOCK_METHOD(void, write, (const uint8_t* buffer, size_t size, bool isEndOfPacket), (override));
|
|
|
|
MOCK_METHOD(size_t, readTimeout, (uint8_t* buffer, size_t size, int timeout), (override));
|
|
|
|
};
|
2022-01-20 11:08:54 -08:00
|
|
|
|
|
|
|
class MockIdleController : public IIdleController {
|
2024-09-17 21:26:58 -07:00
|
|
|
public:
|
|
|
|
MockIdleController();
|
|
|
|
virtual ~MockIdleController();
|
|
|
|
|
2024-09-24 23:40:49 -07:00
|
|
|
MOCK_METHOD(IIdleController::Phase, determinePhase, (float rpm, float targetRpm, SensorResult tps, float vss, float crankingTaperFraction), (override));
|
2022-01-20 11:08:54 -08:00
|
|
|
MOCK_METHOD(int, getTargetRpm, (float clt), (override));
|
|
|
|
MOCK_METHOD(float, getCrankingOpenLoop, (float clt), (const, override));
|
2023-06-11 15:09:36 -07:00
|
|
|
MOCK_METHOD(float, getRunningOpenLoop, (IIdleController::Phase phase, float rpm, float clt, SensorResult tps), (override));
|
2022-08-25 18:23:23 -07:00
|
|
|
MOCK_METHOD(float, getOpenLoop, (IIdleController::Phase phase, float rpm, float clt, SensorResult tps, float crankingTaperFraction), (override));
|
2024-09-24 23:40:49 -07:00
|
|
|
MOCK_METHOD(float, getClosedLoop, (IIdleController::Phase phase, float tps, float rpm, float target), (override));
|
2022-01-20 11:08:54 -08:00
|
|
|
MOCK_METHOD(float, getCrankingTaperFraction, (), (const, override));
|
|
|
|
MOCK_METHOD(bool, isIdlingOrTaper, (), (const, override));
|
2024-09-24 23:40:49 -07:00
|
|
|
MOCK_METHOD(float, getIdleTimingAdjustment, (float rpm), (override));
|
2022-01-20 11:08:54 -08:00
|
|
|
};
|
2024-09-17 21:26:58 -07:00
|
|
|
|
|
|
|
class MockIgnitionController : public IgnitionController {
|
|
|
|
public:
|
|
|
|
MockIgnitionController();
|
|
|
|
virtual ~MockIgnitionController();
|
|
|
|
|
|
|
|
MOCK_METHOD(bool, getIgnState, (), (const, override));
|
|
|
|
};
|