diff options
| author | Agent <agent@example.com> | 2026-03-24 23:02:14 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-25 04:55:41 +0000 |
| commit | e5cd0ce6bf65fff1bbbb5d8e12c4076da088ebe1 (patch) | |
| tree | 9c153dc4d2ad5f784121047bf71739d2153d1cf8 /android-app/app/src/test/kotlin/com/example/androidapp | |
| parent | 31b1b3a05d2100ada78042770d62c824d47603ec (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'android-app/app/src/test/kotlin/com/example/androidapp')
| -rw-r--r-- | android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt | 32 |
1 files changed, 32 insertions, 0 deletions
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) + } +} |
