Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/quick_tiling_test.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 111 | { | |||
---|---|---|---|---|---|
112 | Test::destroyWaylandConnection(); | 112 | Test::destroyWaylandConnection(); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | void QuickTilingTest::testQuickTiling_data() | 115 | void QuickTilingTest::testQuickTiling_data() | ||
116 | { | 116 | { | ||
117 | QTest::addColumn<AbstractClient::QuickTileMode>("mode"); | 117 | QTest::addColumn<AbstractClient::QuickTileMode>("mode"); | ||
118 | QTest::addColumn<QRect>("expectedGeometry"); | 118 | QTest::addColumn<QRect>("expectedGeometry"); | ||
119 | QTest::addColumn<QRect>("secondScreen"); | 119 | QTest::addColumn<QRect>("secondScreen"); | ||
120 | QTest::addColumn<AbstractClient::QuickTileMode>("expectedModeAfterToggle"); | ||||
120 | 121 | | |||
121 | #define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name) | 122 | #define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name) | ||
122 | 123 | | |||
123 | QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024); | 124 | QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right); | ||
124 | QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512); | 125 | QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top); | ||
125 | QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024); | 126 | QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << AbstractClient::QuickTileMode(); | ||
126 | QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << QRect(1280, 512, 1280, 512); | 127 | QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << QRect(1280, 512, 1280, 512) << FLAG(Bottom); | ||
127 | 128 | | |||
128 | QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512); | 129 | QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top)); | ||
129 | QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512); | 130 | QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << AbstractClient::QuickTileMode(); | ||
130 | QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512); | 131 | QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom)); | ||
131 | QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << QRect(1920, 512, 640, 512); | 132 | QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << QRect(1920, 512, 640, 512) << AbstractClient::QuickTileMode(); | ||
132 | 133 | | |||
133 | QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024); | 134 | QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024) << AbstractClient::QuickTileMode(); | ||
134 | 135 | | |||
135 | #undef FLAG | 136 | #undef FLAG | ||
136 | } | 137 | } | ||
137 | 138 | | |||
138 | void QuickTilingTest::testQuickTiling() | 139 | void QuickTilingTest::testQuickTiling() | ||
139 | { | 140 | { | ||
140 | using namespace KWayland::Client; | 141 | using namespace KWayland::Client; | ||
141 | 142 | | |||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
183 | 184 | | |||
184 | // send window to other screen | 185 | // send window to other screen | ||
185 | QCOMPARE(c->screen(), 0); | 186 | QCOMPARE(c->screen(), 0); | ||
186 | c->sendToScreen(1); | 187 | c->sendToScreen(1); | ||
187 | QCOMPARE(c->screen(), 1); | 188 | QCOMPARE(c->screen(), 1); | ||
188 | // quick tile should not be changed | 189 | // quick tile should not be changed | ||
189 | QCOMPARE(c->quickTileMode(), mode); | 190 | QCOMPARE(c->quickTileMode(), mode); | ||
190 | QTEST(c->geometry(), "secondScreen"); | 191 | QTEST(c->geometry(), "secondScreen"); | ||
192 | | ||||
193 | // now try to toggle again | ||||
194 | c->setQuickTileMode(mode, true); | ||||
195 | QTEST(c->quickTileMode(), "expectedModeAfterToggle"); | ||||
191 | } | 196 | } | ||
192 | 197 | | |||
193 | void QuickTilingTest::testQuickMaximizing_data() | 198 | void QuickTilingTest::testQuickMaximizing_data() | ||
194 | { | 199 | { | ||
195 | QTest::addColumn<AbstractClient::QuickTileMode>("mode"); | 200 | QTest::addColumn<AbstractClient::QuickTileMode>("mode"); | ||
196 | 201 | | |||
197 | #define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name) | 202 | #define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name) | ||
198 | 203 | | |||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Line(s) | 425 | { | |||
421 | xcb_disconnect(pointer); | 426 | xcb_disconnect(pointer); | ||
422 | } | 427 | } | ||
423 | }; | 428 | }; | ||
424 | 429 | | |||
425 | void QuickTilingTest::testX11QuickTiling_data() | 430 | void QuickTilingTest::testX11QuickTiling_data() | ||
426 | { | 431 | { | ||
427 | QTest::addColumn<AbstractClient::QuickTileMode>("mode"); | 432 | QTest::addColumn<AbstractClient::QuickTileMode>("mode"); | ||
428 | QTest::addColumn<QRect>("expectedGeometry"); | 433 | QTest::addColumn<QRect>("expectedGeometry"); | ||
434 | QTest::addColumn<int>("screen"); | ||||
435 | QTest::addColumn<AbstractClient::QuickTileMode>("modeAfterToggle"); | ||||
429 | 436 | | |||
430 | #define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name) | 437 | #define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name) | ||
431 | 438 | | |||
432 | QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024); | 439 | QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << 0 << AbstractClient::QuickTileMode(); | ||
433 | QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512); | 440 | QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << 1 << FLAG(Top); | ||
434 | QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024); | 441 | QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << 1 << FLAG(Left); | ||
435 | QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512); | 442 | QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << 1 << FLAG(Bottom); | ||
443 | | ||||
444 | QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << 0 << AbstractClient::QuickTileMode(); | ||||
445 | QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << 1 << (FLAG(Left) | FLAG(Top)); | ||||
446 | QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << 0 << AbstractClient::QuickTileMode(); | ||||
447 | QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << 1 << (FLAG(Left) | FLAG(Bottom)); | ||||
436 | 448 | | |||
437 | QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512); | 449 | QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << 0 << AbstractClient::QuickTileMode(); | ||
438 | QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512); | | |||
439 | QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512); | | |||
440 | QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512); | | |||
441 | | ||||
442 | QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024); | | |||
443 | 450 | | |||
444 | #undef FLAG | 451 | #undef FLAG | ||
445 | } | 452 | } | ||
446 | void QuickTilingTest::testX11QuickTiling() | 453 | void QuickTilingTest::testX11QuickTiling() | ||
447 | { | 454 | { | ||
448 | QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr)); | 455 | QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr)); | ||
449 | QVERIFY(!xcb_connection_has_error(c.data())); | 456 | QVERIFY(!xcb_connection_has_error(c.data())); | ||
450 | const QRect windowGeometry(0, 0, 100, 200); | 457 | const QRect windowGeometry(0, 0, 100, 200); | ||
Show All 27 Lines | |||||
478 | QFETCH(AbstractClient::QuickTileMode, mode); | 485 | QFETCH(AbstractClient::QuickTileMode, mode); | ||
479 | client->setQuickTileMode(mode, true); | 486 | client->setQuickTileMode(mode, true); | ||
480 | QCOMPARE(client->quickTileMode(), mode); | 487 | QCOMPARE(client->quickTileMode(), mode); | ||
481 | QTEST(client->geometry(), "expectedGeometry"); | 488 | QTEST(client->geometry(), "expectedGeometry"); | ||
482 | QCOMPARE(client->geometryRestore(), origGeo); | 489 | QCOMPARE(client->geometryRestore(), origGeo); | ||
483 | QEXPECT_FAIL("maximize", "For maximize we get two changed signals", Continue); | 490 | QEXPECT_FAIL("maximize", "For maximize we get two changed signals", Continue); | ||
484 | QCOMPARE(quickTileChangedSpy.count(), 1); | 491 | QCOMPARE(quickTileChangedSpy.count(), 1); | ||
485 | 492 | | |||
493 | // quick tile to same edge again should also act like send to screen | ||||
494 | QCOMPARE(client->screen(), 0); | ||||
495 | client->setQuickTileMode(mode, true); | ||||
496 | QTEST(client->screen(), "screen"); | ||||
497 | QTEST(client->quickTileMode(), "modeAfterToggle"); | ||||
498 | QCOMPARE(client->geometryRestore(), origGeo); | ||||
499 | | ||||
486 | // and destroy the window again | 500 | // and destroy the window again | ||
487 | xcb_unmap_window(c.data(), w); | 501 | xcb_unmap_window(c.data(), w); | ||
488 | xcb_destroy_window(c.data(), w); | 502 | xcb_destroy_window(c.data(), w); | ||
489 | xcb_flush(c.data()); | 503 | xcb_flush(c.data()); | ||
490 | c.reset(); | 504 | c.reset(); | ||
491 | 505 | | |||
492 | QSignalSpy windowClosedSpy(client, &Client::windowClosed); | 506 | QSignalSpy windowClosedSpy(client, &Client::windowClosed); | ||
493 | QVERIFY(windowClosedSpy.isValid()); | 507 | QVERIFY(windowClosedSpy.isValid()); | ||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |