From 610e8ce4842ec5a103432b2a21e8de1b8cc5f293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 22 Sep 2014 11:08:14 +0200 Subject: [PATCH] Add test case for Registry::destroy --- .../client/test_wayland_registry.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/wayland/autotests/client/test_wayland_registry.cpp b/src/wayland/autotests/client/test_wayland_registry.cpp index 5870194bb5..54aa9a5601 100644 --- a/src/wayland/autotests/client/test_wayland_registry.cpp +++ b/src/wayland/autotests/client/test_wayland_registry.cpp @@ -46,6 +46,7 @@ private Q_SLOTS: void testBindShm(); void testBindSeat(); void testRemoval(); + void testDestroy(); private: KWayland::Server::Display *m_display; @@ -243,5 +244,35 @@ void TestWaylandRegistry::testRemoval() // cannot test shmRemoved as there is no functionality for it } +void TestWaylandRegistry::testDestroy() +{ + using namespace KWayland::Client; + KWayland::Client::ConnectionThread connection; + QSignalSpy connectedSpy(&connection, SIGNAL(connected())); + connection.setSocketName(s_socketName); + connection.initConnection(); + QVERIFY(connectedSpy.wait()); + + Registry registry; + QVERIFY(!registry.isValid()); + registry.create(connection.display()); + registry.setup(); + QVERIFY(registry.isValid()); + + connect(&connection, &ConnectionThread::connectionDied, ®istry, &Registry::destroy); + + QSignalSpy connectionDiedSpy(&connection, SIGNAL(connectionDied())); + QVERIFY(connectionDiedSpy.isValid()); + delete m_display; + m_display = nullptr; + QVERIFY(connectionDiedSpy.wait()); + + // now the registry should be destroyed; + QVERIFY(!registry.isValid()); + + // calling destroy again should not fail + registry.destroy(); +} + QTEST_MAIN(TestWaylandRegistry) #include "test_wayland_registry.moc"