diff --git a/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.cpp b/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.cpp index 8de21c3471..a1dc495744 100644 --- a/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.cpp +++ b/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.cpp @@ -14,9 +14,9 @@ FlatShiftConditionTestBase::FlatShiftConditionTestBase( } void FlatShiftConditionTestBase::SetUp() { - ShiftTorqueReductionTestBase::SetUp(); + TestBase::SetUp(); - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) diff --git a/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.h b/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.h index 58bd5c61e2..eae72b01a5 100644 --- a/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.h +++ b/unit_tests/tests/shift_torque_reduction/flat_shift_condition_test_base.h @@ -4,9 +4,9 @@ #pragma once -#include "shift_torque_reduction_test_base.h" +#include "util/test_base.h" -class FlatShiftConditionTestBase : public ShiftTorqueReductionTestBase { +class FlatShiftConditionTestBase : public TestBase { protected: static constexpr switch_input_pin_e TEST_TORQUE_REDUCTION_BUTTON_PIN = Gpio::G10; static constexpr float TEST_TORQUE_REDUCTION_ARMING_APP = 7.89; diff --git a/unit_tests/tests/shift_torque_reduction/shift_torque_reduction_test_base.cpp b/unit_tests/tests/shift_torque_reduction/shift_torque_reduction_test_base.cpp deleted file mode 100644 index b3aca40be4..0000000000 --- a/unit_tests/tests/shift_torque_reduction/shift_torque_reduction_test_base.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -// Created by kifir on 9/30/24. -// - -#include "pch.h" - -#include "shift_torque_reduction_test_base.h" - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setLaunchActivatePin( - const std::optional value -) { - m_launchActivatePin = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setLaunchActivateInverted( - const std::optional value -) { - m_launchActivateInverted = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionEnabled( - const std::optional value -) { - m_isTorqueReductionEnabled = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionActivationMode( - const std::optional value -) { - m_torqueReductionActivationMode = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionTriggerPin( - const std::optional value -) { - m_torqueReductionTriggerPin = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionTriggerPinInverted( - const std::optional value -) { - m_torqueReductionTriggerPinInverted = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setLimitTorqueReductionTime(std::optional value) { - m_limitTorqueReductionTime = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionTime( - const std::optional value -) { - m_torqueReductionTime = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionArmingRpm(std::optional value) { - m_torqueReductionArmingRpm = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionArmingApp(std::optional value) { - m_torqueReductionArmingApp = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionIgnitionCut( - const std::optional value -) { - m_torqueReductionIgnitionCut = value; - return *this; -} - -ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionIgnitionRetard( - const std::optional value -) { - m_torqueReductionIgnitionRetard = value; - return *this; -} - -void ShiftTorqueReductionTestBase::setUpTestConfig(const ShiftTorqueReductionTestConfig& config) { - // Launch Control - getTestEngineConfiguration().configureLaunchActivatePin(config.getLaunchActivatePin()); - getTestEngineConfiguration().configureLaunchActivateInverted(config.getLaunchActivateInverted()); - - // Shift Torque Reduction (Flat Shift) - getTestEngineConfiguration().configureTorqueReductionEnabled(config.getTorqueReductionEnabled()); - getTestEngineConfiguration().configureTorqueReductionActivationMode(config.getTorqueReductionActivationMode()); - getTestEngineConfiguration().configureTorqueReductionTriggerPin(config.getTorqueReductionTriggerPin()); - getTestEngineConfiguration().configureTorqueReductionButtonInverted(config.getTorqueReductionTriggerPinInverted()); - getTestEngineConfiguration().configureLimitTorqueReductionTime(config.getLimitTorqueReductionTime()); - getTestEngineConfiguration().configureTorqueReductionTime(config.getTorqueReductionTime()); - getTestEngineConfiguration().configureTorqueReductionArmingRpm(config.getTorqueReductionArmingRpm()); - getTestEngineConfiguration().configureTorqueReductionArmingApp(config.getTorqueReductionArmingApp()); - getTestEngineConfiguration().configureTorqueReductionIgnitionCut(config.getTorqueReductionIgnitionCut()); - getTestEngineConfiguration().configureTorqueReductionIgnitionRetard(config.getTorqueReductionIgnitionRetard()); -} diff --git a/unit_tests/tests/shift_torque_reduction/shift_torque_reduction_test_base.h b/unit_tests/tests/shift_torque_reduction/shift_torque_reduction_test_base.h deleted file mode 100644 index 75731e4810..0000000000 --- a/unit_tests/tests/shift_torque_reduction/shift_torque_reduction_test_base.h +++ /dev/null @@ -1,70 +0,0 @@ -// -// Created by kifir on 9/30/24. -// - -#pragma once - -#include "util/test_base.h" - -class ShiftTorqueReductionTestConfig { -public: - // Launch Control - std::optional getLaunchActivatePin() const { return m_launchActivatePin; } - std::optional getLaunchActivateInverted() const { return m_launchActivateInverted; } - - // Shift Torque Reduction (Flat Shift) - std::optional getTorqueReductionEnabled() const { return m_isTorqueReductionEnabled; } - std::optional getTorqueReductionActivationMode() const { - return m_torqueReductionActivationMode; - } - std::optional getTorqueReductionTriggerPin() const { return m_torqueReductionTriggerPin; } - std::optional getTorqueReductionTriggerPinInverted() const { return m_torqueReductionTriggerPinInverted; } - std::optional getLimitTorqueReductionTime() const { return m_limitTorqueReductionTime; } - std::optional getTorqueReductionTime() const { return m_torqueReductionTime; } - std::optional getTorqueReductionArmingRpm() const { return m_torqueReductionArmingRpm; } - std::optional getTorqueReductionArmingApp() const { return m_torqueReductionArmingApp; } - std::optional getTorqueReductionIgnitionCut() const { return m_torqueReductionIgnitionCut; } - std::optional getTorqueReductionIgnitionRetard() const { return m_torqueReductionIgnitionRetard; } - - // We do not core about performance in tests, but we want to use builder-like style, so setters return new instance - // of configuration: - - // Launch Control - ShiftTorqueReductionTestConfig setLaunchActivatePin(std::optional value); - ShiftTorqueReductionTestConfig setLaunchActivateInverted(std::optional value); - - // Shift Torque Reduction (Flat Shift) - ShiftTorqueReductionTestConfig setTorqueReductionEnabled(std::optional value); - ShiftTorqueReductionTestConfig setTorqueReductionActivationMode( - std::optional value - ); - ShiftTorqueReductionTestConfig setTorqueReductionTriggerPin(std::optional value); - ShiftTorqueReductionTestConfig setTorqueReductionTriggerPinInverted(std::optional value); - ShiftTorqueReductionTestConfig setLimitTorqueReductionTime(std::optional value); - ShiftTorqueReductionTestConfig setTorqueReductionTime(std::optional value); - ShiftTorqueReductionTestConfig setTorqueReductionArmingRpm(std::optional value); - ShiftTorqueReductionTestConfig setTorqueReductionArmingApp(std::optional value); - ShiftTorqueReductionTestConfig setTorqueReductionIgnitionCut(std::optional value); - ShiftTorqueReductionTestConfig setTorqueReductionIgnitionRetard(std::optional value); -private: - // Launch Control - std::optional m_launchActivatePin; - std::optional m_launchActivateInverted; - - // Shift Torque Reduction (Flat Shift) - std::optional m_isTorqueReductionEnabled; - std::optional m_torqueReductionActivationMode; - std::optional m_torqueReductionTriggerPin; - std::optional m_torqueReductionTriggerPinInverted; - std::optional m_limitTorqueReductionTime; - std::optional m_torqueReductionTime; - std::optional m_torqueReductionArmingRpm; - std::optional m_torqueReductionArmingApp; - std::optional m_torqueReductionIgnitionCut; - std::optional m_torqueReductionIgnitionRetard; -}; - -class ShiftTorqueReductionTestBase : public TestBase { -protected: - void setUpTestConfig(const ShiftTorqueReductionTestConfig& config); -}; diff --git a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_app_condition.cpp b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_app_condition.cpp index 7f59c76e4f..1c8d2aff4c 100644 --- a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_app_condition.cpp +++ b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_app_condition.cpp @@ -4,12 +4,12 @@ #include "pch.h" -#include "shift_torque_reduction_test_base.h" +#include "util/test_base.h" namespace { constexpr float TEST_TORQUE_REDUCTION_ARMING_APP = 17.0f; - class ShiftTorqueReductionAppConditionTest : public ShiftTorqueReductionTestBase { + class ShiftTorqueReductionAppConditionTest : public TestBase { protected: void checkAppCondition(std::optional rpm, bool expectedAppCondition, const char* context); }; @@ -24,7 +24,7 @@ namespace { } TEST_F(ShiftTorqueReductionAppConditionTest, checkZeroArmingApp) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionArmingApp(0.0f) ); @@ -34,7 +34,7 @@ namespace { } TEST_F(ShiftTorqueReductionAppConditionTest, checkArmingApp) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionArmingApp(TEST_TORQUE_REDUCTION_ARMING_APP) ); diff --git a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_flat_shift_condition.cpp b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_flat_shift_condition.cpp index 1c64549f0c..4fa9440cc9 100644 --- a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_flat_shift_condition.cpp +++ b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_flat_shift_condition.cpp @@ -4,10 +4,10 @@ #include "pch.h" -#include "shift_torque_reduction_test_base.h" +#include "util/test_base.h" namespace { - class ShiftTorqueReductionFlatShiftConditionTest : public ShiftTorqueReductionTestBase { + class ShiftTorqueReductionFlatShiftConditionTest : public TestBase { protected: static constexpr switch_input_pin_e TEST_TORQUE_REDUCTION_BUTTON_PIN = Gpio::E13; static constexpr float TEST_TORQUE_REDUCTION_TIME = 123.45f; @@ -26,7 +26,7 @@ namespace { void ShiftTorqueReductionFlatShiftConditionTest::SetUp() { TestBase::SetUp(); - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) diff --git a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_rpm_condition.cpp b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_rpm_condition.cpp index 16a1a07e48..434701b573 100644 --- a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_rpm_condition.cpp +++ b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_rpm_condition.cpp @@ -4,12 +4,12 @@ #include "pch.h" -#include "shift_torque_reduction_test_base.h" +#include "util/test_base.h" namespace { constexpr float TEST_TORQUE_REDUCTION_ARMING_RPM = 239.0f; - class ShiftTorqueReductionRpmConditionTest : public ShiftTorqueReductionTestBase { + class ShiftTorqueReductionRpmConditionTest : public TestBase { protected: void checkRpmCondition(float rpm, bool expectedRpmCondition, const char* context); }; @@ -24,7 +24,7 @@ namespace { } TEST_F(ShiftTorqueReductionRpmConditionTest, checkZeroArmingRpm) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionArmingRpm(0.0f) ); @@ -33,7 +33,7 @@ namespace { } TEST_F(ShiftTorqueReductionRpmConditionTest, checkArmingRpm) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionArmingRpm(TEST_TORQUE_REDUCTION_ARMING_RPM) ); diff --git a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_time_condition.cpp b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_time_condition.cpp index fdd4f8db44..ee2e5f22b8 100644 --- a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_time_condition.cpp +++ b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_time_condition.cpp @@ -4,14 +4,14 @@ #include "pch.h" -#include "shift_torque_reduction_test_base.h" +#include "util/test_base.h" namespace { constexpr switch_input_pin_e TEST_TORQUE_REDUCTION_BUTTON_PIN = Gpio::F13; constexpr float TEST_TORQUE_REDUCTION_TIME = 239.17; constexpr float IMMEDIATELY = 0.0f; - class ShiftTorqueReductionTimeConditionTest : public ShiftTorqueReductionTestBase { + class ShiftTorqueReductionTimeConditionTest : public TestBase { protected: void waitAndCheckTimeCondition( float timeoutInMs, @@ -42,7 +42,7 @@ namespace { } TEST_F(ShiftTorqueReductionTimeConditionTest, checkExpiration) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) @@ -61,7 +61,7 @@ namespace { } TEST_F(ShiftTorqueReductionTimeConditionTest, checkDeactivation) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) @@ -79,7 +79,7 @@ namespace { } TEST_F(ShiftTorqueReductionTimeConditionTest, checkReactivation) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) @@ -104,7 +104,7 @@ namespace { } TEST_F(ShiftTorqueReductionTimeConditionTest, checkTimeConditionIsNeverSatisfiedWithZeroTorqueReductionTime) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) @@ -129,7 +129,7 @@ namespace { } TEST_F(ShiftTorqueReductionTimeConditionTest, checkDeactivationWithoutLimitedTorqueReductionTime) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) diff --git a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_trigger_pin_state.cpp b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_trigger_pin_state.cpp index d6297184c6..14105ab2ca 100644 --- a/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_trigger_pin_state.cpp +++ b/unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_trigger_pin_state.cpp @@ -4,7 +4,7 @@ #include "pch.h" -#include "shift_torque_reduction_test_base.h" +#include "util/test_base.h" namespace { constexpr switch_input_pin_e TEST_TORQUE_REDUCTION_BUTTON_PIN = Gpio::F15; @@ -16,7 +16,7 @@ namespace { const bool torqueReductionTriggerPinState; }; - class ShiftTorqueReductionTriggerPinTest : public ShiftTorqueReductionTestBase { + class ShiftTorqueReductionTriggerPinTest : public TestBase { protected: void checkShiftTorqueReductionState(const ShiftTorqueReductionTriggerPinTestData& expected); void checkShiftTorqueReductionStateAfterPeriodicFastCallback( @@ -60,13 +60,13 @@ namespace { } TEST_F(ShiftTorqueReductionTriggerPinTest, checkDefaultConfiguration) { - setUpTestConfig(ShiftTorqueReductionTestConfig()); + setUpEngineConfiguration(EngineConfig()); checkShiftTorqueReductionStateAfterPeriodicFastCallback({ "Default trigger pin state", false, false }); } TEST_F(ShiftTorqueReductionTriggerPinTest, checkTorqueReductionTriggerPinSwitch) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) @@ -99,7 +99,7 @@ namespace { } TEST_F(ShiftTorqueReductionTriggerPinTest, checkTorqueReductionTriggerInvertedPinSwitch) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) @@ -120,7 +120,7 @@ namespace { } TEST_F(ShiftTorqueReductionTriggerPinTest, checkLaunchActivatePinSwitch) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(true) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::LAUNCH_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) @@ -153,7 +153,7 @@ namespace { } TEST_F(ShiftTorqueReductionTriggerPinTest, checkTorqueReductionTriggerPinSwitchWithDisabledTorqueReduction) { - setUpTestConfig(ShiftTorqueReductionTestConfig() + setUpEngineConfiguration(EngineConfig() .setTorqueReductionEnabled(false) .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index 80f7b17f71..046883d48b 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -62,7 +62,6 @@ TESTS_SRC_CPP = \ tests/launch/test_retard_threshold_rpm.cpp \ tests/launch/test_ignition_angle_advance.cpp \ tests/launch/test_spark_skip_ratio.cpp \ - tests/shift_torque_reduction/shift_torque_reduction_test_base.cpp \ tests/shift_torque_reduction/flat_shift_condition_test_base.cpp \ tests/shift_torque_reduction/test_shift_torque_reduction_trigger_pin_state.cpp \ tests/shift_torque_reduction/test_shift_torque_reduction_time_condition.cpp \ diff --git a/unit_tests/tests/util/engine_config.cpp b/unit_tests/tests/util/engine_config.cpp index 108454a14d..4f03cc4dbe 100644 --- a/unit_tests/tests/util/engine_config.cpp +++ b/unit_tests/tests/util/engine_config.cpp @@ -10,6 +10,68 @@ EngineConfig EngineConfig::clone() const { return *this; } +EngineConfig EngineConfig::setLaunchActivatePin(const std::optional value) { + m_launchActivatePin = value; + return *this; +} + +EngineConfig EngineConfig::setLaunchActivateInverted(const std::optional value) { + m_launchActivateInverted = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionEnabled(const std::optional value) { + m_isTorqueReductionEnabled = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionActivationMode( + const std::optional value +) { + m_torqueReductionActivationMode = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionTriggerPin(const std::optional value) { + m_torqueReductionTriggerPin = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionTriggerPinInverted(const std::optional value) { + m_torqueReductionTriggerPinInverted = value; + return *this; +} + +EngineConfig EngineConfig::setLimitTorqueReductionTime(std::optional value) { + m_limitTorqueReductionTime = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionTime(const std::optional value) { + m_torqueReductionTime = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionArmingRpm(std::optional value) { + m_torqueReductionArmingRpm = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionArmingApp(std::optional value) { + m_torqueReductionArmingApp = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionIgnitionCut(const std::optional value) { + m_torqueReductionIgnitionCut = value; + return *this; +} + +EngineConfig EngineConfig::setTorqueReductionIgnitionRetard(const std::optional value) { + m_torqueReductionIgnitionRetard = value; + return *this; +} + EngineConfig EngineConfig::setInjectorFlowAsMassFlow(const std::optional injectorFlowAsMassFlow) { m_injectorFlowAsMassFlow = injectorFlowAsMassFlow; return *this; diff --git a/unit_tests/tests/util/engine_config.h b/unit_tests/tests/util/engine_config.h index 590ae63e4d..47065f5870 100644 --- a/unit_tests/tests/util/engine_config.h +++ b/unit_tests/tests/util/engine_config.h @@ -10,6 +10,24 @@ class EngineConfig { public: EngineConfig clone() const; + // Launch Control + std::optional getLaunchActivatePin() const { return m_launchActivatePin; } + std::optional getLaunchActivateInverted() const { return m_launchActivateInverted; } + + // Shift Torque Reduction (Flat Shift) + std::optional getTorqueReductionEnabled() const { return m_isTorqueReductionEnabled; } + std::optional getTorqueReductionActivationMode() const { + return m_torqueReductionActivationMode; + } + std::optional getTorqueReductionTriggerPin() const { return m_torqueReductionTriggerPin; } + std::optional getTorqueReductionTriggerPinInverted() const { return m_torqueReductionTriggerPinInverted; } + std::optional getLimitTorqueReductionTime() const { return m_limitTorqueReductionTime; } + std::optional getTorqueReductionTime() const { return m_torqueReductionTime; } + std::optional getTorqueReductionArmingRpm() const { return m_torqueReductionArmingRpm; } + std::optional getTorqueReductionArmingApp() const { return m_torqueReductionArmingApp; } + std::optional getTorqueReductionIgnitionCut() const { return m_torqueReductionIgnitionCut; } + std::optional getTorqueReductionIgnitionRetard() const { return m_torqueReductionIgnitionRetard; } + // Injector std::optional getInjectorFlow() const { return m_injectorFlow; } std::optional getInjectorBattLagCorr() const { return m_injectorBattLagCorrCurve; } @@ -25,6 +43,22 @@ public: // We do not core about performance in tests, but we want to use builder-like style, so setters return new instance // of configuration: + // Launch Control + EngineConfig setLaunchActivatePin(std::optional value); + EngineConfig setLaunchActivateInverted(std::optional value); + + // Shift Torque Reduction (Flat Shift) + EngineConfig setTorqueReductionEnabled(std::optional value); + EngineConfig setTorqueReductionActivationMode(std::optional value); + EngineConfig setTorqueReductionTriggerPin(std::optional value); + EngineConfig setTorqueReductionTriggerPinInverted(std::optional value); + EngineConfig setLimitTorqueReductionTime(std::optional value); + EngineConfig setTorqueReductionTime(std::optional value); + EngineConfig setTorqueReductionArmingRpm(std::optional value); + EngineConfig setTorqueReductionArmingApp(std::optional value); + EngineConfig setTorqueReductionIgnitionCut(std::optional value); + EngineConfig setTorqueReductionIgnitionRetard(std::optional value); + // Injector EngineConfig setInjectorFlowAsMassFlow(std::optional injectorFlowAsMassFlow); EngineConfig setInjectorFlow(std::optional flow); @@ -37,6 +71,22 @@ public: // Staged injection EngineConfig setStagedInjectionEnabled(std::optional value); private: + // Launch Control + std::optional m_launchActivatePin; + std::optional m_launchActivateInverted; + + // Shift Torque Reduction (Flat Shift) + std::optional m_isTorqueReductionEnabled; + std::optional m_torqueReductionActivationMode; + std::optional m_torqueReductionTriggerPin; + std::optional m_torqueReductionTriggerPinInverted; + std::optional m_limitTorqueReductionTime; + std::optional m_torqueReductionTime; + std::optional m_torqueReductionArmingRpm; + std::optional m_torqueReductionArmingApp; + std::optional m_torqueReductionIgnitionCut; + std::optional m_torqueReductionIgnitionRetard; + // Injector std::optional m_injectorFlow; std::optional m_injectorBattLagCorrCurve; diff --git a/unit_tests/tests/util/test_base.cpp b/unit_tests/tests/util/test_base.cpp index c2999481d3..65d995c977 100644 --- a/unit_tests/tests/util/test_base.cpp +++ b/unit_tests/tests/util/test_base.cpp @@ -27,6 +27,22 @@ TestEngineState& TestBase::getTestEngineState() { } void TestBase::setUpEngineConfiguration(const EngineConfig& config) { + // Launch Control + getTestEngineConfiguration().configureLaunchActivatePin(config.getLaunchActivatePin()); + getTestEngineConfiguration().configureLaunchActivateInverted(config.getLaunchActivateInverted()); + + // Shift Torque Reduction (Flat Shift) + getTestEngineConfiguration().configureTorqueReductionEnabled(config.getTorqueReductionEnabled()); + getTestEngineConfiguration().configureTorqueReductionActivationMode(config.getTorqueReductionActivationMode()); + getTestEngineConfiguration().configureTorqueReductionTriggerPin(config.getTorqueReductionTriggerPin()); + getTestEngineConfiguration().configureTorqueReductionButtonInverted(config.getTorqueReductionTriggerPinInverted()); + getTestEngineConfiguration().configureLimitTorqueReductionTime(config.getLimitTorqueReductionTime()); + getTestEngineConfiguration().configureTorqueReductionTime(config.getTorqueReductionTime()); + getTestEngineConfiguration().configureTorqueReductionArmingRpm(config.getTorqueReductionArmingRpm()); + getTestEngineConfiguration().configureTorqueReductionArmingApp(config.getTorqueReductionArmingApp()); + getTestEngineConfiguration().configureTorqueReductionIgnitionCut(config.getTorqueReductionIgnitionCut()); + getTestEngineConfiguration().configureTorqueReductionIgnitionRetard(config.getTorqueReductionIgnitionRetard()); + // Injector getTestEngineConfiguration().configureInjectorFlowAsMassFlow(config.getInjectorFlowAsMassFlow()); getTestEngineConfiguration().configureInjectorFlow(config.getInjectorFlow());