1package core
2
3import "testing"
4
5// With no monitor on that side, move-column-left/right at a cascade band
6// edge does nothing: the column never crosses into the adjacent band.
7// Bands {1 2 3} {4 5}.
8func TestCascadeMoveColumnAtBandEdgeDoesNothing(t *testing.T) {
9 for _, tc := range []struct {
10 name string
11 from WindowID
12 action Action
13 }{
14 {"right from band end", 3, ActionMoveColumnRight},
15 {"left from band start", 4, ActionMoveColumnLeft},
16 {"left from first column", 1, ActionMoveColumnLeft},
17 {"right from last column", 5, ActionMoveColumnRight},
18 } {
19 t.Run(tc.name, func(t *testing.T) {
20 c, w := cascadeMovesCore(t, 5, 3, false)
21 w.FocusID(tc.from)
22 c.applyAction(tc.action)
23 wantColumns(t, w, 1, 2, 3, 4, 5)
24 wantFocus(t, c, "M", tc.from)
25 wantActive(t, c.cur().mon, 0)
26 })
27 }
28}
29
30// Inside a band the column still swaps with its neighbor.
31func TestCascadeMoveColumnInsideBandSwaps(t *testing.T) {
32 c, w := cascadeMovesCore(t, 5, 3, false)
33 w.FocusID(2)
34 c.applyAction(ActionMoveColumnRight)
35 wantColumns(t, w, 1, 3, 2, 4, 5)
36 wantFocus(t, c, "M", 2)
37 c.applyAction(ActionMoveColumnRight)
38 wantColumns(t, w, 1, 3, 2, 4, 5)
39 c.applyAction(ActionMoveColumnLeft)
40 c.applyAction(ActionMoveColumnLeft)
41 wantColumns(t, w, 2, 1, 3, 4, 5)
42 c.applyAction(ActionMoveColumnLeft)
43 wantColumns(t, w, 2, 1, 3, 4, 5)
44}
45
46// A neighbor monitor on the left screen's right side wins over an occupied
47// workspace there: focus-column-right at the band edge goes to the screen.
48func TestCascadeFocusColumnEdgePrefersMonitorOverWorkspace(t *testing.T) {
49 c := layoutCore(0, tile{"L", 0, 0, 900, 600}, tile{"R", 900, 0, 900, 600})
50 m := c.cur().mon
51 m.SetOverflow(OverflowCascade)
52 m.SetMaxColumns(3)
53 m.AddWindow(1)
54 m.AddWindow(2)
55 m.Focus(1)
56 m.AddWindow(3) // an occupied workspace to the right on L
57 m.Focus(0)
58 m.normalize()
59 m.Current().FocusID(2)
60 c.applyAction(ActionFocusColumnRight)
61 wantFocus(t, c, "R", 0)
62 wantActive(t, m, 0)
63}
64
65// With no monitor on that side, the occupied neighbor workspace is next.
66func TestCascadeFocusColumnEdgeSwitchesToOccupiedWorkspace(t *testing.T) {
67 c := layoutCore(0, tile{"M", 0, 0, 900, 600})
68 m := c.cur().mon
69 m.SetOverflow(OverflowCascade)
70 m.SetMaxColumns(3)
71 m.AddWindow(1)
72 m.AddWindow(2)
73 m.Focus(1)
74 m.AddWindow(3)
75 m.Focus(0)
76 m.normalize()
77 m.Current().FocusID(2)
78 c.applyAction(ActionFocusColumnRight)
79 wantActive(t, m, 1)
80 wantFocus(t, c, "M", 3)
81}