[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.
This commit is contained in:
Martin Gräßlin 2016-07-01 12:37:09 +02:00
parent 2780639936
commit ce74d8a5e5
3 changed files with 19 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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()

View file

@ -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();
}
}
}