From cab076594717eef5b57c524e0b72b1fd571d241b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 19 May 2023 14:58:32 +0300 Subject: [PATCH] autotests: Use layer-shell based panels --- .../effects/minimize_animation_test.cpp | 30 +++++------ .../integration/move_resize_window_test.cpp | 52 +++++++++---------- autotests/integration/transient_placement.cpp | 22 ++++---- 3 files changed, 48 insertions(+), 56 deletions(-) diff --git a/autotests/integration/effects/minimize_animation_test.cpp b/autotests/integration/effects/minimize_animation_test.cpp index 889d4e0107..ecbf8ed4b0 100644 --- a/autotests/integration/effects/minimize_animation_test.cpp +++ b/autotests/integration/effects/minimize_animation_test.cpp @@ -18,7 +18,6 @@ #include "window.h" #include "workspace.h" -#include #include #include @@ -75,8 +74,7 @@ void MinimizeAnimationTest::initTestCase() void MinimizeAnimationTest::init() { - QVERIFY(Test::setupWaylandConnection( - Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::WindowManagement)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::LayerShellV1 | Test::AdditionalWaylandInterface::WindowManagement)); } void MinimizeAnimationTest::cleanup() @@ -102,27 +100,25 @@ void MinimizeAnimationTest::testMinimizeUnminimize() // This test verifies that a minimize effect tries to animate a window // when it's minimized or unminimized. - QSignalSpy plasmaWindowCreatedSpy(Test::waylandWindowManagement(), &KWayland::Client::PlasmaWindowManagement::windowCreated); // Create a panel at the top of the screen. const QRect panelRect = QRect(0, 0, 1280, 36); - std::unique_ptr panelSurface(Test::createSurface()); - QVERIFY(panelSurface != nullptr); - std::unique_ptr panelShellSurface(Test::createXdgToplevelSurface(panelSurface.get())); - QVERIFY(panelShellSurface != nullptr); - std::unique_ptr plasmaPanelShellSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.get())); - QVERIFY(plasmaPanelShellSurface != nullptr); - plasmaPanelShellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel); - plasmaPanelShellSurface->setPosition(panelRect.topLeft()); - plasmaPanelShellSurface->setPanelBehavior(KWayland::Client::PlasmaShellSurface::PanelBehavior::AlwaysVisible); - Window *panel = Test::renderAndWaitForShown(panelSurface.get(), panelRect.size(), Qt::blue); + std::unique_ptr panelSurface{Test::createSurface()}; + std::unique_ptr panelShellSurface{Test::createLayerSurfaceV1(panelSurface.get(), QStringLiteral("dock"))}; + panelShellSurface->set_size(panelRect.width(), panelRect.height()); + panelShellSurface->set_exclusive_zone(panelRect.height()); + panelShellSurface->set_anchor(Test::LayerSurfaceV1::anchor_top); + panelSurface->commit(KWayland::Client::Surface::CommitFlag::None); + + QSignalSpy panelConfigureRequestedSpy(panelShellSurface.get(), &Test::LayerSurfaceV1::configureRequested); + QVERIFY(panelConfigureRequestedSpy.wait()); + Window *panel = Test::renderAndWaitForShown(panelSurface.get(), panelConfigureRequestedSpy.last().at(1).toSize(), Qt::blue); QVERIFY(panel); QVERIFY(panel->isDock()); QCOMPARE(panel->frameGeometry(), panelRect); - QVERIFY(plasmaWindowCreatedSpy.wait()); - QCOMPARE(plasmaWindowCreatedSpy.count(), 1); // Create the test window. + QSignalSpy plasmaWindowCreatedSpy(Test::waylandWindowManagement(), &KWayland::Client::PlasmaWindowManagement::windowCreated); std::unique_ptr surface(Test::createSurface()); QVERIFY(surface != nullptr); std::unique_ptr shellSurface(Test::createXdgToplevelSurface(surface.get())); @@ -130,7 +126,7 @@ void MinimizeAnimationTest::testMinimizeUnminimize() Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::red); QVERIFY(window); QVERIFY(plasmaWindowCreatedSpy.wait()); - QCOMPARE(plasmaWindowCreatedSpy.count(), 2); + QCOMPARE(plasmaWindowCreatedSpy.count(), 1); // We have to set the minimized geometry because the squash effect needs it, // otherwise it won't start animation. diff --git a/autotests/integration/move_resize_window_test.cpp b/autotests/integration/move_resize_window_test.cpp index 5dc37445d7..cd2c3ab942 100644 --- a/autotests/integration/move_resize_window_test.cpp +++ b/autotests/integration/move_resize_window_test.cpp @@ -60,10 +60,10 @@ private Q_SLOTS: void testPlasmaShellSurfaceMovable_data(); void testPlasmaShellSurfaceMovable(); void testNetMove(); - void testAdjustClientGeometryOfAutohidingX11Panel_data(); - void testAdjustClientGeometryOfAutohidingX11Panel(); - void testAdjustClientGeometryOfAutohidingWaylandPanel_data(); - void testAdjustClientGeometryOfAutohidingWaylandPanel(); + void testAdjustClientGeometryOfHiddenX11Panel_data(); + void testAdjustClientGeometryOfHiddenX11Panel(); + void testAdjustClientGeometryOfHiddenWaylandPanel_data(); + void testAdjustClientGeometryOfHiddenWaylandPanel(); void testResizeForVirtualKeyboard_data(); void testResizeForVirtualKeyboard(); void testResizeForVirtualKeyboardWithMaximize(); @@ -94,7 +94,7 @@ void MoveResizeWindowTest::initTestCase() void MoveResizeWindowTest::init() { - QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::Seat)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::LayerShellV1 | Test::AdditionalWaylandInterface::Seat)); QVERIFY(Test::waitForWaylandPointer()); m_connection = Test::waylandConnection(); m_compositor = Test::waylandCompositor(); @@ -657,7 +657,7 @@ void MoveResizeWindowTest::testNetMove() QVERIFY(windowClosedSpy.wait()); } -void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel_data() +void MoveResizeWindowTest::testAdjustClientGeometryOfHiddenX11Panel_data() { QTest::addColumn("panelGeometry"); QTest::addColumn("targetPoint"); @@ -670,7 +670,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel_data() QTest::newRow("right") << QRect(1280 - 20, 0, 20, 100) << QPoint(1280 - 25 - 100, 50) << QPoint(1280 - 20 - 100, 50) << 1u; } -void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel() +void MoveResizeWindowTest::testAdjustClientGeometryOfHiddenX11Panel() { // this test verifies that auto hiding panels are ignored when adjusting client geometry // see BUG 365892 @@ -745,36 +745,37 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel() QVERIFY(windowClosedSpy.wait()); } -void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingWaylandPanel_data() +void MoveResizeWindowTest::testAdjustClientGeometryOfHiddenWaylandPanel_data() { + QTest::addColumn("anchor"); QTest::addColumn("panelGeometry"); QTest::addColumn("targetPoint"); QTest::addColumn("expectedAdjustedPoint"); - QTest::newRow("top") << QRect(0, 0, 100, 20) << QPoint(50, 25) << QPoint(50, 20); - QTest::newRow("bottom") << QRect(0, 1024 - 20, 100, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50); - QTest::newRow("left") << QRect(0, 0, 20, 100) << QPoint(25, 50) << QPoint(20, 50); - QTest::newRow("right") << QRect(1280 - 20, 0, 20, 100) << QPoint(1280 - 25 - 100, 50) << QPoint(1280 - 20 - 100, 50); + QTest::newRow("top") << uint32_t(Test::LayerSurfaceV1::anchor_top) << QRect(0, 0, 1280, 20) << QPoint(50, 25) << QPoint(50, 20); + QTest::newRow("bottom") << uint32_t(Test::LayerSurfaceV1::anchor_bottom) << QRect(0, 1024 - 20, 1280, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50); + QTest::newRow("left") << uint32_t(Test::LayerSurfaceV1::anchor_left) << QRect(0, 0, 20, 1024) << QPoint(25, 50) << QPoint(20, 50); + QTest::newRow("right") << uint32_t(Test::LayerSurfaceV1::anchor_right) << QRect(1280 - 20, 0, 20, 1024) << QPoint(1280 - 25 - 100, 50) << QPoint(1280 - 20 - 100, 50); } -void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingWaylandPanel() +void MoveResizeWindowTest::testAdjustClientGeometryOfHiddenWaylandPanel() { - // this test verifies that auto hiding panels are ignored when adjusting client geometry + // this test verifies that hidden panels are ignored when adjusting client geometry // see BUG 365892 // first create our panel std::unique_ptr panelSurface(Test::createSurface()); - QVERIFY(panelSurface != nullptr); - std::unique_ptr panelShellSurface(Test::createXdgToplevelSurface(panelSurface.get())); - QVERIFY(panelShellSurface != nullptr); - std::unique_ptr plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.get())); - QVERIFY(plasmaSurface != nullptr); - plasmaSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel); - plasmaSurface->setPanelBehavior(KWayland::Client::PlasmaShellSurface::PanelBehavior::AutoHide); + std::unique_ptr panelShellSurface(Test::createLayerSurfaceV1(panelSurface.get(), QStringLiteral("dock"))); QFETCH(QRect, panelGeometry); - plasmaSurface->setPosition(panelGeometry.topLeft()); + QFETCH(uint32_t, anchor); + panelShellSurface->set_anchor(anchor); + panelShellSurface->set_size(panelGeometry.width(), panelGeometry.height()); + panelSurface->commit(KWayland::Client::Surface::CommitFlag::None); + // let's render - auto panel = Test::renderAndWaitForShown(panelSurface.get(), panelGeometry.size(), Qt::blue); + QSignalSpy panelConfigureRequestedSpy(panelShellSurface.get(), &Test::LayerSurfaceV1::configureRequested); + QVERIFY(panelConfigureRequestedSpy.wait()); + auto panel = Test::renderAndWaitForShown(panelSurface.get(), panelConfigureRequestedSpy.last().at(1).toSize(), Qt::blue); QVERIFY(panel); QCOMPARE(panel->frameGeometry(), panelGeometry); QVERIFY(panel->isDock()); @@ -794,16 +795,13 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingWaylandPanel() QTEST(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false).toPoint(), "expectedAdjustedPoint"); // now let's hide the panel - QSignalSpy panelHiddenSpy(panel, &Window::windowHidden); - plasmaSurface->requestHideAutoHidingPanel(); - QVERIFY(panelHiddenSpy.wait()); + panel->hideClient(); // now try to snap again QCOMPARE(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false), targetPoint); // and destroy the panel again QSignalSpy panelClosedSpy(panel, &Window::closed); - plasmaSurface.reset(); panelShellSurface.reset(); panelSurface.reset(); QVERIFY(panelClosedSpy.wait()); diff --git a/autotests/integration/transient_placement.cpp b/autotests/integration/transient_placement.cpp index 50df18456a..9eed5d9701 100644 --- a/autotests/integration/transient_placement.cpp +++ b/autotests/integration/transient_placement.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -79,7 +78,7 @@ void TransientPlacementTest::initTestCase() void TransientPlacementTest::init() { - QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | Test::AdditionalWaylandInterface::PlasmaShell)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | Test::AdditionalWaylandInterface::LayerShellV1)); workspace()->setActiveOutput(QPoint(640, 512)); input()->pointer()->warp(QPoint(640, 512)); @@ -470,18 +469,17 @@ void TransientPlacementTest::testXdgPopupWithPanel() { const Output *output = workspace()->activeOutput(); - std::unique_ptr surface{Test::createSurface()}; - QVERIFY(surface != nullptr); - std::unique_ptr dockShellSurface{Test::createXdgToplevelSurface(surface.get())}; - QVERIFY(dockShellSurface != nullptr); - std::unique_ptr plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.get())); - QVERIFY(plasmaSurface != nullptr); - plasmaSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel); - plasmaSurface->setPosition(QPoint(0, output->geometry().height() - 50)); - plasmaSurface->setPanelBehavior(KWayland::Client::PlasmaShellSurface::PanelBehavior::AlwaysVisible); + std::unique_ptr dockSurface{Test::createSurface()}; + std::unique_ptr dockShellSurface{Test::createLayerSurfaceV1(dockSurface.get(), QStringLiteral("dock"))}; + dockShellSurface->set_size(1280, 50); + dockShellSurface->set_anchor(Test::LayerSurfaceV1::anchor_bottom); + dockShellSurface->set_exclusive_zone(50); + dockSurface->commit(KWayland::Client::Surface::CommitFlag::None); // now render and map the window - auto dock = Test::renderAndWaitForShown(surface.get(), QSize(1280, 50), Qt::blue); + QSignalSpy dockConfigureRequestedSpy(dockShellSurface.get(), &Test::LayerSurfaceV1::configureRequested); + QVERIFY(dockConfigureRequestedSpy.wait()); + auto dock = Test::renderAndWaitForShown(dockSurface.get(), dockConfigureRequestedSpy.last().at(1).toSize(), Qt::blue); QVERIFY(dock); QCOMPARE(dock->windowType(), NET::Dock); QVERIFY(dock->isDock());