overview_cascade_test.go RawHistoryFolder
1package core
2
3import (
4 "github.com/bnema/neferwl/internal/ports"
5 "testing"
6)
7
8func TestOverviewCascadeBandGeometry(t *testing.T) {
9 w := cascadeWorkspace(7)
10 tiles, p := w.previewTiles()
11 if p.bounds.W != w.Usable.W || p.bounds.H != 3*w.Usable.H {
12 t.Fatalf("bounds=%v", p.bounds)
13 }
14 for i, tile := range tiles {
15 if tile.Rect.X != w.cellX(i) || tile.Rect.Y != w.gap()+w.band(i)*w.Usable.H {
16 t.Fatalf("tile %d=%v", i, tile.Rect)
17 }
18 }
19}
20
21func TestOverviewCascadePreviewBufferAllocations(t *testing.T) {
22 w := cascadeWorkspace(7)
23 buf, _ := w.previewTiles()
24 if n := testing.AllocsPerRun(100, func() { buf, _ = w.previewTilesInto(buf[:0]) }); n != 0 {
25 t.Fatalf("allocations=%v", n)
26 }
27}
28
29func TestOverviewMixedLayoutGestureAndCancel(t *testing.T) {
30 m := overviewMonitor()
31 m.SetOverflow(OverflowFixed)
32 m.Current().Overflow = OverflowCascade
33 from := m.Current()
34 m.ToggleOverview()
35 rows, _ := m.overviewRows()
36 if rows[m.Workspaces[1]].X <= 0 {
37 t.Fatal("cascade neighbor not horizontal")
38 }
39 m.overviewScroll(ports.PointerAxis{Source: ports.AxisFinger, Horizontal: ports.ScrollAxis{Set: true, Value: overviewScrollStep}})
40 if m.Current() == from {
41 t.Fatal("horizontal gesture did not change workspace")
42 }
43 if m.Current().Overflow != OverflowFixed {
44 t.Fatal("destination lost fixed policy")
45 }
46 m.CancelOverview()
47 if m.Current() != from {
48 t.Fatal("cancel lost source workspace")
49 }
50}
51
52func TestOverviewCascadeReloadRetainsSelection(t *testing.T) {
53 m := overviewMonitor()
54 m.ToggleOverview()
55 w := m.Current()
56 id, _ := w.Focused()
57 m.SetOverflow(OverflowCascade)
58 if got, _ := w.Focused(); !m.ov.open || got != id {
59 t.Fatal("reload lost overview selection")
60 }
61 m.CancelOverview()
62 if got, _ := w.Focused(); got != id {
63 t.Fatal("cancel lost original focus")
64 }
65}
66
67func TestOverviewMixedWheelDoesNotBounce(t *testing.T) {
68 for _, source := range []ports.AxisSource{ports.AxisWheel, ports.AxisContinuous} {
69 m := overviewMonitor()
70 m.SetOverflow(OverflowFixed)
71 m.Workspaces[1].Overflow = OverflowCascade
72 m.ToggleOverview()
73 from := m.Current()
74 m.overviewScroll(ports.PointerAxis{Source: source, Vertical: ports.ScrollAxis{Set: true, Value: overviewScrollStep, V120: 120}})
75 if m.Current() == from {
76 t.Fatalf("source %v bounced", source)
77 }
78 }
79}
80
81func TestOverviewCascadeStashScale(t *testing.T) {
82 w := cascadeWorkspace(7)
83 w.Stash = []Float{{ID: 20}}
84 cards := w.pile(0, false, 0)
85 if len(cards) != 1 || cards[0].Preview != overviewCardZoom {
86 t.Fatalf("cards=%v", cards)
87 }
88 if w.pileWidth() > w.overviewArea().W/3 {
89 t.Fatal("stash exceeds width budget")
90 }
91}