SettingsStackTest.kt

2.5 KB · raw

1package com.peachpasswords.ui.settings23import androidx.compose.ui.unit.dp4import org.junit.Assert.assertEquals5import org.junit.Assert.assertTrue6import org.junit.Test78class SettingsStackTest {910    // ── Screen fill: collapsed tabs fan to use the whole height ────────────────1112    @Test fun settings_stack_collapsed_fills_screen_height() {13        // 6 tabs, 258dp active card, 50dp tab card. On a tall screen the stride14        // opens up toward the cap rather than staying at the 32dp floor.15        val tall = collapsedTabStride(16            available = 800.dp, expanded = 258.dp, tabCard = 50.dp, tabCount = 6,17            min = 32.dp, max = 72.dp,18        )19        val short = collapsedTabStride(20            available = 480.dp, expanded = 258.dp, tabCard = 50.dp, tabCount = 6,21            min = 32.dp, max = 72.dp,22        )23        assertTrue("taller screen spreads tabs further", tall > short)24        // raw = (800-258-50)/6 = 82 → clamped to the 72dp cap.25        assertEquals(72.dp, tall)26        // raw = (480-258-50)/6 ≈ 28.7 → clamped up to the 32dp floor.27        assertEquals(32.dp, short)28    }2930    @Test fun stride_falls_back_to_min_with_no_tabs() {31        assertEquals(32.dp, collapsedTabStride(800.dp, 258.dp, 50.dp, 0, 32.dp, 72.dp))32    }3334    // ── Drag gesture resolution ───────────────────────────────────────────────3536    @Test fun settings_stack_drag_up_expands_card() {37        // Collapsed (deck) card dragged up past the 60px threshold → focus it.38        assertEquals(DragOutcome.EXPAND, resolveStackDrag(dragOffsetPx = -90f, thresholdPx = 60f, isExpanded = false))39    }4041    @Test fun settings_stack_drag_down_collapses_card() {42        // Focused card dragged down past the threshold → back to the deck.43        assertEquals(DragOutcome.COLLAPSE, resolveStackDrag(dragOffsetPx = 90f, thresholdPx = 60f, isExpanded = true))44    }4546    @Test fun settings_stack_drag_below_threshold_is_noop() {47        assertEquals(DragOutcome.NONE, resolveStackDrag(-40f, 60f, isExpanded = false))48        assertEquals(DragOutcome.NONE, resolveStackDrag(40f, 60f, isExpanded = true))49        // Right direction, wrong state: dragging an already-focused card up does nothing.50        assertEquals(DragOutcome.NONE, resolveStackDrag(-90f, 60f, isExpanded = true))51        // Dragging a collapsed card down does nothing.52        assertEquals(DragOutcome.NONE, resolveStackDrag(90f, 60f, isExpanded = false))53    }54}