Add test case for Surface::destroy

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

View file

@ -46,6 +46,7 @@ private Q_SLOTS:
void testDamage(); void testDamage();
void testFrameCallback(); void testFrameCallback();
void testAttachBuffer(); void testAttachBuffer();
void testDestroy();
private: private:
KWayland::Server::Display *m_display; KWayland::Server::Display *m_display;
@ -343,5 +344,28 @@ void TestWaylandSurface::testAttachBuffer()
buffer->unref(); buffer->unref();
} }
void TestWaylandSurface::testDestroy()
{
using namespace KWayland::Client;
Surface *s = m_compositor->createSurface();
connect(m_connection, &ConnectionThread::connectionDied, s, &Surface::destroy);
connect(m_connection, &ConnectionThread::connectionDied, m_compositor, &Compositor::destroy);
QVERIFY(s->isValid());
QSignalSpy connectionDiedSpy(m_connection, SIGNAL(connectionDied()));
QVERIFY(connectionDiedSpy.isValid());
delete m_display;
m_display = nullptr;
m_compositorInterface = nullptr;
QVERIFY(connectionDiedSpy.wait());
// now the Surface should be destroyed;
QVERIFY(!s->isValid());
// calling destroy again should not fail
s->destroy();
}
QTEST_MAIN(TestWaylandSurface) QTEST_MAIN(TestWaylandSurface)
#include "test_wayland_surface.moc" #include "test_wayland_surface.moc"