package core import ( "github.com/bnema/neferwl/internal/ports" "testing" ) func TestOverviewCascadeBandGeometry(t *testing.T) { w := cascadeWorkspace(7) tiles, p := w.previewTiles() if p.bounds.W != w.Usable.W || p.bounds.H != 3*w.Usable.H { t.Fatalf("bounds=%v", p.bounds) } for i, tile := range tiles { if tile.Rect.X != w.cellX(i) || tile.Rect.Y != w.gap()+w.band(i)*w.Usable.H { t.Fatalf("tile %d=%v", i, tile.Rect) } } } func TestOverviewCascadePreviewBufferAllocations(t *testing.T) { w := cascadeWorkspace(7) buf, _ := w.previewTiles() if n := testing.AllocsPerRun(100, func() { buf, _ = w.previewTilesInto(buf[:0]) }); n != 0 { t.Fatalf("allocations=%v", n) } } func TestOverviewMixedLayoutGestureAndCancel(t *testing.T) { m := overviewMonitor() m.SetOverflow(OverflowFixed) m.Current().Overflow = OverflowCascade from := m.Current() m.ToggleOverview() rows, _ := m.overviewRows() if rows[m.Workspaces[1]].X <= 0 { t.Fatal("cascade neighbor not horizontal") } m.overviewScroll(ports.PointerAxis{Source: ports.AxisFinger, Horizontal: ports.ScrollAxis{Set: true, Value: overviewScrollStep}}) if m.Current() == from { t.Fatal("horizontal gesture did not change workspace") } if m.Current().Overflow != OverflowFixed { t.Fatal("destination lost fixed policy") } m.CancelOverview() if m.Current() != from { t.Fatal("cancel lost source workspace") } } func TestOverviewCascadeReloadRetainsSelection(t *testing.T) { m := overviewMonitor() m.ToggleOverview() w := m.Current() id, _ := w.Focused() m.SetOverflow(OverflowCascade) if got, _ := w.Focused(); !m.ov.open || got != id { t.Fatal("reload lost overview selection") } m.CancelOverview() if got, _ := w.Focused(); got != id { t.Fatal("cancel lost original focus") } } func TestOverviewMixedWheelDoesNotBounce(t *testing.T) { for _, source := range []ports.AxisSource{ports.AxisWheel, ports.AxisContinuous} { m := overviewMonitor() m.SetOverflow(OverflowFixed) m.Workspaces[1].Overflow = OverflowCascade m.ToggleOverview() from := m.Current() m.overviewScroll(ports.PointerAxis{Source: source, Vertical: ports.ScrollAxis{Set: true, Value: overviewScrollStep, V120: 120}}) if m.Current() == from { t.Fatalf("source %v bounced", source) } } } func TestOverviewCascadeStashScale(t *testing.T) { w := cascadeWorkspace(7) w.Stash = []Float{{ID: 20}} cards := w.pile(0, false, 0) if len(cards) != 1 || cards[0].Preview != overviewCardZoom { t.Fatalf("cards=%v", cards) } if w.pileWidth() > w.overviewArea().W/3 { t.Fatal("stash exceeds width budget") } }