Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/window_selection_test.cpp
Show All 24 Lines | |||||
25 | #include "shell_client.h" | 25 | #include "shell_client.h" | ||
26 | #include "screens.h" | 26 | #include "screens.h" | ||
27 | #include "wayland_server.h" | 27 | #include "wayland_server.h" | ||
28 | #include "workspace.h" | 28 | #include "workspace.h" | ||
29 | 29 | | |||
30 | #include <KWayland/Client/compositor.h> | 30 | #include <KWayland/Client/compositor.h> | ||
31 | #include <KWayland/Client/keyboard.h> | 31 | #include <KWayland/Client/keyboard.h> | ||
32 | #include <KWayland/Client/pointer.h> | 32 | #include <KWayland/Client/pointer.h> | ||
33 | #include <KWayland/Client/shell.h> | | |||
34 | #include <KWayland/Client/seat.h> | 33 | #include <KWayland/Client/seat.h> | ||
35 | #include <KWayland/Client/shm_pool.h> | 34 | #include <KWayland/Client/shm_pool.h> | ||
36 | #include <KWayland/Client/surface.h> | 35 | #include <KWayland/Client/surface.h> | ||
37 | #include <KWayland/Client/touch.h> | 36 | #include <KWayland/Client/touch.h> | ||
38 | 37 | | |||
39 | #include <linux/input.h> | 38 | #include <linux/input.h> | ||
40 | 39 | | |||
41 | using namespace KWin; | 40 | using namespace KWin; | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
94 | { | 93 | { | ||
95 | Test::destroyWaylandConnection(); | 94 | Test::destroyWaylandConnection(); | ||
96 | } | 95 | } | ||
97 | 96 | | |||
98 | void TestWindowSelection::testSelectOnWindowPointer() | 97 | void TestWindowSelection::testSelectOnWindowPointer() | ||
99 | { | 98 | { | ||
100 | // this test verifies window selection through pointer works | 99 | // this test verifies window selection through pointer works | ||
101 | QScopedPointer<Surface> surface(Test::createSurface()); | 100 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
102 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 101 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
103 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | 102 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | ||
104 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | 103 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | ||
105 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | 104 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | ||
106 | QVERIFY(pointerEnteredSpy.isValid()); | 105 | QVERIFY(pointerEnteredSpy.isValid()); | ||
107 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | 106 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | ||
108 | QVERIFY(pointerLeftSpy.isValid()); | 107 | QVERIFY(pointerLeftSpy.isValid()); | ||
109 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 108 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
110 | QVERIFY(keyboardEnteredSpy.isValid()); | 109 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 175 | { | |||
180 | QTest::newRow("keypad enter") << KEY_KPENTER; | 179 | QTest::newRow("keypad enter") << KEY_KPENTER; | ||
181 | QTest::newRow("space") << KEY_SPACE; | 180 | QTest::newRow("space") << KEY_SPACE; | ||
182 | } | 181 | } | ||
183 | 182 | | |||
184 | void TestWindowSelection::testSelectOnWindowKeyboard() | 183 | void TestWindowSelection::testSelectOnWindowKeyboard() | ||
185 | { | 184 | { | ||
186 | // this test verifies window selection through keyboard key | 185 | // this test verifies window selection through keyboard key | ||
187 | QScopedPointer<Surface> surface(Test::createSurface()); | 186 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
188 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 187 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
189 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | 188 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | ||
190 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | 189 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | ||
191 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | 190 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | ||
192 | QVERIFY(pointerEnteredSpy.isValid()); | 191 | QVERIFY(pointerEnteredSpy.isValid()); | ||
193 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | 192 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | ||
194 | QVERIFY(pointerLeftSpy.isValid()); | 193 | QVERIFY(pointerLeftSpy.isValid()); | ||
195 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 194 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
196 | QVERIFY(keyboardEnteredSpy.isValid()); | 195 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
257 | { | 256 | { | ||
258 | // this test verifies window selection through touch | 257 | // this test verifies window selection through touch | ||
259 | QScopedPointer<Touch> touch(Test::waylandSeat()->createTouch()); | 258 | QScopedPointer<Touch> touch(Test::waylandSeat()->createTouch()); | ||
260 | QSignalSpy touchStartedSpy(touch.data(), &Touch::sequenceStarted); | 259 | QSignalSpy touchStartedSpy(touch.data(), &Touch::sequenceStarted); | ||
261 | QVERIFY(touchStartedSpy.isValid()); | 260 | QVERIFY(touchStartedSpy.isValid()); | ||
262 | QSignalSpy touchCanceledSpy(touch.data(), &Touch::sequenceCanceled); | 261 | QSignalSpy touchCanceledSpy(touch.data(), &Touch::sequenceCanceled); | ||
263 | QVERIFY(touchCanceledSpy.isValid()); | 262 | QVERIFY(touchCanceledSpy.isValid()); | ||
264 | QScopedPointer<Surface> surface(Test::createSurface()); | 263 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
265 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 264 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
266 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 265 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
267 | QVERIFY(client); | 266 | QVERIFY(client); | ||
268 | 267 | | |||
269 | Toplevel *selectedWindow = nullptr; | 268 | Toplevel *selectedWindow = nullptr; | ||
270 | auto callback = [&selectedWindow] (Toplevel *t) { | 269 | auto callback = [&selectedWindow] (Toplevel *t) { | ||
271 | selectedWindow = t; | 270 | selectedWindow = t; | ||
272 | }; | 271 | }; | ||
273 | 272 | | |||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
315 | QCOMPARE(touchStartedSpy.count(), 1); | 314 | QCOMPARE(touchStartedSpy.count(), 1); | ||
316 | QCOMPARE(touchCanceledSpy.count(), 1); | 315 | QCOMPARE(touchCanceledSpy.count(), 1); | ||
317 | } | 316 | } | ||
318 | 317 | | |||
319 | void TestWindowSelection::testCancelOnWindowPointer() | 318 | void TestWindowSelection::testCancelOnWindowPointer() | ||
320 | { | 319 | { | ||
321 | // this test verifies that window selection cancels through right button click | 320 | // this test verifies that window selection cancels through right button click | ||
322 | QScopedPointer<Surface> surface(Test::createSurface()); | 321 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
323 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 322 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
324 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | 323 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | ||
325 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | 324 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | ||
326 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | 325 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | ||
327 | QVERIFY(pointerEnteredSpy.isValid()); | 326 | QVERIFY(pointerEnteredSpy.isValid()); | ||
328 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | 327 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | ||
329 | QVERIFY(pointerLeftSpy.isValid()); | 328 | QVERIFY(pointerLeftSpy.isValid()); | ||
330 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 329 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
331 | QVERIFY(keyboardEnteredSpy.isValid()); | 330 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
374 | QCOMPARE(pointerEnteredSpy.count(), 2); | 373 | QCOMPARE(pointerEnteredSpy.count(), 2); | ||
375 | QCOMPARE(keyboardEnteredSpy.count(), 2); | 374 | QCOMPARE(keyboardEnteredSpy.count(), 2); | ||
376 | } | 375 | } | ||
377 | 376 | | |||
378 | void TestWindowSelection::testCancelOnWindowKeyboard() | 377 | void TestWindowSelection::testCancelOnWindowKeyboard() | ||
379 | { | 378 | { | ||
380 | // this test verifies that cancel window selection through escape key works | 379 | // this test verifies that cancel window selection through escape key works | ||
381 | QScopedPointer<Surface> surface(Test::createSurface()); | 380 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
382 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 381 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
383 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | 382 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | ||
384 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | 383 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | ||
385 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | 384 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | ||
386 | QVERIFY(pointerEnteredSpy.isValid()); | 385 | QVERIFY(pointerEnteredSpy.isValid()); | ||
387 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | 386 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | ||
388 | QVERIFY(pointerLeftSpy.isValid()); | 387 | QVERIFY(pointerLeftSpy.isValid()); | ||
389 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 388 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
390 | QVERIFY(keyboardEnteredSpy.isValid()); | 389 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
433 | QCOMPARE(keyboardEnteredSpy.count(), 2); | 432 | QCOMPARE(keyboardEnteredSpy.count(), 2); | ||
434 | kwinApp()->platform()->keyboardKeyReleased(KEY_ESC, timestamp++); | 433 | kwinApp()->platform()->keyboardKeyReleased(KEY_ESC, timestamp++); | ||
435 | } | 434 | } | ||
436 | 435 | | |||
437 | void TestWindowSelection::testSelectPointPointer() | 436 | void TestWindowSelection::testSelectPointPointer() | ||
438 | { | 437 | { | ||
439 | // this test verifies point selection through pointer works | 438 | // this test verifies point selection through pointer works | ||
440 | QScopedPointer<Surface> surface(Test::createSurface()); | 439 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
441 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 440 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
442 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | 441 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | ||
443 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | 442 | QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard()); | ||
444 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | 443 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | ||
445 | QVERIFY(pointerEnteredSpy.isValid()); | 444 | QVERIFY(pointerEnteredSpy.isValid()); | ||
446 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | 445 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | ||
447 | QVERIFY(pointerLeftSpy.isValid()); | 446 | QVERIFY(pointerLeftSpy.isValid()); | ||
448 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 447 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
449 | QVERIFY(keyboardEnteredSpy.isValid()); | 448 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |