package com.peachpasswords.ui.settings import androidx.compose.ui.unit.dp import org.junit.Assert.assertEquals import org.junit.Test class SettingsStackTest { // ── Collapsed tab layout: fixed browser-parity stride ───────────────────── @Test fun collapsed_tabs_use_fixed_browser_stride() { // Browser StackDeck.tsx: top = EXPANDED_H - TAB_OVERLAP + distance * (TAB_H - TAB_OVERLAP) // = 258 - 14 + distance * (46 - 14) = 244 + distance * 32. Independent of // screen height — the deck reads as a tight stack, not spread to fill. assertEquals(244.dp, collapsedTabTop(0)) assertEquals(276.dp, collapsedTabTop(1)) assertEquals(308.dp, collapsedTabTop(2)) } @Test fun collapsed_tab_stride_is_constant() { // Every successive tab steps down by exactly one stride (32dp), regardless // of how many tabs there are — no dynamic fill. val stride = collapsedTabTop(3) - collapsedTabTop(2) assertEquals(32.dp, stride) assertEquals(collapsedTabTop(5) - collapsedTabTop(4), stride) } @Test fun settings_deck_fills_available_height_instead_of_the_browsers_small_popup_cap() { // The deck used to hard-cap (a literal port of the browser's small popup, // later a MAX_DECK_H*2 bound), which stranded dead space below the stack and // clipped the Pro card's buttons on tall panels like the Galaxy Z Fold 7. It // now fills the available height minus the bottom gutter on every screen size. assertEquals(864.dp, settingsDeckHeight(900.dp)) assertEquals(444.dp, settingsDeckHeight(480.dp)) assertEquals(0.dp, settingsDeckHeight(24.dp)) // Taller than the old 924dp cap allowed: still fills to the gutter, no cap. assertEquals(1164.dp, settingsDeckHeight(1200.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)) } }