From f99a456f330292fd0e4bf1871588455c7d52443e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 30 Aug 2016 13:04:10 +0200 Subject: [PATCH] [autotests] Extend PlasmaSurface to verify position of OSD windows This adds a new test case which maps an OSD window and verifies that it's positioned correctly. Then an additional screen is added which should not affect the position, but as the test case shows: it does affect the position. CCBUG: 366696 --- autotests/integration/plasma_surface_test.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp index 819de4c0c6..5e6c728d9a 100644 --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -20,6 +20,7 @@ along with this program. If not, see . #include "kwin_wayland_test.h" #include "platform.h" #include "shell_client.h" +#include "screens.h" #include "wayland_server.h" #include "workspace.h" #include @@ -50,6 +51,7 @@ private Q_SLOTS: void testAcceptsFocus(); void testDesktopIsOpaque(); + void testOSDPlacement(); private: ConnectionThread *m_connection = nullptr; @@ -199,5 +201,40 @@ void PlasmaSurfaceTest::testDesktopIsOpaque() QCOMPARE(c->depth(), 24); } +void PlasmaSurfaceTest::testOSDPlacement() +{ + QScopedPointer surface(Test::createSurface()); + QVERIFY(!surface.isNull()); + QScopedPointer shellSurface(Test::createShellSurface(surface.data())); + QVERIFY(!shellSurface.isNull()); + QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data())); + QVERIFY(!plasmaSurface.isNull()); + plasmaSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay); + + // now render and map the window + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + + QVERIFY(c); + QCOMPARE(c->windowType(), NET::OnScreenDisplay); + QVERIFY(c->isOnScreenDisplay()); + QCOMPARE(c->geometry(), QRect(590, 649, 100, 50)); + + // change the screen size + QSignalSpy screensChangedSpy(screens(), &Screens::changed); + QVERIFY(screensChangedSpy.isValid()); + const QVector geometries{QRect(0, 0, 1280, 1024), QRect(1280, 0, 1280, 1024)}; + QMetaObject::invokeMethod(kwinApp()->platform(), "outputGeometriesChanged", + Qt::DirectConnection, + Q_ARG(QVector, geometries)); + QVERIFY(screensChangedSpy.wait()); + QCOMPARE(screensChangedSpy.count(), 1); + QCOMPARE(screens()->count(), 2); + QCOMPARE(screens()->geometry(0), geometries.at(0)); + QCOMPARE(screens()->geometry(1), geometries.at(1)); + + QEXPECT_FAIL("", "Geometry should not change due to a screen being added", Continue); + QCOMPARE(c->geometry(), QRect(590, 649, 100, 50)); +} + WAYLANDTEST_MAIN(PlasmaSurfaceTest) #include "plasma_surface_test.moc"