refactor(navigator): add test to confirm that new data invalidates old data

This commit is contained in:
jonas
2026-07-27 08:28:45 +02:00
committed by Beat Küng
parent af4ab1bb8b
commit 32c82c5128
2 changed files with 13 additions and 0 deletions
@@ -94,6 +94,10 @@ public:
/** True after queuing, reading, or validating the current mission land item failed. */
bool missionLandItemAttemptFailed() const { return _mission_land.retry.retry_count > 0; }
/**
* Returns the item count of the complete, validated safe-point generation.
* Returns zero while a replacement is pending (check safePointsReady()) and for a ready empty set.
*/
int safePointCount() const override;
bool loadSafePointItem(int index, mission_item_s &safe_point_item) const override;
@@ -325,8 +325,17 @@ TEST_F(MissionRouteCacheTest, SafePointIdChangeReloadsReplacementSet)
mission.safe_points_id = 101;
mission.timestamp = hrt_absolute_time();
// A source change immediately hides the old generation instead of blocking or exposing stale data.
_cache.update(mission);
EXPECT_EQ(_cache.safePointsId(), mission.safe_points_id);
EXPECT_FALSE(_cache.safePointsReady());
EXPECT_TRUE(_cache.safePointUpdatePending());
EXPECT_EQ(_cache.safePointCount(), 0);
EXPECT_FALSE(_cache.loadSafePointItem(0, safe_point));
ASSERT_TRUE(MissionRouteCacheTestPeer::runCacheUntil(_cache, mission, [&] { return _cache.safePointsReady(); }))
<< "safe-point cache did not become ready";
EXPECT_FALSE(_cache.safePointUpdatePending());
// The stale set is replaced.
ASSERT_TRUE(_cache.loadSafePointItem(0, safe_point));