test(wayland): prove dropped gesture commands sent nothing by ordering
- commit
- 12a64100642c36ae097e44248c34d19b4e126dea
- author
- brice · · 2026-10-08 19:54 UTC
- parent
- 034458a
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +14 -4
M internal/adapters/wayland/gestures_test.go +14 -4
| @@ -140,9 +140,13 @@ func TestPointerGestures(t *testing.T) { | |||
| 140 | 140 | quiet(t, c, swipe) | |
| 141 | 141 | quiet(t, c, hold) | |
| 142 | 142 | ||
| 143 | - | // The pointer leaving the window cancels the gesture. | |
| 143 | + | // The pointer leaving the window cancels the gesture. Commands run in | |
| 144 | + | // order: the next pinch event being this begin proves the dropped | |
| 145 | + | // update above sent nothing. | |
| 144 | 146 | commands <- ports.GestureBeginTo{ID: w.ID, Kind: ports.GesturePinch, Fingers: 2, Time: 4000 * 1e6} | |
| 145 | - | next(t, c, pinch) | |
| 147 | + | if ev := next(t, c, pinch); ev[0] != 0 || ev[2] != 4000 { | |
| 148 | + | t.Fatalf("pinch begin %v", ev) | |
| 149 | + | } | |
| 146 | 150 | commands <- ports.PointerFocus{} | |
| 147 | 151 | if ev := next(t, c, pinch); ev[0] != 2 || ev[3] != 1 { | |
| 148 | 152 | t.Fatalf("pinch not cancelled on leave: %v", ev) | |
| @@ -157,6 +161,12 @@ func TestPointerGestures(t *testing.T) { | |||
| 157 | 161 | if ev := next(t, c, hold); ev[0] != 0 || ev[4] != 4 { | |
| 158 | 162 | t.Fatalf("hold begin after release %v", ev) | |
| 159 | 163 | } | |
| 164 | + | // The end after the cancel sent nothing: the next pinch event is this | |
| 165 | + | // begin. | |
| 166 | + | commands <- ports.GestureBeginTo{ID: w.ID, Kind: ports.GesturePinch, Fingers: 2, Time: 6000 * 1e6} | |
| 167 | + | if ev := next(t, c, pinch); ev[0] != 0 || ev[2] != 6000 { | |
| 168 | + | t.Fatalf("pinch begin after cancelled end %v", ev) | |
| 169 | + | } | |
| 160 | 170 | ||
| 161 | 171 | // The client without the pointer saw nothing. | |
| 162 | 172 | quiet(t, other, oSwipe) | |
| @@ -164,8 +174,8 @@ func TestPointerGestures(t *testing.T) { | |||
| 164 | 174 | quiet(t, other, oHold) | |
| 165 | 175 | } | |
| 166 | 176 | ||
| 167 | - | // A window with the pointer but no gesture object gets nothing, and a | |
| 168 | - | // gesture on a window that does not have the pointer is refused. | |
| 177 | + | // A window with the pointer but no gesture object gets gesture commands | |
| 178 | + | // without the server failing or the client being disconnected. | |
| 169 | 179 | func TestPointerGesturesWithoutObjects(t *testing.T) { | |
| 170 | 180 | s, events, commands, dir := lifecycleServer(t) | |
| 171 | 181 | c := protocolClient(t, s, dir) | |
| @@ -140,9 +140,13 @@ func TestPointerGestures(t *testing.T) { | |||||
| 140 | quiet(t, c, swipe) | 140 | quiet(t, c, swipe) | ||
| 141 | quiet(t, c, hold) | 141 | quiet(t, c, hold) | ||
| 142 | 142 | ||||
| 143 | - | // The pointer leaving the window cancels the gesture. | 143 | + | // The pointer leaving the window cancels the gesture. Commands run in |
| 144 | + | // order: the next pinch event being this begin proves the dropped | |||
| 145 | + | // update above sent nothing. | |||
| 144 | commands <- ports.GestureBeginTo{ID: w.ID, Kind: ports.GesturePinch, Fingers: 2, Time: 4000 * 1e6} | 146 | commands <- ports.GestureBeginTo{ID: w.ID, Kind: ports.GesturePinch, Fingers: 2, Time: 4000 * 1e6} | ||
| 145 | - | next(t, c, pinch) | 147 | + | if ev := next(t, c, pinch); ev[0] != 0 || ev[2] != 4000 { |
| 148 | + | t.Fatalf("pinch begin %v", ev) | |||
| 149 | + | } | |||
| 146 | commands <- ports.PointerFocus{} | 150 | commands <- ports.PointerFocus{} | ||
| 147 | if ev := next(t, c, pinch); ev[0] != 2 || ev[3] != 1 { | 151 | if ev := next(t, c, pinch); ev[0] != 2 || ev[3] != 1 { | ||
| 148 | t.Fatalf("pinch not cancelled on leave: %v", ev) | 152 | t.Fatalf("pinch not cancelled on leave: %v", ev) | ||
| @@ -157,6 +161,12 @@ func TestPointerGestures(t *testing.T) { | |||||
| 157 | if ev := next(t, c, hold); ev[0] != 0 || ev[4] != 4 { | 161 | if ev := next(t, c, hold); ev[0] != 0 || ev[4] != 4 { | ||
| 158 | t.Fatalf("hold begin after release %v", ev) | 162 | t.Fatalf("hold begin after release %v", ev) | ||
| 159 | } | 163 | } | ||
| 164 | + | // The end after the cancel sent nothing: the next pinch event is this | |||
| 165 | + | // begin. | |||
| 166 | + | commands <- ports.GestureBeginTo{ID: w.ID, Kind: ports.GesturePinch, Fingers: 2, Time: 6000 * 1e6} | |||
| 167 | + | if ev := next(t, c, pinch); ev[0] != 0 || ev[2] != 6000 { | |||
| 168 | + | t.Fatalf("pinch begin after cancelled end %v", ev) | |||
| 169 | + | } | |||
| 160 | 170 | ||||
| 161 | // The client without the pointer saw nothing. | 171 | // The client without the pointer saw nothing. | ||
| 162 | quiet(t, other, oSwipe) | 172 | quiet(t, other, oSwipe) | ||
| @@ -164,8 +174,8 @@ func TestPointerGestures(t *testing.T) { | |||||
| 164 | quiet(t, other, oHold) | 174 | quiet(t, other, oHold) | ||
| 165 | } | 175 | } | ||
| 166 | 176 | ||||
| 167 | - | // A window with the pointer but no gesture object gets nothing, and a | 177 | + | // A window with the pointer but no gesture object gets gesture commands |
| 168 | - | // gesture on a window that does not have the pointer is refused. | 178 | + | // without the server failing or the client being disconnected. |
| 169 | func TestPointerGesturesWithoutObjects(t *testing.T) { | 179 | func TestPointerGesturesWithoutObjects(t *testing.T) { | ||
| 170 | s, events, commands, dir := lifecycleServer(t) | 180 | s, events, commands, dir := lifecycleServer(t) | ||
| 171 | c := protocolClient(t, s, dir) | 181 | c := protocolClient(t, s, dir) | ||