From b0a8294b0521944eb6bf40c38ba3cef534e55f6f Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 23 Jul 2024 16:16:25 +0200 Subject: [PATCH] autotests: test placement to always put the titlebar on the screen CCBUG: 489500 --- autotests/integration/placement_test.cpp | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/autotests/integration/placement_test.cpp b/autotests/integration/placement_test.cpp index e99904047c..33d76778ae 100644 --- a/autotests/integration/placement_test.cpp +++ b/autotests/integration/placement_test.cpp @@ -46,6 +46,8 @@ private Q_SLOTS: void testCascadeIfCoveringIgnoreNonCovering(); void testCascadeIfCoveringIgnoreOutOfArea(); void testCascadeIfCoveringIgnoreAlreadyCovered(); + void testTitlebarOnScreen_data(); + void testTitlebarOnScreen(); private: void setPlacementPolicy(PlacementPolicy policy); @@ -533,5 +535,37 @@ void TestPlacement::testCascadeIfCoveringIgnoreAlreadyCovered() QVERIFY(Test::waitForWindowClosed(window1)); } +void TestPlacement::testTitlebarOnScreen_data() +{ + QTest::addColumn("placementMode"); + QTest::addRow("PlacementRandom") << PlacementPolicy::PlacementRandom; + QTest::addRow("PlacementSmart") << PlacementPolicy::PlacementSmart; + QTest::addRow("PlacementCentered") << PlacementPolicy::PlacementCentered; + QTest::addRow("PlacementZeroCornered") << PlacementPolicy::PlacementZeroCornered; + QTest::addRow("PlacementUnderMouse") << PlacementPolicy::PlacementUnderMouse; + QTest::addRow("PlacementMaximizing") << PlacementPolicy::PlacementMaximizing; +} + +void TestPlacement::testTitlebarOnScreen() +{ + // this test verifies that windows that are bigger than the screen + // still get placed with their title bar on the screen + + QFETCH(PlacementPolicy, placementMode); + setPlacementPolicy(PlacementPolicy(placementMode)); + + KWin::input()->pointer()->warp(QPoint(200, 0)); + QCOMPARE(KWin::Cursors::self()->mouse()->pos(), QPoint(200, 0)); + + std::unique_ptr surface(Test::createSurface()); + std::unique_ptr shellSurface(Test::createXdgToplevelSurface(surface.get())); + Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, workspace()->outputs().front()->geometry().height() + 100), Qt::red); + QVERIFY(window); + QCOMPARE(window->frameGeometry().y(), 0); + + shellSurface.reset(); + QVERIFY(Test::waitForWindowClosed(window)); +} + WAYLANDTEST_MAIN(TestPlacement) #include "placement_test.moc"