Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_surface.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 44 | private Q_SLOTS: | |||
---|---|---|---|---|---|
53 | void testOpaque(); | 53 | void testOpaque(); | ||
54 | void testInput(); | 54 | void testInput(); | ||
55 | void testScale(); | 55 | void testScale(); | ||
56 | void testDestroy(); | 56 | void testDestroy(); | ||
57 | void testUnmapOfNotMappedSurface(); | 57 | void testUnmapOfNotMappedSurface(); | ||
58 | void testDamageTracking(); | 58 | void testDamageTracking(); | ||
59 | void testSurfaceAt(); | 59 | void testSurfaceAt(); | ||
60 | void testDestroyAttachedBuffer(); | 60 | void testDestroyAttachedBuffer(); | ||
61 | void testDisconnect(); | ||||
61 | 62 | | |||
62 | private: | 63 | private: | ||
63 | KWayland::Server::Display *m_display; | 64 | KWayland::Server::Display *m_display; | ||
64 | KWayland::Server::CompositorInterface *m_compositorInterface; | 65 | KWayland::Server::CompositorInterface *m_compositorInterface; | ||
65 | KWayland::Client::ConnectionThread *m_connection; | 66 | KWayland::Client::ConnectionThread *m_connection; | ||
66 | KWayland::Client::Compositor *m_compositor; | 67 | KWayland::Client::Compositor *m_compositor; | ||
67 | KWayland::Client::ShmPool *m_shm; | 68 | KWayland::Client::ShmPool *m_shm; | ||
68 | KWayland::Client::EventQueue *m_queue; | 69 | KWayland::Client::EventQueue *m_queue; | ||
▲ Show 20 Lines • Show All 799 Lines • ▼ Show 20 Line(s) | 839 | { | |||
868 | delete m_shm; | 869 | delete m_shm; | ||
869 | m_shm = nullptr; | 870 | m_shm = nullptr; | ||
870 | QVERIFY(destroySpy.wait()); | 871 | QVERIFY(destroySpy.wait()); | ||
871 | 872 | | |||
872 | // TODO: should this emit unmapped? | 873 | // TODO: should this emit unmapped? | ||
873 | QVERIFY(!serverSurface->buffer()); | 874 | QVERIFY(!serverSurface->buffer()); | ||
874 | } | 875 | } | ||
875 | 876 | | |||
877 | void TestWaylandSurface::testDisconnect() | ||||
878 | { | ||||
879 | // this test verifies that the server side correctly tears down the resources when the client disconnects | ||||
880 | using namespace KWayland::Client; | ||||
881 | using namespace KWayland::Server; | ||||
882 | QScopedPointer<Surface> s(m_compositor->createSurface()); | ||||
883 | QVERIFY(!s.isNull()); | ||||
884 | QVERIFY(s->isValid()); | ||||
885 | QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated); | ||||
886 | QVERIFY(surfaceCreatedSpy.isValid()); | ||||
887 | QVERIFY(surfaceCreatedSpy.wait()); | ||||
888 | auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface*>(); | ||||
889 | QVERIFY(serverSurface); | ||||
890 | | ||||
891 | // destroy client | ||||
892 | QSignalSpy clientDisconnectedSpy(serverSurface->client(), &ClientConnection::disconnected); | ||||
893 | QVERIFY(clientDisconnectedSpy.isValid()); | ||||
894 | QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed); | ||||
895 | QVERIFY(surfaceDestroyedSpy.isValid()); | ||||
896 | if (m_connection) { | ||||
897 | m_connection->deleteLater(); | ||||
898 | m_connection = nullptr; | ||||
899 | } | ||||
900 | QVERIFY(clientDisconnectedSpy.wait()); | ||||
901 | QCOMPARE(clientDisconnectedSpy.count(), 1); | ||||
902 | QCOMPARE(surfaceDestroyedSpy.count(), 0); | ||||
903 | QVERIFY(surfaceDestroyedSpy.wait()); | ||||
904 | QCOMPARE(surfaceDestroyedSpy.count(), 1); | ||||
905 | | ||||
906 | s->destroy(); | ||||
907 | m_shm->destroy(); | ||||
908 | m_compositor->destroy(); | ||||
909 | m_queue->destroy(); | ||||
910 | } | ||||
911 | | ||||
876 | QTEST_GUILESS_MAIN(TestWaylandSurface) | 912 | QTEST_GUILESS_MAIN(TestWaylandSurface) | ||
877 | #include "test_wayland_surface.moc" | 913 | #include "test_wayland_surface.moc" |