diff --git a/src/wayland/autotests/client/test_wayland_shell.cpp b/src/wayland/autotests/client/test_wayland_shell.cpp index a30665d494..b4f7d84df7 100644 --- a/src/wayland/autotests/client/test_wayland_shell.cpp +++ b/src/wayland/autotests/client/test_wayland_shell.cpp @@ -46,6 +46,7 @@ private Q_SLOTS: void testPing(); void testTitle(); void testWindowClass(); + void testDestroy(); private: KWayland::Server::Display *m_display; @@ -299,5 +300,33 @@ void TestWaylandShell::testWindowClass() QCOMPARE(windowClassSpy.first().first().toByteArray(), testClass); } +void TestWaylandShell::testDestroy() +{ + using namespace KWayland::Client; + QScopedPointer s(m_compositor->createSurface()); + QVERIFY(!s.isNull()); + QVERIFY(s->isValid()); + ShellSurface *surface = m_shell->createSurface(s.data(), m_shell); + QVERIFY(surface->isValid()); + + connect(m_connection, &ConnectionThread::connectionDied, m_shell, &Shell::destroy); + connect(m_connection, &ConnectionThread::connectionDied, m_compositor, &Compositor::destroy); + connect(m_connection, &ConnectionThread::connectionDied, s.data(), &Surface::destroy); + + QSignalSpy connectionDiedSpy(m_connection, SIGNAL(connectionDied())); + QVERIFY(connectionDiedSpy.isValid()); + delete m_display; + m_display = nullptr; + m_compositorInterface = nullptr; + m_shellInterface = nullptr; + QVERIFY(connectionDiedSpy.wait()); + + QVERIFY(!m_shell->isValid()); + QVERIFY(!surface->isValid()); + + m_shell->destroy(); + surface->destroy(); +} + QTEST_MAIN(TestWaylandShell) #include "test_wayland_shell.moc"