SettingsStackTest.kt

2.6 KB · raw

1package com.peachpasswords.ui.settings23import androidx.compose.ui.unit.dp4import org.junit.Assert.assertEquals5import org.junit.Test67class SettingsStackTest {89    // ── Collapsed tab layout: fixed browser-parity stride ─────────────────────1011    @Test fun collapsed_tabs_use_fixed_browser_stride() {12        // Browser StackDeck.tsx: top = EXPANDED_H - TAB_OVERLAP + distance * (TAB_H - TAB_OVERLAP)13        // = 258 - 14 + distance * (46 - 14) = 244 + distance * 32. Independent of14        // screen height — the deck reads as a tight stack, not spread to fill.15        assertEquals(244.dp, collapsedTabTop(0))16        assertEquals(276.dp, collapsedTabTop(1))17        assertEquals(308.dp, collapsedTabTop(2))18    }1920    @Test fun collapsed_tab_stride_is_constant() {21        // Every successive tab steps down by exactly one stride (32dp), regardless22        // of how many tabs there are — no dynamic fill.23        val stride = collapsedTabTop(3) - collapsedTabTop(2)24        assertEquals(32.dp, stride)25        assertEquals(collapsedTabTop(5) - collapsedTabTop(4), stride)26    }2728    @Test fun settings_deck_is_bounded_like_browser_stack_deck() {29        assertEquals(462.dp, settingsDeckHeight(900.dp))30        assertEquals(444.dp, settingsDeckHeight(480.dp))31        assertEquals(0.dp, settingsDeckHeight(24.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}