From 44a51fef8b4505f46fc2cb04c4c20e744a9b60d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 22 Sep 2014 11:14:05 +0200 Subject: [PATCH] Add test case for Surface::destroy --- .../autotests/client/test_wayland_surface.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/wayland/autotests/client/test_wayland_surface.cpp b/src/wayland/autotests/client/test_wayland_surface.cpp index ea6b14fa7c..e1eb3129fe 100644 --- a/src/wayland/autotests/client/test_wayland_surface.cpp +++ b/src/wayland/autotests/client/test_wayland_surface.cpp @@ -46,6 +46,7 @@ private Q_SLOTS: void testDamage(); void testFrameCallback(); void testAttachBuffer(); + void testDestroy(); private: KWayland::Server::Display *m_display; @@ -343,5 +344,28 @@ void TestWaylandSurface::testAttachBuffer() 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) #include "test_wayland_surface.moc"