Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/move_resize_window_test.cpp
Show All 30 Lines | |||||
31 | #include "shell_client.h" | 31 | #include "shell_client.h" | ||
32 | #include "deleted.h" | 32 | #include "deleted.h" | ||
33 | 33 | | |||
34 | #include <KWayland/Client/connection_thread.h> | 34 | #include <KWayland/Client/connection_thread.h> | ||
35 | #include <KWayland/Client/compositor.h> | 35 | #include <KWayland/Client/compositor.h> | ||
36 | #include <KWayland/Client/pointer.h> | 36 | #include <KWayland/Client/pointer.h> | ||
37 | #include <KWayland/Client/plasmashell.h> | 37 | #include <KWayland/Client/plasmashell.h> | ||
38 | #include <KWayland/Client/seat.h> | 38 | #include <KWayland/Client/seat.h> | ||
39 | #include <KWayland/Client/shell.h> | | |||
40 | #include <KWayland/Client/xdgshell.h> | 39 | #include <KWayland/Client/xdgshell.h> | ||
41 | #include <KWayland/Client/surface.h> | 40 | #include <KWayland/Client/surface.h> | ||
42 | #include <KWayland/Client/xdgshell.h> | 41 | #include <KWayland/Client/xdgshell.h> | ||
43 | 42 | | |||
44 | #include <linux/input.h> | 43 | #include <linux/input.h> | ||
45 | #include <xcb/xcb_icccm.h> | 44 | #include <xcb/xcb_icccm.h> | ||
46 | 45 | | |||
47 | Q_DECLARE_METATYPE(KWin::QuickTileMode) | 46 | Q_DECLARE_METATYPE(KWin::QuickTileMode) | ||
Show All 36 Lines | 57 | private Q_SLOTS: | |||
84 | void testDestroyMoveClient(); | 83 | void testDestroyMoveClient(); | ||
85 | void testDestroyResizeClient(); | 84 | void testDestroyResizeClient(); | ||
86 | void testUnmapMoveClient(); | 85 | void testUnmapMoveClient(); | ||
87 | void testUnmapResizeClient(); | 86 | void testUnmapResizeClient(); | ||
88 | 87 | | |||
89 | private: | 88 | private: | ||
90 | KWayland::Client::ConnectionThread *m_connection = nullptr; | 89 | KWayland::Client::ConnectionThread *m_connection = nullptr; | ||
91 | KWayland::Client::Compositor *m_compositor = nullptr; | 90 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
92 | KWayland::Client::Shell *m_shell = nullptr; | | |||
93 | }; | 91 | }; | ||
94 | 92 | | |||
95 | void MoveResizeWindowTest::initTestCase() | 93 | void MoveResizeWindowTest::initTestCase() | ||
96 | { | 94 | { | ||
97 | qRegisterMetaType<KWin::AbstractClient *>(); | 95 | qRegisterMetaType<KWin::AbstractClient *>(); | ||
98 | qRegisterMetaType<KWin::Deleted *>(); | 96 | qRegisterMetaType<KWin::Deleted *>(); | ||
99 | qRegisterMetaType<KWin::ShellClient *>(); | 97 | qRegisterMetaType<KWin::ShellClient *>(); | ||
100 | qRegisterMetaType<KWin::MaximizeMode>("MaximizeMode"); | 98 | qRegisterMetaType<KWin::MaximizeMode>("MaximizeMode"); | ||
101 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 99 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
102 | QVERIFY(workspaceCreatedSpy.isValid()); | 100 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
103 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 101 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
104 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 102 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
105 | kwinApp()->start(); | 103 | kwinApp()->start(); | ||
106 | QVERIFY(workspaceCreatedSpy.wait()); | 104 | QVERIFY(workspaceCreatedSpy.wait()); | ||
107 | QCOMPARE(screens()->count(), 1); | 105 | QCOMPARE(screens()->count(), 1); | ||
108 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 106 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
109 | } | 107 | } | ||
110 | 108 | | |||
111 | void MoveResizeWindowTest::init() | 109 | void MoveResizeWindowTest::init() | ||
112 | { | 110 | { | ||
113 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::Seat)); | 111 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::Seat)); | ||
114 | QVERIFY(Test::waitForWaylandPointer()); | 112 | QVERIFY(Test::waitForWaylandPointer()); | ||
115 | m_connection = Test::waylandConnection(); | 113 | m_connection = Test::waylandConnection(); | ||
116 | m_compositor = Test::waylandCompositor(); | 114 | m_compositor = Test::waylandCompositor(); | ||
117 | m_shell = Test::waylandShell(); | | |||
118 | 115 | | |||
119 | screens()->setCurrent(0); | 116 | screens()->setCurrent(0); | ||
120 | } | 117 | } | ||
121 | 118 | | |||
122 | void MoveResizeWindowTest::cleanup() | 119 | void MoveResizeWindowTest::cleanup() | ||
123 | { | 120 | { | ||
124 | Test::destroyWaylandConnection(); | 121 | Test::destroyWaylandConnection(); | ||
125 | } | 122 | } | ||
126 | 123 | | |||
127 | void MoveResizeWindowTest::testMove() | 124 | void MoveResizeWindowTest::testMove() | ||
128 | { | 125 | { | ||
129 | using namespace KWayland::Client; | 126 | using namespace KWayland::Client; | ||
130 | 127 | | |||
131 | QScopedPointer<Surface> surface(Test::createSurface()); | 128 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
132 | QVERIFY(!surface.isNull()); | 129 | QVERIFY(!surface.isNull()); | ||
133 | 130 | | |||
134 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 131 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
135 | QVERIFY(!shellSurface.isNull()); | 132 | QVERIFY(!shellSurface.isNull()); | ||
136 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 133 | QSignalSpy sizeChangeSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | ||
137 | QVERIFY(sizeChangeSpy.isValid()); | 134 | QVERIFY(sizeChangeSpy.isValid()); | ||
138 | // let's render | 135 | // let's render | ||
139 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 136 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
140 | 137 | | |||
141 | QVERIFY(c); | 138 | QVERIFY(c); | ||
142 | QCOMPARE(workspace()->activeClient(), c); | 139 | QCOMPARE(workspace()->activeClient(), c); | ||
143 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | 140 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | ||
144 | QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged); | 141 | QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged); | ||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Line(s) | |||||
349 | 346 | | |||
350 | void MoveResizeWindowTest::testPackTo() | 347 | void MoveResizeWindowTest::testPackTo() | ||
351 | { | 348 | { | ||
352 | using namespace KWayland::Client; | 349 | using namespace KWayland::Client; | ||
353 | 350 | | |||
354 | QScopedPointer<Surface> surface(Test::createSurface()); | 351 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
355 | QVERIFY(!surface.isNull()); | 352 | QVERIFY(!surface.isNull()); | ||
356 | 353 | | |||
357 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 354 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
358 | QVERIFY(!shellSurface.isNull()); | 355 | QVERIFY(!shellSurface.isNull()); | ||
359 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 356 | QSignalSpy sizeChangeSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | ||
360 | QVERIFY(sizeChangeSpy.isValid()); | 357 | QVERIFY(sizeChangeSpy.isValid()); | ||
361 | // let's render | 358 | // let's render | ||
362 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 359 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
363 | 360 | | |||
364 | QVERIFY(c); | 361 | QVERIFY(c); | ||
365 | QCOMPARE(workspace()->activeClient(), c); | 362 | QCOMPARE(workspace()->activeClient(), c); | ||
366 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | 363 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | ||
367 | 364 | | |||
Show All 27 Lines | 388 | { | |||
395 | QVERIFY(!surface1.isNull()); | 392 | QVERIFY(!surface1.isNull()); | ||
396 | QScopedPointer<Surface> surface2(Test::createSurface()); | 393 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
397 | QVERIFY(!surface2.isNull()); | 394 | QVERIFY(!surface2.isNull()); | ||
398 | QScopedPointer<Surface> surface3(Test::createSurface()); | 395 | QScopedPointer<Surface> surface3(Test::createSurface()); | ||
399 | QVERIFY(!surface3.isNull()); | 396 | QVERIFY(!surface3.isNull()); | ||
400 | QScopedPointer<Surface> surface4(Test::createSurface()); | 397 | QScopedPointer<Surface> surface4(Test::createSurface()); | ||
401 | QVERIFY(!surface4.isNull()); | 398 | QVERIFY(!surface4.isNull()); | ||
402 | 399 | | |||
403 | QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data())); | 400 | QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data())); | ||
404 | QVERIFY(!shellSurface1.isNull()); | 401 | QVERIFY(!shellSurface1.isNull()); | ||
405 | QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data())); | 402 | QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data())); | ||
406 | QVERIFY(!shellSurface2.isNull()); | 403 | QVERIFY(!shellSurface2.isNull()); | ||
407 | QScopedPointer<ShellSurface> shellSurface3(Test::createShellSurface(surface3.data())); | 404 | QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data())); | ||
408 | QVERIFY(!shellSurface3.isNull()); | 405 | QVERIFY(!shellSurface3.isNull()); | ||
409 | QScopedPointer<ShellSurface> shellSurface4(Test::createShellSurface(surface4.data())); | 406 | QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data())); | ||
410 | QVERIFY(!shellSurface4.isNull()); | 407 | QVERIFY(!shellSurface4.isNull()); | ||
411 | auto renderWindow = [this] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { | 408 | auto renderWindow = [this] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { | ||
412 | // let's render | 409 | // let's render | ||
413 | auto c = Test::renderAndWaitForShown(surface, QSize(10, 10), Qt::blue); | 410 | auto c = Test::renderAndWaitForShown(surface, QSize(10, 10), Qt::blue); | ||
414 | 411 | | |||
415 | QVERIFY(c); | 412 | QVERIFY(c); | ||
416 | QCOMPARE(workspace()->activeClient(), c); | 413 | QCOMPARE(workspace()->activeClient(), c); | ||
417 | QCOMPARE(c->geometry().size(), QSize(10, 10)); | 414 | QCOMPARE(c->geometry().size(), QSize(10, 10)); | ||
418 | // let's place it centered | 415 | // let's place it centered | ||
419 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | 416 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | ||
420 | QCOMPARE(c->geometry(), QRect(635, 507, 10, 10)); | 417 | QCOMPARE(c->geometry(), QRect(635, 507, 10, 10)); | ||
421 | QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); | 418 | QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); | ||
422 | QCOMPARE(c->geometry(), expectedGeometry); | 419 | QCOMPARE(c->geometry(), expectedGeometry); | ||
423 | }; | 420 | }; | ||
424 | renderWindow(surface1.data(), QStringLiteral("slotWindowPackLeft"), QRect(0, 507, 10, 10)); | 421 | renderWindow(surface1.data(), QStringLiteral("slotWindowPackLeft"), QRect(0, 507, 10, 10)); | ||
425 | renderWindow(surface2.data(), QStringLiteral("slotWindowPackUp"), QRect(635, 0, 10, 10)); | 422 | renderWindow(surface2.data(), QStringLiteral("slotWindowPackUp"), QRect(635, 0, 10, 10)); | ||
426 | renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10)); | 423 | renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10)); | ||
427 | renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10)); | 424 | renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10)); | ||
428 | 425 | | |||
429 | QScopedPointer<Surface> surface(Test::createSurface()); | 426 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
430 | QVERIFY(!surface.isNull()); | 427 | QVERIFY(!surface.isNull()); | ||
431 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 428 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
432 | QVERIFY(!shellSurface.isNull()); | 429 | QVERIFY(!shellSurface.isNull()); | ||
433 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 430 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
434 | 431 | | |||
435 | QVERIFY(c); | 432 | QVERIFY(c); | ||
436 | QCOMPARE(workspace()->activeClient(), c); | 433 | QCOMPARE(workspace()->activeClient(), c); | ||
437 | // let's place it centered | 434 | // let's place it centered | ||
438 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | 435 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | ||
439 | QCOMPARE(c->geometry(), QRect(590, 487, 100, 50)); | 436 | QCOMPARE(c->geometry(), QRect(590, 487, 100, 50)); | ||
Show All 16 Lines | |||||
456 | 453 | | |||
457 | void MoveResizeWindowTest::testGrowShrink() | 454 | void MoveResizeWindowTest::testGrowShrink() | ||
458 | { | 455 | { | ||
459 | using namespace KWayland::Client; | 456 | using namespace KWayland::Client; | ||
460 | 457 | | |||
461 | // block geometry helper | 458 | // block geometry helper | ||
462 | QScopedPointer<Surface> surface1(Test::createSurface()); | 459 | QScopedPointer<Surface> surface1(Test::createSurface()); | ||
463 | QVERIFY(!surface1.isNull()); | 460 | QVERIFY(!surface1.isNull()); | ||
464 | QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data())); | 461 | QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data())); | ||
465 | QVERIFY(!shellSurface1.isNull()); | 462 | QVERIFY(!shellSurface1.isNull()); | ||
466 | Test::render(surface1.data(), QSize(650, 514), Qt::blue); | 463 | Test::render(surface1.data(), QSize(650, 514), Qt::blue); | ||
467 | QVERIFY(Test::waitForWaylandWindowShown()); | 464 | QVERIFY(Test::waitForWaylandWindowShown()); | ||
468 | workspace()->slotWindowPackRight(); | 465 | workspace()->slotWindowPackRight(); | ||
469 | workspace()->slotWindowPackDown(); | 466 | workspace()->slotWindowPackDown(); | ||
470 | 467 | | |||
471 | QScopedPointer<Surface> surface(Test::createSurface()); | 468 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
472 | QVERIFY(!surface.isNull()); | 469 | QVERIFY(!surface.isNull()); | ||
473 | 470 | | |||
474 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 471 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
475 | QVERIFY(!shellSurface.isNull()); | 472 | QVERIFY(!shellSurface.isNull()); | ||
476 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 473 | QSignalSpy sizeChangeSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | ||
477 | QVERIFY(sizeChangeSpy.isValid()); | 474 | QVERIFY(sizeChangeSpy.isValid()); | ||
478 | // let's render | 475 | // let's render | ||
479 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 476 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
480 | 477 | | |||
481 | QVERIFY(c); | 478 | QVERIFY(c); | ||
482 | QCOMPARE(workspace()->activeClient(), c); | 479 | QCOMPARE(workspace()->activeClient(), c); | ||
483 | 480 | | |||
484 | // let's place it centered | 481 | // let's place it centered | ||
Show All 31 Lines | |||||
516 | void MoveResizeWindowTest::testPointerMoveEnd() | 513 | void MoveResizeWindowTest::testPointerMoveEnd() | ||
517 | { | 514 | { | ||
518 | // this test verifies that moving a window through pointer only ends if all buttons are released | 515 | // this test verifies that moving a window through pointer only ends if all buttons are released | ||
519 | using namespace KWayland::Client; | 516 | using namespace KWayland::Client; | ||
520 | 517 | | |||
521 | QScopedPointer<Surface> surface(Test::createSurface()); | 518 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
522 | QVERIFY(!surface.isNull()); | 519 | QVERIFY(!surface.isNull()); | ||
523 | 520 | | |||
524 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 521 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
525 | QVERIFY(!shellSurface.isNull()); | 522 | QVERIFY(!shellSurface.isNull()); | ||
526 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 523 | QSignalSpy sizeChangeSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | ||
527 | QVERIFY(sizeChangeSpy.isValid()); | 524 | QVERIFY(sizeChangeSpy.isValid()); | ||
528 | // let's render | 525 | // let's render | ||
529 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 526 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
530 | 527 | | |||
531 | QVERIFY(c); | 528 | QVERIFY(c); | ||
532 | QCOMPARE(c, workspace()->activeClient()); | 529 | QCOMPARE(c, workspace()->activeClient()); | ||
533 | QVERIFY(!c->isMove()); | 530 | QVERIFY(!c->isMove()); | ||
534 | 531 | | |||
Show All 16 Lines | |||||
551 | // but releasing the other button should now end moving | 548 | // but releasing the other button should now end moving | ||
552 | kwinApp()->platform()->pointerButtonReleased(additionalButton, timestamp++); | 549 | kwinApp()->platform()->pointerButtonReleased(additionalButton, timestamp++); | ||
553 | QVERIFY(!c->isMove()); | 550 | QVERIFY(!c->isMove()); | ||
554 | surface.reset(); | 551 | surface.reset(); | ||
555 | QVERIFY(Test::waitForWindowDestroyed(c)); | 552 | QVERIFY(Test::waitForWindowDestroyed(c)); | ||
556 | } | 553 | } | ||
557 | void MoveResizeWindowTest::testClientSideMove_data() | 554 | void MoveResizeWindowTest::testClientSideMove_data() | ||
558 | { | 555 | { | ||
559 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 556 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
560 | 557 | | |||
561 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 558 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
562 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 559 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
563 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 560 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
564 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
565 | } | 561 | } | ||
566 | 562 | | |||
567 | void MoveResizeWindowTest::testClientSideMove() | 563 | void MoveResizeWindowTest::testClientSideMove() | ||
568 | { | 564 | { | ||
569 | using namespace KWayland::Client; | 565 | using namespace KWayland::Client; | ||
570 | Cursor::setPos(640, 512); | 566 | Cursor::setPos(640, 512); | ||
571 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | 567 | QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer()); | ||
572 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | 568 | QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered); | ||
573 | QVERIFY(pointerEnteredSpy.isValid()); | 569 | QVERIFY(pointerEnteredSpy.isValid()); | ||
574 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | 570 | QSignalSpy pointerLeftSpy(pointer.data(), &Pointer::left); | ||
575 | QVERIFY(pointerLeftSpy.isValid()); | 571 | QVERIFY(pointerLeftSpy.isValid()); | ||
576 | QSignalSpy buttonSpy(pointer.data(), &Pointer::buttonStateChanged); | 572 | QSignalSpy buttonSpy(pointer.data(), &Pointer::buttonStateChanged); | ||
577 | QVERIFY(buttonSpy.isValid()); | 573 | QVERIFY(buttonSpy.isValid()); | ||
578 | 574 | | |||
579 | QScopedPointer<Surface> surface(Test::createSurface()); | 575 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
580 | QFETCH(Test::ShellSurfaceType, type); | 576 | QFETCH(Test::XdgShellSurfaceType, type); | ||
581 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 577 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
582 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 578 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
583 | QVERIFY(c); | 579 | QVERIFY(c); | ||
584 | 580 | | |||
585 | // move pointer into center of geometry | 581 | // move pointer into center of geometry | ||
586 | const QRect startGeometry = c->geometry(); | 582 | const QRect startGeometry = c->geometry(); | ||
587 | Cursor::setPos(startGeometry.center()); | 583 | Cursor::setPos(startGeometry.center()); | ||
588 | QVERIFY(pointerEnteredSpy.wait()); | 584 | QVERIFY(pointerEnteredSpy.wait()); | ||
589 | QCOMPARE(pointerEnteredSpy.first().last().toPoint(), QPoint(49, 24)); | 585 | QCOMPARE(pointerEnteredSpy.first().last().toPoint(), QPoint(49, 24)); | ||
590 | // simulate press | 586 | // simulate press | ||
591 | quint32 timestamp = 1; | 587 | quint32 timestamp = 1; | ||
592 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | 588 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||
593 | QVERIFY(buttonSpy.wait()); | 589 | QVERIFY(buttonSpy.wait()); | ||
594 | QSignalSpy moveStartSpy(c, &AbstractClient::clientStartUserMovedResized); | 590 | QSignalSpy moveStartSpy(c, &AbstractClient::clientStartUserMovedResized); | ||
595 | QVERIFY(moveStartSpy.isValid()); | 591 | QVERIFY(moveStartSpy.isValid()); | ||
596 | if (auto s = qobject_cast<ShellSurface*>(shellSurface.data())) { | 592 | shellSurface->requestMove(Test::waylandSeat(), buttonSpy.first().first().value<quint32>()); | ||
597 | s->requestMove(Test::waylandSeat(), buttonSpy.first().first().value<quint32>()); | | |||
598 | } else if (auto s = qobject_cast<XdgShellSurface*>(shellSurface.data())) { | | |||
599 | s->requestMove(Test::waylandSeat(), buttonSpy.first().first().value<quint32>()); | | |||
600 | } | | |||
601 | QVERIFY(moveStartSpy.wait()); | 593 | QVERIFY(moveStartSpy.wait()); | ||
602 | QCOMPARE(c->isMove(), true); | 594 | QCOMPARE(c->isMove(), true); | ||
603 | QVERIFY(pointerLeftSpy.wait()); | 595 | QVERIFY(pointerLeftSpy.wait()); | ||
604 | 596 | | |||
605 | // move a bit | 597 | // move a bit | ||
606 | QSignalSpy clientMoveStepSpy(c, &AbstractClient::clientStepUserMovedResized); | 598 | QSignalSpy clientMoveStepSpy(c, &AbstractClient::clientStepUserMovedResized); | ||
607 | QVERIFY(clientMoveStepSpy.isValid()); | 599 | QVERIFY(clientMoveStepSpy.isValid()); | ||
608 | const QPoint startPoint = startGeometry.center(); | 600 | const QPoint startPoint = startGeometry.center(); | ||
Show All 25 Lines | |||||
634 | 626 | | |||
635 | void MoveResizeWindowTest::testPlasmaShellSurfaceMovable() | 627 | void MoveResizeWindowTest::testPlasmaShellSurfaceMovable() | ||
636 | { | 628 | { | ||
637 | // this test verifies that certain window types from PlasmaShellSurface are not moveable or resizable | 629 | // this test verifies that certain window types from PlasmaShellSurface are not moveable or resizable | ||
638 | using namespace KWayland::Client; | 630 | using namespace KWayland::Client; | ||
639 | QScopedPointer<Surface> surface(Test::createSurface()); | 631 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
640 | QVERIFY(!surface.isNull()); | 632 | QVERIFY(!surface.isNull()); | ||
641 | 633 | | |||
642 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 634 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
643 | QVERIFY(!shellSurface.isNull()); | 635 | QVERIFY(!shellSurface.isNull()); | ||
644 | // and a PlasmaShellSurface | 636 | // and a PlasmaShellSurface | ||
645 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data())); | 637 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data())); | ||
646 | QVERIFY(!plasmaSurface.isNull()); | 638 | QVERIFY(!plasmaSurface.isNull()); | ||
647 | QFETCH(KWayland::Client::PlasmaShellSurface::Role, role); | 639 | QFETCH(KWayland::Client::PlasmaShellSurface::Role, role); | ||
648 | plasmaSurface->setRole(role); | 640 | plasmaSurface->setRole(role); | ||
649 | // let's render | 641 | // let's render | ||
650 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 642 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | 748 | { | |||
785 | QCOMPARE(panel->geometry(), panelGeometry); | 777 | QCOMPARE(panel->geometry(), panelGeometry); | ||
786 | QVERIFY(panel->isDock()); | 778 | QVERIFY(panel->isDock()); | ||
787 | 779 | | |||
788 | // let's create a window | 780 | // let's create a window | ||
789 | using namespace KWayland::Client; | 781 | using namespace KWayland::Client; | ||
790 | QScopedPointer<Surface> surface(Test::createSurface()); | 782 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
791 | QVERIFY(!surface.isNull()); | 783 | QVERIFY(!surface.isNull()); | ||
792 | 784 | | |||
793 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 785 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
794 | QVERIFY(!shellSurface.isNull()); | 786 | QVERIFY(!shellSurface.isNull()); | ||
795 | auto testWindow = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 787 | auto testWindow = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
796 | 788 | | |||
797 | QVERIFY(testWindow); | 789 | QVERIFY(testWindow); | ||
798 | QVERIFY(testWindow->isMovable()); | 790 | QVERIFY(testWindow->isMovable()); | ||
799 | // panel is not yet hidden, we should snap against it | 791 | // panel is not yet hidden, we should snap against it | ||
800 | QFETCH(QPoint, targetPoint); | 792 | QFETCH(QPoint, targetPoint); | ||
801 | QTEST(Workspace::self()->adjustClientPosition(testWindow, targetPoint, false), "expectedAdjustedPoint"); | 793 | QTEST(Workspace::self()->adjustClientPosition(testWindow, targetPoint, false), "expectedAdjustedPoint"); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
848 | { | 840 | { | ||
849 | // this test verifies that auto hiding panels are ignored when adjusting client geometry | 841 | // this test verifies that auto hiding panels are ignored when adjusting client geometry | ||
850 | // see BUG 365892 | 842 | // see BUG 365892 | ||
851 | 843 | | |||
852 | // first create our panel | 844 | // first create our panel | ||
853 | using namespace KWayland::Client; | 845 | using namespace KWayland::Client; | ||
854 | QScopedPointer<Surface> panelSurface(Test::createSurface()); | 846 | QScopedPointer<Surface> panelSurface(Test::createSurface()); | ||
855 | QVERIFY(!panelSurface.isNull()); | 847 | QVERIFY(!panelSurface.isNull()); | ||
856 | QScopedPointer<ShellSurface> panelShellSurface(Test::createShellSurface(panelSurface.data())); | 848 | QScopedPointer<XdgShellSurface> panelShellSurface(Test::createXdgShellStableSurface(panelSurface.data())); | ||
857 | QVERIFY(!panelShellSurface.isNull()); | 849 | QVERIFY(!panelShellSurface.isNull()); | ||
858 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.data())); | 850 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.data())); | ||
859 | QVERIFY(!plasmaSurface.isNull()); | 851 | QVERIFY(!plasmaSurface.isNull()); | ||
860 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 852 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
861 | plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AutoHide); | 853 | plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AutoHide); | ||
862 | QFETCH(QRect, panelGeometry); | 854 | QFETCH(QRect, panelGeometry); | ||
863 | plasmaSurface->setPosition(panelGeometry.topLeft()); | 855 | plasmaSurface->setPosition(panelGeometry.topLeft()); | ||
864 | // let's render | 856 | // let's render | ||
865 | auto panel = Test::renderAndWaitForShown(panelSurface.data(), panelGeometry.size(), Qt::blue); | 857 | auto panel = Test::renderAndWaitForShown(panelSurface.data(), panelGeometry.size(), Qt::blue); | ||
866 | QVERIFY(panel); | 858 | QVERIFY(panel); | ||
867 | QCOMPARE(panel->geometry(), panelGeometry); | 859 | QCOMPARE(panel->geometry(), panelGeometry); | ||
868 | QVERIFY(panel->isDock()); | 860 | QVERIFY(panel->isDock()); | ||
869 | 861 | | |||
870 | // let's create a window | 862 | // let's create a window | ||
871 | QScopedPointer<Surface> surface(Test::createSurface()); | 863 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
872 | QVERIFY(!surface.isNull()); | 864 | QVERIFY(!surface.isNull()); | ||
873 | 865 | | |||
874 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 866 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
875 | QVERIFY(!shellSurface.isNull()); | 867 | QVERIFY(!shellSurface.isNull()); | ||
876 | auto testWindow = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 868 | auto testWindow = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
877 | 869 | | |||
878 | QVERIFY(testWindow); | 870 | QVERIFY(testWindow); | ||
879 | QVERIFY(testWindow->isMovable()); | 871 | QVERIFY(testWindow->isMovable()); | ||
880 | // panel is not yet hidden, we should snap against it | 872 | // panel is not yet hidden, we should snap against it | ||
881 | QFETCH(QPoint, targetPoint); | 873 | QFETCH(QPoint, targetPoint); | ||
882 | QTEST(Workspace::self()->adjustClientPosition(testWindow, targetPoint, false), "expectedAdjustedPoint"); | 874 | QTEST(Workspace::self()->adjustClientPosition(testWindow, targetPoint, false), "expectedAdjustedPoint"); | ||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |