Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_shell.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 47 | private Q_SLOTS: | |||
---|---|---|---|---|---|
58 | void testPing(); | 58 | void testPing(); | ||
59 | void testTitle(); | 59 | void testTitle(); | ||
60 | void testWindowClass(); | 60 | void testWindowClass(); | ||
61 | void testDestroy(); | 61 | void testDestroy(); | ||
62 | void testCast(); | 62 | void testCast(); | ||
63 | void testMove(); | 63 | void testMove(); | ||
64 | void testResize_data(); | 64 | void testResize_data(); | ||
65 | void testResize(); | 65 | void testResize(); | ||
66 | void testDisconnect(); | ||||
66 | 67 | | |||
67 | private: | 68 | private: | ||
68 | KWayland::Server::Display *m_display; | 69 | KWayland::Server::Display *m_display; | ||
69 | KWayland::Server::CompositorInterface *m_compositorInterface; | 70 | KWayland::Server::CompositorInterface *m_compositorInterface; | ||
70 | KWayland::Server::ShellInterface *m_shellInterface; | 71 | KWayland::Server::ShellInterface *m_shellInterface; | ||
71 | KWayland::Server::SeatInterface *m_seatInterface; | 72 | KWayland::Server::SeatInterface *m_seatInterface; | ||
72 | KWayland::Client::ConnectionThread *m_connection; | 73 | KWayland::Client::ConnectionThread *m_connection; | ||
73 | KWayland::Client::Compositor *m_compositor; | 74 | KWayland::Client::Compositor *m_compositor; | ||
▲ Show 20 Lines • Show All 622 Lines • ▼ Show 20 Line(s) | 673 | { | |||
696 | surface->requestResize(m_seat, pointerButtonChangedSpy.first().first().value<quint32>(), resizeEdge); | 697 | surface->requestResize(m_seat, pointerButtonChangedSpy.first().first().value<quint32>(), resizeEdge); | ||
697 | QVERIFY(resizeRequestedSpy.wait()); | 698 | QVERIFY(resizeRequestedSpy.wait()); | ||
698 | QCOMPARE(resizeRequestedSpy.count(), 1); | 699 | QCOMPARE(resizeRequestedSpy.count(), 1); | ||
699 | QCOMPARE(resizeRequestedSpy.first().at(0).value<SeatInterface*>(), m_seatInterface); | 700 | QCOMPARE(resizeRequestedSpy.first().at(0).value<SeatInterface*>(), m_seatInterface); | ||
700 | QCOMPARE(resizeRequestedSpy.first().at(1).value<quint32>(), m_seatInterface->pointerButtonSerial(Qt::LeftButton)); | 701 | QCOMPARE(resizeRequestedSpy.first().at(1).value<quint32>(), m_seatInterface->pointerButtonSerial(Qt::LeftButton)); | ||
701 | QTEST(resizeRequestedSpy.first().at(2).value<Qt::Edges>(), "expectedEdge"); | 702 | QTEST(resizeRequestedSpy.first().at(2).value<Qt::Edges>(), "expectedEdge"); | ||
702 | } | 703 | } | ||
703 | 704 | | |||
705 | void TestWaylandShell::testDisconnect() | ||||
706 | { | ||||
707 | // this test verifies that the server side correctly tears down the resources when the client disconnects | ||||
708 | using namespace KWayland::Client; | ||||
709 | using namespace KWayland::Server; | ||||
710 | QScopedPointer<KWayland::Client::Surface> s(m_compositor->createSurface()); | ||||
711 | QVERIFY(!s.isNull()); | ||||
712 | QVERIFY(s->isValid()); | ||||
713 | QScopedPointer<ShellSurface> surface(m_shell->createSurface(s.data(), m_shell)); | ||||
714 | QSignalSpy serverSurfaceSpy(m_shellInterface, &ShellInterface::surfaceCreated); | ||||
715 | QVERIFY(serverSurfaceSpy.isValid()); | ||||
716 | QVERIFY(serverSurfaceSpy.wait()); | ||||
717 | ShellSurfaceInterface *serverSurface = serverSurfaceSpy.first().first().value<ShellSurfaceInterface*>(); | ||||
718 | QVERIFY(serverSurface); | ||||
719 | | ||||
720 | // destroy client | ||||
721 | QSignalSpy clientDisconnectedSpy(serverSurface->client(), &ClientConnection::disconnected); | ||||
722 | QVERIFY(clientDisconnectedSpy.isValid()); | ||||
723 | QSignalSpy shellSurfaceDestroyedSpy(serverSurface, &QObject::destroyed); | ||||
724 | QVERIFY(shellSurfaceDestroyedSpy.isValid()); | ||||
725 | if (m_connection) { | ||||
726 | m_connection->deleteLater(); | ||||
727 | m_connection = nullptr; | ||||
728 | } | ||||
729 | QVERIFY(clientDisconnectedSpy.wait()); | ||||
730 | QCOMPARE(clientDisconnectedSpy.count(), 1); | ||||
731 | QCOMPARE(shellSurfaceDestroyedSpy.count(), 0); | ||||
732 | QVERIFY(shellSurfaceDestroyedSpy.wait()); | ||||
733 | QCOMPARE(shellSurfaceDestroyedSpy.count(), 1); | ||||
734 | | ||||
735 | s->destroy(); | ||||
736 | surface->destroy(); | ||||
737 | m_shell->destroy(); | ||||
738 | m_compositor->destroy(); | ||||
739 | m_pointer->destroy(); | ||||
740 | m_seat->destroy(); | ||||
741 | m_queue->destroy(); | ||||
742 | } | ||||
743 | | ||||
704 | QTEST_GUILESS_MAIN(TestWaylandShell) | 744 | QTEST_GUILESS_MAIN(TestWaylandShell) | ||
705 | #include "test_wayland_shell.moc" | 745 | #include "test_wayland_shell.moc" |