| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Created by kifir on 12/17/24. | |||
| 3 | // | |||
| 4 | ||||
| 5 | #include "pch.h" | |||
| 6 | ||||
| 7 | #include "shift_torque_reduction_switch_test_base.h" | |||
| 8 | ||||
| 9 | namespace { | |||
| 10 | class ShiftTorqueReductionSwitchTest : public ShiftTorqueReductionSwitchTestBase { | |||
| 11 | protected: | |||
| 12 | void checkThatOtherPinsAreIgnored(TestSwitchPin exceptPin, const std::string& context); | |||
| 13 | }; | |||
| 14 | ||||
| 15 | 32 | void ShiftTorqueReductionSwitchTest::checkThatOtherPinsAreIgnored( | ||
| 16 | const TestSwitchPin exceptPin, | |||
| 17 | const std::string& context | |||
| 18 | ) { | |||
| 19 | static const TestSwitchPin testInputPins[] = { | |||
| 20 | TestSwitchPin::TORQUE_REDUCTION, | |||
| 21 | TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
| 22 | TestSwitchPin::LAUNCH, | |||
| 23 | TestSwitchPin::CLUTCH_DOWN, | |||
| 24 | TestSwitchPin::LUA_CLUTCH_DOWN, | |||
| 25 | TestSwitchPin::CLUTCH_UP, | |||
| 26 | TestSwitchPin::LUA_CLUTCH_UP, | |||
| 27 | }; | |||
| 28 | 32 | const bool expectedIsTorqueReductionTriggerPinValid = | ||
| 29 | 32 | engine->shiftTorqueReductionController.isTorqueReductionTriggerPinValid; | ||
| 30 | 32 | const bool expectedTorqueReductionTriggerPinState = | ||
| 31 | 32 | engine->shiftTorqueReductionController.torqueReductionTriggerPinState; | ||
| 32 |
2/2✓ Branch 0 taken 224 times.
✓ Branch 1 taken 32 times.
|
2/2✓ Decision 'true' taken 224 times.
✓ Decision 'false' taken 32 times.
|
256 | for (const TestSwitchPin& pin: testInputPins) { |
| 33 |
2/2✓ Branch 0 taken 192 times.
✓ Branch 1 taken 32 times.
|
2/2✓ Decision 'true' taken 192 times.
✓ Decision 'false' taken 32 times.
|
224 | if (pin != exceptPin) { |
| 34 | 192 | setPinState(pin, true); | ||
| 35 | 192 | checkShiftTorqueReductionState( | ||
| 36 | context.c_str(), | |||
| 37 | expectedIsTorqueReductionTriggerPinValid, | |||
| 38 | expectedTorqueReductionTriggerPinState | |||
| 39 | ); | |||
| 40 | ||||
| 41 | 192 | setPinState(pin, false); | ||
| 42 | 192 | checkShiftTorqueReductionState( | ||
| 43 | context.c_str(), | |||
| 44 | expectedIsTorqueReductionTriggerPinValid, | |||
| 45 | expectedTorqueReductionTriggerPinState | |||
| 46 | ); | |||
| 47 | } | |||
| 48 | } | |||
| 49 | 32 | } | ||
| 50 | ||||
| 51 |
6/8✓ Branch 6 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
✓ Branch 21 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 29 taken 1 time.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
|
39 | TEST_P(ShiftTorqueReductionSwitchTest, checkTorqueReductionTriggerPinSwitch) { | |
| 52 | 16 | setUpEngineConfiguration(GetParam().config); | ||
| 53 | ||||
| 54 | 16 | const bool expectedIsTorqueReductionTriggerPinValid = GetParam().expectedIsTorqueReductionTriggerPinValid; | ||
| 55 | ||||
| 56 | 16 | checkShiftTorqueReductionState("default", expectedIsTorqueReductionTriggerPinValid, false); | ||
| 57 | ||||
| 58 | 16 | const TestSwitchPin inputPin = GetParam().inputPin; | ||
| 59 | 16 | setPinState(inputPin, true); | ||
| 60 | 16 | checkShiftTorqueReductionState( | ||
| 61 | "Torque reduction trigger pin is on", | |||
| 62 | expectedIsTorqueReductionTriggerPinValid, | |||
| 63 | true | |||
| 64 | ); | |||
| 65 |
2/2✓ Branch 3 taken 16 times.
✓ Branch 6 taken 16 times.
|
48 | checkThatOtherPinsAreIgnored(inputPin, "Other pins are ignored when torque reduction trigger pin is on"); | |
| 66 | ||||
| 67 | 16 | setPinState(GetParam().inputPin, false); | ||
| 68 | 16 | checkShiftTorqueReductionState( | ||
| 69 | "Torque reduction trigger pin is off", | |||
| 70 | expectedIsTorqueReductionTriggerPinValid, | |||
| 71 | false | |||
| 72 | ); | |||
| 73 |
2/2✓ Branch 3 taken 16 times.
✓ Branch 6 taken 16 times.
|
48 | checkThatOtherPinsAreIgnored(inputPin, "Other pins are ignored when torque reduction trigger pin is off"); | |
| 74 | 16 | } | ||
| 75 | ||||
| 76 |
70/140(anonymous namespace)::gtest_ShiftTorqueReductionSwitchTestForVariousInputPinsShiftTorqueReductionSwitchTest_EvalGenerateName_(testing::TestParamInfo<ShiftTorqueReductionSwitchParams> const&):
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 11 not taken.
✗ Branch 17 not taken.
✗ Branch 23 not taken.
✗ Branch 29 not taken.
✗ Branch 33 not taken.
✗ Branch 40 not taken.
✗ Branch 46 not taken.
✗ Branch 52 not taken.
✗ Branch 58 not taken.
✗ Branch 62 not taken.
✗ Branch 68 not taken.
✗ Branch 74 not taken.
✗ Branch 80 not taken.
✗ Branch 84 not taken.
✗ Branch 90 not taken.
✗ Branch 96 not taken.
✗ Branch 102 not taken.
✗ Branch 106 not taken.
✗ Branch 113 not taken.
✗ Branch 119 not taken.
✗ Branch 125 not taken.
✗ Branch 131 not taken.
✗ Branch 135 not taken.
✗ Branch 142 not taken.
✗ Branch 148 not taken.
✗ Branch 154 not taken.
✗ Branch 160 not taken.
✗ Branch 164 not taken.
✗ Branch 170 not taken.
✗ Branch 176 not taken.
✗ Branch 182 not taken.
✗ Branch 186 not taken.
✗ Branch 192 not taken.
✗ Branch 198 not taken.
✗ Branch 204 not taken.
✗ Branch 208 not taken.
✗ Branch 213 not taken.
✗ Branch 219 not taken.
✗ Branch 223 not taken.
✗ Branch 229 not taken.
✗ Branch 235 not taken.
✗ Branch 241 not taken.
✗ Branch 245 not taken.
✗ Branch 250 not taken.
✗ Branch 256 not taken.
✗ Branch 260 not taken.
✗ Branch 267 not taken.
✗ Branch 273 not taken.
✗ Branch 279 not taken.
✗ Branch 285 not taken.
✗ Branch 289 not taken.
✗ Branch 296 not taken.
✗ Branch 302 not taken.
✗ Branch 308 not taken.
✗ Branch 314 not taken.
✗ Branch 318 not taken.
✗ Branch 324 not taken.
✗ Branch 330 not taken.
✗ Branch 336 not taken.
✗ Branch 340 not taken.
✗ Branch 346 not taken.
✗ Branch 352 not taken.
✗ Branch 358 not taken.
✗ Branch 362 not taken.
✗ Branch 367 not taken.
✗ Branch 373 not taken.
✗ Branch 377 not taken.
✗ Branch 380 not taken.
✗ Branch 383 not taken.
(anonymous namespace)::gtest_ShiftTorqueReductionSwitchTestForVariousInputPinsShiftTorqueReductionSwitchTest_EvalGenerator_():
✓ Branch 6 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 18 taken 1 time.
✓ Branch 24 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 35 taken 1 time.
✓ Branch 41 taken 1 time.
✓ Branch 47 taken 1 time.
✓ Branch 53 taken 1 time.
✓ Branch 57 taken 1 time.
✓ Branch 63 taken 1 time.
✓ Branch 69 taken 1 time.
✓ Branch 75 taken 1 time.
✓ Branch 79 taken 1 time.
✓ Branch 85 taken 1 time.
✓ Branch 91 taken 1 time.
✓ Branch 97 taken 1 time.
✓ Branch 101 taken 1 time.
✓ Branch 108 taken 1 time.
✓ Branch 114 taken 1 time.
✓ Branch 120 taken 1 time.
✓ Branch 126 taken 1 time.
✓ Branch 130 taken 1 time.
✓ Branch 137 taken 1 time.
✓ Branch 143 taken 1 time.
✓ Branch 149 taken 1 time.
✓ Branch 155 taken 1 time.
✓ Branch 159 taken 1 time.
✓ Branch 165 taken 1 time.
✓ Branch 171 taken 1 time.
✓ Branch 177 taken 1 time.
✓ Branch 181 taken 1 time.
✓ Branch 187 taken 1 time.
✓ Branch 193 taken 1 time.
✓ Branch 199 taken 1 time.
✓ Branch 203 taken 1 time.
✓ Branch 208 taken 1 time.
✓ Branch 214 taken 1 time.
✓ Branch 218 taken 1 time.
✓ Branch 224 taken 1 time.
✓ Branch 230 taken 1 time.
✓ Branch 236 taken 1 time.
✓ Branch 240 taken 1 time.
✓ Branch 245 taken 1 time.
✓ Branch 251 taken 1 time.
✓ Branch 255 taken 1 time.
✓ Branch 262 taken 1 time.
✓ Branch 268 taken 1 time.
✓ Branch 274 taken 1 time.
✓ Branch 280 taken 1 time.
✓ Branch 284 taken 1 time.
✓ Branch 291 taken 1 time.
✓ Branch 297 taken 1 time.
✓ Branch 303 taken 1 time.
✓ Branch 309 taken 1 time.
✓ Branch 313 taken 1 time.
✓ Branch 319 taken 1 time.
✓ Branch 325 taken 1 time.
✓ Branch 331 taken 1 time.
✓ Branch 335 taken 1 time.
✓ Branch 341 taken 1 time.
✓ Branch 347 taken 1 time.
✓ Branch 353 taken 1 time.
✓ Branch 357 taken 1 time.
✓ Branch 362 taken 1 time.
✓ Branch 368 taken 1 time.
✓ Branch 372 taken 1 time.
✓ Branch 375 taken 1 time.
✓ Branch 378 taken 1 time.
|
50 | INSTANTIATE_TEST_SUITE_P( | |
| 77 | ShiftTorqueReductionSwitchTestForVariousInputPins, | |||
| 78 | ShiftTorqueReductionSwitchTest, | |||
| 79 | testing::Values( | |||
| 80 | ShiftTorqueReductionSwitchParams { | |||
| 81 | /* inputPin = */ TestSwitchPin::TORQUE_REDUCTION, | |||
| 82 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 83 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON), | |||
| 84 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
| 85 | /* description = */ "TORQUE_REDUCTION" | |||
| 86 | }, | |||
| 87 | ShiftTorqueReductionSwitchParams { | |||
| 88 | /* inputPin = */ TestSwitchPin::TORQUE_REDUCTION, | |||
| 89 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 90 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
| 91 | .setTorqueReductionTriggerPinMode(PI_DEFAULT), | |||
| 92 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
| 93 | /* description = */ "TORQUE_REDUCTION (pinMode = PI_DEFAULT)" | |||
| 94 | }, | |||
| 95 | ShiftTorqueReductionSwitchParams { | |||
| 96 | /* inputPin = */ TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
| 97 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 98 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
| 99 | .setTorqueReductionTriggerPin(Gpio::Unassigned), | |||
| 100 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 101 | /* description = */ "LUA_TORQUE_REDUCTION" | |||
| 102 | }, | |||
| 103 | ShiftTorqueReductionSwitchParams { | |||
| 104 | /* inputPin = */ TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
| 105 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 106 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
| 107 | .setTorqueReductionTriggerPin(Gpio::Unassigned) | |||
| 108 | .setTorqueReductionTriggerPinMode(PI_DEFAULT), | |||
| 109 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 110 | /* description = */ "LUA_TORQUE_REDUCTION (pinMode = PI_DEFAULT)" | |||
| 111 | }, | |||
| 112 | ShiftTorqueReductionSwitchParams { | |||
| 113 | /* inputPin = */ TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
| 114 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 115 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
| 116 | .setTorqueReductionTriggerPin(Gpio::Unassigned) | |||
| 117 | .setTorqueReductionTriggerPinMode(PI_INVERTED_DEFAULT), | |||
| 118 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 119 | /* description = */ "LUA_TORQUE_REDUCTION (pinMode = PI_INVERTED_DEFAULT)" | |||
| 120 | }, | |||
| 121 | ShiftTorqueReductionSwitchParams { | |||
| 122 | /* inputPin = */ TestSwitchPin::LAUNCH, | |||
| 123 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 124 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::LAUNCH_BUTTON), | |||
| 125 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
| 126 | /* description = */ "LAUNCH" | |||
| 127 | }, | |||
| 128 | ShiftTorqueReductionSwitchParams { | |||
| 129 | /* inputPin = */ TestSwitchPin::LAUNCH, | |||
| 130 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 131 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::LAUNCH_BUTTON) | |||
| 132 | .setLaunchActivatePinMode(PI_DEFAULT), | |||
| 133 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
| 134 | /* description = */ "LAUNCH (pinMode = PI_DEFAULT)" | |||
| 135 | }, | |||
| 136 | ShiftTorqueReductionSwitchParams { | |||
| 137 | /* inputPin = */ TestSwitchPin::CLUTCH_DOWN, | |||
| 138 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 139 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH), | |||
| 140 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
| 141 | /* description = */ "CLUTCH_DOWN" | |||
| 142 | }, | |||
| 143 | ShiftTorqueReductionSwitchParams { | |||
| 144 | /* inputPin = */ TestSwitchPin::CLUTCH_DOWN, | |||
| 145 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 146 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
| 147 | .setClutchDownPinMode(PI_DEFAULT), | |||
| 148 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
| 149 | /* description = */ "CLUTCH_DOWN (pinMode = PI_DEFAULT)" | |||
| 150 | }, | |||
| 151 | ShiftTorqueReductionSwitchParams { | |||
| 152 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_DOWN, | |||
| 153 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 154 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
| 155 | .setClutchDownPin(Gpio::Unassigned), | |||
| 156 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 157 | /* description = */ "LUA_CLUTCH_DOWN" | |||
| 158 | }, | |||
| 159 | ShiftTorqueReductionSwitchParams { | |||
| 160 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_DOWN, | |||
| 161 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 162 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
| 163 | .setClutchDownPin(Gpio::Unassigned) | |||
| 164 | .setClutchDownPinMode(PI_DEFAULT), | |||
| 165 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 166 | /* description = */ "LUA_CLUTCH_DOWN (pinMode = PI_DEFAULT)" | |||
| 167 | }, | |||
| 168 | ShiftTorqueReductionSwitchParams { | |||
| 169 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_DOWN, | |||
| 170 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 171 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
| 172 | .setClutchDownPin(Gpio::Unassigned) | |||
| 173 | .setClutchDownPinMode(PI_INVERTED_DEFAULT), | |||
| 174 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 175 | /* description = */ "LUA_CLUTCH_DOWN (pinMode = PI_INVERTED_DEFAULT)" | |||
| 176 | }, | |||
| 177 | ShiftTorqueReductionSwitchParams { | |||
| 178 | /* inputPin = */ TestSwitchPin::CLUTCH_UP, | |||
| 179 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 180 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
| 181 | .setClutchUpPinMode(PI_INVERTED_DEFAULT), | |||
| 182 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
| 183 | /* description = */ "CLUTCH_UP" | |||
| 184 | }, | |||
| 185 | ShiftTorqueReductionSwitchParams { | |||
| 186 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP, | |||
| 187 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 188 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
| 189 | .setClutchUpPin(Gpio::Unassigned), | |||
| 190 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 191 | /* description = */ "LUA_CLUTCH_UP" | |||
| 192 | }, | |||
| 193 | ShiftTorqueReductionSwitchParams { | |||
| 194 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP, | |||
| 195 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 196 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
| 197 | .setClutchUpPin(Gpio::Unassigned) | |||
| 198 | .setClutchUpPinMode(PI_DEFAULT), | |||
| 199 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 200 | /* description = */ "LUA_CLUTCH_UP (pinMode = PI_DEFAULT)" | |||
| 201 | }, | |||
| 202 | ShiftTorqueReductionSwitchParams { | |||
| 203 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP, | |||
| 204 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
| 205 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
| 206 | .setClutchUpPin(Gpio::Unassigned) | |||
| 207 | .setClutchUpPinMode(PI_INVERTED_DEFAULT), | |||
| 208 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
| 209 | /* description = */ "LUA_CLUTCH_UP (pinMode = PI_INVERTED_DEFAULT)" | |||
| 210 | } | |||
| 211 | ) | |||
| 212 | ); | |||
| 213 | } | |||
| 214 |