package com.onthelevel.core.sensors

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

class SurfacePresentationDetectorTest {

    @Test
    fun `axis suppression boundary is hysteretic`() {
        val detector = SurfacePresentationDetector()

        assertEquals(SurfacePresentation.FACE_UP, detector.update(79.9))
        assertEquals(SurfacePresentation.NEAR_VERTICAL, detector.update(80.0))
        assertEquals(SurfacePresentation.NEAR_VERTICAL, detector.update(79.2))
        assertEquals(SurfacePresentation.FACE_UP, detector.update(78.9))
    }

    @Test
    fun `screen down boundary is hysteretic`() {
        val detector = SurfacePresentationDetector()

        detector.update(80.0)
        assertEquals(SurfacePresentation.NEAR_VERTICAL, detector.update(90.0))
        assertEquals(SurfacePresentation.SCREEN_DOWN, detector.update(90.1))
        assertEquals(SurfacePresentation.SCREEN_DOWN, detector.update(89.2))
        assertEquals(SurfacePresentation.NEAR_VERTICAL, detector.update(89.0))
    }
}
