From 73fa7df1fc9c5d6c3546a99bd2503ec6e4cbcd6d Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 11 Jun 2019 15:24:24 +0200 Subject: [PATCH] [autotests] Fix remaining autotests with failing border calculation Summary: As in 2c088894b fix remaining autotests failing since no borders has become the new default behavior of Breeze. Autotests should not rely on this default behavior of Breeze though, but be run with a faked deco such that changes on Breeze does not directly change the autotests behavior. That's a goal for the future. Test Plan: 100% tests passed, 0 tests failed out of 147 Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D21746 --- autotests/integration/dont_crash_glxgears.cpp | 3 ++- autotests/integration/maximize_test.cpp | 26 +++++++++++++------ autotests/integration/quick_tiling_test.cpp | 11 +++++++- autotests/integration/shell_client_test.cpp | 20 +++++++++++--- autotests/integration/xwayland_input_test.cpp | 2 +- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/autotests/integration/dont_crash_glxgears.cpp b/autotests/integration/dont_crash_glxgears.cpp index a3943244b3..998a68ccb7 100644 --- a/autotests/integration/dont_crash_glxgears.cpp +++ b/autotests/integration/dont_crash_glxgears.cpp @@ -75,7 +75,8 @@ void DontCrashGlxgearsTest::testGlxgears() QVERIFY(decoration); // send a mouse event to the position of the close button - QPointF pos = decoration->rect().topRight() + QPointF(-decoration->borderRight() * 2, decoration->borderRight() * 2); + // TODO: position is dependent on the decoration in use. We should use a static target instead, a fake deco for autotests. + QPointF pos = decoration->rect().topRight() + QPointF(-decoration->borderTop() / 2, decoration->borderTop() / 2); QHoverEvent event(QEvent::HoverMove, pos, pos); QCoreApplication::instance()->sendEvent(decoration, &event); // mouse press diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp index 5abe5928df..d843332b7e 100644 --- a/autotests/integration/maximize_test.cpp +++ b/autotests/integration/maximize_test.cpp @@ -19,6 +19,8 @@ along with this program. If not, see . *********************************************************************/ #include "kwin_wayland_test.h" #include "cursor.h" +#include "decorations/decorationbridge.h" +#include "decorations/settings.h" #include "platform.h" #include "shell_client.h" #include "screens.h" @@ -37,8 +39,9 @@ along with this program. If not, see . #include #include -#include #include +#include +#include using namespace KWin; using namespace KWayland::Client; @@ -120,6 +123,10 @@ void TestMaximized::testMaximizedPassedToDeco() QVERIFY(decoration); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); + // When there are no borders, there is no change to them when maximizing. + // TODO: we should test both cases with fixed fake decoration for autotests. + const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; + // now maximize QVERIFY(sizeChangedSpy.isEmpty()); QSignalSpy bordersChangedSpy(decoration, &KDecoration2::Decoration::bordersChanged); @@ -134,11 +141,14 @@ void TestMaximized::testMaximizedPassedToDeco() QCOMPARE(sizeChangedSpy.first().first().toSize(), QSize(1280, 1024 - decoration->borderTop())); Test::render(surface.data(), sizeChangedSpy.first().first().toSize(), Qt::red); QVERIFY(geometryShapeChangedSpy.wait()); - QCOMPARE(geometryShapeChangedSpy.count(), 2); + + // If no borders, there is only the initial geometry shape change, but none through border resizing. + QCOMPARE(geometryShapeChangedSpy.count(), hasBorders ? 2 : 1); + QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); QCOMPARE(maximizedChangedSpy.count(), 1); QCOMPARE(maximizedChangedSpy.last().first().toBool(), true); - QCOMPARE(bordersChangedSpy.count(), 1); + QCOMPARE(bordersChangedSpy.count(), hasBorders ? 1 : 0); QCOMPARE(decoration->borderLeft(), 0); QCOMPARE(decoration->borderBottom(), 0); QCOMPARE(decoration->borderRight(), 0); @@ -149,15 +159,15 @@ void TestMaximized::testMaximizedPassedToDeco() Test::render(surface.data(), QSize(100, 50), Qt::red); QVERIFY(geometryShapeChangedSpy.wait()); - QCOMPARE(geometryShapeChangedSpy.count(), 4); + QCOMPARE(geometryShapeChangedSpy.count(), hasBorders ? 4 : 2); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); QCOMPARE(maximizedChangedSpy.count(), 2); QCOMPARE(maximizedChangedSpy.last().first().toBool(), false); - QCOMPARE(bordersChangedSpy.count(), 2); + QCOMPARE(bordersChangedSpy.count(), hasBorders ? 2 : 0); QVERIFY(decoration->borderTop() != 0); - QVERIFY(decoration->borderLeft() != 0); - QVERIFY(decoration->borderRight() != 0); - QVERIFY(decoration->borderBottom() != 0); + QVERIFY(decoration->borderLeft() != !hasBorders); + QVERIFY(decoration->borderRight() != !hasBorders); + QVERIFY(decoration->borderBottom() != !hasBorders); QCOMPARE(sizeChangedSpy.count(), 2); QCOMPARE(sizeChangedSpy.last().first().toSize(), QSize(100, 50)); diff --git a/autotests/integration/quick_tiling_test.cpp b/autotests/integration/quick_tiling_test.cpp index 45d14fe323..144a9f5c2c 100644 --- a/autotests/integration/quick_tiling_test.cpp +++ b/autotests/integration/quick_tiling_test.cpp @@ -22,13 +22,17 @@ along with this program. If not, see . #include "abstract_client.h" #include "client.h" #include "cursor.h" +#include "decorations/decorationbridge.h" +#include "decorations/settings.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" #include "shell_client.h" #include "scripting/scripting.h" +#include #include +#include #include #include @@ -579,10 +583,15 @@ void QuickTilingTest::testQuickTilingTouchMoveXdgShell() kwinApp()->platform()->touchUp(0, timestamp++); QVERIFY(!workspace()->moveResizeClient()); + + // When there are no borders, there is no change to them when quick-tiling. + // TODO: we should test both cases with fixed fake decoration for autotests. + const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; + QCOMPARE(quickTileChangedSpy.count(), 1); QTEST(c->quickTileMode(), "expectedMode"); QVERIFY(configureRequestedSpy.wait()); - QTRY_COMPARE(configureRequestedSpy.count(), 5); + QTRY_COMPARE(configureRequestedSpy.count(), hasBorders ? 5 : 4); QCOMPARE(false, configureRequestedSpy.last().first().toSize().isEmpty()); } diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp index 67fbf31c0d..5a10cda006 100644 --- a/autotests/integration/shell_client_test.cpp +++ b/autotests/integration/shell_client_test.cpp @@ -20,6 +20,8 @@ along with this program. If not, see . *********************************************************************/ #include "kwin_wayland_test.h" #include "cursor.h" +#include "decorations/decorationbridge.h" +#include "decorations/settings.h" #include "effects.h" #include "deleted.h" #include "platform.h" @@ -28,7 +30,9 @@ along with this program. If not, see . #include "wayland_server.h" #include "workspace.h" -#include +#include +#include +#include #include #include @@ -45,6 +49,8 @@ along with this program. If not, see . #include #include +#include + // system #include #include @@ -74,6 +80,7 @@ private Q_SLOTS: void testMinimizeActiveWindow(); void testFullscreen_data(); void testFullscreen(); + void testFullscreenRestore_data(); void testFullscreenRestore(); void testUserCanSetFullscreen_data(); @@ -81,6 +88,7 @@ private Q_SLOTS: void testUserSetFullscreenWlShell(); void testUserSetFullscreenXdgShell_data(); void testUserSetFullscreenXdgShell(); + void testMaximizedToFullscreenWlShell_data(); void testMaximizedToFullscreenWlShell(); void testMaximizedToFullscreenXdgShell_data(); @@ -776,9 +784,15 @@ void TestShellClient::testMaximizedToFullscreenWlShell() QVERIFY(fullscreenChangedSpy.wait()); if (decoMode == ServerSideDecoration::Mode::Server) { QVERIFY(sizeChangeRequestedSpy.wait()); - // fails as we don't correctly call setMaximize(false) + + // TODO: we should test both cases with fixed fake decoration for autotests. + const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; + + // fails if we have borders as we don't correctly call setMaximize(false) // but realistically the only toolkits that support the deco also use XDGShell - QEXPECT_FAIL("wlShell - deco", "With decoration incorrect geometry requested", Continue); + if (hasBorders) { + QEXPECT_FAIL("wlShell - deco", "With decoration incorrect geometry requested", Continue); + } QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); } // TODO: should switch to fullscreen once it's updated diff --git a/autotests/integration/xwayland_input_test.cpp b/autotests/integration/xwayland_input_test.cpp index a88bc3a15d..dfbe8f173b 100644 --- a/autotests/integration/xwayland_input_test.cpp +++ b/autotests/integration/xwayland_input_test.cpp @@ -147,7 +147,7 @@ void XWaylandInputTest::testPointerEnterLeave() Xcb::Atom atom(QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"), false, c.data()); xcb_window_t w = xcb_generate_id(c.data()); - const QRect windowGeometry = QRect(0, 0, 10, 20); + const QRect windowGeometry = QRect(0, 0, 100, 200); const uint32_t values[] = { XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW