SettingsStackTest.kt

3.1 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 (a literal port of the browser's small popup,30        // later a MAX_DECK_H*2 bound), which stranded dead space below the stack and31        // clipped the Pro card's buttons on tall panels like the Galaxy Z Fold 7. It32        // now fills the available height minus the bottom gutter on every screen size.33        assertEquals(864.dp, settingsDeckHeight(900.dp))34        assertEquals(444.dp, settingsDeckHeight(480.dp))35        assertEquals(0.dp, settingsDeckHeight(24.dp))36        // Taller than the old 924dp cap allowed: still fills to the gutter, no cap.37        assertEquals(1164.dp, settingsDeckHeight(1200.dp))38    }3940    // ── Drag gesture resolution ───────────────────────────────────────────────4142    @Test fun settings_stack_drag_up_expands_card() {43        // Collapsed (deck) card dragged up past the 60px threshold → focus it.44        assertEquals(DragOutcome.EXPAND, resolveStackDrag(dragOffsetPx = -90f, thresholdPx = 60f, isExpanded = false))45    }4647    @Test fun settings_stack_drag_down_collapses_card() {48        // Focused card dragged down past the threshold → back to the deck.49        assertEquals(DragOutcome.COLLAPSE, resolveStackDrag(dragOffsetPx = 90f, thresholdPx = 60f, isExpanded = true))50    }5152    @Test fun settings_stack_drag_below_threshold_is_noop() {53        assertEquals(DragOutcome.NONE, resolveStackDrag(-40f, 60f, isExpanded = false))54        assertEquals(DragOutcome.NONE, resolveStackDrag(40f, 60f, isExpanded = true))55        // Right direction, wrong state: dragging an already-focused card up does nothing.56        assertEquals(DragOutcome.NONE, resolveStackDrag(-90f, 60f, isExpanded = true))57        // Dragging a collapsed card down does nothing.58        assertEquals(DragOutcome.NONE, resolveStackDrag(90f, 60f, isExpanded = false))59    }60}