package de.arxsilex.maptools.converter.desktop

import de.arxsilex.maptools.converter.core.NormalizedMapArea
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class MapViewportTest {
    @Test
    fun `focused viewport contains and centers selected area`() {
        val area = NormalizedMapArea(0.2f, 0.3f, 0.4f, 0.5f)

        val viewport = MapViewport.focusedOn(area)

        assertTrue(viewport.left < area.left)
        assertTrue(viewport.top < area.top)
        assertTrue(viewport.right > area.right)
        assertTrue(viewport.bottom > area.bottom)
        assertEquals(0.3f, (viewport.left + viewport.right) / 2f, 0.0001f)
        assertEquals(0.4f, (viewport.top + viewport.bottom) / 2f, 0.0001f)
    }
}
