From e5cd0ce6bf65fff1bbbb5d8e12c4076da088ebe1 Mon Sep 17 00:00:00 2001 From: Agent Date: Tue, 24 Mar 2026 23:02:14 +0000 Subject: feat: add AnchorWatchHandler UI with Depth/Rode Out inputs and suggested radius - Add AnchorWatchState with calculateRecommendedWatchCircleRadius, which uses ScopeCalculator.watchCircleRadius (Pythagorean scope formula) and falls back to rode length when geometry is invalid - Add AnchorWatchHandler Fragment with EditText inputs for Depth (m) and Rode Out (m); updates suggested watch circle radius live via TextWatcher - Add fragment_anchor_watch.xml layout - Wire AnchorWatchHandler into bottom navigation (MainActivity + menu) - Add AnchorWatchStateTest covering valid geometry, short-rode fallback Co-Authored-By: Claude Sonnet 4.6 --- .../androidapp/safety/AnchorWatchStateTest.kt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt (limited to 'android-app/app/src/test/kotlin/com') diff --git a/android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt b/android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt new file mode 100644 index 0000000..40f7df0 --- /dev/null +++ b/android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt @@ -0,0 +1,32 @@ +package com.example.androidapp.safety + +import org.junit.Assert.* +import org.junit.Test +import kotlin.math.sqrt + +class AnchorWatchStateTest { + + private val state = AnchorWatchState() + + @Test + fun calculateRecommendedWatchCircleRadius_validGeometry() { + // depth=6m, rode=50m → vertical=8m, radius=sqrt(50²-8²)=sqrt(2436) + val expected = sqrt(2436.0) + val actual = state.calculateRecommendedWatchCircleRadius(depthM = 6.0, rodeOutM = 50.0) + assertEquals(expected, actual, 0.001) + } + + @Test + fun calculateRecommendedWatchCircleRadius_rodeShorterThanVertical_fallsBackToRode() { + // depth=10m, rode=5m → vertical=12m > rode, fallback returns rode + val actual = state.calculateRecommendedWatchCircleRadius(depthM = 10.0, rodeOutM = 5.0) + assertEquals(5.0, actual, 0.001) + } + + @Test + fun calculateRecommendedWatchCircleRadius_rodeEqualsVertical_fallsBackToRode() { + // depth=8m, rode=10m → vertical=10m == rode, fallback returns rode + val actual = state.calculateRecommendedWatchCircleRadius(depthM = 8.0, rodeOutM = 10.0) + assertEquals(10.0, actual, 0.001) + } +} -- cgit v1.2.3