Add test case for Registry::destroy

This commit is contained in:
Martin Gräßlin 2014-09-22 11:08:14 +02:00
parent ca3b8b0cec
commit 610e8ce484

View file

@ -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, &registry, &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"