Changeset View
Changeset View
Standalone View
Standalone View
autotests/wayland/decoration_input_test.cpp
Show All 16 Lines | |||||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "platform.h" | 21 | #include "platform.h" | ||
22 | #include "abstract_client.h" | 22 | #include "abstract_client.h" | ||
23 | #include "cursor.h" | 23 | #include "cursor.h" | ||
24 | #include "pointer_input.h" | 24 | #include "pointer_input.h" | ||
25 | #include "touch_input.h" | ||||
25 | #include "screenedge.h" | 26 | #include "screenedge.h" | ||
26 | #include "screens.h" | 27 | #include "screens.h" | ||
27 | #include "wayland_server.h" | 28 | #include "wayland_server.h" | ||
28 | #include "workspace.h" | 29 | #include "workspace.h" | ||
29 | #include "shell_client.h" | 30 | #include "shell_client.h" | ||
30 | #include <kwineffects.h> | 31 | #include <kwineffects.h> | ||
31 | #include "decorations/decoratedclient.h" | 32 | #include "decorations/decoratedclient.h" | ||
32 | 33 | | |||
Show All 25 Lines | |||||
58 | private Q_SLOTS: | 59 | private Q_SLOTS: | ||
59 | void initTestCase(); | 60 | void initTestCase(); | ||
60 | void init(); | 61 | void init(); | ||
61 | void cleanup(); | 62 | void cleanup(); | ||
62 | void testAxis_data(); | 63 | void testAxis_data(); | ||
63 | void testAxis(); | 64 | void testAxis(); | ||
64 | void testDoubleClick_data(); | 65 | void testDoubleClick_data(); | ||
65 | void testDoubleClick(); | 66 | void testDoubleClick(); | ||
67 | void testDoubleTap_data(); | ||||
68 | void testDoubleTap(); | ||||
66 | void testHover(); | 69 | void testHover(); | ||
67 | void testPressToMove_data(); | 70 | void testPressToMove_data(); | ||
68 | void testPressToMove(); | 71 | void testPressToMove(); | ||
72 | void testTapToMove_data(); | ||||
73 | void testTapToMove(); | ||||
69 | 74 | | |||
70 | private: | 75 | private: | ||
71 | AbstractClient *showWindow(); | 76 | AbstractClient *showWindow(); | ||
72 | KWayland::Client::ConnectionThread *m_connection = nullptr; | 77 | KWayland::Client::ConnectionThread *m_connection = nullptr; | ||
73 | KWayland::Client::Compositor *m_compositor = nullptr; | 78 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
74 | KWayland::Client::ServerSideDecorationManager *m_deco = nullptr; | 79 | KWayland::Client::ServerSideDecorationManager *m_deco = nullptr; | ||
75 | KWayland::Client::Seat *m_seat = nullptr; | 80 | KWayland::Client::Seat *m_seat = nullptr; | ||
76 | KWayland::Client::ShmPool *m_shm = nullptr; | 81 | KWayland::Client::ShmPool *m_shm = nullptr; | ||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Line(s) | 313 | { | |||
339 | PRESS; | 344 | PRESS; | ||
340 | RELEASE; | 345 | RELEASE; | ||
341 | QVERIFY(!c->isOnAllDesktops()); | 346 | QVERIFY(!c->isOnAllDesktops()); | ||
342 | PRESS; | 347 | PRESS; | ||
343 | RELEASE; | 348 | RELEASE; | ||
344 | QVERIFY(c->isOnAllDesktops()); | 349 | QVERIFY(c->isOnAllDesktops()); | ||
345 | } | 350 | } | ||
346 | 351 | | |||
352 | void DecorationInputTest::testDoubleTap_data() | ||||
353 | { | ||||
354 | QTest::addColumn<QPoint>("decoPoint"); | ||||
355 | QTest::addColumn<Qt::WindowFrameSection>("expectedSection"); | ||||
356 | | ||||
357 | QTest::newRow("topLeft") << QPoint(0, 0) << Qt::TopLeftSection; | ||||
358 | QTest::newRow("top") << QPoint(250, 0) << Qt::TopSection; | ||||
359 | QTest::newRow("topRight") << QPoint(499, 0) << Qt::TopRightSection; | ||||
360 | } | ||||
361 | | ||||
362 | void KWin::DecorationInputTest::testDoubleTap() | ||||
363 | { | ||||
364 | AbstractClient *c = showWindow(); | ||||
365 | QVERIFY(c); | ||||
366 | QVERIFY(c->isDecorated()); | ||||
367 | QVERIFY(!c->noBorder()); | ||||
368 | QVERIFY(!c->isOnAllDesktops()); | ||||
369 | quint32 timestamp = 1; | ||||
370 | const QPoint tapPoint(c->geometry().center().x(), c->clientPos().y() / 2); | ||||
371 | | ||||
372 | // double tap | ||||
373 | kwinApp()->platform()->touchDown(0, tapPoint, timestamp++); | ||||
374 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
375 | kwinApp()->platform()->touchDown(0, tapPoint, timestamp++); | ||||
376 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
377 | QVERIFY(c->isOnAllDesktops()); | ||||
378 | // double tap again | ||||
379 | kwinApp()->platform()->touchDown(0, tapPoint, timestamp++); | ||||
380 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
381 | QVERIFY(c->isOnAllDesktops()); | ||||
382 | kwinApp()->platform()->touchDown(0, tapPoint, timestamp++); | ||||
383 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
384 | QVERIFY(!c->isOnAllDesktops()); | ||||
385 | | ||||
386 | // test top most deco pixel, BUG: 362860 | ||||
387 | c->move(0, 0); | ||||
388 | QFETCH(QPoint, decoPoint); | ||||
389 | // double click | ||||
390 | kwinApp()->platform()->touchDown(0, decoPoint, timestamp++); | ||||
391 | QVERIFY(!input()->touch()->decoration().isNull()); | ||||
392 | QCOMPARE(input()->touch()->decoration()->client(), c); | ||||
393 | QTEST(input()->touch()->decoration()->decoration()->sectionUnderMouse(), "expectedSection"); | ||||
394 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
395 | QVERIFY(!c->isOnAllDesktops()); | ||||
396 | kwinApp()->platform()->touchDown(0, decoPoint, timestamp++); | ||||
397 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
398 | QVERIFY(c->isOnAllDesktops()); | ||||
399 | } | ||||
400 | | ||||
347 | void DecorationInputTest::testHover() | 401 | void DecorationInputTest::testHover() | ||
348 | { | 402 | { | ||
349 | AbstractClient *c = showWindow(); | 403 | AbstractClient *c = showWindow(); | ||
350 | QVERIFY(c); | 404 | QVERIFY(c); | ||
351 | QVERIFY(c->isDecorated()); | 405 | QVERIFY(c->isDecorated()); | ||
352 | QVERIFY(!c->noBorder()); | 406 | QVERIFY(!c->noBorder()); | ||
353 | 407 | | |||
354 | // our left border is moved out of the visible area, so move the window to a better place | 408 | // our left border is moved out of the visible area, so move the window to a better place | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 450 | { | |||
434 | 488 | | |||
435 | RELEASE; | 489 | RELEASE; | ||
436 | QTRY_VERIFY(!c->isMove()); | 490 | QTRY_VERIFY(!c->isMove()); | ||
437 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2); | 491 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2); | ||
438 | // TODO: the offset should also be included | 492 | // TODO: the offset should also be included | ||
439 | QCOMPARE(c->pos(), oldPos + offset2 + offset3); | 493 | QCOMPARE(c->pos(), oldPos + offset2 + offset3); | ||
440 | } | 494 | } | ||
441 | 495 | | |||
496 | void DecorationInputTest::testTapToMove_data() | ||||
497 | { | ||||
498 | QTest::addColumn<QPoint>("offset"); | ||||
499 | QTest::addColumn<QPoint>("offset2"); | ||||
500 | QTest::addColumn<QPoint>("offset3"); | ||||
501 | | ||||
502 | QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0); | ||||
503 | QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0); | ||||
504 | QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30); | ||||
505 | QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30); | ||||
506 | } | ||||
507 | | ||||
508 | void DecorationInputTest::testTapToMove() | ||||
509 | { | ||||
510 | AbstractClient *c = showWindow(); | ||||
511 | QVERIFY(c); | ||||
512 | QVERIFY(c->isDecorated()); | ||||
513 | QVERIFY(!c->noBorder()); | ||||
514 | c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); | ||||
515 | QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized); | ||||
516 | QVERIFY(startMoveResizedSpy.isValid()); | ||||
517 | QSignalSpy clientFinishUserMovedResizedSpy(c, &AbstractClient::clientFinishUserMovedResized); | ||||
518 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
519 | | ||||
520 | quint32 timestamp = 1; | ||||
521 | QPoint p = QPoint(c->geometry().center().x(), c->y() + c->clientPos().y() / 2); | ||||
522 | | ||||
523 | kwinApp()->platform()->touchDown(0, p, timestamp++); | ||||
524 | QVERIFY(!c->isMove()); | ||||
525 | QFETCH(QPoint, offset); | ||||
526 | QCOMPARE(input()->touch()->decorationPressId(), 0); | ||||
527 | kwinApp()->platform()->touchMotion(0, p + offset, timestamp++); | ||||
528 | const QPoint oldPos = c->pos(); | ||||
529 | QVERIFY(c->isMove()); | ||||
530 | QCOMPARE(startMoveResizedSpy.count(), 1); | ||||
531 | | ||||
532 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
533 | QTRY_VERIFY(!c->isMove()); | ||||
534 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1); | ||||
535 | QEXPECT_FAIL("", "Just trigger move doesn't move the window", Continue); | ||||
536 | QCOMPARE(c->pos(), oldPos + offset); | ||||
537 | | ||||
538 | // again | ||||
539 | kwinApp()->platform()->touchDown(1, p + offset, timestamp++); | ||||
540 | QCOMPARE(input()->touch()->decorationPressId(), 1); | ||||
541 | QVERIFY(!c->isMove()); | ||||
542 | QFETCH(QPoint, offset2); | ||||
543 | kwinApp()->platform()->touchMotion(1, QPoint(c->geometry().center().x(), c->y() + c->clientPos().y() / 2) + offset2, timestamp++); | ||||
544 | QVERIFY(c->isMove()); | ||||
545 | QCOMPARE(startMoveResizedSpy.count(), 2); | ||||
546 | QFETCH(QPoint, offset3); | ||||
547 | kwinApp()->platform()->touchMotion(1, QPoint(c->geometry().center().x(), c->y() + c->clientPos().y() / 2) + offset3, timestamp++); | ||||
548 | | ||||
549 | kwinApp()->platform()->touchUp(1, timestamp++); | ||||
550 | QTRY_VERIFY(!c->isMove()); | ||||
551 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2); | ||||
552 | // TODO: the offset should also be included | ||||
553 | QCOMPARE(c->pos(), oldPos + offset2 + offset3); | ||||
554 | } | ||||
555 | | ||||
442 | } | 556 | } | ||
443 | 557 | | |||
444 | WAYLANDTEST_MAIN(KWin::DecorationInputTest) | 558 | WAYLANDTEST_MAIN(KWin::DecorationInputTest) | ||
445 | #include "decoration_input_test.moc" | 559 | #include "decoration_input_test.moc" |