From ce74d8a5e579069fd4f942efaf5e47bc13c2e981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 1 Jul 2016 12:37:09 +0200 Subject: [PATCH] [autotests] Try to make the move_resize_window_test more robust On build.kde.org it's failing due to Windows being still present in the next test method. This change tries to destroy them in the test methods. --- autotests/integration/kwin_wayland_test.h | 6 ++++++ autotests/integration/move_resize_window_test.cpp | 4 ++++ autotests/integration/test_helpers.cpp | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/autotests/integration/kwin_wayland_test.h b/autotests/integration/kwin_wayland_test.h index 320efafa91..a567257491 100644 --- a/autotests/integration/kwin_wayland_test.h +++ b/autotests/integration/kwin_wayland_test.h @@ -45,6 +45,7 @@ class Surface; namespace KWin { +class AbstractClient; class ShellClient; class WaylandTestApplication : public Application @@ -129,6 +130,11 @@ ShellClient *waitForWaylandWindowShown(int timeout = 5000); * Combination of @link{render} and @link{waitForWaylandWindowShown}. **/ ShellClient *renderAndWaitForShown(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32, int timeout = 5000); + +/** + * Waits for the @p client to be destroyed. + **/ +bool waitForWindowDestroyed(AbstractClient *client); } } diff --git a/autotests/integration/move_resize_window_test.cpp b/autotests/integration/move_resize_window_test.cpp index c1db4501be..07cbb7ae36 100644 --- a/autotests/integration/move_resize_window_test.cpp +++ b/autotests/integration/move_resize_window_test.cpp @@ -180,6 +180,8 @@ void MoveResizeWindowTest::testMove() QCOMPARE(c->geometry(), QRect(16, 32, 100, 50)); QCOMPARE(c->isMove(), false); QVERIFY(workspace()->getMovingClient() == nullptr); + surface.reset(); + QVERIFY(Test::waitForWindowDestroyed(c)); } void MoveResizeWindowTest::testPackTo_data() @@ -218,6 +220,8 @@ void MoveResizeWindowTest::testPackTo() QFETCH(QString, methodCall); QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); QTEST(c->geometry(), "expectedGeometry"); + surface.reset(); + QVERIFY(Test::waitForWindowDestroyed(c)); } void MoveResizeWindowTest::testPackAgainstClient_data() diff --git a/autotests/integration/test_helpers.cpp b/autotests/integration/test_helpers.cpp index 417debb4d9..7fb61862a6 100644 --- a/autotests/integration/test_helpers.cpp +++ b/autotests/integration/test_helpers.cpp @@ -305,5 +305,14 @@ ShellSurface *createShellSurface(Surface *surface, QObject *parent) return s; } +bool waitForWindowDestroyed(AbstractClient *client) +{ + QSignalSpy destroyedSpy(client, &QObject::destroyed); + if (!destroyedSpy.isValid()) { + return false; + } + return destroyedSpy.wait(); +} + } }