package com.peachpasswords.ui.settings import androidx.compose.ui.unit.dp import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test class SettingsStackTest { // ── Screen fill: collapsed tabs fan to use the whole height ──────────────── @Test fun settings_stack_collapsed_fills_screen_height() { // 6 tabs, 258dp active card, 50dp tab card. On a tall screen the stride // opens up toward the cap rather than staying at the 32dp floor. val tall = collapsedTabStride( available = 800.dp, expanded = 258.dp, tabCard = 50.dp, tabCount = 6, min = 32.dp, max = 72.dp, ) val short = collapsedTabStride( available = 480.dp, expanded = 258.dp, tabCard = 50.dp, tabCount = 6, min = 32.dp, max = 72.dp, ) assertTrue("taller screen spreads tabs further", tall > short) // raw = (800-258-50)/6 = 82 → clamped to the 72dp cap. assertEquals(72.dp, tall) // raw = (480-258-50)/6 ≈ 28.7 → clamped up to the 32dp floor. assertEquals(32.dp, short) } @Test fun stride_falls_back_to_min_with_no_tabs() { assertEquals(32.dp, collapsedTabStride(800.dp, 258.dp, 50.dp, 0, 32.dp, 72.dp)) } // ── Drag gesture resolution ─────────────────────────────────────────────── @Test fun settings_stack_drag_up_expands_card() { // Collapsed (deck) card dragged up past the 60px threshold → focus it. assertEquals(DragOutcome.EXPAND, resolveStackDrag(dragOffsetPx = -90f, thresholdPx = 60f, isExpanded = false)) } @Test fun settings_stack_drag_down_collapses_card() { // Focused card dragged down past the threshold → back to the deck. assertEquals(DragOutcome.COLLAPSE, resolveStackDrag(dragOffsetPx = 90f, thresholdPx = 60f, isExpanded = true)) } @Test fun settings_stack_drag_below_threshold_is_noop() { assertEquals(DragOutcome.NONE, resolveStackDrag(-40f, 60f, isExpanded = false)) assertEquals(DragOutcome.NONE, resolveStackDrag(40f, 60f, isExpanded = true)) // Right direction, wrong state: dragging an already-focused card up does nothing. assertEquals(DragOutcome.NONE, resolveStackDrag(-90f, 60f, isExpanded = true)) // Dragging a collapsed card down does nothing. assertEquals(DragOutcome.NONE, resolveStackDrag(90f, 60f, isExpanded = false)) } }