SettingsStackTest.kt

2.9 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_fills_available_height_instead_of_the_browsers_small_popup_cap() {29        // The deck used to hard-cap at 462dp (a literal port of the browser's small30        // popup), stranding a third of a phone screen as dead space below the stack.31        // It now fills the available height (minus the bottom gutter) up to a much32        // larger bound that only matters on very tall/tablet screens.33        assertEquals(864.dp, settingsDeckHeight(900.dp))34        assertEquals(444.dp, settingsDeckHeight(480.dp))35        assertEquals(0.dp, settingsDeckHeight(24.dp))36    }3738    // ── Drag gesture resolution ───────────────────────────────────────────────3940    @Test fun settings_stack_drag_up_expands_card() {41        // Collapsed (deck) card dragged up past the 60px threshold → focus it.42        assertEquals(DragOutcome.EXPAND, resolveStackDrag(dragOffsetPx = -90f, thresholdPx = 60f, isExpanded = false))43    }4445    @Test fun settings_stack_drag_down_collapses_card() {46        // Focused card dragged down past the threshold → back to the deck.47        assertEquals(DragOutcome.COLLAPSE, resolveStackDrag(dragOffsetPx = 90f, thresholdPx = 60f, isExpanded = true))48    }4950    @Test fun settings_stack_drag_below_threshold_is_noop() {51        assertEquals(DragOutcome.NONE, resolveStackDrag(-40f, 60f, isExpanded = false))52        assertEquals(DragOutcome.NONE, resolveStackDrag(40f, 60f, isExpanded = true))53        // Right direction, wrong state: dragging an already-focused card up does nothing.54        assertEquals(DragOutcome.NONE, resolveStackDrag(-90f, 60f, isExpanded = true))55        // Dragging a collapsed card down does nothing.56        assertEquals(DragOutcome.NONE, resolveStackDrag(90f, 60f, isExpanded = false))57    }58}