From 2c088894b40d928ef9ccc3241cbfac3932dfa241 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Fri, 7 Jun 2019 11:55:11 +0200 Subject: [PATCH] [autotests] Fix decoration input test Since d51b8dc09393 the test fails on CI, apparently because we test with Breeze default settings, which is no borders now and we can move a bit into the window geometry and still be on the border if borders exist, otherwise not. For now fix it by checking if there are borders or not and then test accordingly. But long-term we should test both cases and besides not rely on external decorations for our test, instead use a fake specific for our integration testing. --- .../integration/decoration_input_test.cpp | 25 +++++++++++++++---- decorations/decorationbridge.h | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/autotests/integration/decoration_input_test.cpp b/autotests/integration/decoration_input_test.cpp index 4ccc4104f4..4bf65af008 100644 --- a/autotests/integration/decoration_input_test.cpp +++ b/autotests/integration/decoration_input_test.cpp @@ -29,7 +29,10 @@ along with this program. If not, see . #include "workspace.h" #include "shell_client.h" #include + #include "decorations/decoratedclient.h" +#include "decorations/decorationbridge.h" +#include "decorations/settings.h" #include #include @@ -42,6 +45,7 @@ along with this program. If not, see . #include #include +#include #include @@ -379,21 +383,32 @@ void DecorationInputTest::testHover() MOTION(QPoint(c->geometry().center().x(), c->clientPos().y() / 2)); QCOMPARE(c->cursor(), CursorShape(Qt::ArrowCursor)); + // There is a mismatch of the cursor key positions between windows + // with and without borders (with borders one can move inside a bit and still + // be on an edge, without not). We should make this consistent in KWin's core. + // + // TODO: Test input position with different border sizes. + // TODO: We should test with the fake decoration to have a fixed test environment. + const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; + auto deviation = [hasBorders] { + return hasBorders ? -1 : 0; + }; + MOTION(QPoint(c->geometry().x(), 0)); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorthWest)); MOTION(QPoint(c->geometry().x() + c->geometry().width() / 2, 0)); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorth)); MOTION(QPoint(c->geometry().x() + c->geometry().width() - 1, 0)); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorthEast)); - MOTION(QPoint(c->geometry().x() + c->geometry().width() - 1, c->height() / 2)); + MOTION(QPoint(c->geometry().x() + c->geometry().width() + deviation(), c->height() / 2)); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeEast)); - MOTION(QPoint(c->geometry().x() + c->geometry().width() - 1, c->height() - 1)); + MOTION(QPoint(c->geometry().x() + c->geometry().width() + deviation(), c->height() - 1)); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouthEast)); - MOTION(QPoint(c->geometry().x() + c->geometry().width() / 2, c->height() - 1)); + MOTION(QPoint(c->geometry().x() + c->geometry().width() / 2, c->height() + deviation())); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouth)); - MOTION(QPoint(c->geometry().x(), c->height() - 1)); + MOTION(QPoint(c->geometry().x(), c->height() + deviation())); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouthWest)); - MOTION(QPoint(c->geometry().x(), c->height() / 2)); + MOTION(QPoint(c->geometry().x() - 1, c->height() / 2)); QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeWest)); MOTION(c->geometry().center()); diff --git a/decorations/decorationbridge.h b/decorations/decorationbridge.h index 7ab70d8309..f85ef8a4f6 100644 --- a/decorations/decorationbridge.h +++ b/decorations/decorationbridge.h @@ -44,7 +44,7 @@ class AbstractClient; namespace Decoration { -class DecorationBridge : public KDecoration2::DecorationBridge +class KWIN_EXPORT DecorationBridge : public KDecoration2::DecorationBridge { Q_OBJECT public: