test(layout): cover cascade band widths with gaps and partial bands
- commit
- 25daf386597ddd0c5b32ab8bb8027956a1994364
- author
- brice · · 2026-10-07 14:38 UTC
- parent
- 7d82780
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +28 -0
M internal/core/cascade_test.go +21 -0
| @@ -14,6 +14,27 @@ func cascadeWorkspace(n int) *Workspace { | |||
| 14 | 14 | return w | |
| 15 | 15 | } | |
| 16 | 16 | ||
| 17 | + | // With gaps and a width that does not divide evenly, the columns of a | |
| 18 | + | // partial band share what the gaps leave, and the configured width follows | |
| 19 | + | // the band as it fills. | |
| 20 | + | func TestCascadeBandWidthWithGaps(t *testing.T) { | |
| 21 | + | w := &Workspace{Overflow: OverflowCascade, MaxColumns: 3} | |
| 22 | + | w.SetOutput(1000, 600) | |
| 23 | + | w.SetGaps(8) | |
| 24 | + | w.AddWindow(1) | |
| 25 | + | if got := w.columnWidth(0); got != 1000-2*8 { | |
| 26 | + | t.Fatalf("lone column width %d, want %d", got, 1000-2*8) | |
| 27 | + | } | |
| 28 | + | w.AddWindow(2) | |
| 29 | + | cell := (1000 - 3*8) / 2 | |
| 30 | + | for i, x := range []int{8, 8 + cell + 8} { | |
| 31 | + | r := w.columnRectsFor(false)[i] | |
| 32 | + | if r.X != x || r.W != cell || w.columnWidth(i) != cell { | |
| 33 | + | t.Fatalf("column %d rect %v width %d, want X %d W %d", i, r, w.columnWidth(i), x, cell) | |
| 34 | + | } | |
| 35 | + | } | |
| 36 | + | } | |
| 37 | + | ||
| 17 | 38 | // Each band's columns share its width equally, as in fixed overflow: a | |
| 18 | 39 | // lone column fills it, a full band of three has thirds. | |
| 19 | 40 | func TestCascadeBandsAndReveal(t *testing.T) { | |
| @@ -14,6 +14,27 @@ func cascadeWorkspace(n int) *Workspace { | |||||
| 14 | return w | 14 | return w | ||
| 15 | } | 15 | } | ||
| 16 | 16 | ||||
| 17 | + | // With gaps and a width that does not divide evenly, the columns of a | |||
| 18 | + | // partial band share what the gaps leave, and the configured width follows | |||
| 19 | + | // the band as it fills. | |||
| 20 | + | func TestCascadeBandWidthWithGaps(t *testing.T) { | |||
| 21 | + | w := &Workspace{Overflow: OverflowCascade, MaxColumns: 3} | |||
| 22 | + | w.SetOutput(1000, 600) | |||
| 23 | + | w.SetGaps(8) | |||
| 24 | + | w.AddWindow(1) | |||
| 25 | + | if got := w.columnWidth(0); got != 1000-2*8 { | |||
| 26 | + | t.Fatalf("lone column width %d, want %d", got, 1000-2*8) | |||
| 27 | + | } | |||
| 28 | + | w.AddWindow(2) | |||
| 29 | + | cell := (1000 - 3*8) / 2 | |||
| 30 | + | for i, x := range []int{8, 8 + cell + 8} { | |||
| 31 | + | r := w.columnRectsFor(false)[i] | |||
| 32 | + | if r.X != x || r.W != cell || w.columnWidth(i) != cell { | |||
| 33 | + | t.Fatalf("column %d rect %v width %d, want X %d W %d", i, r, w.columnWidth(i), x, cell) | |||
| 34 | + | } | |||
| 35 | + | } | |||
| 36 | + | } | |||
| 37 | + | ||||
| 17 | // Each band's columns share its width equally, as in fixed overflow: a | 38 | // Each band's columns share its width equally, as in fixed overflow: a | ||
| 18 | // lone column fills it, a full band of three has thirds. | 39 | // lone column fills it, a full band of three has thirds. | ||
| 19 | func TestCascadeBandsAndReveal(t *testing.T) { | 40 | func TestCascadeBandsAndReveal(t *testing.T) { | ||
M internal/core/overview_cascade_test.go +7 -0
| @@ -90,6 +90,9 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) { | |||
| 90 | 90 | {n: 4, max: 0, cards: []int{0, 1, 2, 0}, order: []int{2, 1, 0}}, | |
| 91 | 91 | {n: 4, max: 1, cards: []int{-1, 0, 1, 0}, order: []int{0, 2, 1}}, | |
| 92 | 92 | {n: 4, max: 3, cards: []int{0, 0, 0, 0}}, | |
| 93 | + | // Partial bands: the card has its band's half width. | |
| 94 | + | {n: 2, max: 0, cards: []int{0, 1}, order: []int{1, 0}}, | |
| 95 | + | {n: 5, max: 4, cards: []int{0, 0, 0, -1, 0}}, | |
| 93 | 96 | } { | |
| 94 | 97 | w := cascadeWorkspace(tc.n) | |
| 95 | 98 | w.Focus = tc.max | |
| @@ -119,6 +122,10 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) { | |||
| 119 | 122 | if p.Hidden || p.Peek != (tc.cards[i] != 0) || p.Focused != (i == tc.max) || p.Rect != want { | |
| 120 | 123 | t.Fatalf("n=%d max=%d column %d: %+v, want rect %+v card %v", tc.n, tc.max, i, p, want, tc.cards[i] != 0) | |
| 121 | 124 | } | |
| 125 | + | // The 900-wide band split among its columns, no gaps. | |
| 126 | + | if inBand := min(tc.n-band*3, 3); i != tc.max && p.Rect.W != 900/inBand { | |
| 127 | + | t.Fatalf("n=%d max=%d column %d width %d, want %d", tc.n, tc.max, i, p.Rect.W, 900/inBand) | |
| 128 | + | } | |
| 122 | 129 | if i == tc.max && sel != want { | |
| 123 | 130 | t.Fatalf("n=%d max=%d sel %+v, want %+v", tc.n, tc.max, sel, want) | |
| 124 | 131 | } | |
| @@ -90,6 +90,9 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) { | |||||
| 90 | {n: 4, max: 0, cards: []int{0, 1, 2, 0}, order: []int{2, 1, 0}}, | 90 | {n: 4, max: 0, cards: []int{0, 1, 2, 0}, order: []int{2, 1, 0}}, | ||
| 91 | {n: 4, max: 1, cards: []int{-1, 0, 1, 0}, order: []int{0, 2, 1}}, | 91 | {n: 4, max: 1, cards: []int{-1, 0, 1, 0}, order: []int{0, 2, 1}}, | ||
| 92 | {n: 4, max: 3, cards: []int{0, 0, 0, 0}}, | 92 | {n: 4, max: 3, cards: []int{0, 0, 0, 0}}, | ||
| 93 | + | // Partial bands: the card has its band's half width. | |||
| 94 | + | {n: 2, max: 0, cards: []int{0, 1}, order: []int{1, 0}}, | |||
| 95 | + | {n: 5, max: 4, cards: []int{0, 0, 0, -1, 0}}, | |||
| 93 | } { | 96 | } { | ||
| 94 | w := cascadeWorkspace(tc.n) | 97 | w := cascadeWorkspace(tc.n) | ||
| 95 | w.Focus = tc.max | 98 | w.Focus = tc.max | ||
| @@ -119,6 +122,10 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) { | |||||
| 119 | if p.Hidden || p.Peek != (tc.cards[i] != 0) || p.Focused != (i == tc.max) || p.Rect != want { | 122 | if p.Hidden || p.Peek != (tc.cards[i] != 0) || p.Focused != (i == tc.max) || p.Rect != want { | ||
| 120 | t.Fatalf("n=%d max=%d column %d: %+v, want rect %+v card %v", tc.n, tc.max, i, p, want, tc.cards[i] != 0) | 123 | t.Fatalf("n=%d max=%d column %d: %+v, want rect %+v card %v", tc.n, tc.max, i, p, want, tc.cards[i] != 0) | ||
| 121 | } | 124 | } | ||
| 125 | + | // The 900-wide band split among its columns, no gaps. | |||
| 126 | + | if inBand := min(tc.n-band*3, 3); i != tc.max && p.Rect.W != 900/inBand { | |||
| 127 | + | t.Fatalf("n=%d max=%d column %d width %d, want %d", tc.n, tc.max, i, p.Rect.W, 900/inBand) | |||
| 128 | + | } | |||
| 122 | if i == tc.max && sel != want { | 129 | if i == tc.max && sel != want { | ||
| 123 | t.Fatalf("n=%d max=%d sel %+v, want %+v", tc.n, tc.max, sel, want) | 130 | t.Fatalf("n=%d max=%d sel %+v, want %+v", tc.n, tc.max, sel, want) | ||
| 124 | } | 131 | } | ||