package com.ponzischeme89.memby.ui.screensaver

import org.junit.Assert.assertEquals
import org.junit.Test

/**
 * Unit tests for the ring's pure geometry. The animation/lifecycle behaviour (progress
 * reaching 100% after the slide duration, advancing exactly once, resetting on the next
 * slide, restarting on manual navigation, and cancelling on teardown) is driven by
 * Compose's [androidx.compose.animation.core.Animatable] + `repeatOnLifecycle` and is
 * verified on-device against the DreamService path rather than here, since this module
 * has no Compose UI-test / Robolectric harness.
 */
class SlideProgressMathTest {

    private val tolerance = 0.0001f

    @Test
    fun beginsEmpty() {
        assertEquals(0f, SlideProgressMath.sweepAngle(0f), tolerance)
    }

    @Test
    fun reachesFullCircleAtCompletion() {
        assertEquals(360f, SlideProgressMath.sweepAngle(1f), tolerance)
    }

    @Test
    fun isProportionalMidway() {
        assertEquals(180f, SlideProgressMath.sweepAngle(0.5f), tolerance)
        assertEquals(90f, SlideProgressMath.sweepAngle(0.25f), tolerance)
    }

    @Test
    fun clampsOutOfRangeValues() {
        assertEquals(0f, SlideProgressMath.sweepAngle(-0.5f), tolerance)
        assertEquals(360f, SlideProgressMath.sweepAngle(1.5f), tolerance)
    }
}
