From 79e0051b040421237a2cb60cd02867d3cf4507b5 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 11 Jul 2022 15:20:35 +0300 Subject: [PATCH] autotests: Port more tests from obsolete Screens --- .../integration/decoration_input_test.cpp | 11 +++++------ .../integration/move_resize_window_test.cpp | 3 +-- autotests/integration/placement_test.cpp | 5 ++--- autotests/integration/pointer_input.cpp | 14 ++++++++------ autotests/integration/screen_changes_test.cpp | 9 +++++---- autotests/integration/struts_test.cpp | 7 +++---- autotests/integration/transient_placement.cpp | 19 ++++++++++--------- autotests/integration/x11_window_test.cpp | 3 +-- autotests/integration/xdgshellwindow_test.cpp | 3 +-- .../integration/xwaylandserver_crash_test.cpp | 1 - .../xwaylandserver_restart_test.cpp | 4 ---- 11 files changed, 36 insertions(+), 43 deletions(-) diff --git a/autotests/integration/decoration_input_test.cpp b/autotests/integration/decoration_input_test.cpp index a0d406e6ce..4abda6ab6e 100644 --- a/autotests/integration/decoration_input_test.cpp +++ b/autotests/integration/decoration_input_test.cpp @@ -13,7 +13,6 @@ #include "output.h" #include "platform.h" #include "pointer_input.h" -#include "screens.h" #include "touch_input.h" #include "wayland_server.h" #include "window.h" @@ -378,7 +377,7 @@ void DecorationInputTest::testPressToMove() QVERIFY(window); QVERIFY(window->isDecorated()); QVERIFY(!window->noBorder()); - window->move(screens()->geometry(0).center() - QPoint(window->width() / 2, window->height() / 2)); + window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2)); QSignalSpy startMoveResizedSpy(window, &Window::clientStartUserMovedResized); QVERIFY(startMoveResizedSpy.isValid()); QSignalSpy clientFinishUserMovedResizedSpy(window, &Window::clientFinishUserMovedResized); @@ -437,7 +436,7 @@ void DecorationInputTest::testTapToMove() QVERIFY(window); QVERIFY(window->isDecorated()); QVERIFY(!window->noBorder()); - window->move(screens()->geometry(0).center() - QPoint(window->width() / 2, window->height() / 2)); + window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2)); QSignalSpy startMoveResizedSpy(window, &Window::clientStartUserMovedResized); QVERIFY(startMoveResizedSpy.isValid()); QSignalSpy clientFinishUserMovedResizedSpy(window, &Window::clientFinishUserMovedResized); @@ -503,7 +502,7 @@ void DecorationInputTest::testResizeOutsideWindow() QVERIFY(window); QVERIFY(window->isDecorated()); QVERIFY(!window->noBorder()); - window->move(screens()->geometry(0).center() - QPoint(window->width() / 2, window->height() / 2)); + window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2)); QVERIFY(window->frameGeometry() != window->inputGeometry()); QVERIFY(window->inputGeometry().contains(window->frameGeometry())); QSignalSpy startMoveResizedSpy(window, &Window::clientStartUserMovedResized); @@ -600,7 +599,7 @@ void DecorationInputTest::testModifierClickUnrestrictedMove() QVERIFY(window); QVERIFY(window->isDecorated()); QVERIFY(!window->noBorder()); - window->move(screens()->geometry(0).center() - QPoint(window->width() / 2, window->height() / 2)); + window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2)); // move cursor on window Cursors::self()->mouse()->setPos(QPoint(window->frameGeometry().center().x(), window->y() + window->clientPos().y() / 2)); @@ -662,7 +661,7 @@ void DecorationInputTest::testModifierScrollOpacity() QVERIFY(window); QVERIFY(window->isDecorated()); QVERIFY(!window->noBorder()); - window->move(screens()->geometry(0).center() - QPoint(window->width() / 2, window->height() / 2)); + window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2)); // move cursor on window Cursors::self()->mouse()->setPos(QPoint(window->frameGeometry().center().x(), window->y() + window->clientPos().y() / 2)); // set the opacity to 0.5 diff --git a/autotests/integration/move_resize_window_test.cpp b/autotests/integration/move_resize_window_test.cpp index 0c5a267c29..d702c94b0b 100644 --- a/autotests/integration/move_resize_window_test.cpp +++ b/autotests/integration/move_resize_window_test.cpp @@ -15,7 +15,6 @@ #include "effects.h" #include "output.h" #include "platform.h" -#include "screens.h" #include "wayland_server.h" #include "window.h" #include "workspace.h" @@ -660,7 +659,7 @@ void MoveResizeWindowTest::testNetMove() const QRect origGeo = window->frameGeometry(); // let's move the cursor outside the window - Cursors::self()->mouse()->setPos(screens()->geometry(0).center()); + Cursors::self()->mouse()->setPos(workspace()->activeOutput()->geometry().center()); QVERIFY(!origGeo.contains(Cursors::self()->mouse()->pos())); QSignalSpy moveStartSpy(window, &X11Window::clientStartUserMovedResized); diff --git a/autotests/integration/placement_test.cpp b/autotests/integration/placement_test.cpp index d00d1ea8f9..184c3611eb 100644 --- a/autotests/integration/placement_test.cpp +++ b/autotests/integration/placement_test.cpp @@ -12,7 +12,6 @@ #include "cursor.h" #include "output.h" #include "platform.h" -#include "screens.h" #include "wayland_server.h" #include "window.h" #include "workspace.h" @@ -371,11 +370,11 @@ void TestPlacement::testFullscreen() shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value()); Test::render(surface.data(), toplevelConfigureRequestedSpy.last().at(0).toSize(), Qt::red); QVERIFY(geometryChangedSpy.wait()); - QCOMPARE(window->frameGeometry(), screens()->geometry(0)); + QCOMPARE(window->frameGeometry(), outputs[0]->geometry()); // this doesn't require a round trip, so should be immediate window->sendToOutput(outputs[1]); - QCOMPARE(window->frameGeometry(), screens()->geometry(1)); + QCOMPARE(window->frameGeometry(), outputs[1]->geometry()); QCOMPARE(geometryChangedSpy.count(), 2); } diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp index 77cb4bac70..1333a078fe 100644 --- a/autotests/integration/pointer_input.cpp +++ b/autotests/integration/pointer_input.cpp @@ -398,7 +398,7 @@ void PointerInputTest::testUpdateFocusAfterScreenChange() Q_ARG(int, 1), Q_ARG(QVector, QVector{QRect(0, 0, 1280, 1024)})); QVERIFY(screensChangedSpy.wait()); - QCOMPARE(screens()->count(), 1); + QCOMPARE(kwinApp()->platform()->enabledOutputs().count(), 1); // this should have warped the cursor QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(639, 511)); @@ -1584,11 +1584,13 @@ void PointerInputTest::testConfineToScreenGeometry() Qt::DirectConnection, Q_ARG(int, geometries.count()), Q_ARG(QVector, geometries)); - QCOMPARE(screens()->count(), geometries.count()); - QCOMPARE(screens()->geometry(0), geometries.at(0)); - QCOMPARE(screens()->geometry(1), geometries.at(1)); - QCOMPARE(screens()->geometry(2), geometries.at(2)); - QCOMPARE(screens()->geometry(3), geometries.at(3)); + + const auto outputs = kwinApp()->platform()->enabledOutputs(); + QCOMPARE(outputs.count(), geometries.count()); + QCOMPARE(outputs[0]->geometry(), geometries.at(0)); + QCOMPARE(outputs[1]->geometry(), geometries.at(1)); + QCOMPARE(outputs[2]->geometry(), geometries.at(2)); + QCOMPARE(outputs[3]->geometry(), geometries.at(3)); // move pointer to initial position QFETCH(QPoint, startPos); diff --git a/autotests/integration/screen_changes_test.cpp b/autotests/integration/screen_changes_test.cpp index 8199a299cc..023397eca9 100644 --- a/autotests/integration/screen_changes_test.cpp +++ b/autotests/integration/screen_changes_test.cpp @@ -81,7 +81,7 @@ void ScreenChangesTest::testScreenAddRemove() auto xdgOutputManager = registry.createXdgOutputManager(xdgOMData.name, xdgOMData.version); // should be one output - QCOMPARE(screens()->count(), 1); + QCOMPARE(kwinApp()->platform()->enabledOutputs().count(), 1); QCOMPARE(outputAnnouncedSpy.count(), 1); const quint32 firstOutputId = outputAnnouncedSpy.first().first().value(); QVERIFY(firstOutputId != 0u); @@ -97,7 +97,7 @@ void ScreenChangesTest::testScreenAddRemove() Q_ARG(QVector, geometries)); QVERIFY(screensChangedSpy.wait()); QCOMPARE(screensChangedSpy.count(), 2); - const auto outputs = kwinApp()->platform()->enabledOutputs(); + auto outputs = kwinApp()->platform()->enabledOutputs(); QCOMPARE(outputs.count(), 2); QCOMPARE(outputs[0]->geometry(), geometries[0]); QCOMPARE(outputs[1]->geometry(), geometries[1]); @@ -169,8 +169,9 @@ void ScreenChangesTest::testScreenAddRemove() Q_ARG(QVector, geometries2)); QVERIFY(screensChangedSpy.wait()); QCOMPARE(screensChangedSpy.count(), 2); - QCOMPARE(screens()->count(), 1); - QCOMPARE(screens()->geometry(0), geometries2.at(0)); + outputs = kwinApp()->platform()->enabledOutputs(); + QCOMPARE(outputs.count(), 1); + QCOMPARE(outputs[0]->geometry(), geometries2.at(0)); QVERIFY(outputAnnouncedSpy.wait()); QCOMPARE(outputAnnouncedSpy.count(), 1); diff --git a/autotests/integration/struts_test.cpp b/autotests/integration/struts_test.cpp index 72b187889a..1f6973a3c9 100644 --- a/autotests/integration/struts_test.cpp +++ b/autotests/integration/struts_test.cpp @@ -13,7 +13,6 @@ #include "output.h" #include "platform.h" #include "screenedge.h" -#include "screens.h" #include "virtualdesktops.h" #include "wayland_server.h" #include "workspace.h" @@ -694,7 +693,7 @@ void StrutsTest::test363804() Qt::DirectConnection, Q_ARG(int, 2), Q_ARG(QVector, geometries)); - QCOMPARE(screens()->geometry(), QRect(0, 0, 1920, 1848)); + QCOMPARE(workspace()->geometry(), QRect(0, 0, 1920, 1848)); VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop(); const QVector outputs = kwinApp()->platform()->enabledOutputs(); @@ -778,7 +777,7 @@ void StrutsTest::testLeftScreenSmallerBottomAligned() Qt::DirectConnection, Q_ARG(int, 2), Q_ARG(QVector, geometries)); - QCOMPARE(screens()->geometry(), QRect(0, 0, 3046, 1050)); + QCOMPARE(workspace()->geometry(), QRect(0, 0, 3046, 1050)); const QVector outputs = kwinApp()->platform()->enabledOutputs(); QCOMPARE(outputs[0]->geometry(), geometries.at(0)); @@ -895,7 +894,7 @@ void StrutsTest::testWindowMoveWithPanelBetweenScreens() Qt::DirectConnection, Q_ARG(int, 2), Q_ARG(QVector, geometries)); - QCOMPARE(screens()->geometry(), QRect(0, 0, 3046, 1050)); + QCOMPARE(workspace()->geometry(), QRect(0, 0, 3046, 1050)); const QVector outputs = kwinApp()->platform()->enabledOutputs(); QCOMPARE(outputs[0]->geometry(), geometries.at(0)); diff --git a/autotests/integration/transient_placement.cpp b/autotests/integration/transient_placement.cpp index b8beb69fac..3a18676fc6 100644 --- a/autotests/integration/transient_placement.cpp +++ b/autotests/integration/transient_placement.cpp @@ -11,7 +11,6 @@ #include "cursor.h" #include "output.h" #include "platform.h" -#include "screens.h" #include "wayland/seat_interface.h" #include "wayland/surface_interface.h" #include "wayland_server.h" @@ -467,6 +466,8 @@ void TransientPlacementTest::testXdgPopupWithPanel() { using namespace KWayland::Client; + const Output *output = workspace()->activeOutput(); + QScopedPointer surface{Test::createSurface()}; QVERIFY(!surface.isNull()); QScopedPointer dockShellSurface{Test::createXdgToplevelSurface(surface.data())}; @@ -474,7 +475,7 @@ void TransientPlacementTest::testXdgPopupWithPanel() QScopedPointer plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data())); QVERIFY(!plasmaSurface.isNull()); plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); - plasmaSurface->setPosition(QPoint(0, screens()->geometry(0).height() - 50)); + plasmaSurface->setPosition(QPoint(0, output->geometry().height() - 50)); plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible); // now render and map the window @@ -482,7 +483,7 @@ void TransientPlacementTest::testXdgPopupWithPanel() QVERIFY(dock); QCOMPARE(dock->windowType(), NET::Dock); QVERIFY(dock->isDock()); - QCOMPARE(dock->frameGeometry(), QRect(0, screens()->geometry(0).height() - 50, 1280, 50)); + QCOMPARE(dock->frameGeometry(), QRect(0, output->geometry().height() - 50, 1280, 50)); QCOMPARE(dock->hasStrut(), true); QCOMPARE(workspace()->clientArea(PlacementArea, dock), QRect(0, 0, 1280, 1024 - 50)); QCOMPARE(workspace()->clientArea(FullScreenArea, dock), QRect(0, 0, 1280, 1024)); @@ -496,9 +497,9 @@ void TransientPlacementTest::testXdgPopupWithPanel() QVERIFY(parent); QVERIFY(!parent->isDecorated()); - parent->move({0, screens()->geometry(0).height() - 600}); + parent->move({0, output->geometry().height() - 600}); parent->keepInArea(workspace()->clientArea(PlacementArea, parent)); - QCOMPARE(parent->frameGeometry(), QRect(0, screens()->geometry(0).height() - 600 - 50, 800, 600)); + QCOMPARE(parent->frameGeometry(), QRect(0, output->geometry().height() - 600 - 50, 800, 600)); QScopedPointer transientSurface(Test::createSurface()); QVERIFY(transientSurface); @@ -514,7 +515,7 @@ void TransientPlacementTest::testXdgPopupWithPanel() QVERIFY(!transient->isDecorated()); QVERIFY(transient->hasTransientPlacementHint()); - QCOMPARE(transient->frameGeometry(), QRect(50, screens()->geometry(0).height() - 200 - 50, 200, 200)); + QCOMPARE(transient->frameGeometry(), QRect(50, output->geometry().height() - 200 - 50, 200, 200)); transientShellSurface.reset(); transientSurface.reset(); @@ -530,14 +531,14 @@ void TransientPlacementTest::testXdgPopupWithPanel() QVERIFY(frameGeometryChangedSpy.isValid()); Test::render(parentSurface.data(), toplevelConfigureRequestedSpy.last().at(0).toSize(), Qt::red); QVERIFY(frameGeometryChangedSpy.wait()); - QCOMPARE(parent->frameGeometry(), screens()->geometry(0)); + QCOMPARE(parent->frameGeometry(), output->geometry()); QVERIFY(parent->isFullScreen()); // another transient, with same hints as before from bottom of window transientSurface.reset(Test::createSurface()); QVERIFY(transientSurface); - const QRect anchorRect2(50, screens()->geometry(0).height() - 100, 200, 200); + const QRect anchorRect2(50, output->geometry().height() - 100, 200, 200); QScopedPointer positioner2(Test::createXdgPositioner()); positioner2->set_size(200, 200); positioner2->set_anchor_rect(anchorRect2.x(), anchorRect2.y(), anchorRect2.width(), anchorRect2.height()); @@ -548,7 +549,7 @@ void TransientPlacementTest::testXdgPopupWithPanel() QVERIFY(!transient->isDecorated()); QVERIFY(transient->hasTransientPlacementHint()); - QCOMPARE(transient->frameGeometry(), QRect(50, screens()->geometry(0).height() - 200, 200, 200)); + QCOMPARE(transient->frameGeometry(), QRect(50, output->geometry().height() - 200, 200, 200)); } } diff --git a/autotests/integration/x11_window_test.cpp b/autotests/integration/x11_window_test.cpp index f1934c0660..f677c7b80d 100644 --- a/autotests/integration/x11_window_test.cpp +++ b/autotests/integration/x11_window_test.cpp @@ -15,7 +15,6 @@ #include "effectloader.h" #include "effects.h" #include "platform.h" -#include "screens.h" #include "wayland_server.h" #include "workspace.h" #include "x11window.h" @@ -517,7 +516,7 @@ void X11WindowTest::testFullscreenLayerWithActiveWaylandWindow() { // this test verifies that an X11 fullscreen window does not stay in the active layer // when a Wayland window is active, see BUG: 375759 - QCOMPARE(screens()->count(), 1); + QCOMPARE(kwinApp()->platform()->enabledOutputs().count(), 1); // first create an X11 window QScopedPointer c(xcb_connect(nullptr, nullptr)); diff --git a/autotests/integration/xdgshellwindow_test.cpp b/autotests/integration/xdgshellwindow_test.cpp index 01b9b930bf..3ae3f6a9d6 100644 --- a/autotests/integration/xdgshellwindow_test.cpp +++ b/autotests/integration/xdgshellwindow_test.cpp @@ -16,7 +16,6 @@ #include "effects.h" #include "output.h" #include "platform.h" -#include "screens.h" #include "virtualdesktops.h" #include "wayland/clientconnection.h" #include "wayland/display.h" @@ -611,7 +610,7 @@ void TestXdgShellWindow::testFullscreenMultipleOutputs() QVERIFY(window->isFullScreen()); - QCOMPARE(window->frameGeometry(), screens()->geometry(i)); + QCOMPARE(window->frameGeometry(), outputs[i]->geometry()); } } diff --git a/autotests/integration/xwaylandserver_crash_test.cpp b/autotests/integration/xwaylandserver_crash_test.cpp index 9c925ebc7d..9c8b654e29 100644 --- a/autotests/integration/xwaylandserver_crash_test.cpp +++ b/autotests/integration/xwaylandserver_crash_test.cpp @@ -11,7 +11,6 @@ #include "output.h" #include "platform.h" #include "scene.h" -#include "screens.h" #include "unmanaged.h" #include "wayland_server.h" #include "workspace.h" diff --git a/autotests/integration/xwaylandserver_restart_test.cpp b/autotests/integration/xwaylandserver_restart_test.cpp index df48fbaba6..c4e1dfb84e 100644 --- a/autotests/integration/xwaylandserver_restart_test.cpp +++ b/autotests/integration/xwaylandserver_restart_test.cpp @@ -10,7 +10,6 @@ #include "main.h" #include "platform.h" #include "scene.h" -#include "screens.h" #include "wayland_server.h" #include "workspace.h" #include "x11window.h" @@ -57,9 +56,6 @@ void XwaylandServerRestartTest::initTestCase() kwinApp()->start(); QVERIFY(applicationStartedSpy.wait()); - QCOMPARE(screens()->count(), 2); - QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); - QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); Test::initWaylandWorkspace(); }