Add test case for Registry::destroy
This commit is contained in:
parent
ca3b8b0cec
commit
610e8ce484
1 changed files with 31 additions and 0 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue