SettingsStackTest.kt

3.2 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_down_to_just_above_the_build_label() {29        // Reserves the label's nav-bar inset (passed in) + its padding/line height30        // (xs 4dp + 12dp = 16dp) + a 1dp gap = navBarBottom + 17dp. No hard cap, so31        // tall panels (Galaxy Z Fold 7) fill to the label instead of stranding dead32        // space below the stack and clipping the Pro card's copy/reveal buttons.33        assertEquals(883.dp, settingsDeckHeight(900.dp, 0.dp))34        assertEquals(463.dp, settingsDeckHeight(480.dp, 0.dp))35        assertEquals(7.dp, settingsDeckHeight(24.dp, 0.dp))36        assertEquals(1183.dp, settingsDeckHeight(1200.dp, 0.dp))37        // A larger nav-bar inset (three-button nav) simply reserves more at the bottom.38        assertEquals(835.dp, settingsDeckHeight(900.dp, 48.dp))39    }4041    // ── Drag gesture resolution ───────────────────────────────────────────────4243    @Test fun settings_stack_drag_up_expands_card() {44        // Collapsed (deck) card dragged up past the 60px threshold → focus it.45        assertEquals(DragOutcome.EXPAND, resolveStackDrag(dragOffsetPx = -90f, thresholdPx = 60f, isExpanded = false))46    }4748    @Test fun settings_stack_drag_down_collapses_card() {49        // Focused card dragged down past the threshold → back to the deck.50        assertEquals(DragOutcome.COLLAPSE, resolveStackDrag(dragOffsetPx = 90f, thresholdPx = 60f, isExpanded = true))51    }5253    @Test fun settings_stack_drag_below_threshold_is_noop() {54        assertEquals(DragOutcome.NONE, resolveStackDrag(-40f, 60f, isExpanded = false))55        assertEquals(DragOutcome.NONE, resolveStackDrag(40f, 60f, isExpanded = true))56        // Right direction, wrong state: dragging an already-focused card up does nothing.57        assertEquals(DragOutcome.NONE, resolveStackDrag(-90f, 60f, isExpanded = true))58        // Dragging a collapsed card down does nothing.59        assertEquals(DragOutcome.NONE, resolveStackDrag(90f, 60f, isExpanded = false))60    }61}