Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_seat.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 57 | private Q_SLOTS: | |||
---|---|---|---|---|---|
70 | void testKeyboardSubSurfaceTreeFromPointer(); | 70 | void testKeyboardSubSurfaceTreeFromPointer(); | ||
71 | void testCursor(); | 71 | void testCursor(); | ||
72 | void testCursorDamage(); | 72 | void testCursorDamage(); | ||
73 | void testKeyboard(); | 73 | void testKeyboard(); | ||
74 | void testCast(); | 74 | void testCast(); | ||
75 | void testDestroy(); | 75 | void testDestroy(); | ||
76 | void testSelection(); | 76 | void testSelection(); | ||
77 | void testTouch(); | 77 | void testTouch(); | ||
78 | void testDisconnect(); | ||||
78 | // TODO: add test for keymap | 79 | // TODO: add test for keymap | ||
79 | 80 | | |||
80 | private: | 81 | private: | ||
81 | KWayland::Server::Display *m_display; | 82 | KWayland::Server::Display *m_display; | ||
82 | KWayland::Server::CompositorInterface *m_compositorInterface; | 83 | KWayland::Server::CompositorInterface *m_compositorInterface; | ||
83 | KWayland::Server::SeatInterface *m_seatInterface; | 84 | KWayland::Server::SeatInterface *m_seatInterface; | ||
84 | KWayland::Server::SubCompositorInterface *m_subCompositorInterface; | 85 | KWayland::Server::SubCompositorInterface *m_subCompositorInterface; | ||
85 | KWayland::Client::ConnectionThread *m_connection; | 86 | KWayland::Client::ConnectionThread *m_connection; | ||
▲ Show 20 Lines • Show All 1444 Lines • ▼ Show 20 Line(s) | 1351 | { | |||
1530 | QCOMPARE(sequenceCanceledSpy.count(), 1); | 1531 | QCOMPARE(sequenceCanceledSpy.count(), 1); | ||
1531 | QCOMPARE(frameEndedSpy.count(), 7); | 1532 | QCOMPARE(frameEndedSpy.count(), 7); | ||
1532 | QCOMPARE(pointAddedSpy.count(), 2); | 1533 | QCOMPARE(pointAddedSpy.count(), 2); | ||
1533 | QCOMPARE(pointMovedSpy.count(), 1); | 1534 | QCOMPARE(pointMovedSpy.count(), 1); | ||
1534 | QCOMPARE(pointRemovedSpy.count(), 3); | 1535 | QCOMPARE(pointRemovedSpy.count(), 3); | ||
1535 | QCOMPARE(touch->sequence().first()->position(), QPointF(0, 0)); | 1536 | QCOMPARE(touch->sequence().first()->position(), QPointF(0, 0)); | ||
1536 | } | 1537 | } | ||
1537 | 1538 | | |||
1539 | void TestWaylandSeat::testDisconnect() | ||||
1540 | { | ||||
1541 | // this test verifies that disconnecting the client cleans up correctly | ||||
1542 | using namespace KWayland::Client; | ||||
1543 | using namespace KWayland::Server; | ||||
1544 | QSignalSpy keyboardCreatedSpy(m_seatInterface, &SeatInterface::keyboardCreated); | ||||
1545 | QVERIFY(keyboardCreatedSpy.isValid()); | ||||
1546 | QSignalSpy pointerCreatedSpy(m_seatInterface, &SeatInterface::pointerCreated); | ||||
1547 | QVERIFY(pointerCreatedSpy.isValid()); | ||||
1548 | QSignalSpy touchCreatedSpy(m_seatInterface, &SeatInterface::touchCreated); | ||||
1549 | QVERIFY(touchCreatedSpy.isValid()); | ||||
1550 | | ||||
1551 | // create the things we need | ||||
1552 | m_seatInterface->setHasKeyboard(true); | ||||
1553 | m_seatInterface->setHasPointer(true); | ||||
1554 | m_seatInterface->setHasTouch(true); | ||||
1555 | QSignalSpy touchSpy(m_seat, &Seat::hasTouchChanged); | ||||
1556 | QVERIFY(touchSpy.isValid()); | ||||
1557 | QVERIFY(touchSpy.wait()); | ||||
1558 | | ||||
1559 | QScopedPointer<Keyboard> keyboard(m_seat->createKeyboard()); | ||||
1560 | QVERIFY(!keyboard.isNull()); | ||||
1561 | QVERIFY(keyboardCreatedSpy.wait()); | ||||
1562 | auto serverKeyboard = keyboardCreatedSpy.first().first().value<KeyboardInterface*>(); | ||||
1563 | QVERIFY(serverKeyboard); | ||||
1564 | | ||||
1565 | QScopedPointer<Pointer> pointer(m_seat->createPointer()); | ||||
1566 | QVERIFY(!pointer.isNull()); | ||||
1567 | QVERIFY(pointerCreatedSpy.wait()); | ||||
1568 | auto serverPointer = pointerCreatedSpy.first().first().value<PointerInterface*>(); | ||||
1569 | QVERIFY(serverPointer); | ||||
1570 | | ||||
1571 | QScopedPointer<Touch> touch(m_seat->createTouch()); | ||||
1572 | QVERIFY(!touch.isNull()); | ||||
1573 | QVERIFY(touchCreatedSpy.wait()); | ||||
1574 | auto serverTouch = touchCreatedSpy.first().first().value<TouchInterface*>(); | ||||
1575 | QVERIFY(serverTouch); | ||||
1576 | | ||||
1577 | // setup destroys | ||||
1578 | QSignalSpy keyboardDestroyedSpy(serverKeyboard, &QObject::destroyed); | ||||
1579 | QVERIFY(keyboardDestroyedSpy.isValid()); | ||||
1580 | QSignalSpy pointerDestroyedSpy(serverPointer, &QObject::destroyed); | ||||
1581 | QVERIFY(pointerDestroyedSpy.isValid()); | ||||
1582 | QSignalSpy touchDestroyedSpy(serverTouch, &QObject::destroyed); | ||||
1583 | QVERIFY(touchDestroyedSpy.isValid()); | ||||
1584 | QSignalSpy clientDisconnectedSpy(serverKeyboard->client(), &ClientConnection::disconnected); | ||||
1585 | QVERIFY(clientDisconnectedSpy.isValid()); | ||||
1586 | | ||||
1587 | if (m_connection) { | ||||
1588 | m_connection->deleteLater(); | ||||
1589 | m_connection = nullptr; | ||||
1590 | } | ||||
1591 | QVERIFY(clientDisconnectedSpy.wait()); | ||||
1592 | QCOMPARE(clientDisconnectedSpy.count(), 1); | ||||
1593 | QCOMPARE(keyboardDestroyedSpy.count(), 0); | ||||
1594 | QCOMPARE(pointerDestroyedSpy.count(), 0); | ||||
1595 | QCOMPARE(touchDestroyedSpy.count(), 0); | ||||
1596 | QVERIFY(keyboardDestroyedSpy.wait()); | ||||
1597 | QCOMPARE(keyboardDestroyedSpy.count(), 1); | ||||
1598 | QCOMPARE(pointerDestroyedSpy.count(), 1); | ||||
1599 | QCOMPARE(touchDestroyedSpy.count(), 1); | ||||
1600 | | ||||
1601 | keyboard->destroy(); | ||||
1602 | pointer->destroy(); | ||||
1603 | touch->destroy(); | ||||
1604 | m_compositor->destroy(); | ||||
1605 | m_seat->destroy(); | ||||
1606 | m_shm->destroy(); | ||||
1607 | m_subCompositor->destroy(); | ||||
1608 | m_queue->destroy(); | ||||
1609 | } | ||||
1610 | | ||||
1538 | QTEST_GUILESS_MAIN(TestWaylandSeat) | 1611 | QTEST_GUILESS_MAIN(TestWaylandSeat) | ||
1539 | #include "test_wayland_seat.moc" | 1612 | #include "test_wayland_seat.moc" |