Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/quick_tiling_test.cpp
Show All 22 Lines | |||||
23 | #include "client.h" | 23 | #include "client.h" | ||
24 | #include "cursor.h" | 24 | #include "cursor.h" | ||
25 | #include "screens.h" | 25 | #include "screens.h" | ||
26 | #include "wayland_server.h" | 26 | #include "wayland_server.h" | ||
27 | #include "workspace.h" | 27 | #include "workspace.h" | ||
28 | #include "shell_client.h" | 28 | #include "shell_client.h" | ||
29 | #include "scripting/scripting.h" | 29 | #include "scripting/scripting.h" | ||
30 | 30 | | |||
31 | #include <KDecoration2/Decoration> | ||||
32 | | ||||
31 | #include <KWayland/Client/connection_thread.h> | 33 | #include <KWayland/Client/connection_thread.h> | ||
32 | #include <KWayland/Client/compositor.h> | 34 | #include <KWayland/Client/compositor.h> | ||
35 | #include <KWayland/Client/server_decoration.h> | ||||
33 | #include <KWayland/Client/shell.h> | 36 | #include <KWayland/Client/shell.h> | ||
34 | #include <KWayland/Client/surface.h> | 37 | #include <KWayland/Client/surface.h> | ||
35 | #include <KWayland/Client/xdgshell.h> | 38 | #include <KWayland/Client/xdgshell.h> | ||
36 | 39 | | |||
37 | #include <QDBusConnection> | 40 | #include <QDBusConnection> | ||
38 | #include <QDBusMessage> | 41 | #include <QDBusMessage> | ||
39 | #include <QDBusPendingCall> | 42 | #include <QDBusPendingCall> | ||
40 | #include <QTemporaryFile> | 43 | #include <QTemporaryFile> | ||
Show All 24 Lines | 62 | private Q_SLOTS: | |||
65 | void testQuickMaximizing_data(); | 68 | void testQuickMaximizing_data(); | ||
66 | void testQuickMaximizing(); | 69 | void testQuickMaximizing(); | ||
67 | void testQuickTilingKeyboardMove_data(); | 70 | void testQuickTilingKeyboardMove_data(); | ||
68 | void testQuickTilingKeyboardMove(); | 71 | void testQuickTilingKeyboardMove(); | ||
69 | void testQuickTilingPointerMove_data(); | 72 | void testQuickTilingPointerMove_data(); | ||
70 | void testQuickTilingPointerMove(); | 73 | void testQuickTilingPointerMove(); | ||
71 | void testQuickTilingPointerMoveXdgShell_data(); | 74 | void testQuickTilingPointerMoveXdgShell_data(); | ||
72 | void testQuickTilingPointerMoveXdgShell(); | 75 | void testQuickTilingPointerMoveXdgShell(); | ||
76 | void testQuickTilingTouchMoveXdgShell_data(); | ||||
77 | void testQuickTilingTouchMoveXdgShell(); | ||||
73 | void testX11QuickTiling_data(); | 78 | void testX11QuickTiling_data(); | ||
74 | void testX11QuickTiling(); | 79 | void testX11QuickTiling(); | ||
75 | void testX11QuickTilingAfterVertMaximize_data(); | 80 | void testX11QuickTilingAfterVertMaximize_data(); | ||
76 | void testX11QuickTilingAfterVertMaximize(); | 81 | void testX11QuickTilingAfterVertMaximize(); | ||
77 | void testShortcut_data(); | 82 | void testShortcut_data(); | ||
78 | void testShortcut(); | 83 | void testShortcut(); | ||
79 | void testScript_data(); | 84 | void testScript_data(); | ||
80 | void testScript(); | 85 | void testScript(); | ||
Show All 29 Lines | 94 | { | |||
110 | QVERIFY(workspaceCreatedSpy.wait()); | 115 | QVERIFY(workspaceCreatedSpy.wait()); | ||
111 | QCOMPARE(screens()->count(), 2); | 116 | QCOMPARE(screens()->count(), 2); | ||
112 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 117 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
113 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 118 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
114 | } | 119 | } | ||
115 | 120 | | |||
116 | void QuickTilingTest::init() | 121 | void QuickTilingTest::init() | ||
117 | { | 122 | { | ||
118 | QVERIFY(Test::setupWaylandConnection()); | 123 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration)); | ||
119 | m_connection = Test::waylandConnection(); | 124 | m_connection = Test::waylandConnection(); | ||
120 | m_compositor = Test::waylandCompositor(); | 125 | m_compositor = Test::waylandCompositor(); | ||
121 | m_shell = Test::waylandShell(); | 126 | m_shell = Test::waylandShell(); | ||
122 | 127 | | |||
123 | screens()->setCurrent(0); | 128 | screens()->setCurrent(0); | ||
124 | } | 129 | } | ||
125 | 130 | | |||
126 | void QuickTilingTest::cleanup() | 131 | void QuickTilingTest::cleanup() | ||
▲ Show 20 Lines • Show All 364 Lines • ▼ Show 20 Line(s) | 459 | { | |||
491 | 496 | | |||
492 | QCOMPARE(quickTileChangedSpy.count(), 1); | 497 | QCOMPARE(quickTileChangedSpy.count(), 1); | ||
493 | QTEST(c->quickTileMode(), "expectedMode"); | 498 | QTEST(c->quickTileMode(), "expectedMode"); | ||
494 | QVERIFY(configureRequestedSpy.wait()); | 499 | QVERIFY(configureRequestedSpy.wait()); | ||
495 | QCOMPARE(configureRequestedSpy.count(), 4); | 500 | QCOMPARE(configureRequestedSpy.count(), 4); | ||
496 | QCOMPARE(false, configureRequestedSpy.last().first().toSize().isEmpty()); | 501 | QCOMPARE(false, configureRequestedSpy.last().first().toSize().isEmpty()); | ||
497 | } | 502 | } | ||
498 | 503 | | |||
504 | void QuickTilingTest::testQuickTilingTouchMoveXdgShell_data() | ||||
505 | { | ||||
506 | QTest::addColumn<QPoint>("targetPos"); | ||||
507 | QTest::addColumn<QuickTileMode>("expectedMode"); | ||||
508 | | ||||
509 | QTest::newRow("topRight") << QPoint(2559, 24) << QuickTileMode(QuickTileFlag::Top | QuickTileFlag::Right); | ||||
510 | QTest::newRow("right") << QPoint(2559, 512) << QuickTileMode(QuickTileFlag::Right); | ||||
511 | QTest::newRow("bottomRight") << QPoint(2559, 1023) << QuickTileMode(QuickTileFlag::Bottom | QuickTileFlag::Right); | ||||
512 | QTest::newRow("bottomLeft") << QPoint(0, 1023) << QuickTileMode(QuickTileFlag::Bottom | QuickTileFlag::Left); | ||||
513 | QTest::newRow("Left") << QPoint(0, 512) << QuickTileMode(QuickTileFlag::Left); | ||||
514 | QTest::newRow("topLeft") << QPoint(0, 24) << QuickTileMode(QuickTileFlag::Top | QuickTileFlag::Left); | ||||
515 | } | ||||
516 | | ||||
517 | void QuickTilingTest::testQuickTilingTouchMoveXdgShell() | ||||
518 | { | ||||
519 | // test verifies that touch on decoration also allows quick tiling | ||||
520 | // see BUG: 390113 | ||||
521 | using namespace KWayland::Client; | ||||
522 | | ||||
523 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
524 | QVERIFY(!surface.isNull()); | ||||
525 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||||
526 | | ||||
527 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellV6Surface(surface.data())); | ||||
528 | QVERIFY(!shellSurface.isNull()); | ||||
529 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
530 | QVERIFY(configureRequestedSpy.isValid()); | ||||
531 | // let's render | ||||
532 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(1000, 50), Qt::blue); | ||||
533 | | ||||
534 | QVERIFY(c); | ||||
535 | QVERIFY(c->isDecorated()); | ||||
536 | const auto decoration = c->decoration(); | ||||
537 | QCOMPARE(workspace()->activeClient(), c); | ||||
538 | QCOMPARE(c->geometry(), QRect(-decoration->borderLeft(), 0, | ||||
539 | 1000 + decoration->borderLeft() + decoration->borderRight(), | ||||
540 | 50 + decoration->borderTop() + decoration->borderBottom())); | ||||
541 | QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None)); | ||||
542 | QCOMPARE(c->maximizeMode(), MaximizeRestore); | ||||
543 | QVERIFY(configureRequestedSpy.wait()); | ||||
544 | QTRY_COMPARE(configureRequestedSpy.count(), 2); | ||||
545 | | ||||
546 | QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged); | ||||
547 | QVERIFY(quickTileChangedSpy.isValid()); | ||||
548 | | ||||
549 | quint32 timestamp = 1; | ||||
550 | kwinApp()->platform()->touchDown(0, QPointF(c->geometry().center().x(), c->geometry().y() + decoration->borderTop() / 2), timestamp++); | ||||
551 | QVERIFY(configureRequestedSpy.wait()); | ||||
552 | QCOMPARE(c, workspace()->getMovingClient()); | ||||
553 | QCOMPARE(configureRequestedSpy.count(), 3); | ||||
554 | | ||||
555 | QFETCH(QPoint, targetPos); | ||||
556 | kwinApp()->platform()->touchMotion(0, targetPos, timestamp++); | ||||
557 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
558 | QVERIFY(!workspace()->getMovingClient()); | ||||
559 | | ||||
560 | QCOMPARE(quickTileChangedSpy.count(), 1); | ||||
561 | QTEST(c->quickTileMode(), "expectedMode"); | ||||
562 | QVERIFY(configureRequestedSpy.wait()); | ||||
563 | QCOMPARE(configureRequestedSpy.count(), 5); | ||||
564 | QCOMPARE(false, configureRequestedSpy.last().first().toSize().isEmpty()); | ||||
565 | } | ||||
566 | | ||||
499 | struct XcbConnectionDeleter | 567 | struct XcbConnectionDeleter | ||
500 | { | 568 | { | ||
501 | static inline void cleanup(xcb_connection_t *pointer) | 569 | static inline void cleanup(xcb_connection_t *pointer) | ||
502 | { | 570 | { | ||
503 | xcb_disconnect(pointer); | 571 | xcb_disconnect(pointer); | ||
504 | } | 572 | } | ||
505 | }; | 573 | }; | ||
506 | 574 | | |||
▲ Show 20 Lines • Show All 330 Lines • Show Last 20 Lines |