Add test cases for *all and *all_with functions
Added test cases for the recently implemented `*all` and `*all_with` functions. Closes #1089.
This commit is contained in:
@@ -398,4 +398,36 @@ TEST_CASE("run command during TILT state transitions correctly", "[relay_chn][ti
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
// Should transition to REVERSE
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
|
||||
}
|
||||
|
||||
// Test run command during active tilt cycle (move/pause)
|
||||
TEST_CASE("run_all command during active tilt cycle stops tilt", "[relay_chn][tilt][interrupt]")
|
||||
{
|
||||
// Set a known sensitivity for predictable timing.
|
||||
// For sensitivity=50, move_time=30ms, pause_time=270ms.
|
||||
relay_chn_tilt_set_sensitivity_all_with(50);
|
||||
const uint32_t move_time_ms = 30;
|
||||
|
||||
// --- Test interrupting during MOVE step ---
|
||||
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
|
||||
relay_chn_tilt_forward_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(move_time_ms / 2)); // Wait for half of the move time
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
|
||||
|
||||
// Interrupt with run_reverse_all while in the MOVE part of the cycle
|
||||
relay_chn_run_reverse_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
// Should stop tilting and go to REVERSE immediately (no inertia from TILT_FORWARD)
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
|
||||
|
||||
// --- Test interrupting during PAUSE step ---
|
||||
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
|
||||
relay_chn_tilt_forward_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(move_time_ms + TEST_DELAY_MARGIN_MS)); // Wait past MOVE, into PAUSE
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
|
||||
|
||||
// Interrupt with run_forward_all while in the PAUSE part of the cycle
|
||||
relay_chn_run_forward_all();
|
||||
// Should stop tilting and go to FORWARD_PENDING (inertia from TILT_FORWARD)
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_FORWARD_PENDING);
|
||||
}
|
||||
Reference in New Issue
Block a user