From bf1168db23876011cd55ca8699c197e977ccf7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 22 Sep 2014 11:33:13 +0200 Subject: [PATCH] Add test case for ShellSurface::destroy --- .../autotests/client/test_wayland_shell.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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"