mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 16:27:35 +08:00
ManualControlSelectorTest: add constantly outdated samples case
Reviewing the code I saw this case arising from the order things get checked.
This commit is contained in:
@@ -173,3 +173,26 @@ TEST(ManualControlSelector, RcTimeout)
|
||||
EXPECT_FALSE(selector.setpoint().valid);
|
||||
EXPECT_EQ(selector.instance(), -1);
|
||||
}
|
||||
|
||||
TEST(ManualControlSelector, RcOutdated)
|
||||
{
|
||||
ManualControlSelector selector;
|
||||
selector.set_rc_in_mode(0);
|
||||
selector.set_timeout(500_ms);
|
||||
|
||||
uint64_t timestamp = some_time;
|
||||
|
||||
manual_control_input_s input {};
|
||||
input.data_source = manual_control_input_s::SOURCE_RC;
|
||||
input.timestamp_sample = timestamp - 600_ms; // First sample is already outdated
|
||||
selector.update_manual_control_input(timestamp, input, 0);
|
||||
|
||||
EXPECT_FALSE(selector.setpoint().valid);
|
||||
EXPECT_EQ(selector.instance(), -1);
|
||||
|
||||
// If we update again it should still not get accepted
|
||||
selector.update_manual_control_input(timestamp, input, 0);
|
||||
|
||||
EXPECT_FALSE(selector.setpoint().valid);
|
||||
EXPECT_EQ(selector.instance(), -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user