From 21023d229c1ebd1acba8df3218acf32db2111141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Sevilla?= <24dasemu@gmail.com> Date: Tue, 13 Oct 2026 13:18:46 +0000 Subject: [PATCH] test: prevent false arrival when rejoining a closed GPX trace --- .../dev/navframe/core/RouteGuidanceTest.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/test/kotlin/dev/navframe/core/RouteGuidanceTest.kt b/core/src/test/kotlin/dev/navframe/core/RouteGuidanceTest.kt index b4bd3d4..55c608e 100644 --- a/core/src/test/kotlin/dev/navframe/core/RouteGuidanceTest.kt +++ b/core/src/test/kotlin/dev/navframe/core/RouteGuidanceTest.kt @@ -271,6 +271,22 @@ class RouteGuidanceTest { tracker.update(fix(lon = 0.012, time = 12), 20_000, 0).navigationStatus) } + @Test fun `closed imported trace rejoin at shared start and finish cannot falsely arrive`() { + val loop = importedTrace.copy(geometry = listOf(GeoPoint(0.0, 0.0), GeoPoint(0.0, 0.002), + GeoPoint(0.002, 0.002), GeoPoint(0.002, 0.0), GeoPoint(0.0, 0.0))) + val tracker = RouteGuidanceTracker(loop) + tracker.update(fix(lon = 0.0005), 0, 0) + for (i in 2L..4L) tracker.update(fix(lat = -0.0007, lon = 0.0005, time = i), (i - 1) * 3_000, 0) + for (i in 5L..9L) { + val state = tracker.update(fix(time = i), (i + 5) * 1_000, 0) + assertNotEquals(NavigationStatus.ARRIVED, state.navigationStatus) + if (i >= 7) { + assertEquals(NavigationStatus.NAVIGATING, state.navigationStatus) + assertTrue(state.remainingDistanceMeters!! > 800) + } + } + } + @Test fun `imported crossing preserves progress until deviation is sustained`() { val crossing = importedTrace.copy(geometry = listOf(GeoPoint(0.0, 0.0), GeoPoint(0.0, 0.002), GeoPoint(0.002, 0.002), GeoPoint(0.002, 0.0), GeoPoint(0.0, 0.0), GeoPoint(0.0, -0.002)))