[autotest/integration] Add helper for waiting for a shown ShellClient
Summary: Many tests create a Wayland window, render it and then wait till it's created in KWin as a ShellClient. To reduce code duplication the test helper provides helper methods to wait for the next ShellClient to be shown and to directly render and wait for the window for that to be shown. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2057
This commit is contained in:
parent
513878e20d
commit
cf3a1d295c
13 changed files with 86 additions and 197 deletions
|
@ -92,8 +92,6 @@ AbstractClient *DecorationInputTest::showWindow()
|
|||
#define COMPARE(actual, expected) \
|
||||
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
|
||||
return nullptr;
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
VERIFY(clientAddedSpy.isValid());
|
||||
|
||||
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||
VERIFY(surface);
|
||||
|
@ -107,13 +105,9 @@ AbstractClient *DecorationInputTest::showWindow()
|
|||
VERIFY(decoSpy.wait());
|
||||
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
||||
// let's render
|
||||
Test::render(surface, QSize(500, 50), Qt::blue);
|
||||
|
||||
Test::flushWaylandConnection();
|
||||
VERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
auto c = Test::renderAndWaitForShown(surface, QSize(500, 50), Qt::blue);
|
||||
VERIFY(c);
|
||||
COMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
COMPARE(workspace()->activeClient(), c);
|
||||
|
||||
#undef VERIFY
|
||||
#undef COMPARE
|
||||
|
|
|
@ -52,10 +52,6 @@ private Q_SLOTS:
|
|||
void init();
|
||||
void cleanup();
|
||||
void testScript();
|
||||
|
||||
private:
|
||||
void unlock();
|
||||
AbstractClient *showWindow();
|
||||
};
|
||||
|
||||
void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
|
||||
|
@ -101,21 +97,14 @@ void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
|
|||
|
||||
using namespace KWayland::Client;
|
||||
// create a window
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||
QVERIFY(surface);
|
||||
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||
QVERIFY(shellSurface);
|
||||
// let's render
|
||||
Test::render(surface, QSize(100, 50), Qt::blue);
|
||||
|
||||
Test::flushWaylandConnection();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue);
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
|
||||
// make sure we animate
|
||||
QTest::qWait(200);
|
||||
|
|
|
@ -98,8 +98,6 @@ void DontCrashNoBorder::testCreateWindow()
|
|||
{
|
||||
// create a window and ensure that this doesn't crash
|
||||
using namespace KWayland::Client;
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
@ -113,13 +111,9 @@ void DontCrashNoBorder::testCreateWindow()
|
|||
QVERIFY(decoSpy.wait());
|
||||
QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(500, 50), Qt::blue);
|
||||
|
||||
Test::flushWaylandConnection();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(500, 50), Qt::blue);
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QVERIFY(!c->isDecorated());
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ class Surface;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class ShellClient;
|
||||
|
||||
class WaylandTestApplication : public Application
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -116,6 +118,17 @@ KWayland::Client::ShellSurface *createShellSurface(KWayland::Client::Surface *su
|
|||
* The @p surface gets damaged and committed, thus it's rendered.
|
||||
**/
|
||||
void render(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32);
|
||||
|
||||
/**
|
||||
* Waits till a new ShellClient is shown and returns the created ShellClient.
|
||||
* If no ShellClient gets shown during @p timeout @c null is returned.
|
||||
**/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -161,21 +161,16 @@ AbstractClient *LockScreenTest::showWindow()
|
|||
#define COMPARE(actual, expected) \
|
||||
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
|
||||
return nullptr;
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
VERIFY(clientAddedSpy.isValid());
|
||||
|
||||
Surface *surface = Test::createSurface(m_compositor);
|
||||
VERIFY(surface);
|
||||
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||
VERIFY(shellSurface);
|
||||
// let's render
|
||||
Test::render(surface, QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
VERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
VERIFY(c);
|
||||
COMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
COMPARE(workspace()->activeClient(), c);
|
||||
|
||||
#undef VERIFY
|
||||
#undef COMPARE
|
||||
|
|
|
@ -87,20 +87,15 @@ void TestMaximized::cleanup()
|
|||
void TestMaximized::testMaximizedPassedToDeco()
|
||||
{
|
||||
// this test verifies that when a ShellClient gets maximized the Decoration receives the signal
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||
QScopedPointer<ServerSideDecoration> ssd(Test::waylandServerSideDecoration()->create(surface.data()));
|
||||
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangedSpy.isValid());
|
||||
|
||||
QVERIFY(clientAddedSpy.isEmpty());
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
auto client = clientAddedSpy.first().first().value<ShellClient*>();
|
||||
QVERIFY(client);
|
||||
QVERIFY(client->isDecorated());
|
||||
auto decoration = client->decoration();
|
||||
|
@ -147,9 +142,6 @@ void TestMaximized::testMaximizedPassedToDeco()
|
|||
void TestMaximized::testInitiallyMaximized()
|
||||
{
|
||||
// this test verifies that a window created as maximized, will be maximized
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||
|
||||
|
@ -161,11 +153,7 @@ void TestMaximized::testInitiallyMaximized()
|
|||
QCOMPARE(shellSurface->size(), QSize(1280, 1024));
|
||||
|
||||
// now let's render in an incorrect size
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
QVERIFY(clientAddedSpy.isEmpty());
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
auto client = clientAddedSpy.first().first().value<ShellClient*>();
|
||||
auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(client);
|
||||
QCOMPARE(client->geometry(), QRect(0, 0, 100, 50));
|
||||
QEXPECT_FAIL("", "Should go out of maximzied", Continue);
|
||||
|
|
|
@ -105,9 +105,6 @@ void MoveResizeWindowTest::testMove()
|
|||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -116,13 +113,10 @@ void MoveResizeWindowTest::testMove()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
|
||||
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged);
|
||||
QVERIFY(geometryChangedSpy.isValid());
|
||||
|
@ -203,9 +197,6 @@ void MoveResizeWindowTest::testPackTo()
|
|||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -214,13 +205,10 @@ void MoveResizeWindowTest::testPackTo()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
|
||||
|
||||
// let's place it centered
|
||||
|
@ -247,9 +235,6 @@ void MoveResizeWindowTest::testPackAgainstClient()
|
|||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface1(Test::createSurface());
|
||||
QVERIFY(!surface1.isNull());
|
||||
QScopedPointer<Surface> surface2(Test::createSurface());
|
||||
|
@ -267,17 +252,13 @@ void MoveResizeWindowTest::testPackAgainstClient()
|
|||
QVERIFY(!shellSurface3.isNull());
|
||||
QScopedPointer<ShellSurface> shellSurface4(Test::createShellSurface(surface4.data()));
|
||||
QVERIFY(!shellSurface4.isNull());
|
||||
auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
|
||||
auto renderWindow = [this] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
|
||||
// let's render
|
||||
Test::render(surface, QSize(10, 10), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface, QSize(10, 10), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QCOMPARE(c->geometry().size(), QSize(10, 10));
|
||||
clientAddedSpy.clear();
|
||||
// let's place it centered
|
||||
Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024));
|
||||
QCOMPARE(c->geometry(), QRect(635, 507, 10, 10));
|
||||
|
@ -293,13 +274,10 @@ void MoveResizeWindowTest::testPackAgainstClient()
|
|||
QVERIFY(!surface.isNull());
|
||||
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||
QVERIFY(!shellSurface.isNull());
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
// let's place it centered
|
||||
Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024));
|
||||
QCOMPARE(c->geometry(), QRect(590, 487, 100, 50));
|
||||
|
@ -323,8 +301,6 @@ void MoveResizeWindowTest::testGrowShrink_data()
|
|||
void MoveResizeWindowTest::testGrowShrink()
|
||||
{
|
||||
using namespace KWayland::Client;
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
// block geometry helper
|
||||
QScopedPointer<Surface> surface1(Test::createSurface());
|
||||
|
@ -332,9 +308,7 @@ void MoveResizeWindowTest::testGrowShrink()
|
|||
QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data()));
|
||||
QVERIFY(!shellSurface1.isNull());
|
||||
Test::render(surface1.data(), QSize(650, 514), Qt::blue);
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
clientAddedSpy.clear();
|
||||
QVERIFY(Test::waitForWaylandWindowShown());
|
||||
workspace()->slotWindowPackRight();
|
||||
workspace()->slotWindowPackDown();
|
||||
|
||||
|
@ -346,13 +320,10 @@ void MoveResizeWindowTest::testGrowShrink()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
|
||||
// let's place it centered
|
||||
Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024));
|
||||
|
@ -391,9 +362,6 @@ void MoveResizeWindowTest::testPointerMoveEnd()
|
|||
// this test verifies that moving a window through pointer only ends if all buttons are released
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -402,12 +370,10 @@ void MoveResizeWindowTest::testPointerMoveEnd()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(c, workspace()->activeClient());
|
||||
QVERIFY(!c->isMove());
|
||||
|
||||
// let's trigger the left button
|
||||
|
@ -448,9 +414,6 @@ void MoveResizeWindowTest::testPlasmaShellSurfaceMovable()
|
|||
{
|
||||
// this test verifies that certain window types from PlasmaShellSurface are not moveable or resizable
|
||||
using namespace KWayland::Client;
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -462,11 +425,8 @@ void MoveResizeWindowTest::testPlasmaShellSurfaceMovable()
|
|||
QFETCH(KWayland::Client::PlasmaShellSurface::Role, role);
|
||||
plasmaSurface->setRole(role);
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = clientAddedSpy.first().first().value<AbstractClient*>();
|
||||
QVERIFY(c);
|
||||
QTEST(c->isMovable(), "movable");
|
||||
QTEST(c->isMovableAcrossScreens(), "movableAcrossScreens");
|
||||
|
|
|
@ -103,15 +103,10 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops()
|
|||
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
||||
QVERIFY(!plasmaSurface.isNull());
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
// now render to map the window
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
AbstractClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
|
||||
// currently the role is not yet set, so the window should not be on all desktops
|
||||
QCOMPARE(c->isOnAllDesktops(), false);
|
||||
|
@ -135,7 +130,7 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops()
|
|||
QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data()));
|
||||
QVERIFY(!shellSurface2.isNull());
|
||||
Test::render(surface2.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
QVERIFY(Test::waitForWaylandWindowShown());
|
||||
|
||||
QVERIFY(workspace()->activeClient() != c);
|
||||
c = workspace()->activeClient();
|
||||
|
@ -173,14 +168,9 @@ void PlasmaSurfaceTest::testAcceptsFocus()
|
|||
QFETCH(PlasmaShellSurface::Role, role);
|
||||
plasmaSurface->setRole(role);
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
// now render to map the window
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
auto c = clientAddedSpy.first().first().value<ShellClient*>();
|
||||
QVERIFY(c);
|
||||
QTEST(c->wantsInput(), "wantsInput");
|
||||
QTEST(c->isActive(), "active");
|
||||
|
|
|
@ -131,9 +131,6 @@ void QuickTilingTest::testQuickTiling()
|
|||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -142,13 +139,10 @@ void QuickTilingTest::testQuickTiling()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
|
||||
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
|
||||
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
|
||||
|
@ -205,9 +199,6 @@ void QuickTilingTest::testQuickMaximizing()
|
|||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -216,13 +207,10 @@ void QuickTilingTest::testQuickMaximizing()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
|
||||
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
|
||||
QCOMPARE(c->maximizeMode(), MaximizeRestore);
|
||||
|
@ -313,9 +301,6 @@ void QuickTilingTest::testQuickTilingKeyboardMove()
|
|||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -324,13 +309,10 @@ void QuickTilingTest::testQuickTilingKeyboardMove()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
|
||||
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
|
||||
QCOMPARE(c->maximizeMode(), MaximizeRestore);
|
||||
|
@ -390,9 +372,6 @@ void QuickTilingTest::testQuickTilingPointerMove()
|
|||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
|
||||
|
@ -401,13 +380,10 @@ void QuickTilingTest::testQuickTilingPointerMove()
|
|||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||
QVERIFY(sizeChangeSpy.isValid());
|
||||
// let's render
|
||||
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(workspace()->activeClient(), c);
|
||||
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
|
||||
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
|
||||
QCOMPARE(c->maximizeMode(), MaximizeRestore);
|
||||
|
|
|
@ -155,8 +155,6 @@ void StrutsTest::testWaylandStruts()
|
|||
|
||||
QFETCH(QVector<QRect>, windowGeometries);
|
||||
// create the panels
|
||||
QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(windowCreatedSpy.isValid());
|
||||
QHash<Surface*, ShellClient*> clients;
|
||||
for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) {
|
||||
const QRect windowGeometry = *it;
|
||||
|
@ -168,17 +166,13 @@ void StrutsTest::testWaylandStruts()
|
|||
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
|
||||
|
||||
// map the window
|
||||
Test::render(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||
auto c = Test::renderAndWaitForShown(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||
|
||||
QVERIFY(windowCreatedSpy.wait());
|
||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||
auto c = windowCreatedSpy.first().first().value<ShellClient*>();
|
||||
QVERIFY(c);
|
||||
QVERIFY(!c->isActive());
|
||||
QCOMPARE(c->geometry(), windowGeometry);
|
||||
QVERIFY(c->isDock());
|
||||
QVERIFY(c->hasStrut());
|
||||
windowCreatedSpy.clear();
|
||||
clients.insert(surface, c);
|
||||
}
|
||||
|
||||
|
@ -224,21 +218,13 @@ void StrutsTest::testMoveWaylandPanel()
|
|||
plasmaSurface->setPosition(windowGeometry.topLeft());
|
||||
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
|
||||
|
||||
QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(windowCreatedSpy.isValid());
|
||||
|
||||
// map the window
|
||||
Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||
|
||||
QVERIFY(windowCreatedSpy.wait());
|
||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||
auto c = windowCreatedSpy.first().first().value<ShellClient*>();
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||
QVERIFY(c);
|
||||
QVERIFY(!c->isActive());
|
||||
QCOMPARE(c->geometry(), windowGeometry);
|
||||
QVERIFY(c->isDock());
|
||||
QVERIFY(c->hasStrut());
|
||||
windowCreatedSpy.clear();
|
||||
QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 0, 1280, 1000));
|
||||
QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 0, 1280, 1000));
|
||||
QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024));
|
||||
|
@ -276,22 +262,13 @@ void StrutsTest::testWaylandMobilePanel()
|
|||
plasmaSurface->setPosition(windowGeometry.topLeft());
|
||||
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
|
||||
|
||||
QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(windowCreatedSpy.isValid());
|
||||
|
||||
// map the first panel
|
||||
Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||
|
||||
QVERIFY(windowCreatedSpy.wait());
|
||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||
|
||||
auto c = windowCreatedSpy.first().first().value<ShellClient*>();
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||
QVERIFY(c);
|
||||
QVERIFY(!c->isActive());
|
||||
QCOMPARE(c->geometry(), windowGeometry);
|
||||
QVERIFY(c->isDock());
|
||||
QVERIFY(c->hasStrut());
|
||||
windowCreatedSpy.clear();
|
||||
|
||||
QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 964));
|
||||
QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 964));
|
||||
|
@ -308,18 +285,13 @@ void StrutsTest::testWaylandMobilePanel()
|
|||
plasmaSurface2->setPosition(windowGeometry2.topLeft());
|
||||
plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel);
|
||||
|
||||
Test::render(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32);
|
||||
auto c1 = Test::renderAndWaitForShown(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32);
|
||||
|
||||
QVERIFY(windowCreatedSpy.wait());
|
||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||
|
||||
auto c1 = windowCreatedSpy.first().first().value<ShellClient*>();
|
||||
QVERIFY(c1);
|
||||
QVERIFY(!c1->isActive());
|
||||
QCOMPARE(c1->geometry(), windowGeometry2);
|
||||
QVERIFY(c1->isDock());
|
||||
QVERIFY(c1->hasStrut());
|
||||
windowCreatedSpy.clear();
|
||||
|
||||
QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 814));
|
||||
QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 814));
|
||||
|
|
|
@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "kwin_wayland_test.h"
|
||||
#include "shell_client.h"
|
||||
#include "wayland_server.h"
|
||||
|
||||
#include <KWayland/Client/compositor.h>
|
||||
#include <KWayland/Client/connection_thread.h>
|
||||
|
@ -244,6 +246,32 @@ void render(Surface *surface, const QSize &size, const QColor &color, const QIma
|
|||
surface->commit(Surface::CommitFlag::None);
|
||||
}
|
||||
|
||||
ShellClient *waitForWaylandWindowShown(int timeout)
|
||||
{
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
if (!clientAddedSpy.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!clientAddedSpy.wait(timeout)) {
|
||||
return nullptr;
|
||||
}
|
||||
return clientAddedSpy.first().first().value<ShellClient*>();
|
||||
}
|
||||
|
||||
ShellClient *renderAndWaitForShown(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format, int timeout)
|
||||
{
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
if (!clientAddedSpy.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
render(surface, size, color, format);
|
||||
flushWaylandConnection();
|
||||
if (!clientAddedSpy.wait(timeout)) {
|
||||
return nullptr;
|
||||
}
|
||||
return clientAddedSpy.first().first().value<ShellClient*>();
|
||||
}
|
||||
|
||||
void flushWaylandConnection()
|
||||
{
|
||||
if (s_waylandConnection.connection) {
|
||||
|
|
|
@ -100,21 +100,16 @@ AbstractClient *TouchInputTest::showWindow()
|
|||
#define COMPARE(actual, expected) \
|
||||
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
|
||||
return nullptr;
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
VERIFY(clientAddedSpy.isValid());
|
||||
|
||||
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||
VERIFY(surface);
|
||||
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||
VERIFY(shellSurface);
|
||||
// let's render
|
||||
Test::render(surface, QSize(100, 50), Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue);
|
||||
|
||||
Test::flushWaylandConnection();
|
||||
VERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
VERIFY(c);
|
||||
COMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
COMPARE(workspace()->activeClient(), c);
|
||||
|
||||
#undef VERIFY
|
||||
#undef COMPARE
|
||||
|
|
|
@ -106,8 +106,6 @@ AbstractClient *TransientPlacementTest::showWindow(const QSize &size, bool decor
|
|||
#define COMPARE(actual, expected) \
|
||||
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
|
||||
return nullptr;
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
VERIFY(clientAddedSpy.isValid());
|
||||
|
||||
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||
VERIFY(surface);
|
||||
|
@ -126,13 +124,10 @@ AbstractClient *TransientPlacementTest::showWindow(const QSize &size, bool decor
|
|||
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
||||
}
|
||||
// let's render
|
||||
Test::render(surface, size, Qt::blue);
|
||||
auto c = Test::renderAndWaitForShown(surface, size, Qt::blue);
|
||||
|
||||
Test::flushWaylandConnection();
|
||||
VERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
VERIFY(c);
|
||||
COMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
COMPARE(workspace()->activeClient(), c);
|
||||
|
||||
#undef VERIFY
|
||||
#undef COMPARE
|
||||
|
|
Loading…
Reference in a new issue