Run clang-format

The .clang-format file is based on the one in ECM except the following
style options:

 - AlwaysBreakBeforeMultilineStrings
 - BinPackArguments
 - BinPackParameters
 - ColumnLimit
 - BreakBeforeBraces
 - KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
Vlad Zahorodnii 2022-03-23 12:13:38 +02:00
parent 68a8fa6034
commit 7096e3ead8
744 changed files with 17960 additions and 16741 deletions

83
.clang-format Normal file
View file

@ -0,0 +1,83 @@
---
---
# SPDX-FileCopyrightText: 2019 Christoph Cullmann <cullmann@kde.org>
# SPDX-FileCopyrightText: 2019 Gernot Gebhard <gebhard@absint.com>
#
# SPDX-License-Identifier: MIT
---
Language: JavaScript
DisableFormat: true
---
# Style for C++
Language: Cpp
Standard: c++17
# base is WebKit coding style: https://webkit.org/code-style-guidelines/
# below are only things set that diverge from this style!
BasedOnStyle: WebKit
# 4 spaces indent
TabWidth: 4
# No line limit
ColumnLimit: 0
# sort includes inside line separated groups
SortIncludes: true
# Braces are usually attached, but not after functions or class declarations.
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
# CrlInstruction *a;
PointerAlignment: Right
# horizontally aligns arguments after an open bracket.
AlignAfterOpenBracket: Align
# don't move all parameters to new line
AllowAllParametersOfDeclarationOnNextLine: false
# no single line functions
AllowShortFunctionsOnASingleLine: None
# In case we have an if statement with multiple lines the operator should be at the beginning of the line
# but we do not want to break assignments
BreakBeforeBinaryOperators: NonAssignment
# format C++11 braced lists like function calls
Cpp11BracedListStyle: true
# do not put a space before C++11 braced lists
SpaceBeforeCpp11BracedList: false
# no namespace indentation to keep indent level low
NamespaceIndentation: None
# we use template< without space.
SpaceAfterTemplateKeyword: false
# Always break after template declaration
AlwaysBreakTemplateDeclarations: true
# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ]
# keep lambda formatting multi-line if not empty
AllowShortLambdasOnASingleLine: Empty
# We do not want clang-format to put all arguments on a new line
AllowAllArgumentsOnNextLine: false

1
.gitignore vendored
View file

@ -20,7 +20,6 @@ random_seed
/build*/
CMakeLists.txt.user*
*.unc-backup*
.clang-format
/compile_commands.json
.clangd
.idea

View file

@ -529,23 +529,22 @@ void ActivationTest::stackScreensHorizontally()
// Process pending wl_output bind requests before destroying all outputs.
QTest::qWait(1);
const QVector<QRect> screenGeometries {
const QVector<QRect> screenGeometries{
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
};
const QVector<int> screenScales {
const QVector<int> screenScales{
1,
1,
};
QMetaObject::invokeMethod(kwinApp()->platform(),
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, screenGeometries.count()),
Q_ARG(QVector<QRect>, screenGeometries),
Q_ARG(QVector<int>, screenScales)
);
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, screenGeometries.count()),
Q_ARG(QVector<QRect>, screenGeometries),
Q_ARG(QVector<int>, screenScales));
}
void ActivationTest::stackScreensVertically()
@ -553,23 +552,22 @@ void ActivationTest::stackScreensVertically()
// Process pending wl_output bind requests before destroying all outputs.
QTest::qWait(1);
const QVector<QRect> screenGeometries {
const QVector<QRect> screenGeometries{
QRect(0, 0, 1280, 1024),
QRect(0, 1024, 1280, 1024),
};
const QVector<int> screenScales {
const QVector<int> screenScales{
1,
1,
};
QMetaObject::invokeMethod(kwinApp()->platform(),
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, screenGeometries.count()),
Q_ARG(QVector<QRect>, screenGeometries),
Q_ARG(QVector<int>, screenScales)
);
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, screenGeometries.count()),
Q_ARG(QVector<QRect>, screenGeometries),
Q_ARG(QVector<int>, screenScales));
}
}

View file

@ -7,15 +7,16 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "activities.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "platform.h"
#include "utils/xcbutils.h"
#include "wayland_server.h"
#include "workspace.h"
#include "utils/xcbutils.h"
#include "x11client.h"
#include <kwineffects.h>
#include <QDBusConnection>
@ -45,8 +46,8 @@ private:
void ActivitiesTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -103,11 +104,11 @@ void ActivitiesTest::testSetOnActivitiesValidates()
const QRect windowGeometry(0, 0, 100, 200);
auto cookie = xcb_create_window_checked(c.data(), 0, w, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, 0, 0, nullptr);
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, 0, 0, nullptr);
QVERIFY(!xcb_request_check(c.data(), cookie));
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
@ -126,7 +127,7 @@ void ActivitiesTest::testSetOnActivitiesValidates()
QCOMPARE(client->window(), w);
QVERIFY(client->isDecorated());
//verify the test machine doesn't have the following activities used
// verify the test machine doesn't have the following activities used
QVERIFY(!Activities::self()->all().contains(QStringLiteral("foo")));
QVERIFY(!Activities::self()->all().contains(QStringLiteral("bar")));

View file

@ -25,7 +25,10 @@ class BufferSizeChangeTest : public GenericSceneOpenGLTest
{
Q_OBJECT
public:
BufferSizeChangeTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2")) {}
BufferSizeChangeTest()
: GenericSceneOpenGLTest(QByteArrayLiteral("O2"))
{
}
private Q_SLOTS:
void init();
void testShmBufferSizeChange();

View file

@ -9,15 +9,16 @@
#include "config-kwin.h"
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "atoms.h"
#include "x11client.h"
#include "deleted.h"
#include "platform.h"
#include "rules.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KWayland/Client/surface.h>
@ -54,8 +55,8 @@ private Q_SLOTS:
void TestDbusInterface::initTestCase()
{
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
@ -78,7 +79,8 @@ void TestDbusInterface::cleanup()
Test::destroyWaylandConnection();
}
namespace {
namespace
{
QDBusPendingCall getWindowInfo(const QUuid &uuid)
{
auto msg = QDBusMessage::createMethodCall(s_destination, s_path, s_interface, QStringLiteral("getWindowInfo"));
@ -114,33 +116,33 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient()
auto client = clientAddedSpy.first().first().value<AbstractClient *>();
QVERIFY(client);
const QVariantMap expectedData {
{ QStringLiteral("type"), int(NET::Normal) },
{ QStringLiteral("x"), client->x() },
{ QStringLiteral("y"), client->y() },
{ QStringLiteral("width"), client->width() },
{ QStringLiteral("height"), client->height() },
{ QStringLiteral("desktops"), client->desktopIds() },
{ QStringLiteral("minimized"), false },
{ QStringLiteral("shaded"), false },
{ QStringLiteral("fullscreen"), false },
{ QStringLiteral("keepAbove"), false },
{ QStringLiteral("keepBelow"), false },
{ QStringLiteral("skipTaskbar"), false },
{ QStringLiteral("skipPager"), false },
{ QStringLiteral("skipSwitcher"), false },
{ QStringLiteral("maximizeHorizontal"), false },
{ QStringLiteral("maximizeVertical"), false },
{ QStringLiteral("noBorder"), false },
{ QStringLiteral("clientMachine"), QString() },
{ QStringLiteral("localhost"), true },
{ QStringLiteral("role"), QString() },
{ QStringLiteral("resourceName"), QStringLiteral("testDbusInterface") },
{ QStringLiteral("resourceClass"), QStringLiteral("org.kde.foo") },
{ QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo") },
{ QStringLiteral("caption"), QStringLiteral("Test window") },
const QVariantMap expectedData = {
{QStringLiteral("type"), int(NET::Normal)},
{QStringLiteral("x"), client->x()},
{QStringLiteral("y"), client->y()},
{QStringLiteral("width"), client->width()},
{QStringLiteral("height"), client->height()},
{QStringLiteral("desktops"), client->desktopIds()},
{QStringLiteral("minimized"), false},
{QStringLiteral("shaded"), false},
{QStringLiteral("fullscreen"), false},
{QStringLiteral("keepAbove"), false},
{QStringLiteral("keepBelow"), false},
{QStringLiteral("skipTaskbar"), false},
{QStringLiteral("skipPager"), false},
{QStringLiteral("skipSwitcher"), false},
{QStringLiteral("maximizeHorizontal"), false},
{QStringLiteral("maximizeVertical"), false},
{QStringLiteral("noBorder"), false},
{QStringLiteral("clientMachine"), QString()},
{QStringLiteral("localhost"), true},
{QStringLiteral("role"), QString()},
{QStringLiteral("resourceName"), QStringLiteral("testDbusInterface")},
{QStringLiteral("resourceClass"), QStringLiteral("org.kde.foo")},
{QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo")},
{QStringLiteral("caption"), QStringLiteral("Test window")},
#if KWIN_BUILD_ACTIVITIES
{ QStringLiteral("activities"), QStringList() },
{QStringLiteral("activities"), QStringList()},
#endif
};
@ -152,7 +154,7 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient()
auto windowData = reply.value();
QCOMPARE(windowData, expectedData);
auto verifyProperty = [client] (const QString &name) {
auto verifyProperty = [client](const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->internalId())};
reply.waitForFinished();
return reply.value().value(name).toBool();
@ -219,7 +221,6 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient()
QVERIFY(reply.value().empty());
}
struct XcbConnectionDeleter
{
static inline void cleanup(xcb_connection_t *pointer)
@ -261,31 +262,31 @@ void TestDbusInterface::testGetWindowInfoX11Client()
QCOMPARE(client->window(), w);
QCOMPARE(client->clientSize(), windowGeometry.size());
const QVariantMap expectedData {
{ QStringLiteral("type"), NET::Normal },
{ QStringLiteral("x"), client->x() },
{ QStringLiteral("y"), client->y() },
{ QStringLiteral("width"), client->width() },
{ QStringLiteral("height"), client->height() },
{ QStringLiteral("desktops"), client->desktopIds() },
{ QStringLiteral("minimized"), false },
{ QStringLiteral("shaded"), false },
{ QStringLiteral("fullscreen"), false },
{ QStringLiteral("keepAbove"), false },
{ QStringLiteral("keepBelow"), false },
{ QStringLiteral("skipTaskbar"), false },
{ QStringLiteral("skipPager"), false },
{ QStringLiteral("skipSwitcher"), false },
{ QStringLiteral("maximizeHorizontal"), false },
{ QStringLiteral("maximizeVertical"), false },
{ QStringLiteral("noBorder"), false },
{ QStringLiteral("role"), QString() },
{ QStringLiteral("resourceName"), QStringLiteral("foo") },
{ QStringLiteral("resourceClass"), QStringLiteral("bar") },
{ QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo") },
{ QStringLiteral("caption"), QStringLiteral("Some caption") },
const QVariantMap expectedData = {
{QStringLiteral("type"), NET::Normal},
{QStringLiteral("x"), client->x()},
{QStringLiteral("y"), client->y()},
{QStringLiteral("width"), client->width()},
{QStringLiteral("height"), client->height()},
{QStringLiteral("desktops"), client->desktopIds()},
{QStringLiteral("minimized"), false},
{QStringLiteral("shaded"), false},
{QStringLiteral("fullscreen"), false},
{QStringLiteral("keepAbove"), false},
{QStringLiteral("keepBelow"), false},
{QStringLiteral("skipTaskbar"), false},
{QStringLiteral("skipPager"), false},
{QStringLiteral("skipSwitcher"), false},
{QStringLiteral("maximizeHorizontal"), false},
{QStringLiteral("maximizeVertical"), false},
{QStringLiteral("noBorder"), false},
{QStringLiteral("role"), QString()},
{QStringLiteral("resourceName"), QStringLiteral("foo")},
{QStringLiteral("resourceClass"), QStringLiteral("bar")},
{QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo")},
{QStringLiteral("caption"), QStringLiteral("Some caption")},
#if KWIN_BUILD_ACTIVITIES
{ QStringLiteral("activities"), QStringList() },
{QStringLiteral("activities"), QStringList()},
#endif
};
@ -300,7 +301,7 @@ void TestDbusInterface::testGetWindowInfoX11Client()
windowData.remove(QStringLiteral("localhost"));
QCOMPARE(windowData, expectedData);
auto verifyProperty = [client] (const QString &name) {
auto verifyProperty = [client](const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->internalId())};
reply.waitForFinished();
return reply.value().value(name).toBool();

View file

@ -7,17 +7,18 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "debug_console.h"
#include "internal_client.h"
#include "platform.h"
#include "utils/xcbutils.h"
#include "wayland_server.h"
#include "workspace.h"
#include "utils/xcbutils.h"
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
@ -386,7 +387,10 @@ class HelperWindow : public QRasterWindow
{
Q_OBJECT
public:
HelperWindow() : QRasterWindow(nullptr) {}
HelperWindow()
: QRasterWindow(nullptr)
{
}
~HelperWindow() override = default;
Q_SIGNALS:
@ -400,7 +404,8 @@ Q_SIGNALS:
void keyReleased();
protected:
void paintEvent(QPaintEvent *event) override {
void paintEvent(QPaintEvent *event) override
{
Q_UNUSED(event)
QPainter p(this);
p.fillRect(0, 0, width(), height(), Qt::red);

View file

@ -7,14 +7,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "internal_client.h"
#include "platform.h"
#include "pointer_input.h"
#include "touch_input.h"
#include "screens.h"
#include "touch_input.h"
#include "wayland_server.h"
#include "workspace.h"
#include <kwineffects.h>
@ -23,8 +24,8 @@
#include "decorations/decorationbridge.h"
#include "decorations/settings.h"
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/seat.h>
@ -83,11 +84,11 @@ private:
AbstractClient *DecorationInputTest::showWindow()
{
using namespace KWayland::Client;
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) \
return nullptr;
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \
return nullptr;
KWayland::Client::Surface *surface = Test::createSurface(Test::waylandCompositor());
@ -365,10 +366,10 @@ void DecorationInputTest::testPressToMove_data()
QTest::addColumn<QPoint>("offset2");
QTest::addColumn<QPoint>("offset3");
QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0);
QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0);
QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30);
QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30);
QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0);
QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0);
QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30);
QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30);
}
void DecorationInputTest::testPressToMove()
@ -377,7 +378,7 @@ void DecorationInputTest::testPressToMove()
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2));
QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized);
QVERIFY(startMoveResizedSpy.isValid());
QSignalSpy clientFinishUserMovedResizedSpy(c, &AbstractClient::clientFinishUserMovedResized);
@ -424,10 +425,10 @@ void DecorationInputTest::testTapToMove_data()
QTest::addColumn<QPoint>("offset2");
QTest::addColumn<QPoint>("offset3");
QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0);
QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0);
QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30);
QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30);
QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0);
QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0);
QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30);
QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30);
}
void DecorationInputTest::testTapToMove()
@ -436,7 +437,7 @@ void DecorationInputTest::testTapToMove()
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2));
QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized);
QVERIFY(startMoveResizedSpy.isValid());
QSignalSpy clientFinishUserMovedResizedSpy(c, &AbstractClient::clientFinishUserMovedResized);
@ -502,7 +503,7 @@ void DecorationInputTest::testResizeOutsideWindow()
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2));
QVERIFY(c->frameGeometry() != c->inputGeometry());
QVERIFY(c->inputGeometry().contains(c->frameGeometry()));
QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized);
@ -513,10 +514,10 @@ void DecorationInputTest::testResizeOutsideWindow()
QFETCH(Qt::Edge, edge);
switch (edge) {
case Qt::LeftEdge:
MOTION(QPoint(c->frameGeometry().x() -1, c->frameGeometry().center().y()));
MOTION(QPoint(c->frameGeometry().x() - 1, c->frameGeometry().center().y()));
break;
case Qt::RightEdge:
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() +1, c->frameGeometry().center().y()));
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() + 1, c->frameGeometry().center().y()));
break;
case Qt::BottomEdge:
MOTION(QPoint(c->frameGeometry().center().x(), c->frameGeometry().y() + c->frameGeometry().height() + 1));
@ -546,33 +547,33 @@ void DecorationInputTest::testModifierClickUnrestrictedMove_data()
const QString alt = QStringLiteral("Alt");
const QString meta = QStringLiteral("Meta");
QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt << false;
QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt << false;
QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt << false;
QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt << false;
QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt << false;
QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt << false;
QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt << false;
QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt << false;
QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt << false;
QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt << false;
QTest::newRow("Right Alt + Middle Click") << KEY_RIGHTALT << BTN_MIDDLE << alt << false;
// now everything with meta
QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta << false;
QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta << false;
QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta << false;
QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta << false;
QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta << false;
QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta << false;
QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Right Meta + Middle Click") << KEY_RIGHTMETA << BTN_MIDDLE << meta << false;
// and with capslock
QTest::newRow("Left Alt + Left Click/CapsLock") << KEY_LEFTALT << BTN_LEFT << alt << true;
QTest::newRow("Left Alt + Right Click/CapsLock") << KEY_LEFTALT << BTN_RIGHT << alt << true;
QTest::newRow("Left Alt + Middle Click/CapsLock") << KEY_LEFTALT << BTN_MIDDLE << alt << true;
QTest::newRow("Right Alt + Left Click/CapsLock") << KEY_RIGHTALT << BTN_LEFT << alt << true;
QTest::newRow("Right Alt + Right Click/CapsLock") << KEY_RIGHTALT << BTN_RIGHT << alt << true;
QTest::newRow("Left Alt + Left Click/CapsLock") << KEY_LEFTALT << BTN_LEFT << alt << true;
QTest::newRow("Left Alt + Right Click/CapsLock") << KEY_LEFTALT << BTN_RIGHT << alt << true;
QTest::newRow("Left Alt + Middle Click/CapsLock") << KEY_LEFTALT << BTN_MIDDLE << alt << true;
QTest::newRow("Right Alt + Left Click/CapsLock") << KEY_RIGHTALT << BTN_LEFT << alt << true;
QTest::newRow("Right Alt + Right Click/CapsLock") << KEY_RIGHTALT << BTN_RIGHT << alt << true;
QTest::newRow("Right Alt + Middle Click/CapsLock") << KEY_RIGHTALT << BTN_MIDDLE << alt << true;
// now everything with meta
QTest::newRow("Left Meta + Left Click/CapsLock") << KEY_LEFTMETA << BTN_LEFT << meta << true;
QTest::newRow("Left Meta + Right Click/CapsLock") << KEY_LEFTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Left Meta + Middle Click/CapsLock") << KEY_LEFTMETA << BTN_MIDDLE << meta << true;
QTest::newRow("Right Meta + Left Click/CapsLock") << KEY_RIGHTMETA << BTN_LEFT << meta << true;
QTest::newRow("Right Meta + Right Click/CapsLock") << KEY_RIGHTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Left Meta + Left Click/CapsLock") << KEY_LEFTMETA << BTN_LEFT << meta << true;
QTest::newRow("Left Meta + Right Click/CapsLock") << KEY_LEFTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Left Meta + Middle Click/CapsLock") << KEY_LEFTMETA << BTN_MIDDLE << meta << true;
QTest::newRow("Right Meta + Left Click/CapsLock") << KEY_RIGHTMETA << BTN_LEFT << meta << true;
QTest::newRow("Right Meta + Right Click/CapsLock") << KEY_RIGHTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Right Meta + Middle Click/CapsLock") << KEY_RIGHTMETA << BTN_MIDDLE << meta << true;
}
@ -599,7 +600,7 @@ void DecorationInputTest::testModifierClickUnrestrictedMove()
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2));
// move cursor on window
Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
@ -635,13 +636,13 @@ void DecorationInputTest::testModifierScrollOpacity_data()
const QString alt = QStringLiteral("Alt");
const QString meta = QStringLiteral("Meta");
QTest::newRow("Left Alt") << KEY_LEFTALT << alt << false;
QTest::newRow("Right Alt") << KEY_RIGHTALT << alt << false;
QTest::newRow("Left Meta") << KEY_LEFTMETA << meta << false;
QTest::newRow("Left Alt") << KEY_LEFTALT << alt << false;
QTest::newRow("Right Alt") << KEY_RIGHTALT << alt << false;
QTest::newRow("Left Meta") << KEY_LEFTMETA << meta << false;
QTest::newRow("Right Meta") << KEY_RIGHTMETA << meta << false;
QTest::newRow("Left Alt/CapsLock") << KEY_LEFTALT << alt << true;
QTest::newRow("Right Alt/CapsLock") << KEY_RIGHTALT << alt << true;
QTest::newRow("Left Meta/CapsLock") << KEY_LEFTMETA << meta << true;
QTest::newRow("Left Alt/CapsLock") << KEY_LEFTALT << alt << true;
QTest::newRow("Right Alt/CapsLock") << KEY_RIGHTALT << alt << true;
QTest::newRow("Left Meta/CapsLock") << KEY_LEFTMETA << meta << true;
QTest::newRow("Right Meta/CapsLock") << KEY_RIGHTMETA << meta << true;
}
@ -661,7 +662,7 @@ void DecorationInputTest::testModifierScrollOpacity()
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2));
// move cursor on window
Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
// set the opacity to 0.5
@ -690,7 +691,10 @@ class EventHelper : public QObject
{
Q_OBJECT
public:
EventHelper() : QObject() {}
EventHelper()
: QObject()
{
}
~EventHelper() override = default;
bool eventFilter(QObject *watched, QEvent *event) override

View file

@ -7,15 +7,16 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "platform.h"
#include "utils/xcbutils.h"
#include "wayland_server.h"
#include "workspace.h"
#include "utils/xcbutils.h"
#include "x11client.h"
#include <kwineffects.h>
#include <netwm.h>
@ -40,8 +41,8 @@ private:
void X11DesktopWindowTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -89,7 +90,7 @@ void X11DesktopWindowTest::testDesktopWindow()
const QRect windowGeometry(0, 0, 1280, 1024);
// helper to find the visual
auto findDepth = [&c] () -> xcb_visualid_t {
auto findDepth = [&c]() -> xcb_visualid_t {
// find a visual with 32 depth
const xcb_setup_t *setup = xcb_get_setup(c.data());
@ -115,11 +116,11 @@ void X11DesktopWindowTest::testDesktopWindow()
const uint32_t values[] = {XCB_PIXMAP_NONE, kwinApp()->x11DefaultScreen()->black_pixel, colormapId};
auto cookie = xcb_create_window_checked(c.data(), 32, w, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualId, XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP, values);
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualId, XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP, values);
QVERIFY(!xcb_request_check(c.data(), cookie));
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));

View file

@ -7,14 +7,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "composite.h"
#include "cursor.h"
#include "platform.h"
#include "renderbackend.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <kwineffects.h>
#include <KDecoration2/Decoration>
@ -35,13 +36,12 @@ private Q_SLOTS:
void initTestCase();
void init();
void testBorderlessMaximizedWindows();
};
void DontCrashAuroraeDestroyDecoTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -108,7 +108,7 @@ void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows()
// verify that the deco is Aurorae
QCOMPARE(qstrcmp(client->decoration()->metaObject()->className(), "Aurorae::Decoration"), 0);
// find the maximize button
QQuickItem *item = client->decoration()->findChild<QQuickItem*>("maximizeButton");
QQuickItem *item = client->decoration()->findChild<QQuickItem *>("maximizeButton");
QVERIFY(item);
const QPointF scenePoint = item->mapToScene(QPoint(0, 0));
@ -117,7 +117,7 @@ void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows()
QVERIFY(client->readyForPainting());
// simulate click on maximize button
QSignalSpy maximizedStateChangedSpy(client, static_cast<void (AbstractClient::*)(KWin::AbstractClient*, MaximizeMode)>(&AbstractClient::clientMaximizedStateChanged));
QSignalSpy maximizedStateChangedSpy(client, static_cast<void (AbstractClient::*)(KWin::AbstractClient *, MaximizeMode)>(&AbstractClient::clientMaximizedStateChanged));
QVERIFY(maximizedStateChangedSpy.isValid());
quint32 timestamp = 1;
Test::pointerMotion(client->frameGeometry().topLeft() + scenePoint.toPoint(), timestamp++);

View file

@ -7,21 +7,22 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "platform.h"
#include "abstract_client.h"
#include "x11client.h"
#include "composite.h"
#include "deleted.h"
#include "effects.h"
#include "effectloader.h"
#include "effects.h"
#include "platform.h"
#include "scripting/scriptedeffect.h"
#include "wayland_server.h"
#include "workspace.h"
#include "scripting/scriptedeffect.h"
#include "x11client.h"
#include <KDecoration2/Decoration>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
@ -42,8 +43,8 @@ private Q_SLOTS:
void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
{
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::AbstractClient *>();
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName));
kwinApp()->start();
@ -75,10 +76,10 @@ void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
if (qstrcmp((*it)->metaObject()->className(), "KWin::EffectLoader") != 0) {
continue;
}
QVERIFY(QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect*, effect), Q_ARG(QString, QStringLiteral("crashy"))));
QVERIFY(QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect *, effect), Q_ARG(QString, QStringLiteral("crashy"))));
break;
}
QVERIFY(static_cast<EffectsHandlerImpl*>(effects)->isEffectLoaded(QStringLiteral("crashy")));
QVERIFY(static_cast<EffectsHandlerImpl *>(effects)->isEffectLoaded(QStringLiteral("crashy")));
using namespace KWayland::Client;
// create a window

View file

@ -7,14 +7,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "effectloader.h"
#include "x11client.h"
#include "cursor.h"
#include "effectloader.h"
#include "effects.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KConfigGroup>
@ -30,7 +31,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_kwin_crash_curs
class DontCrashCursorPhysicalSizeEmpty : public QObject
{
Q_OBJECT
Q_OBJECT
private Q_SLOTS:
void init();
void initTestCase();
@ -53,7 +54,7 @@ void DontCrashCursorPhysicalSizeEmpty::cleanup()
void DontCrashCursorPhysicalSizeEmpty::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -7,14 +7,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "composite.h"
#include "cursor.h"
#include "platform.h"
#include "renderbackend.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <kwineffects.h>
#include <KDecoration2/Decoration>
@ -37,7 +38,7 @@ private Q_SLOTS:
void DontCrashEmptyDecorationTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -7,12 +7,13 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "platform.h"
#include "abstract_client.h"
#include "x11client.h"
#include "deleted.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KDecoration2/Decoration>
@ -31,7 +32,7 @@ private Q_SLOTS:
void DontCrashGlxgearsTest::initTestCase()
{
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -8,14 +8,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "composite.h"
#include "cursor.h"
#include "platform.h"
#include "renderbackend.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <kwineffects.h>
#include <KWayland/Client/surface.h>
@ -41,7 +42,7 @@ private Q_SLOTS:
void DontCrashNoBorder::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -95,9 +95,9 @@ void DontCrashReinitializeCompositorTest::testReinitializeCompositor_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
}
void DontCrashReinitializeCompositorTest::testReinitializeCompositor()

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
@ -45,7 +46,7 @@ private Q_SLOTS:
void TestDontCrashUseractionsMenu::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -88,8 +88,8 @@ void DesktopSwitchingAnimationTest::testSwitchDesktops_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade Desktop") << QStringLiteral("kwin4_effect_fadedesktop");
QTest::newRow("Slide") << QStringLiteral("slide");
QTest::newRow("Fade Desktop") << QStringLiteral("kwin4_effect_fadedesktop");
QTest::newRow("Slide") << QStringLiteral("slide");
}
void DesktopSwitchingAnimationTest::testSwitchDesktops()

View file

@ -71,9 +71,7 @@ void MinimizeAnimationTest::initTestCase()
void MinimizeAnimationTest::init()
{
QVERIFY(Test::setupWaylandConnection(
Test::AdditionalWaylandInterface::PlasmaShell |
Test::AdditionalWaylandInterface::WindowManagement
));
Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::WindowManagement));
}
void MinimizeAnimationTest::cleanup()
@ -91,7 +89,7 @@ void MinimizeAnimationTest::testMinimizeUnminimize_data()
QTest::addColumn<QString>("effectName");
QTest::newRow("Magic Lamp") << QStringLiteral("magiclamp");
QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash");
QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash");
}
void MinimizeAnimationTest::testMinimizeUnminimize()

View file

@ -7,8 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "scripting/scriptedeffect.h"
#include "libkwineffects/anidata_p.h"
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "composite.h"
@ -16,25 +15,25 @@
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "kwin_wayland_test.h"
#include "libkwineffects/anidata_p.h"
#include "platform.h"
#include "renderbackend.h"
#include "scripting/scriptedeffect.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "workspace.h"
#include <QJSValue>
#include <QQmlEngine>
#include <KConfigGroup>
#include <KGlobalAccel>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/slide.h>
#include <KWayland/Client/surface.h>
#include <QJSValue>
#include <QQmlEngine>
using namespace KWin;
using namespace std::chrono_literals;
@ -79,8 +78,8 @@ public:
bool load(const QString &name);
using AnimationEffect::AniMap;
using AnimationEffect::state;
Q_INVOKABLE void sendTestResponse(const QString &out); //proxies triggers out from the tests
QList<QAction*> actions(); //returns any QActions owned by the ScriptEngine
Q_INVOKABLE void sendTestResponse(const QString &out); // proxies triggers out from the tests
QList<QAction *> actions(); // returns any QActions owned by the ScriptEngine
Q_SIGNALS:
void testOutput(const QString &data);
};
@ -106,7 +105,7 @@ bool ScriptedEffectWithDebugSpy::load(const QString &name)
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
const QString path = QFINDTESTDATA("./scripts/" + name + ".js");
engine()->globalObject().setProperty("sendTestResponse", selfContext.property("sendTestResponse"));
if (!init(name, path)) {
if (!init(name, path)) {
return false;
}
@ -118,18 +117,18 @@ bool ScriptedEffectWithDebugSpy::load(const QString &name)
if (qstrcmp((*it)->metaObject()->className(), "KWin::EffectLoader") != 0) {
continue;
}
QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect*, this), Q_ARG(QString, name));
QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect *, this), Q_ARG(QString, name));
break;
}
return (static_cast<EffectsHandlerImpl*>(effects)->isEffectLoaded(name));
return (static_cast<EffectsHandlerImpl *>(effects)->isEffectLoaded(name));
}
void ScriptedEffectsTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::Effect*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -250,7 +249,7 @@ void ScriptedEffectsTest::testAnimations_data()
QTest::addColumn<int>("animationCount");
QTest::newRow("single") << "animationTest" << 1;
QTest::newRow("multi") << "animationTestMulti" << 2;
QTest::newRow("multi") << "animationTestMulti" << 2;
}
void ScriptedEffectsTest::testAnimations()
@ -353,7 +352,7 @@ void ScriptedEffectsTest::testFullScreenEffect_data()
QTest::addColumn<QString>("file");
QTest::newRow("single") << "fullScreenEffectTest";
QTest::newRow("multi") << "fullScreenEffectTestMulti";
QTest::newRow("multi") << "fullScreenEffectTestMulti";
QTest::newRow("global") << "fullScreenEffectTestGlobal";
}
@ -368,8 +367,8 @@ void ScriptedEffectsTest::testFullScreenEffect()
QVERIFY(effectMain->load(file));
//load any random effect from another test to confirm fullscreen effect state is correctly
//shown as being someone else
// load any random effect from another test to confirm fullscreen effect state is correctly
// shown as being someone else
auto effectOther = new ScriptedEffectWithDebugSpy();
QVERIFY(effectOther->load("screenEdgeTouchTest"));
QSignalSpy isActiveFullScreenEffectSpyOther(effectOther, &ScriptedEffect::isActiveFullScreenEffectChanged);
@ -387,7 +386,7 @@ void ScriptedEffectsTest::testFullScreenEffect()
QCOMPARE(effects->hasActiveFullScreenEffect(), false);
QCOMPARE(effectMain->isActiveFullScreenEffect(), false);
//trigger animation
// trigger animation
KWin::VirtualDesktopManager::self()->setCurrent(2);
QCOMPARE(effects->activeFullScreenEffect(), effectMain);
@ -400,18 +399,18 @@ void ScriptedEffectsTest::testFullScreenEffect()
QCOMPARE(effectOther->isActiveFullScreenEffect(), false);
QCOMPARE(isActiveFullScreenEffectSpyOther.count(), 0);
//after 500ms trigger another full screen animation
// after 500ms trigger another full screen animation
QTest::qWait(500);
KWin::VirtualDesktopManager::self()->setCurrent(1);
QCOMPARE(effects->activeFullScreenEffect(), effectMain);
//after 1000ms (+a safety margin for time based tests) we should still be the active full screen effect
//despite first animation expiring
QTest::qWait(500+100);
// after 1000ms (+a safety margin for time based tests) we should still be the active full screen effect
// despite first animation expiring
QTest::qWait(500 + 100);
QCOMPARE(effects->activeFullScreenEffect(), effectMain);
//after 1500ms (+a safetey margin) we should have no full screen effect
QTest::qWait(500+100);
// after 1500ms (+a safetey margin) we should have no full screen effect
QTest::qWait(500 + 100);
QCOMPARE(effects->activeFullScreenEffect(), nullptr);
}
@ -420,8 +419,8 @@ void ScriptedEffectsTest::testKeepAlive_data()
QTest::addColumn<QString>("file");
QTest::addColumn<bool>("keepAlive");
QTest::newRow("keep") << "keepAliveTest" << true;
QTest::newRow("don't keep") << "keepAliveTestDontKeep" << false;
QTest::newRow("keep") << "keepAliveTest" << true;
QTest::newRow("don't keep") << "keepAliveTestDontKeep" << false;
}
void ScriptedEffectsTest::testKeepAlive()
@ -613,9 +612,9 @@ void ScriptedEffectsTest::testRedirect_data()
QTest::addColumn<QString>("file");
QTest::addColumn<bool>("shouldTerminate");
QTest::newRow("animate/DontTerminateAtSource") << "redirectAnimateDontTerminateTest" << false;
QTest::newRow("animate/TerminateAtSource") << "redirectAnimateTerminateTest" << true;
QTest::newRow("set/DontTerminate") << "redirectSetDontTerminateTest" << false;
QTest::newRow("set/Terminate") << "redirectSetTerminateTest" << true;
QTest::newRow("animate/TerminateAtSource") << "redirectAnimateTerminateTest" << true;
QTest::newRow("set/DontTerminate") << "redirectSetDontTerminateTest" << false;
QTest::newRow("set/Terminate") << "redirectSetTerminateTest" << true;
}
void ScriptedEffectsTest::testRedirect()
@ -637,9 +636,9 @@ void ScriptedEffectsTest::testRedirect()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
auto around = [] (std::chrono::milliseconds elapsed,
std::chrono::milliseconds pivot,
std::chrono::milliseconds margin) {
auto around = [](std::chrono::milliseconds elapsed,
std::chrono::milliseconds pivot,
std::chrono::milliseconds margin) {
return qAbs(elapsed.count() - pivot.count()) < margin.count();
};
@ -715,9 +714,9 @@ void ScriptedEffectsTest::testComplete()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
auto around = [] (std::chrono::milliseconds elapsed,
std::chrono::milliseconds pivot,
std::chrono::milliseconds margin) {
auto around = [](std::chrono::milliseconds elapsed,
std::chrono::milliseconds pivot,
std::chrono::milliseconds margin) {
return qAbs(elapsed.count() - pivot.count()) < margin.count();
};

View file

@ -6,24 +6,24 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "x11client.h"
#include "composite.h"
#include "deleted.h"
#include "effects.h"
#include "effectloader.h"
#include "cursor.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "kwin_wayland_test.h"
#include "platform.h"
#include "renderbackend.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KConfigGroup>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/slide.h>
#include <KWayland/Client/surface.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
@ -33,7 +33,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_effects_sliding
class SlidingPopupsTest : public QObject
{
Q_OBJECT
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
@ -48,9 +48,9 @@ private Q_SLOTS:
void SlidingPopupsTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::Effect*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -88,7 +88,7 @@ void SlidingPopupsTest::init()
void SlidingPopupsTest::cleanup()
{
Test::destroyWaylandConnection();
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl*>(effects);
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
while (!e->loadedEffects().isEmpty()) {
const QString effect = e->loadedEffects().first();
e->unloadEffect(effect);
@ -104,7 +104,6 @@ struct XcbConnectionDeleter
}
};
void SlidingPopupsTest::testWithOtherEffect_data()
{
QTest::addColumn<QStringList>("effectsToLoad");
@ -129,9 +128,9 @@ void SlidingPopupsTest::testWithOtherEffect()
// this test verifies that slidingpopups effect grabs the window added role
// independently of the sequence how the effects are loaded.
// see BUG 336866
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl*>(effects);
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
// find the effectsloader
auto effectloader = e->findChild<AbstractEffectLoader*>();
auto effectloader = e->findChild<AbstractEffectLoader *>();
QVERIFY(effectloader);
QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded);
QVERIFY(effectLoadedSpy.isValid());
@ -145,7 +144,7 @@ void SlidingPopupsTest::testWithOtherEffect()
QVERIFY(e->isEffectLoaded(effectName));
QCOMPARE(effectLoadedSpy.count(), 1);
Effect *effect = effectLoadedSpy.first().first().value<Effect*>();
Effect *effect = effectLoadedSpy.first().first().value<Effect *>();
if (effectName == QStringLiteral("slidingpopups")) {
slidingPoupus = effect;
} else {
@ -267,9 +266,9 @@ void SlidingPopupsTest::testWithOtherEffectWayland()
// independently of the sequence how the effects are loaded.
// see BUG 336866
// the test is like testWithOtherEffect, but simulates using a Wayland window
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl*>(effects);
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
// find the effectsloader
auto effectloader = e->findChild<AbstractEffectLoader*>();
auto effectloader = e->findChild<AbstractEffectLoader *>();
QVERIFY(effectloader);
QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded);
QVERIFY(effectLoadedSpy.isValid());
@ -283,7 +282,7 @@ void SlidingPopupsTest::testWithOtherEffectWayland()
QVERIFY(e->isEffectLoaded(effectName));
QCOMPARE(effectLoadedSpy.count(), 1);
Effect *effect = effectLoadedSpy.first().first().value<Effect*>();
Effect *effect = effectLoadedSpy.first().first().value<Effect *>();
if (effectName == QStringLiteral("slidingpopups")) {
slidingPoupus = effect;
} else {

View file

@ -89,9 +89,9 @@ void ToplevelOpenCloseAnimationTest::testAnimateToplevels_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
}
void ToplevelOpenCloseAnimationTest::testAnimateToplevels()
@ -142,9 +142,9 @@ void ToplevelOpenCloseAnimationTest::testDontAnimatePopups_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
}
void ToplevelOpenCloseAnimationTest::testDontAnimatePopups()

View file

@ -7,14 +7,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "x11client.h"
#include "composite.h"
#include "effects.h"
#include "effectloader.h"
#include "cursor.h"
#include "effectloader.h"
#include "effects.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KConfigGroup>
@ -26,7 +27,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_effects_translu
class TranslucencyTest : public QObject
{
Q_OBJECT
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
@ -42,8 +43,8 @@ private:
void TranslucencyTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Effect*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -71,9 +72,9 @@ void TranslucencyTest::initTestCase()
void TranslucencyTest::init()
{
// load the translucency effect
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl*>(effects);
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
// find the effectsloader
auto effectloader = e->findChild<AbstractEffectLoader*>();
auto effectloader = e->findChild<AbstractEffectLoader *>();
QVERIFY(effectloader);
QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded);
QVERIFY(effectLoadedSpy.isValid());
@ -83,13 +84,13 @@ void TranslucencyTest::init()
QVERIFY(e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency")));
QCOMPARE(effectLoadedSpy.count(), 1);
m_translucencyEffect = effectLoadedSpy.first().first().value<Effect*>();
m_translucencyEffect = effectLoadedSpy.first().first().value<Effect *>();
QVERIFY(m_translucencyEffect);
}
void TranslucencyTest::cleanup()
{
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl*>(effects);
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
if (e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency"))) {
e->unloadEffect(QStringLiteral("kwin4_effect_translucency"));
}

View file

@ -7,22 +7,23 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "x11client.h"
#include "composite.h"
#include "cursor.h"
#include "effects.h"
#include "effectloader.h"
#include "effects.h"
#include "platform.h"
#include "renderbackend.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KConfigGroup>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/slide.h>
#include <KWayland/Client/surface.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
@ -32,7 +33,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_effects_wobbly_
class WobblyWindowsShadeTest : public QObject
{
Q_OBJECT
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
@ -43,8 +44,8 @@ private Q_SLOTS:
void WobblyWindowsShadeTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Effect*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -95,11 +96,10 @@ struct XcbConnectionDeleter
void WobblyWindowsShadeTest::testShadeMove()
{
// this test simulates the condition from BUG 390953
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl*>(effects);
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
QVERIFY(e->loadEffect(QStringLiteral("wobblywindows")));
QVERIFY(e->isEffectLoaded(QStringLiteral("wobblywindows")));
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
const QRect windowGeometry(0, 0, 100, 200);

View file

@ -12,23 +12,28 @@
#include <KDecoration2/Decoration>
#include <KPluginFactory>
class FakeDecoWithShadows : public KDecoration2::Decoration
{
Q_OBJECT
public:
explicit FakeDecoWithShadows(QObject *parent = nullptr, const QVariantList &args = QVariantList())
: Decoration(parent, args) {}
~FakeDecoWithShadows() override {}
: Decoration(parent, args)
{
}
~FakeDecoWithShadows() override
{
}
void paint(QPainter *painter, const QRect &repaintRegion) override {
void paint(QPainter *painter, const QRect &repaintRegion) override
{
Q_UNUSED(painter)
Q_UNUSED(repaintRegion)
}
public Q_SLOTS:
void init() override {
void init() override
{
const int shadowSize = 128;
const int offsetTop = 64;
const int offsetLeft = 48;
@ -55,7 +60,6 @@ public Q_SLOTS:
K_PLUGIN_FACTORY_WITH_JSON(
FakeDecoWithShadowsFactory,
"fakedecoration_with_shadows.json",
registerPlugin<FakeDecoWithShadows>();
)
registerPlugin<FakeDecoWithShadows>();)
#include "fakedecoration_with_shadows.moc"

View file

@ -9,8 +9,8 @@
#include "generic_scene_opengl_test.h"
#include "abstract_client.h"
#include "composite.h"
#include "effectloader.h"
#include "cursor.h"
#include "effectloader.h"
#include "platform.h"
#include "renderbackend.h"
#include "scene.h"
@ -38,7 +38,7 @@ void GenericSceneOpenGLTest::cleanup()
void GenericSceneOpenGLTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -13,9 +13,10 @@
class GenericSceneOpenGLTest : public QObject
{
Q_OBJECT
Q_OBJECT
public:
~GenericSceneOpenGLTest() override;
protected:
GenericSceneOpenGLTest(const QByteArray &envVariable);
private Q_SLOTS:

View file

@ -7,7 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "x11client.h"
#include "cursor.h"
#include "input.h"
#include "internal_client.h"
@ -16,6 +16,7 @@
#include "useractions.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KWayland/Client/surface.h>
#include <KWaylandServer/keyboard_interface.h>
@ -96,34 +97,31 @@ void GlobalShortcutsTest::testNonLatinLayout_data()
QTest::addColumn<Qt::Key>("qtKey");
for (const auto &modifier :
QVector<QPair<int, Qt::Modifier>> {
{KEY_LEFTCTRL, Qt::CTRL},
{KEY_LEFTALT, Qt::ALT},
{KEY_LEFTSHIFT, Qt::SHIFT},
{KEY_LEFTMETA, Qt::META},
} )
{
QVector<QPair<int, Qt::Modifier>>{
{KEY_LEFTCTRL, Qt::CTRL},
{KEY_LEFTALT, Qt::ALT},
{KEY_LEFTSHIFT, Qt::SHIFT},
{KEY_LEFTMETA, Qt::META},
}) {
for (const auto &key :
QVector<QPair<int, Qt::Key>> {
// Tab is example of a key usually the same on different layouts, check it first
{KEY_TAB, Qt::Key_Tab},
{KEY_TAB, Qt::Key_Tab},
// Then check a key with a Latin letter.
// The symbol will probably be differ on non-Latin layout.
// On Russian layout, "w" key has a cyrillic letter "ц"
{KEY_W, Qt::Key_W},
// Then check a key with a Latin letter.
// The symbol will probably be differ on non-Latin layout.
// On Russian layout, "w" key has a cyrillic letter "ц"
{KEY_W, Qt::Key_W},
#if QT_VERSION_MAJOR > 5 // since Qt 5 LTS is frozen
// More common case with any Latin1 symbol keys, including punctuation, should work also.
// "`" key has a "ё" letter on Russian layout
// FIXME: QTBUG-90611
{KEY_GRAVE, Qt::Key_QuoteLeft},
#endif
} )
{
#if QT_VERSION_MAJOR > 5 // since Qt 5 LTS is frozen
// More common case with any Latin1 symbol keys, including punctuation, should work also.
// "`" key has a "ё" letter on Russian layout
// FIXME: QTBUG-90611
{KEY_GRAVE, Qt::Key_QuoteLeft},
#endif
}) {
QTest::newRow(QKeySequence(modifier.second + key.second).toString().toLatin1().constData())
<< modifier.first << modifier.second << key.first << key.second;
<< modifier.first << modifier.second << key.first << key.second;
}
}
}
@ -315,9 +313,7 @@ void GlobalShortcutsTest::testX11ClientShortcut()
xcb_window_t w = xcb_generate_id(c.data());
const QRect windowGeometry = QRect(0, 0, 10, 20);
const uint32_t values[] = {
XCB_EVENT_MASK_ENTER_WINDOW |
XCB_EVENT_MASK_LEAVE_WINDOW
};
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW};
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
@ -409,7 +405,7 @@ void GlobalShortcutsTest::testWaylandClientShortcut()
shellSurface.reset();
surface.reset();
QVERIFY(Test::waitForWindowDestroyed(client));
QTRY_VERIFY_WITH_TIMEOUT(workspace()->shortcutAvailable(seq), 500); //we need the try since KGlobalAccelPrivate::unregister is async
QTRY_VERIFY_WITH_TIMEOUT(workspace()->shortcutAvailable(seq), 500); // we need the try since KGlobalAccelPrivate::unregister is async
}
void GlobalShortcutsTest::testSetupWindowShortcut()
@ -431,7 +427,7 @@ void GlobalShortcutsTest::testSetupWindowShortcut()
auto dialog = shortcutDialogAddedSpy.first().first().value<InternalClient *>();
QVERIFY(dialog);
QVERIFY(dialog->isInternal());
auto sequenceEdit = workspace()->shortcutDialog()->findChild<QKeySequenceEdit*>();
auto sequenceEdit = workspace()->shortcutDialog()->findChild<QKeySequenceEdit *>();
QVERIFY(sequenceEdit);
// the QKeySequenceEdit field does not get focus, we need to pass it focus manually

View file

@ -42,7 +42,7 @@ void Window::focusInEvent(QFocusEvent *event)
{
QRasterWindow::focusInEvent(event);
// TODO: make it work without singleshot
QTimer::singleShot(100,[] {
QTimer::singleShot(100, [] {
qApp->clipboard()->setText(QStringLiteral("test"));
});
}

View file

@ -24,7 +24,7 @@ int main(int argc, char *argv[])
w.show();
auto freezeHandler = [](int) {
while(true) {
while (true) {
sleep(10000);
}
};

View file

@ -41,12 +41,11 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QObject::connect(app.clipboard(), &QClipboard::changed, &app,
[] {
if (qApp->clipboard()->text() == QLatin1String("test")) {
QTimer::singleShot(100, qApp, &QCoreApplication::quit);
}
}
);
[] {
if (qApp->clipboard()->text() == QLatin1String("test")) {
QTimer::singleShot(100, qApp, &QCoreApplication::quit);
}
});
QScopedPointer<Window> w(new Window);
w->setGeometry(QRect(0, 0, 100, 200));
w->show();

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "platform.h"
#include "virtualdesktops.h"
@ -41,7 +42,7 @@ private Q_SLOTS:
void TestIdleInhibition::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
@ -57,7 +58,6 @@ void TestIdleInhibition::initTestCase()
void TestIdleInhibition::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::IdleInhibitV1));
}
void TestIdleInhibition::cleanup()
@ -70,7 +70,7 @@ void TestIdleInhibition::cleanup()
void TestIdleInhibition::testInhibit()
{
auto idle = waylandServer()->display()->findChild<IdleInterface*>();
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
QVERIFY(idle);
QVERIFY(!idle->isInhibited());
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
@ -172,7 +172,7 @@ void TestIdleInhibition::testDontInhibitWhenMinimized()
// This test verifies that the idle inhibitor object is not honored when the
// associated surface is minimized.
// Get reference to the idle interface.
// Get reference to the idle interface.
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
QVERIFY(idle);
QVERIFY(!idle->isInhibited());

View file

@ -7,20 +7,21 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "deleted.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include <kwineffects.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/event_queue.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
@ -47,8 +48,8 @@ private:
void InputStackingOrderTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -7,28 +7,29 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "effects.h"
#include "deleted.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "effects.h"
#include "inputmethod.h"
#include "virtualkeyboard_dbus.h"
#include "platform.h"
#include "qwayland-input-method-unstable-v1.h"
#include "qwayland-text-input-unstable-v3.h"
#include "virtualkeyboard_dbus.h"
#include "wayland_server.h"
#include "workspace.h"
#include <QTest>
#include <QSignalSpy>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingReply>
#include <KWaylandServer/clientconnection.h>
#include <KWaylandServer/display.h>
#include <KWaylandServer/seat_interface.h>
#include <KWaylandServer/surface_interface.h>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingReply>
#include <QSignalSpy>
#include <QTest>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/keyboard.h>
@ -63,14 +64,14 @@ private Q_SLOTS:
void testModifierForwarding();
private:
void touchNow() {
void touchNow()
{
static int time = 0;
Test::touchDown(0, {100, 100}, ++time);
Test::touchUp(0, ++time);
}
};
void InputMethodTest::initTestCase()
{
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kwin.testvirtualkeyboard"));
@ -93,16 +94,12 @@ void InputMethodTest::initTestCase()
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
Test::initWaylandWorkspace();
}
void InputMethodTest::init()
{
touchNow();
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat |
Test::AdditionalWaylandInterface::TextInputManagerV2 |
Test::AdditionalWaylandInterface::InputMethodV1 |
Test::AdditionalWaylandInterface::TextInputManagerV3));
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::TextInputManagerV2 | Test::AdditionalWaylandInterface::InputMethodV1 | Test::AdditionalWaylandInterface::TextInputManagerV3));
workspace()->setActiveOutput(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
@ -291,7 +288,6 @@ void InputMethodTest::testHidePanel()
// Destroy the test client.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(client));
}
void InputMethodTest::testSwitchFocusedSurfaces()

View file

@ -7,12 +7,13 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "cursor.h"
#include "deleted.h"
#include "effects.h"
#include "internal_client.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
@ -20,8 +21,8 @@
#include <QRasterWindow>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/surface.h>
#include <KWindowSystem>
#include <KWaylandServer/surface_interface.h>
@ -76,10 +77,12 @@ public:
HelperWindow();
~HelperWindow() override;
QPoint latestGlobalMousePos() const {
QPoint latestGlobalMousePos() const
{
return m_latestGlobalMousePos;
}
Qt::MouseButtons pressedButtons() const {
Qt::MouseButtons pressedButtons() const
{
return m_pressedButtons;
}
@ -676,9 +679,9 @@ void InternalWindowTest::testPopup()
void InternalWindowTest::testScale()
{
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection,
Q_ARG(int, 2),
Q_ARG(QVector<QRect>, QVector<QRect>({QRect(0,0,1280, 1024), QRect(1280/2, 0, 1280, 1024)})),
Q_ARG(QVector<int>, QVector<int>({2,2})));
Q_ARG(int, 2),
Q_ARG(QVector<QRect>, QVector<QRect>({QRect(0, 0, 1280, 1024), QRect(1280 / 2, 0, 1280, 1024)})),
Q_ARG(QVector<int>, QVector<int>({2, 2})));
QSignalSpy clientAddedSpy(workspace(), &Workspace::internalClientAdded);
QVERIFY(clientAddedSpy.isValid());
@ -838,7 +841,7 @@ void InternalWindowTest::testDismissPopup()
auto serverPopup = clientAddedSpy.last().first().value<InternalClient *>();
QVERIFY(serverPopup);
//Create the other window to click
// Create the other window to click
HelperWindow otherClientToplevel;
otherClientToplevel.setGeometry(100, 100, 100, 100);
otherClientToplevel.show();

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "keyboard_input.h"
#include "keyboard_layout.h"
@ -109,25 +110,29 @@ void KeyboardLayoutTest::resetLayouts()
callSession(QStringLiteral("loadSession"));
}
auto KeyboardLayoutTest::changeLayout(uint index) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.keyboard"), QStringLiteral("/Layouts"), QStringLiteral("org.kde.KeyboardLayouts"), QStringLiteral("setLayout"));
auto KeyboardLayoutTest::changeLayout(uint index)
{
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.keyboard"),
QStringLiteral("/Layouts"),
QStringLiteral("org.kde.KeyboardLayouts"),
QStringLiteral("setLayout"));
msg << index;
return QDBusConnection::sessionBus().asyncCall(msg);
}
void KeyboardLayoutTest::callSession(const QString &method) {
QDBusMessage msg = QDBusMessage::createMethodCall(
QStringLiteral("org.kde.KWin"),
QStringLiteral("/Session"),
QStringLiteral("org.kde.KWin.Session"),
method);
msg << QLatin1String(); // session name
void KeyboardLayoutTest::callSession(const QString &method)
{
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Session"),
QStringLiteral("org.kde.KWin.Session"),
method);
msg << QLatin1String(); // session name
QVERIFY(QDBusConnection::sessionBus().call(msg).type() != QDBusMessage::ErrorMessage);
}
void KeyboardLayoutTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -144,9 +149,9 @@ void KeyboardLayoutTest::initTestCase()
Test::initWaylandWorkspace();
// don't get DBus signal on one-layout configuration
// QVERIFY(layoutsReconfiguredSpy.wait());
// QCOMPARE(layoutsReconfiguredSpy.count(), 1);
// layoutsReconfiguredSpy.clear();
// QVERIFY(layoutsReconfiguredSpy.wait());
// QCOMPARE(layoutsReconfiguredSpy.count(), 1);
// layoutsReconfiguredSpy.clear();
}
void KeyboardLayoutTest::init()
@ -189,7 +194,12 @@ void KeyboardLayoutTest::testChangeLayoutThroughDBus()
{
// this test verifies that the layout can be changed through DBus
// first configure layouts
enum Layout {de, us, de_neo, bad};
enum Layout {
de,
us,
de_neo,
bad,
};
layoutGroup.writeEntry("LayoutList", QStringLiteral("de,us,de(neo)"));
layoutGroup.sync();
reconfigureLayouts();
@ -257,12 +267,12 @@ void KeyboardLayoutTest::testPerLayoutShortcut()
QAction *a = new QAction(this);
a->setObjectName(QStringLiteral("Switch keyboard layout to English (US)"));
a->setProperty("componentName", componentName);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>{Qt::CTRL|Qt::ALT|Qt::Key_1}, KGlobalAccel::NoAutoloading);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>{Qt::CTRL | Qt::ALT | Qt::Key_1}, KGlobalAccel::NoAutoloading);
delete a;
a = new QAction(this);
a->setObjectName(QStringLiteral("Switch keyboard layout to German"));
a->setProperty("componentName", componentName);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>{Qt::CTRL|Qt::ALT|Qt::Key_2}, KGlobalAccel::NoAutoloading);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>{Qt::CTRL | Qt::ALT | Qt::Key_2}, KGlobalAccel::NoAutoloading);
delete a;
// now we should have three layouts
@ -356,18 +366,18 @@ void KeyboardLayoutTest::testVirtualDesktopPolicy()
resetLayouts();
// check layout set on desktop switching as intended
for(--desktop;;) {
for (--desktop;;) {
QCOMPARE(desktops.at(desktop), VirtualDesktopManager::self()->currentDesktop());
layout = (desktop + 1) % xkb->numberOfLayouts();
QCOMPARE(xkb->currentLayout(), layout);
if (--desktop >= VirtualDesktopManager::self()->count()) // overflow
if (--desktop >= VirtualDesktopManager::self()->count()) // overflow
break;
VirtualDesktopManager::self()->setCurrent(desktops.at(desktop));
}
// remove virtual desktops
desktop = 0;
const KWin::VirtualDesktop* deletedDesktop = desktops.last();
const KWin::VirtualDesktop *deletedDesktop = desktops.last();
VirtualDesktopManager::self()->setCount(1);
QCOMPARE(xkb->currentLayout(), layout = (desktop + 1) % xkb->numberOfLayouts());
QCOMPARE(xkb->layoutName(), QStringLiteral("German"));
@ -386,12 +396,17 @@ void KeyboardLayoutTest::testVirtualDesktopPolicy()
QVERIFY(deletedDesktopSpy.isValid());
QVERIFY(deletedDesktopSpy.wait());
resetLayouts();
QCOMPARE(layoutGroup.keyList().filter( QStringLiteral("LayoutDefault") ).count(), 1);
QCOMPARE(layoutGroup.keyList().filter(QStringLiteral("LayoutDefault")).count(), 1);
}
void KeyboardLayoutTest::testWindowPolicy()
{
enum Layout {us, de, de_neo, bad};
enum Layout {
us,
de,
de_neo,
bad,
};
layoutGroup.writeEntry("LayoutList", QStringLiteral("us,de,de(neo)"));
layoutGroup.writeEntry("SwitchMode", QStringLiteral("Window"));
layoutGroup.sync();
@ -433,7 +448,12 @@ void KeyboardLayoutTest::testWindowPolicy()
void KeyboardLayoutTest::testApplicationPolicy()
{
enum Layout {us, de, de_neo, bad};
enum Layout {
us,
de,
de_neo,
bad,
};
layoutGroup.writeEntry("LayoutList", QStringLiteral("us,de,de(neo)"));
layoutGroup.writeEntry("SwitchMode", QStringLiteral("WinClass"));
layoutGroup.sync();
@ -488,7 +508,7 @@ void KeyboardLayoutTest::testApplicationPolicy()
QCOMPARE(xkb->layoutName(), QStringLiteral("German (Neo 2)"));
resetLayouts();
QCOMPARE(layoutGroup.keyList().filter( QStringLiteral("LayoutDefault") ).count(), 1);
QCOMPARE(layoutGroup.keyList().filter(QStringLiteral("LayoutDefault")).count(), 1);
}
void KeyboardLayoutTest::testNumLock()

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "keyboard_input.h"
#include "keyboard_layout.h"
@ -46,7 +47,7 @@ void KeymapCreationFailureTest::initTestCase()
qputenv("XKB_DEFAULT_VARIANT", "no");
qputenv("XKB_DEFAULT_OPTIONS", "no");
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -13,9 +13,9 @@
#include "inputmethod.h"
#include "platform.h"
#include "pluginmanager.h"
#include "utils/xcbutils.h"
#include "wayland_server.h"
#include "workspace.h"
#include "utils/xcbutils.h"
#include "xwl/xwayland.h"
#include <KPluginMetaData>
@ -27,9 +27,9 @@
#include <QtConcurrentRun>
// system
#include <unistd.h>
#include <sys/socket.h>
#include <iostream>
#include <sys/socket.h>
#include <unistd.h>
Q_IMPORT_PLUGIN(KWinIntegrationPlugin)
Q_IMPORT_PLUGIN(KGlobalAccelImpl)
@ -83,7 +83,7 @@ WaylandTestApplication::~WaylandTestApplication()
// need to unload all effects prior to destroying X connection as they might do X calls
// also before destroy Workspace, as effects might call into Workspace
if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
static_cast<EffectsHandlerImpl *>(effects)->unloadAllEffects();
}
delete m_xwayland;
m_xwayland = nullptr;

View file

@ -76,7 +76,8 @@ public:
WaylandTestApplication(OperationMode mode, int &argc, char **argv);
~WaylandTestApplication() override;
void setInputMethodServerToStart(const QString &inputMethodServer) {
void setInputMethodServerToStart(const QString &inputMethodServer)
{
m_inputMethodServerToStart = inputMethodServer;
}
@ -111,14 +112,20 @@ class MockInputMethod;
class TextInputManagerV3 : public QtWayland::zwp_text_input_manager_v3
{
public:
~TextInputManagerV3() override { destroy(); }
~TextInputManagerV3() override
{
destroy();
}
};
class TextInputV3 : public QObject, public QtWayland::zwp_text_input_v3
{
Q_OBJECT
public:
~TextInputV3() override { destroy(); }
~TextInputV3() override
{
destroy();
}
Q_SIGNALS:
void preeditString(const QString &text, int cursor_begin, int cursor_end);
@ -198,10 +205,10 @@ class XdgToplevel : public QObject, public QtWayland::xdg_toplevel
public:
enum class State {
Maximized = 1 << 0,
Maximized = 1 << 0,
Fullscreen = 1 << 1,
Resizing = 1 << 2,
Activated = 1 << 3
Resizing = 1 << 2,
Activated = 1 << 3
};
Q_DECLARE_FLAGS(States, State)
@ -608,7 +615,6 @@ XdgPopup *createXdgPopupSurface(KWayland::Client::Surface *surface, XdgSurface *
XdgToplevelDecorationV1 *createXdgToplevelDecorationV1(XdgToplevel *toplevel, QObject *parent = nullptr);
IdleInhibitorV1 *createIdleInhibitorV1(KWayland::Client::Surface *surface);
/**
* Creates a shared memory buffer of @p size in @p color and attaches it to the @p surface.
* The @p surface gets damaged and committed, thus it's rendered.
@ -662,22 +668,22 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Test::AdditionalWaylandInterfaces)
Q_DECLARE_METATYPE(KWin::Test::XdgToplevel::States)
Q_DECLARE_METATYPE(QtWayland::zxdg_toplevel_decoration_v1::mode)
#define WAYLANDTEST_MAIN_HELPER(TestObject, DPI, OperationMode) \
int main(int argc, char *argv[]) \
{ \
setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); \
setenv("QT_QPA_PLATFORM_PLUGIN_PATH", QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath().toLocal8Bit().constData(), true); \
setenv("KWIN_FORCE_OWN_QPA", "1", true); \
qunsetenv("KDE_FULL_SESSION"); \
qunsetenv("KDE_SESSION_VERSION"); \
qunsetenv("XDG_SESSION_DESKTOP"); \
qunsetenv("XDG_CURRENT_DESKTOP"); \
DPI; \
KWin::WaylandTestApplication app(OperationMode, argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
#define WAYLANDTEST_MAIN_HELPER(TestObject, DPI, OperationMode) \
int main(int argc, char *argv[]) \
{ \
setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); \
setenv("QT_QPA_PLATFORM_PLUGIN_PATH", QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath().toLocal8Bit().constData(), true); \
setenv("KWIN_FORCE_OWN_QPA", "1", true); \
qunsetenv("KDE_FULL_SESSION"); \
qunsetenv("KDE_SESSION_VERSION"); \
qunsetenv("XDG_SESSION_DESKTOP"); \
qunsetenv("XDG_CURRENT_DESKTOP"); \
DPI; \
KWin::WaylandTestApplication app(OperationMode, argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
#ifdef NO_XWAYLAND
#define WAYLANDTEST_MAIN(TestObject) WAYLANDTEST_MAIN_HELPER(TestObject, QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps), KWin::Application::OperationModeWaylandOnly)

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "cursor.h"
#include "input.h"
@ -42,10 +43,9 @@ private Q_SLOTS:
void testWindowToDesktop();
};
void KWinBindingsTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -100,7 +100,7 @@ void KWinBindingsTest::testSwitchWindow()
// now let's trigger the shortcuts
// invoke global shortcut through dbus
auto invokeShortcut = [] (const QString &shortcut) {
auto invokeShortcut = [](const QString &shortcut) {
auto msg = QDBusMessage::createMethodCall(
QStringLiteral("org.kde.kglobalaccel"),
QStringLiteral("/component/kwin"),
@ -157,7 +157,7 @@ void KWinBindingsTest::testSwitchWindowScript()
c3->move(QPoint(200, 200));
c4->move(QPoint(0, 200));
auto runScript = [] (const QString &slot) {
auto runScript = [](const QString &slot) {
QTemporaryFile tmpFile;
QVERIFY(tmpFile.open());
QTextStream out(&tmpFile);
@ -227,7 +227,7 @@ void KWinBindingsTest::testWindowToDesktop()
VirtualDesktopManager::self()->setCount(desktop);
// now trigger the shortcut
auto invokeShortcut = [] (int desktop) {
auto invokeShortcut = [](int desktop) {
auto msg = QDBusMessage::createMethodCall(
QStringLiteral("org.kde.kglobalaccel"),
QStringLiteral("/component/kwin"),

View file

@ -5,6 +5,7 @@
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "main.h"
@ -84,7 +85,7 @@ void LayerShellV1ClientTest::testOutput_data()
{
QTest::addColumn<int>("screenId");
QTest::addRow("first output") << 0;
QTest::addRow("first output") << 0;
QTest::addRow("second output") << 1;
}
@ -127,33 +128,29 @@ void LayerShellV1ClientTest::testAnchor_data()
QTest::addColumn<int>("anchor");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 450, 280, 124);
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 450, 280, 124);
QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top |
Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 0, 280, 124);
QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 0, 280, 124);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top)
<< QRect(500, 0, 280, 124);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top)
<< QRect(500, 0, 280, 124);
QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top |
Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 0, 280, 124);
QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 0, 280, 124);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 450, 280, 124);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 450, 280, 124);
QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom |
Test::LayerSurfaceV1::anchor_right)
QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 900, 280, 124);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom)
<< QRect(500, 900, 280, 124);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom)
<< QRect(500, 900, 280, 124);
QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom |
Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 900, 280, 124);
QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 900, 280, 124);
}
void LayerShellV1ClientTest::testAnchor()
@ -194,41 +191,37 @@ void LayerShellV1ClientTest::testMargins_data()
QTest::addColumn<QMargins>("margins");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 0, 0, 0)
<< QRect(100, 450, 280, 124);
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 0, 0, 0)
<< QRect(100, 450, 280, 124);
QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top |
Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 200, 0, 0)
<< QRect(100, 200, 280, 124);
QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 200, 0, 0)
<< QRect(100, 200, 280, 124);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top)
<< QMargins(0, 200, 0, 0)
<< QRect(500, 200, 280, 124);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top)
<< QMargins(0, 200, 0, 0)
<< QRect(500, 200, 280, 124);
QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top |
Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 200, 300, 0)
<< QRect(700, 200, 280, 124);
QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 200, 300, 0)
<< QRect(700, 200, 280, 124);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 0, 300, 0)
<< QRect(700, 450, 280, 124);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 0, 300, 0)
<< QRect(700, 450, 280, 124);
QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom |
Test::LayerSurfaceV1::anchor_right)
QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 0, 300, 400)
<< QRect(700, 500, 280, 124);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom)
<< QMargins(0, 0, 0, 400)
<< QRect(500, 500, 280, 124);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom)
<< QMargins(0, 0, 0, 400)
<< QRect(500, 500, 280, 124);
QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom |
Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 0, 0, 400)
<< QRect(100, 500, 280, 124);
QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 0, 0, 400)
<< QRect(100, 500, 280, 124);
}
void LayerShellV1ClientTest::testMargins()
@ -269,9 +262,9 @@ void LayerShellV1ClientTest::testLayer_data()
QTest::addColumn<int>("protocolLayer");
QTest::addColumn<Layer>("compositorLayer");
QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << UnmanagedLayer;
QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << AboveLayer;
QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << BelowLayer;
QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << UnmanagedLayer;
QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << AboveLayer;
QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << BelowLayer;
QTest::addRow("background") << int(Test::LayerShellV1::layer_background) << DesktopLayer;
}
@ -312,9 +305,9 @@ void LayerShellV1ClientTest::testPlacementArea_data()
QTest::addColumn<int>("exclusiveZone");
QTest::addColumn<QRect>("placementArea");
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) << 300 << QRect(300, 0, 980, 1024);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) << 300 << QRect(0, 300, 1280, 724);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) << 300 << QRect(0, 0, 980, 1024);
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) << 300 << QRect(300, 0, 980, 1024);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) << 300 << QRect(0, 300, 1280, 724);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) << 300 << QRect(0, 0, 980, 1024);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) << 300 << QRect(0, 0, 1280, 724);
}
@ -357,22 +350,17 @@ void LayerShellV1ClientTest::testFill_data()
QTest::addColumn<QSize>("desiredSize");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addRow("horizontal") << (Test::LayerSurfaceV1::anchor_left |
Test::LayerSurfaceV1::anchor_right)
QTest::addRow("horizontal") << (Test::LayerSurfaceV1::anchor_left | Test::LayerSurfaceV1::anchor_right)
<< QSize(0, 124)
<< QRect(0, 450, 1280, 124);
QTest::addRow("vertical") << (Test::LayerSurfaceV1::anchor_top |
Test::LayerSurfaceV1::anchor_bottom)
<< QSize(280, 0)
<< QRect(500, 0, 280, 1024);
QTest::addRow("vertical") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_bottom)
<< QSize(280, 0)
<< QRect(500, 0, 280, 1024);
QTest::addRow("all") << (Test::LayerSurfaceV1::anchor_left |
Test::LayerSurfaceV1::anchor_top |
Test::LayerSurfaceV1::anchor_right |
Test::LayerSurfaceV1::anchor_bottom)
<< QSize(0, 0)
<< QRect(0, 0, 1280, 1024);
QTest::addRow("all") << (Test::LayerSurfaceV1::anchor_left | Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right | Test::LayerSurfaceV1::anchor_bottom)
<< QSize(0, 0)
<< QRect(0, 0, 1280, 1024);
}
void LayerShellV1ClientTest::testFill()
@ -493,9 +481,9 @@ void LayerShellV1ClientTest::testActivate_data()
QTest::addColumn<int>("layer");
QTest::addColumn<bool>("active");
QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << true;
QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << true;
QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << false;
QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << true;
QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << true;
QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << false;
QTest::addRow("background") << int(Test::LayerShellV1::layer_background) << false;
}

View file

@ -7,22 +7,23 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "composite.h"
#include "cursor.h"
#include "platform.h"
#include "renderbackend.h"
#include "screenedge.h"
#include "wayland_server.h"
#include "workspace.h"
#include <kwineffects.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
@ -30,7 +31,7 @@
#include <KWaylandServer/keyboard_interface.h>
#include <KWaylandServer/seat_interface.h>
//screenlocker
// screenlocker
#include <KScreenLocker/KsldApp>
#include <KGlobalAccel>
@ -80,41 +81,48 @@ class HelperEffect : public Effect
{
Q_OBJECT
public:
HelperEffect() {}
~HelperEffect() override {}
HelperEffect()
{
}
~HelperEffect() override
{
}
void windowInputMouseEvent(QEvent*) override {
void windowInputMouseEvent(QEvent *) override
{
Q_EMIT inputEvent();
}
void grabbedKeyboardEvent(QKeyEvent *e) override {
void grabbedKeyboardEvent(QKeyEvent *e) override
{
Q_EMIT keyEvent(e->text());
}
Q_SIGNALS:
void inputEvent();
void keyEvent(const QString&);
void keyEvent(const QString &);
};
#define LOCK \
QVERIFY(!waylandServer()->isScreenLocked()); \
QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); \
QVERIFY(lockStateChangedSpy.isValid()); \
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); \
QCOMPARE(lockStateChangedSpy.count(), 1); \
QVERIFY(waylandServer()->isScreenLocked());
#define LOCK \
do { \
QVERIFY(!waylandServer()->isScreenLocked()); \
QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); \
QVERIFY(lockStateChangedSpy.isValid()); \
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); \
QCOMPARE(lockStateChangedSpy.count(), 1); \
QVERIFY(waylandServer()->isScreenLocked()); \
} while (false)
#define UNLOCK \
int expectedLockCount = 1; \
if (ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked) { \
expectedLockCount = 2; \
} \
QCOMPARE(lockStateChangedSpy.count(), expectedLockCount); \
unlock(); \
if (lockStateChangedSpy.count() < expectedLockCount + 1) { \
QVERIFY(lockStateChangedSpy.wait()); \
} \
QCOMPARE(lockStateChangedSpy.count(), expectedLockCount + 1); \
QVERIFY(!waylandServer()->isScreenLocked());
#define UNLOCK \
do { \
QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); \
QVERIFY(lockStateChangedSpy.isValid()); \
unlock(); \
if (lockStateChangedSpy.count() != 1) { \
QVERIFY(lockStateChangedSpy.wait()); \
} \
QCOMPARE(lockStateChangedSpy.count(), 1); \
QVERIFY(!waylandServer()->isScreenLocked()); \
} while (false)
#define MOTION(target) Test::pointerMotion(target, timestamp++)
@ -142,11 +150,11 @@ void LockScreenTest::unlock()
AbstractClient *LockScreenTest::showWindow()
{
using namespace KWayland::Client;
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) \
return nullptr;
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \
return nullptr;
KWayland::Client::Surface *surface = Test::createSurface(m_compositor);
@ -167,7 +175,7 @@ AbstractClient *LockScreenTest::showWindow()
void LockScreenTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -212,7 +220,7 @@ void LockScreenTest::testStackingOrder()
QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid());
LOCK
LOCK;
QVERIFY(clientAddedSpy.wait());
AbstractClient *client = clientAddedSpy.first().first().value<AbstractClient *>();
@ -220,7 +228,7 @@ void LockScreenTest::testStackingOrder()
QVERIFY(client->isLockScreen());
QCOMPARE(client->layer(), UnmanagedLayer);
UNLOCK
UNLOCK;
}
void LockScreenTest::testPointer()
@ -242,7 +250,7 @@ void LockScreenTest::testPointer()
MOTION(c->frameGeometry().center());
QVERIFY(enteredSpy.wait());
LOCK
LOCK;
QVERIFY(leftSpy.wait());
QCOMPARE(leftSpy.count(), 1);
@ -258,7 +266,7 @@ void LockScreenTest::testPointer()
// go back on the window
MOTION(c->frameGeometry().center());
// and unlock
UNLOCK
UNLOCK;
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 2);
@ -294,7 +302,7 @@ void LockScreenTest::testPointerButton()
RELEASE;
QVERIFY(buttonChangedSpy.wait());
LOCK
LOCK;
// and simulate a click
PRESS;
@ -302,7 +310,7 @@ void LockScreenTest::testPointerButton()
RELEASE;
QVERIFY(!buttonChangedSpy.wait());
UNLOCK
UNLOCK;
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 2);
@ -335,16 +343,16 @@ void LockScreenTest::testPointerAxis()
Test::pointerAxisHorizontal(5.0, timestamp++);
QVERIFY(axisChangedSpy.wait());
LOCK
LOCK;
// and simulate axis
Test::pointerAxisHorizontal(5.0, timestamp++);
// and simulate axis
Test::pointerAxisHorizontal(5.0, timestamp++);
QVERIFY(!axisChangedSpy.wait(100));
Test::pointerAxisVertical(5.0, timestamp++);
QVERIFY(!axisChangedSpy.wait(100));
// and unlock
UNLOCK
UNLOCK;
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 2);
@ -387,14 +395,14 @@ void LockScreenTest::testKeyboard()
QCOMPARE(keyChangedSpy.at(1).at(1).value<Keyboard::KeyState>(), Keyboard::KeyState::Released);
QCOMPARE(keyChangedSpy.at(1).at(2).value<quint32>(), quint32(2));
LOCK
LOCK;
QVERIFY(leftSpy.wait());
KEYPRESS(KEY_B);
KEYRELEASE(KEY_B);
QCOMPARE(leftSpy.count(), 1);
QCOMPARE(keyChangedSpy.count(), 2);
UNLOCK
UNLOCK;
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 2);
KEYPRESS(KEY_C);
@ -422,13 +430,13 @@ void LockScreenTest::testScreenEdge()
MOTION(QPoint(5, 5));
QCOMPARE(screenEdgeSpy.count(), 1);
LOCK
LOCK;
MOTION(QPoint(4, 4));
QCOMPARE(screenEdgeSpy.count(), 1);
// and unlock
UNLOCK
UNLOCK;
MOTION(QPoint(5, 5));
QCOMPARE(screenEdgeSpy.count(), 2);
@ -451,7 +459,7 @@ void LockScreenTest::testEffects()
RELEASE;
QCOMPARE(inputSpy.count(), 3);
LOCK
LOCK;
MOTION(QPoint(6, 6));
QCOMPARE(inputSpy.count(), 3);
@ -461,7 +469,7 @@ void LockScreenTest::testEffects()
RELEASE;
QCOMPARE(inputSpy.count(), 3);
UNLOCK
UNLOCK;
MOTION(QPoint(5, 5));
QCOMPARE(inputSpy.count(), 4);
@ -490,13 +498,13 @@ void LockScreenTest::testEffectsKeyboard()
QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a"));
QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a"));
LOCK
LOCK;
KEYPRESS(KEY_B);
QCOMPARE(inputSpy.count(), 2);
KEYRELEASE(KEY_B);
QCOMPARE(inputSpy.count(), 2);
UNLOCK
UNLOCK;
KEYPRESS(KEY_C);
QCOMPARE(inputSpy.count(), 3);
QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a"));
@ -541,13 +549,13 @@ void LockScreenTest::testEffectsKeyboardAutorepeat()
QCOMPARE(inputSpy.count(), 1);
// while locked key repeat should not pass any events to the Effect
LOCK
LOCK;
KEYPRESS(KEY_B);
QVERIFY(!inputSpy.wait(200));
KEYRELEASE(KEY_B);
QVERIFY(!inputSpy.wait(200));
UNLOCK
UNLOCK;
// don't test again, that's covered by testEffectsKeyboard
effects->ungrabKeyboard();
@ -576,14 +584,14 @@ void LockScreenTest::testMoveWindow()
QCOMPARE(clientStepUserMovedResizedSpy.count(), 1);
// while locking our window should continue to be in move resize
LOCK
LOCK;
QCOMPARE(workspace()->moveResizeClient(), c);
QVERIFY(c->isInteractiveMove());
Test::keyboardKeyPressed(KEY_RIGHT, timestamp++);
Test::keyboardKeyReleased(KEY_RIGHT, timestamp++);
QCOMPARE(clientStepUserMovedResizedSpy.count(), 1);
UNLOCK
UNLOCK;
QCOMPARE(workspace()->moveResizeClient(), c);
QVERIFY(c->isInteractiveMove());
Test::keyboardKeyPressed(KEY_RIGHT, timestamp++);
@ -604,29 +612,30 @@ void LockScreenTest::testPointerShortcut()
// try to trigger the shortcut
quint32 timestamp = 1;
#define PERFORM(expectedCount) \
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \
PRESS; \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount); \
RELEASE; \
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount);
#define PERFORM(expectedCount) \
do { \
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \
PRESS; \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount); \
RELEASE; \
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount); \
} while (false)
PERFORM(1)
PERFORM(1);
// now the same thing with a locked screen
LOCK
PERFORM(1)
LOCK;
PERFORM(1);
// and as unlocked
UNLOCK
PERFORM(2)
UNLOCK;
PERFORM(2);
#undef PERFORM
}
void LockScreenTest::testAxisShortcut_data()
{
QTest::addColumn<Qt::Orientation>("direction");
@ -656,27 +665,29 @@ void LockScreenTest::testAxisShortcut()
// try to trigger the shortcut
quint32 timestamp = 1;
#define PERFORM(expectedCount) \
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \
if (direction == Qt::Vertical) \
Test::pointerAxisVertical(sign * 5.0, timestamp++); \
else \
Test::pointerAxisHorizontal(sign * 5.0, timestamp++); \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount); \
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount);
#define PERFORM(expectedCount) \
do { \
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \
if (direction == Qt::Vertical) \
Test::pointerAxisVertical(sign * 5.0, timestamp++); \
else \
Test::pointerAxisHorizontal(sign * 5.0, timestamp++); \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount); \
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \
QCoreApplication::instance()->processEvents(); \
QCOMPARE(actionSpy.count(), expectedCount); \
} while (false)
PERFORM(1)
PERFORM(1);
// now the same thing with a locked screen
LOCK
PERFORM(1)
LOCK;
PERFORM(1);
// and as unlocked
UNLOCK
PERFORM(2)
UNLOCK;
PERFORM(2);
#undef PERFORM
}
@ -690,7 +701,7 @@ void LockScreenTest::testKeyboardShortcut()
action->setObjectName("LockScreenTest::testKeyboardShortcut");
KGlobalAccel::self()->setDefaultShortcut(action.data(), QList<QKeySequence>{Qt::CTRL | Qt::META | Qt::ALT | Qt::Key_Space});
KGlobalAccel::self()->setShortcut(action.data(), QList<QKeySequence>{Qt::CTRL | Qt::META | Qt::ALT | Qt::Key_Space},
KGlobalAccel::NoAutoloading);
KGlobalAccel::NoAutoloading);
// try to trigger the shortcut
quint32 timestamp = 1;
@ -704,7 +715,7 @@ void LockScreenTest::testKeyboardShortcut()
QVERIFY(!actionSpy.wait());
QCOMPARE(actionSpy.count(), 1);
LOCK
LOCK;
KEYPRESS(KEY_SPACE);
QVERIFY(!actionSpy.wait());
QCOMPARE(actionSpy.count(), 1);
@ -712,7 +723,7 @@ void LockScreenTest::testKeyboardShortcut()
QVERIFY(!actionSpy.wait());
QCOMPARE(actionSpy.count(), 1);
UNLOCK
UNLOCK;
KEYPRESS(KEY_SPACE);
QVERIFY(actionSpy.wait());
QCOMPARE(actionSpy.count(), 2);
@ -744,7 +755,7 @@ void LockScreenTest::testTouch()
QVERIFY(sequenceStartedSpy.wait());
QCOMPARE(sequenceStartedSpy.count(), 1);
LOCK
LOCK;
QVERIFY(cancelSpy.wait());
Test::touchUp(1, timestamp++);
@ -753,7 +764,7 @@ void LockScreenTest::testTouch()
Test::touchMotion(1, QPointF(26, 26), timestamp++);
Test::touchUp(1, timestamp++);
UNLOCK
UNLOCK;
Test::touchDown(1, QPointF(25, 25), timestamp++);
QVERIFY(sequenceStartedSpy.wait());
QCOMPARE(sequenceStartedSpy.count(), 2);

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
@ -17,9 +18,9 @@
#include "workspace.h"
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/plasmashell.h>
#include <KDecoration2/DecoratedClient>
#include <KDecoration2/Decoration>
@ -46,7 +47,7 @@ private Q_SLOTS:
void TestMaximized::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -66,8 +67,7 @@ void TestMaximized::initTestCase()
void TestMaximized::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::XdgDecorationV1 |
Test::AdditionalWaylandInterface::PlasmaShell));
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::XdgDecorationV1 | Test::AdditionalWaylandInterface::PlasmaShell));
workspace()->setActiveOutput(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));

View file

@ -7,7 +7,9 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "kwin_wayland_test.h"
#include "cursor.h"
#include "input.h"
#include "keyboard_input.h"
@ -122,7 +124,7 @@ void ModifierOnlyShortcutTest::testTrigger_data()
QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
QTest::newRow("rightShift") << e << e << e << trigger <<KEY_RIGHTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
}
void ModifierOnlyShortcutTest::testTrigger()
@ -322,7 +324,7 @@ void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled_data()
QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL;
QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL;
QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT;
QTest::newRow("rightShift") << e << e << e << trigger <<KEY_RIGHTSHIFT;
QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT;
}
void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled()

View file

@ -8,22 +8,23 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "atoms.h"
#include "platform.h"
#include "abstract_client.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "effects.h"
#include "platform.h"
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include "deleted.h"
#include "x11client.h"
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/surface.h>
@ -320,10 +321,10 @@ void MoveResizeWindowTest::testPackTo_data()
QTest::addColumn<QString>("methodCall");
QTest::addColumn<QRect>("expectedGeometry");
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(0, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 0, 100, 50);
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(0, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 0, 100, 50);
QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRect(1180, 487, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 974, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 974, 100, 50);
}
void MoveResizeWindowTest::testPackTo()
@ -358,10 +359,10 @@ void MoveResizeWindowTest::testPackAgainstClient_data()
QTest::addColumn<QString>("methodCall");
QTest::addColumn<QRect>("expectedGeometry");
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(10, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 10, 100, 50);
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(10, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 10, 100, 50);
QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRect(1170, 487, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 964, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 964, 100, 50);
}
void MoveResizeWindowTest::testPackAgainstClient()
@ -385,7 +386,7 @@ void MoveResizeWindowTest::testPackAgainstClient()
QVERIFY(!shellSurface3.isNull());
QScopedPointer<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.data()));
QVERIFY(!shellSurface4.isNull());
auto renderWindow = [] (KWayland::Client::Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
auto renderWindow = [](KWayland::Client::Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
// let's render
auto c = Test::renderAndWaitForShown(surface, QSize(10, 10), Qt::blue);
@ -398,10 +399,10 @@ void MoveResizeWindowTest::testPackAgainstClient()
QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData());
QCOMPARE(c->frameGeometry(), expectedGeometry);
};
renderWindow(surface1.data(), QStringLiteral("slotWindowMoveLeft"), QRect(0, 507, 10, 10));
renderWindow(surface2.data(), QStringLiteral("slotWindowMoveUp"), QRect(635, 0, 10, 10));
renderWindow(surface1.data(), QStringLiteral("slotWindowMoveLeft"), QRect(0, 507, 10, 10));
renderWindow(surface2.data(), QStringLiteral("slotWindowMoveUp"), QRect(635, 0, 10, 10));
renderWindow(surface3.data(), QStringLiteral("slotWindowMoveRight"), QRect(1270, 507, 10, 10));
renderWindow(surface4.data(), QStringLiteral("slotWindowMoveDown"), QRect(635, 1014, 10, 10));
renderWindow(surface4.data(), QStringLiteral("slotWindowMoveDown"), QRect(635, 1014, 10, 10));
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(!surface.isNull());
@ -425,9 +426,9 @@ void MoveResizeWindowTest::testGrowShrink_data()
QTest::addColumn<QString>("methodCall");
QTest::addColumn<QRect>("expectedGeometry");
QTest::newRow("grow vertical") << QStringLiteral("slotWindowExpandVertical") << QRect(590, 487, 100, 537);
QTest::newRow("grow horizontal") << QStringLiteral("slotWindowExpandHorizontal") << QRect(590, 487, 690, 50);
QTest::newRow("shrink vertical") << QStringLiteral("slotWindowShrinkVertical") << QRect(590, 487, 100, 23);
QTest::newRow("grow vertical") << QStringLiteral("slotWindowExpandVertical") << QRect(590, 487, 100, 537);
QTest::newRow("grow horizontal") << QStringLiteral("slotWindowExpandHorizontal") << QRect(590, 487, 690, 50);
QTest::newRow("shrink vertical") << QStringLiteral("slotWindowShrinkVertical") << QRect(590, 487, 100, 23);
QTest::newRow("shrink horizontal") << QStringLiteral("slotWindowShrinkHorizontal") << QRect(590, 487, 40, 50);
}
@ -481,14 +482,14 @@ void MoveResizeWindowTest::testPointerMoveEnd_data()
{
QTest::addColumn<int>("additionalButton");
QTest::newRow("BTN_RIGHT") << BTN_RIGHT;
QTest::newRow("BTN_MIDDLE") << BTN_MIDDLE;
QTest::newRow("BTN_SIDE") << BTN_SIDE;
QTest::newRow("BTN_EXTRA") << BTN_EXTRA;
QTest::newRow("BTN_RIGHT") << BTN_RIGHT;
QTest::newRow("BTN_MIDDLE") << BTN_MIDDLE;
QTest::newRow("BTN_SIDE") << BTN_SIDE;
QTest::newRow("BTN_EXTRA") << BTN_EXTRA;
QTest::newRow("BTN_FORWARD") << BTN_FORWARD;
QTest::newRow("BTN_BACK") << BTN_BACK;
QTest::newRow("BTN_TASK") << BTN_TASK;
for (int i=BTN_TASK + 1; i < BTN_JOYSTICK; i++) {
QTest::newRow("BTN_BACK") << BTN_BACK;
QTest::newRow("BTN_TASK") << BTN_TASK;
for (int i = BTN_TASK + 1; i < BTN_JOYSTICK; i++) {
QTest::newRow(QByteArray::number(i, 16).constData()) << i;
}
}
@ -589,10 +590,10 @@ void MoveResizeWindowTest::testPlasmaShellSurfaceMovable_data()
QTest::addColumn<bool>("movableAcrossScreens");
QTest::addColumn<bool>("resizable");
QTest::newRow("normal") << KWayland::Client::PlasmaShellSurface::Role::Normal << true << true << true;
QTest::newRow("desktop") << KWayland::Client::PlasmaShellSurface::Role::Desktop << false << false << false;
QTest::newRow("panel") << KWayland::Client::PlasmaShellSurface::Role::Panel << false << false << false;
QTest::newRow("osd") << KWayland::Client::PlasmaShellSurface::Role::OnScreenDisplay << false << false << false;
QTest::newRow("normal") << KWayland::Client::PlasmaShellSurface::Role::Normal << true << true << true;
QTest::newRow("desktop") << KWayland::Client::PlasmaShellSurface::Role::Desktop << false << false << false;
QTest::newRow("panel") << KWayland::Client::PlasmaShellSurface::Role::Panel << false << false << false;
QTest::newRow("osd") << KWayland::Client::PlasmaShellSurface::Role::OnScreenDisplay << false << false << false;
}
void MoveResizeWindowTest::testPlasmaShellSurfaceMovable()
@ -710,7 +711,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel_data()
QTest::addColumn<quint32>("hideLocation");
QTest::newRow("top") << QRect(0, 0, 100, 20) << QPoint(50, 25) << QPoint(50, 20) << 0u;
QTest::newRow("bottom") << QRect(0, 1024-20, 100, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50) << 2u;
QTest::newRow("bottom") << QRect(0, 1024 - 20, 100, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50) << 2u;
QTest::newRow("left") << QRect(0, 0, 20, 100) << QPoint(25, 50) << QPoint(20, 50) << 3u;
QTest::newRow("right") << QRect(1280 - 20, 0, 20, 100) << QPoint(1280 - 25 - 100, 50) << QPoint(1280 - 20 - 100, 50) << 1u;
}
@ -802,7 +803,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingWaylandPanel_data
QTest::addColumn<QPoint>("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("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);
}

View file

@ -7,11 +7,11 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "platform.h"
#include "wayland_server.h"
#include "plugins/nightcolor/nightcolormanager.h"
#include "platform.h"
#include "plugins/nightcolor/constants.h"
#include "plugins/nightcolor/nightcolormanager.h"
#include "wayland_server.h"
#include <KConfigGroup>
@ -102,7 +102,6 @@ void NightColorTest::testConfigRead()
} else {
QCOMPARE(manager->mode(), mode);
}
}
WAYLANDTEST_MAIN(NightColorTest)

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "cursor.h"
#include "input.h"
#include "keyboard_input.h"
@ -131,7 +132,7 @@ void NoGlobalShortcutsTest::testTrigger_data()
QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
QTest::newRow("rightShift") << e << e << e << trigger <<KEY_RIGHTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
}
void NoGlobalShortcutsTest::testTrigger()

View file

@ -10,8 +10,8 @@
#include "abstract_output.h"
#include "cursor.h"
#include "platform.h"
#include "waylandoutputconfig.h"
#include "wayland_server.h"
#include "waylandoutputconfig.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>

View file

@ -7,10 +7,11 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "kwin_wayland_test.h"
#include "platform.h"
#include "screens.h"
#include "wayland_server.h"
@ -77,7 +78,7 @@ void TestPlacement::cleanup()
void TestPlacement::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -136,7 +137,7 @@ void TestPlacement::testPlaceSmart()
{
setPlacementPolicy(Placement::Smart);
QScopedPointer<QObject> testParent(new QObject); //dumb QObject just for scoping surfaces to the test
QScopedPointer<QObject> testParent(new QObject); // dumb QObject just for scoping surfaces to the test
QRegion usedArea;
@ -166,7 +167,7 @@ void TestPlacement::testPlaceZeroCornered()
QCOMPARE(windowPlacement.initiallyConfiguredSize, QSize(0, 0));
// size should match our buffer
QCOMPARE(windowPlacement.finalGeometry.size(), QSize(600, 500));
//and it should be in the corner
// and it should be in the corner
QCOMPARE(windowPlacement.finalGeometry.topLeft(), QPoint(0, 0));
}
}
@ -225,7 +226,7 @@ void TestPlacement::testPlaceMaximizedLeavesFullscreen()
auto c = Test::renderAndWaitForShown(surface, initiallyConfiguredSize, Qt::red);
QVERIFY(initiallyConfiguredStates & Test::XdgToplevel::State::Fullscreen);
QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024 ));
QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024));
QCOMPARE(c->frameGeometry(), QRect(0, 0, 1280, 1024));
}
}

View file

@ -7,16 +7,17 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "platform.h"
#include "cursor.h"
#include "platform.h"
#include "screens.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "workspace.h"
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/event_queue.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/registry.h>
@ -240,7 +241,6 @@ void PlasmaSurfaceTest::testOSDPlacementManualPosition()
QCOMPARE(c->frameGeometry(), QRect(50, 70, 100, 50));
}
void PlasmaSurfaceTest::testPanelTypeHasStrut_data()
{
QTest::addColumn<PlasmaShellSurface::PanelBehavior>("panelBehavior");

View file

@ -7,19 +7,20 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "cursor.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <kwineffects.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/surface.h>
#include <KWaylandServer/seat_interface.h>
//screenlocker
// screenlocker
#if KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
@ -57,7 +58,7 @@ private:
void PlasmaWindowTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -307,7 +308,7 @@ void PlasmaWindowTest::testDestroyedButNotUnmapped()
// this should create a plasma window
QVERIFY(plasmaWindowCreatedSpy.wait());
QCOMPARE(plasmaWindowCreatedSpy.count(), 1);
auto window = plasmaWindowCreatedSpy.first().first().value<PlasmaWindow*>();
auto window = plasmaWindowCreatedSpy.first().first().value<PlasmaWindow *>();
QVERIFY(window);
QSignalSpy destroyedSpy(window, &QObject::destroyed);
QVERIFY(destroyedSpy.isValid());

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "cursor.h"
#include "platform.h"
#include "wayland_server.h"

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
@ -34,7 +35,7 @@
using namespace KWin;
using namespace KWayland::Client;
typedef std::function<QPoint(const QRect&)> PointerFunc;
typedef std::function<QPoint(const QRect &)> PointerFunc;
Q_DECLARE_METATYPE(PointerFunc)
static const QString s_socketName = QStringLiteral("wayland_test_kwin_pointer_constraints-0");
@ -56,7 +57,7 @@ private Q_SLOTS:
void TestPointerConstraints::initTestCase()
{
qRegisterMetaType<PointerFunc>();
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -71,7 +72,6 @@ void TestPointerConstraints::initTestCase()
kwinApp()->setConfig(config);
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = kwinApp()->platform()->enabledOutputs();
@ -105,10 +105,10 @@ void TestPointerConstraints::testConfinedPointer_data()
PointerFunc topRight = &QRect::topRight;
PointerFunc topLeft = &QRect::topLeft;
QTest::newRow("XdgWmBase - bottomLeft") << bottomLeft << -1 << 1;
QTest::newRow("XdgWmBase - bottomRight") << bottomRight << 1 << 1;
QTest::newRow("XdgWmBase - topLeft") << topLeft << -1 << -1;
QTest::newRow("XdgWmBase - topRight") << topRight << 1 << -1;
QTest::newRow("XdgWmBase - bottomLeft") << bottomLeft << -1 << 1;
QTest::newRow("XdgWmBase - bottomRight") << bottomRight << 1 << 1;
QTest::newRow("XdgWmBase - topLeft") << topLeft << -1 << -1;
QTest::newRow("XdgWmBase - topRight") << topRight << 1 << -1;
}
void TestPointerConstraints::testConfinedPointer()
@ -208,7 +208,7 @@ void TestPointerConstraints::testConfinedPointer()
QVERIFY(unconfinedSpy2.isValid());
// activate it again, this confines again
workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->focus()));
workspace()->activateClient(static_cast<AbstractClient *>(input()->pointer()->focus()));
QVERIFY(confinedSpy2.wait());
QCOMPARE(input()->pointer()->isConstrained(), true);
@ -217,7 +217,7 @@ void TestPointerConstraints::testConfinedPointer()
QVERIFY(unconfinedSpy2.wait());
QCOMPARE(input()->pointer()->isConstrained(), false);
// activate it again, this confines again
workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->focus()));
workspace()->activateClient(static_cast<AbstractClient *>(input()->pointer()->focus()));
QVERIFY(confinedSpy2.wait());
QCOMPARE(input()->pointer()->isConstrained(), true);
@ -314,7 +314,7 @@ void TestPointerConstraints::testLockedPointer()
QVERIFY(lockedSpy2.isValid());
// activate the client again, this should lock again
workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->focus()));
workspace()->activateClient(static_cast<AbstractClient *>(input()->pointer()->focus()));
QVERIFY(lockedSpy2.wait());
QCOMPARE(input()->pointer()->isConstrained(), true);

View file

@ -7,14 +7,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "deleted.h"
#include "effects.h"
#include "pointer_input.h"
#include "options.h"
#include "platform.h"
#include "pointer_input.h"
#include "screenedge.h"
#include "screens.h"
#include "virtualdesktops.h"
@ -24,8 +25,8 @@
#include <kwineffects.h>
#include <KWayland/Client/buffer.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/region.h>
#include <KWayland/Client/seat.h>
@ -131,8 +132,8 @@ private:
void PointerInputTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -162,9 +163,7 @@ void PointerInputTest::initTestCase()
void PointerInputTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat |
Test::AdditionalWaylandInterface::Decoration |
Test::AdditionalWaylandInterface::XdgDecorationV1));
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration | Test::AdditionalWaylandInterface::XdgDecorationV1));
QVERIFY(Test::waitForWaylandPointer());
m_compositor = Test::waylandCompositor();
m_seat = Test::waylandSeat();
@ -224,7 +223,7 @@ void PointerInputTest::testWarpingUpdatesFocus()
QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window->surface());
// and out again
Cursors::self()->mouse()->setPos(QPoint(250, 250));;
Cursors::self()->mouse()->setPos(QPoint(250, 250));
QVERIFY(leftSpy.wait());
QCOMPARE(leftSpy.count(), 1);
// there should not be a focused pointer surface anymore
@ -301,7 +300,7 @@ void PointerInputTest::testWarpingDuringFilter()
QVERIFY(window->frameGeometry().contains(Cursors::self()->mouse()->pos()));
// is PresentWindows effect for top left screen edge loaded
QVERIFY(static_cast<EffectsHandlerImpl*>(effects)->isEffectLoaded("presentwindows"));
QVERIFY(static_cast<EffectsHandlerImpl *>(effects)->isEffectLoaded("presentwindows"));
QVERIFY(movedSpy.isEmpty());
quint32 timestamp = 0;
Test::pointerMotion(QPoint(0, 0), timestamp++);
@ -511,33 +510,33 @@ void PointerInputTest::testModifierClickUnrestrictedMove_data()
const QString alt = QStringLiteral("Alt");
const QString meta = QStringLiteral("Meta");
QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt << false;
QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt << false;
QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt << false;
QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt << false;
QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt << false;
QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt << false;
QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt << false;
QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt << false;
QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt << false;
QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt << false;
QTest::newRow("Right Alt + Middle Click") << KEY_RIGHTALT << BTN_MIDDLE << alt << false;
// now everything with meta
QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta << false;
QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta << false;
QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta << false;
QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta << false;
QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta << false;
QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta << false;
QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Right Meta + Middle Click") << KEY_RIGHTMETA << BTN_MIDDLE << meta << false;
// and with capslock
QTest::newRow("Left Alt + Left Click/CapsLock") << KEY_LEFTALT << BTN_LEFT << alt << true;
QTest::newRow("Left Alt + Right Click/CapsLock") << KEY_LEFTALT << BTN_RIGHT << alt << true;
QTest::newRow("Left Alt + Middle Click/CapsLock") << KEY_LEFTALT << BTN_MIDDLE << alt << true;
QTest::newRow("Right Alt + Left Click/CapsLock") << KEY_RIGHTALT << BTN_LEFT << alt << true;
QTest::newRow("Right Alt + Right Click/CapsLock") << KEY_RIGHTALT << BTN_RIGHT << alt << true;
QTest::newRow("Left Alt + Left Click/CapsLock") << KEY_LEFTALT << BTN_LEFT << alt << true;
QTest::newRow("Left Alt + Right Click/CapsLock") << KEY_LEFTALT << BTN_RIGHT << alt << true;
QTest::newRow("Left Alt + Middle Click/CapsLock") << KEY_LEFTALT << BTN_MIDDLE << alt << true;
QTest::newRow("Right Alt + Left Click/CapsLock") << KEY_RIGHTALT << BTN_LEFT << alt << true;
QTest::newRow("Right Alt + Right Click/CapsLock") << KEY_RIGHTALT << BTN_RIGHT << alt << true;
QTest::newRow("Right Alt + Middle Click/CapsLock") << KEY_RIGHTALT << BTN_MIDDLE << alt << true;
// now everything with meta
QTest::newRow("Left Meta + Left Click/CapsLock") << KEY_LEFTMETA << BTN_LEFT << meta << true;
QTest::newRow("Left Meta + Right Click/CapsLock") << KEY_LEFTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Left Meta + Middle Click/CapsLock") << KEY_LEFTMETA << BTN_MIDDLE << meta << true;
QTest::newRow("Right Meta + Left Click/CapsLock") << KEY_RIGHTMETA << BTN_LEFT << meta << true;
QTest::newRow("Right Meta + Right Click/CapsLock") << KEY_RIGHTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Left Meta + Left Click/CapsLock") << KEY_LEFTMETA << BTN_LEFT << meta << true;
QTest::newRow("Left Meta + Right Click/CapsLock") << KEY_LEFTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Left Meta + Middle Click/CapsLock") << KEY_LEFTMETA << BTN_MIDDLE << meta << true;
QTest::newRow("Right Meta + Left Click/CapsLock") << KEY_RIGHTMETA << BTN_LEFT << meta << true;
QTest::newRow("Right Meta + Right Click/CapsLock") << KEY_RIGHTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Right Meta + Middle Click/CapsLock") << KEY_RIGHTMETA << BTN_MIDDLE << meta << true;
}
@ -676,13 +675,13 @@ void PointerInputTest::testModifierScrollOpacity_data()
const QString alt = QStringLiteral("Alt");
const QString meta = QStringLiteral("Meta");
QTest::newRow("Left Alt") << KEY_LEFTALT << alt << false;
QTest::newRow("Right Alt") << KEY_RIGHTALT << alt << false;
QTest::newRow("Left Meta") << KEY_LEFTMETA << meta << false;
QTest::newRow("Left Alt") << KEY_LEFTALT << alt << false;
QTest::newRow("Right Alt") << KEY_RIGHTALT << alt << false;
QTest::newRow("Left Meta") << KEY_LEFTMETA << meta << false;
QTest::newRow("Right Meta") << KEY_RIGHTMETA << meta << false;
QTest::newRow("Left Alt/CapsLock") << KEY_LEFTALT << alt << true;
QTest::newRow("Right Alt/CapsLock") << KEY_RIGHTALT << alt << true;
QTest::newRow("Left Meta/CapsLock") << KEY_LEFTMETA << meta << true;
QTest::newRow("Left Alt/CapsLock") << KEY_LEFTALT << alt << true;
QTest::newRow("Right Alt/CapsLock") << KEY_RIGHTALT << alt << true;
QTest::newRow("Left Meta/CapsLock") << KEY_LEFTMETA << meta << true;
QTest::newRow("Right Meta/CapsLock") << KEY_RIGHTMETA << meta << true;
}
@ -800,7 +799,7 @@ void PointerInputTest::testModifierScrollOpacityGlobalShortcutsDisabled()
workspace()->disableGlobalShortcutsForClient(false);
}
void PointerInputTest::testScrollAction()
void PointerInputTest::testScrollAction()
{
// this test verifies that scroll on inactive window performs a mouse action
using namespace KWayland::Client;
@ -939,9 +938,9 @@ void PointerInputTest::testMouseActionInactiveWindow_data()
{
QTest::addColumn<quint32>("button");
QTest::newRow("Left") << quint32(BTN_LEFT);
QTest::newRow("Left") << quint32(BTN_LEFT);
QTest::newRow("Middle") << quint32(BTN_MIDDLE);
QTest::newRow("Right") << quint32(BTN_RIGHT);
QTest::newRow("Right") << quint32(BTN_RIGHT);
}
void PointerInputTest::testMouseActionInactiveWindow()
@ -1023,7 +1022,7 @@ void PointerInputTest::testMouseActionActiveWindow_data()
QTest::addColumn<bool>("clickRaise");
QTest::addColumn<quint32>("button");
for (quint32 i=BTN_LEFT; i < BTN_JOYSTICK; i++) {
for (quint32 i = BTN_LEFT; i < BTN_JOYSTICK; i++) {
QByteArray number = QByteArray::number(i, 16);
QTest::newRow(QByteArrayLiteral("click raise/").append(number).constData()) << true << i;
QTest::newRow(QByteArrayLiteral("no click raise/").append(number).constData()) << false << i;
@ -1193,7 +1192,7 @@ void PointerInputTest::testCursorImage()
cursorSurface->commit();
QVERIFY(cursorRenderedSpy.wait());
QTRY_COMPARE(cursor->image(), blueScaled);
QCOMPARE(cursor->hotspot(), QPoint(6, 6)); //surface-local (so not changed)
QCOMPARE(cursor->hotspot(), QPoint(6, 6)); // surface-local (so not changed)
// hide the cursor
pointer->setCursor(nullptr);
@ -1211,8 +1210,12 @@ class HelperEffect : public Effect
{
Q_OBJECT
public:
HelperEffect() {}
~HelperEffect() override {}
HelperEffect()
{
}
~HelperEffect() override
{
}
};
void PointerInputTest::testEffectOverrideCursorImage()
@ -1525,41 +1528,41 @@ void PointerInputTest::testConfineToScreenGeometry_data()
// +----------+
//
QTest::newRow("move top-left - left screen") << QPoint(640, 512) << QPoint(-100, -100) << QPoint(0, 0);
QTest::newRow("move top - left screen") << QPoint(640, 512) << QPoint(640, -100) << QPoint(640, 0);
QTest::newRow("move top-right - left screen") << QPoint(640, 512) << QPoint(1380, -100) << QPoint(1380, 0);
QTest::newRow("move right - left screen") << QPoint(640, 512) << QPoint(1380, 512) << QPoint(1380, 512);
QTest::newRow("move bottom-right - left screen") << QPoint(640, 512) << QPoint(1380, 1124) << QPoint(1380, 1124);
QTest::newRow("move bottom - left screen") << QPoint(640, 512) << QPoint(640, 1124) << QPoint(640, 1023);
QTest::newRow("move bottom-left - left screen") << QPoint(640, 512) << QPoint(-100, 1124) << QPoint(0, 1023);
QTest::newRow("move left - left screen") << QPoint(640, 512) << QPoint(-100, 512) << QPoint(0, 512);
QTest::newRow("move top-left - left screen") << QPoint(640, 512) << QPoint(-100, -100) << QPoint(0, 0);
QTest::newRow("move top - left screen") << QPoint(640, 512) << QPoint(640, -100) << QPoint(640, 0);
QTest::newRow("move top-right - left screen") << QPoint(640, 512) << QPoint(1380, -100) << QPoint(1380, 0);
QTest::newRow("move right - left screen") << QPoint(640, 512) << QPoint(1380, 512) << QPoint(1380, 512);
QTest::newRow("move bottom-right - left screen") << QPoint(640, 512) << QPoint(1380, 1124) << QPoint(1380, 1124);
QTest::newRow("move bottom - left screen") << QPoint(640, 512) << QPoint(640, 1124) << QPoint(640, 1023);
QTest::newRow("move bottom-left - left screen") << QPoint(640, 512) << QPoint(-100, 1124) << QPoint(0, 1023);
QTest::newRow("move left - left screen") << QPoint(640, 512) << QPoint(-100, 512) << QPoint(0, 512);
QTest::newRow("move top-left - top screen") << QPoint(1920, 512) << QPoint(1180, -100) << QPoint(1180, 0);
QTest::newRow("move top - top screen") << QPoint(1920, 512) << QPoint(1920, -100) << QPoint(1920, 0);
QTest::newRow("move top-right - top screen") << QPoint(1920, 512) << QPoint(2660, -100) << QPoint(2660, 0);
QTest::newRow("move right - top screen") << QPoint(1920, 512) << QPoint(2660, 512) << QPoint(2660, 512);
QTest::newRow("move bottom-right - top screen") << QPoint(1920, 512) << QPoint(2660, 1124) << QPoint(2559, 1023);
QTest::newRow("move bottom - top screen") << QPoint(1920, 512) << QPoint(1920, 1124) << QPoint(1920, 1124);
QTest::newRow("move bottom-left - top screen") << QPoint(1920, 512) << QPoint(1180, 1124) << QPoint(1280, 1023);
QTest::newRow("move left - top screen") << QPoint(1920, 512) << QPoint(1180, 512) << QPoint(1180, 512);
QTest::newRow("move top-left - top screen") << QPoint(1920, 512) << QPoint(1180, -100) << QPoint(1180, 0);
QTest::newRow("move top - top screen") << QPoint(1920, 512) << QPoint(1920, -100) << QPoint(1920, 0);
QTest::newRow("move top-right - top screen") << QPoint(1920, 512) << QPoint(2660, -100) << QPoint(2660, 0);
QTest::newRow("move right - top screen") << QPoint(1920, 512) << QPoint(2660, 512) << QPoint(2660, 512);
QTest::newRow("move bottom-right - top screen") << QPoint(1920, 512) << QPoint(2660, 1124) << QPoint(2559, 1023);
QTest::newRow("move bottom - top screen") << QPoint(1920, 512) << QPoint(1920, 1124) << QPoint(1920, 1124);
QTest::newRow("move bottom-left - top screen") << QPoint(1920, 512) << QPoint(1180, 1124) << QPoint(1280, 1023);
QTest::newRow("move left - top screen") << QPoint(1920, 512) << QPoint(1180, 512) << QPoint(1180, 512);
QTest::newRow("move top-left - right screen") << QPoint(3200, 512) << QPoint(2460, -100) << QPoint(2460, 0);
QTest::newRow("move top - right screen") << QPoint(3200, 512) << QPoint(3200, -100) << QPoint(3200, 0);
QTest::newRow("move top-right - right screen") << QPoint(3200, 512) << QPoint(3940, -100) << QPoint(3839, 0);
QTest::newRow("move right - right screen") << QPoint(3200, 512) << QPoint(3940, 512) << QPoint(3839, 512);
QTest::newRow("move bottom-right - right screen") << QPoint(3200, 512) << QPoint(3940, 1124) << QPoint(3839, 1023);
QTest::newRow("move bottom - right screen") << QPoint(3200, 512) << QPoint(3200, 1124) << QPoint(3200, 1023);
QTest::newRow("move bottom-left - right screen") << QPoint(3200, 512) << QPoint(2460, 1124) << QPoint(2460, 1124);
QTest::newRow("move left - right screen") << QPoint(3200, 512) << QPoint(2460, 512) << QPoint(2460, 512);
QTest::newRow("move top-left - right screen") << QPoint(3200, 512) << QPoint(2460, -100) << QPoint(2460, 0);
QTest::newRow("move top - right screen") << QPoint(3200, 512) << QPoint(3200, -100) << QPoint(3200, 0);
QTest::newRow("move top-right - right screen") << QPoint(3200, 512) << QPoint(3940, -100) << QPoint(3839, 0);
QTest::newRow("move right - right screen") << QPoint(3200, 512) << QPoint(3940, 512) << QPoint(3839, 512);
QTest::newRow("move bottom-right - right screen") << QPoint(3200, 512) << QPoint(3940, 1124) << QPoint(3839, 1023);
QTest::newRow("move bottom - right screen") << QPoint(3200, 512) << QPoint(3200, 1124) << QPoint(3200, 1023);
QTest::newRow("move bottom-left - right screen") << QPoint(3200, 512) << QPoint(2460, 1124) << QPoint(2460, 1124);
QTest::newRow("move left - right screen") << QPoint(3200, 512) << QPoint(2460, 512) << QPoint(2460, 512);
QTest::newRow("move top-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 924) << QPoint(1180, 924);
QTest::newRow("move top - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 924) << QPoint(1920, 924);
QTest::newRow("move top-right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 924) << QPoint(2660, 924);
QTest::newRow("move right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 1536) << QPoint(2559, 1536);
QTest::newRow("move top-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 924) << QPoint(1180, 924);
QTest::newRow("move top - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 924) << QPoint(1920, 924);
QTest::newRow("move top-right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 924) << QPoint(2660, 924);
QTest::newRow("move right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 1536) << QPoint(2559, 1536);
QTest::newRow("move bottom-right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 2148) << QPoint(2559, 2047);
QTest::newRow("move bottom - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 2148) << QPoint(1920, 2047);
QTest::newRow("move bottom-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 2148) << QPoint(1280, 2047);
QTest::newRow("move left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 1536) << QPoint(1280, 1536);
QTest::newRow("move bottom - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 2148) << QPoint(1920, 2047);
QTest::newRow("move bottom-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 2148) << QPoint(1280, 2047);
QTest::newRow("move left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 1536) << QPoint(1280, 1536);
}
void PointerInputTest::testConfineToScreenGeometry()
@ -1569,15 +1572,14 @@ void PointerInputTest::testConfineToScreenGeometry()
// unload the Present Windows effect because it pushes back
// pointer if it's at (0, 0)
static_cast<EffectsHandlerImpl*>(effects)->unloadEffect(QStringLiteral("presentwindows"));
static_cast<EffectsHandlerImpl *>(effects)->unloadEffect(QStringLiteral("presentwindows"));
// setup screen layout
const QVector<QRect> geometries {
const QVector<QRect> geometries{
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
QRect(2560, 0, 1280, 1024),
QRect(1280, 1024, 1280, 1024)
};
QRect(1280, 1024, 1280, 1024)};
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, geometries.count()),
@ -1606,14 +1608,14 @@ void PointerInputTest::testResizeCursor_data()
QTest::addColumn<Qt::Edges>("edges");
QTest::addColumn<KWin::CursorShape>("cursorShape");
QTest::newRow("top-left") << Qt::Edges(Qt::TopEdge | Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeNorthWest);
QTest::newRow("top") << Qt::Edges(Qt::TopEdge) << CursorShape(ExtendedCursor::SizeNorth);
QTest::newRow("top-right") << Qt::Edges(Qt::TopEdge | Qt::RightEdge) << CursorShape(ExtendedCursor::SizeNorthEast);
QTest::newRow("right") << Qt::Edges(Qt::RightEdge) << CursorShape(ExtendedCursor::SizeEast);
QTest::newRow("top-left") << Qt::Edges(Qt::TopEdge | Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeNorthWest);
QTest::newRow("top") << Qt::Edges(Qt::TopEdge) << CursorShape(ExtendedCursor::SizeNorth);
QTest::newRow("top-right") << Qt::Edges(Qt::TopEdge | Qt::RightEdge) << CursorShape(ExtendedCursor::SizeNorthEast);
QTest::newRow("right") << Qt::Edges(Qt::RightEdge) << CursorShape(ExtendedCursor::SizeEast);
QTest::newRow("bottom-right") << Qt::Edges(Qt::BottomEdge | Qt::RightEdge) << CursorShape(ExtendedCursor::SizeSouthEast);
QTest::newRow("bottom") << Qt::Edges(Qt::BottomEdge) << CursorShape(ExtendedCursor::SizeSouth);
QTest::newRow("bottom-left") << Qt::Edges(Qt::BottomEdge | Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeSouthWest);
QTest::newRow("left") << Qt::Edges(Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeWest);
QTest::newRow("bottom") << Qt::Edges(Qt::BottomEdge) << CursorShape(ExtendedCursor::SizeSouth);
QTest::newRow("bottom-left") << Qt::Edges(Qt::BottomEdge | Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeSouthWest);
QTest::newRow("left") << Qt::Edges(Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeWest);
}
void PointerInputTest::testResizeCursor()

View file

@ -7,23 +7,24 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "abstract_client.h"
#include "x11client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "decorations/decorationbridge.h"
#include "decorations/settings.h"
#include "platform.h"
#include "scripting/scripting.h"
#include "wayland_server.h"
#include "workspace.h"
#include "scripting/scripting.h"
#include "x11client.h"
#include <KDecoration2/DecoratedClient>
#include <KDecoration2/Decoration>
#include <KDecoration2/DecorationSettings>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/surface.h>
@ -79,7 +80,7 @@ private:
void QuickTilingTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::MaximizeMode>("MaximizeMode");
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
@ -130,14 +131,14 @@ void QuickTilingTest::testQuickTiling_data()
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right);
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << QuickTileMode();
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right);
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << QuickTileMode();
QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << QRect(1280, 512, 1280, 512) << FLAG(Bottom);
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top));
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << QuickTileMode();
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom));
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top));
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << QuickTileMode();
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom));
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << QRect(1920, 512, 640, 512) << QuickTileMode();
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024) << QuickTileMode();
@ -279,10 +280,10 @@ void QuickTilingTest::testQuickMaximizing()
// client is now set to maximised
QCOMPARE(maximizeChangedSpy1.count(), 1);
QCOMPARE(maximizeChangedSpy1.first().first().value<KWin::AbstractClient*>(), c);
QCOMPARE(maximizeChangedSpy1.first().first().value<KWin::AbstractClient *>(), c);
QCOMPARE(maximizeChangedSpy1.first().last().value<KWin::MaximizeMode>(), MaximizeFull);
QCOMPARE(maximizeChangedSpy2.count(), 1);
QCOMPARE(maximizeChangedSpy2.first().first().value<KWin::AbstractClient*>(), c);
QCOMPARE(maximizeChangedSpy2.first().first().value<KWin::AbstractClient *>(), c);
QCOMPARE(maximizeChangedSpy2.first().at(1).toBool(), true);
QCOMPARE(maximizeChangedSpy2.first().at(2).toBool(), true);
QCOMPARE(c->maximizeMode(), MaximizeFull);
@ -309,10 +310,10 @@ void QuickTilingTest::testQuickMaximizing()
QCOMPARE(c->frameGeometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
QCOMPARE(maximizeChangedSpy1.count(), 2);
QCOMPARE(maximizeChangedSpy1.last().first().value<KWin::AbstractClient*>(), c);
QCOMPARE(maximizeChangedSpy1.last().first().value<KWin::AbstractClient *>(), c);
QCOMPARE(maximizeChangedSpy1.last().last().value<KWin::MaximizeMode>(), MaximizeRestore);
QCOMPARE(maximizeChangedSpy2.count(), 2);
QCOMPARE(maximizeChangedSpy2.last().first().value<KWin::AbstractClient*>(), c);
QCOMPARE(maximizeChangedSpy2.last().first().value<KWin::AbstractClient *>(), c);
QCOMPARE(maximizeChangedSpy2.last().at(1).toBool(), false);
QCOMPARE(maximizeChangedSpy2.last().at(2).toBool(), false);
}
@ -505,9 +506,7 @@ void QuickTilingTest::testQuickTilingTouchMove()
QVERIFY(c->isDecorated());
const auto decoration = c->decoration();
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->frameGeometry(), QRect(-decoration->borderLeft(), 0,
1000 + decoration->borderLeft() + decoration->borderRight(),
50 + decoration->borderTop() + decoration->borderBottom()));
QCOMPARE(c->frameGeometry(), QRect(-decoration->borderLeft(), 0, 1000 + decoration->borderLeft() + decoration->borderRight(), 50 + decoration->borderTop() + decoration->borderBottom()));
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QCOMPARE(c->maximizeMode(), MaximizeRestore);
@ -530,7 +529,6 @@ void QuickTilingTest::testQuickTilingTouchMove()
Test::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;
@ -559,14 +557,14 @@ void QuickTilingTest::testX11QuickTiling_data()
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << 0 << QuickTileMode();
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << 1 << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << 1 << FLAG(Left);
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << 0 << QuickTileMode();
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << 1 << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << 1 << FLAG(Left);
QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << 1 << FLAG(Bottom);
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << 0 << QuickTileMode();
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << 1 << (FLAG(Left) | FLAG(Top));
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << 0 << QuickTileMode();
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << 0 << QuickTileMode();
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << 1 << (FLAG(Left) | FLAG(Top));
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << 0 << QuickTileMode();
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << 1 << (FLAG(Left) | FLAG(Bottom));
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << 0 << QuickTileMode();
@ -640,14 +638,14 @@ void QuickTilingTest::testX11QuickTilingAfterVertMaximize_data()
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024);
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024);
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024);
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024);
QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512);
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512);
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512);
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512);
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512);
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512);
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512);
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512);
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024);

View file

@ -12,7 +12,10 @@ class SceneOpenGLESTest : public GenericSceneOpenGLTest
{
Q_OBJECT
public:
SceneOpenGLESTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2ES")) {}
SceneOpenGLESTest()
: GenericSceneOpenGLTest(QByteArrayLiteral("O2ES"))
{
}
};
WAYLANDTEST_MAIN(SceneOpenGLESTest)

View file

@ -12,7 +12,10 @@ class SceneOpenGLTest : public GenericSceneOpenGLTest
{
Q_OBJECT
public:
SceneOpenGLTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2")) {}
SceneOpenGLTest()
: GenericSceneOpenGLTest(QByteArrayLiteral("O2"))
{
}
};
WAYLANDTEST_MAIN(SceneOpenGLTest)

View file

@ -7,20 +7,21 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "effectloader.h"
#include "x11client.h"
#include "cursor.h"
#include "effectloader.h"
#include "effects.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KConfigGroup>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/pointer.h>
#include <KWaylandServer/shmclientbuffer.h>
#include <KWaylandServer/surface_interface.h>
@ -34,7 +35,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_qpai
class SceneQPainterTest : public QObject
{
Q_OBJECT
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanup();
@ -53,7 +54,7 @@ void SceneQPainterTest::cleanup()
void SceneQPainterTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -210,14 +211,14 @@ void SceneQPainterTest::testWindowScaled()
// now let's map the window
s->setScale(2);
//draw a blue square@400x600 with red rectangle@200x200 in the middle
const QSize size(400,600);
// draw a blue square@400x600 with red rectangle@200x200 in the middle
const QSize size(400, 600);
QImage img(size, QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::blue);
QPainter surfacePainter(&img);
surfacePainter.fillRect(200,300,200,200, Qt::red);
surfacePainter.fillRect(200, 300, 200, 200, Qt::red);
//add buffer
// add buffer
Test::render(s.data(), img);
QVERIFY(pointerEnteredSpy.wait());
p->setCursor(cs.data(), QPoint(5, 5));
@ -229,7 +230,7 @@ void SceneQPainterTest::testWindowScaled()
QPainter painter(&referenceImage);
painter.fillRect(0, 0, 200, 300, Qt::blue);
painter.fillRect(100, 150, 100, 100, Qt::red);
painter.fillRect(5, 5, 10, 10, Qt::red); //cursor
painter.fillRect(5, 5, 10, 10, Qt::red); // cursor
const auto outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst()));
@ -337,7 +338,6 @@ void SceneQPainterTest::testX11Window()
xcb_map_window(c.data(), w);
xcb_flush(c.data());
// we should get a client for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(windowCreatedSpy.isValid());

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "cursor.h"
#include "platform.h"
@ -15,8 +16,8 @@
#include "workspace.h"
#include <KWayland/Client/output.h>
#include <KWayland/Client/xdgoutput.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/xdgoutput.h>
using namespace KWin;
using namespace KWayland::Client;
@ -133,7 +134,7 @@ void ScreenChangesTest::testScreenAddRemove()
QVERIFY(o2ChangedSpy.wait());
QCOMPARE(o2->geometry(), geometries.at(1));
//and check XDGOutput is synced
// and check XDGOutput is synced
QScopedPointer<XdgOutput> xdgO1(xdgOutputManager->getXdgOutput(o1.data()));
QSignalSpy xdgO1ChangedSpy(xdgO1.data(), &XdgOutput::changed);
QVERIFY(xdgO1ChangedSpy.isValid());

View file

@ -7,14 +7,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "platform.h"
#include "screenedge.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <kwineffects.h>
#include <netwm.h>
@ -39,8 +40,8 @@ private Q_SLOTS:
void ScreenEdgeClientShowTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -72,7 +73,6 @@ void ScreenEdgeClientShowTest::init()
QVERIFY(waylandServer()->clients().isEmpty());
}
struct XcbConnectionDeleter
{
static inline void cleanup(xcb_connection_t *pointer)
@ -163,16 +163,16 @@ void ScreenEdgeClientShowTest::testScreenEdgeShowHideX11()
// go into event loop to trigger xcb_flush
QTest::qWait(1);
//hide window again
// hide window again
Cursors::self()->mouse()->setPos(QPoint(640, 512));
xcb_change_property(c.data(), XCB_PROP_MODE_REPLACE, w, atom, XCB_ATOM_CARDINAL, 32, 1, &location);
xcb_flush(c.data());
QVERIFY(clientHiddenSpy.wait());
QVERIFY(client->isHiddenInternal());
QFETCH(QRect, resizedWindowGeometry);
//resizewhile hidden
// resizewhile hidden
client->moveResize(resizedWindowGeometry);
//triggerPos shouldn't be valid anymore
// triggerPos shouldn't be valid anymore
Cursors::self()->mouse()->setPos(triggerPos);
QVERIFY(client->isHiddenInternal());

View file

@ -14,8 +14,8 @@
#include "cursor.h"
#include "effectloader.h"
#include "main.h"
#include "screenedge.h"
#include "platform.h"
#include "screenedge.h"
#include "wayland_server.h"
#include "workspace.h"

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"

View file

@ -67,8 +67,7 @@ static QString locateMainScript(const QString &pluginName)
QStringLiteral("kwin/scripts"),
[&](const KPluginMetaData &metaData) {
return metaData.pluginId() == pluginName;
}
);
});
if (offers.isEmpty()) {
return QString();
}

View file

@ -7,12 +7,13 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "cursor.h"
#include "effectloader.h"
#include "platform.h"
#include "scripting/scripting.h"
#include "wayland_server.h"
#include "workspace.h"
#include "scripting/scripting.h"
#define private public
#include "screenedge.h"
@ -90,7 +91,7 @@ void ScreenEdgeTest::cleanup()
{
// try to unload the script
const QStringList scripts = {QFINDTESTDATA("./scripts/screenedge.js"), QFINDTESTDATA("./scripts/screenedgeunregister.js"), QFINDTESTDATA("./scripts/touchScreenedge.js")};
for (const QString &script: scripts) {
for (const QString &script : scripts) {
if (!script.isEmpty()) {
if (Scripting::self()->isScriptLoaded(script)) {
QVERIFY(Scripting::self()->unloadScript(script));
@ -105,17 +106,17 @@ void ScreenEdgeTest::testEdge_data()
QTest::addColumn<KWin::ElectricBorder>("edge");
QTest::addColumn<QPoint>("triggerPos");
QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0);
QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0);
QTest::newRow("TopRight") << KWin::ElectricTopRight << QPoint(1279, 0);
QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 512);
QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 512);
QTest::newRow("BottomRight") << KWin::ElectricBottomRight << QPoint(1279, 1023);
QTest::newRow("Bottom") << KWin::ElectricBottom << QPoint(512, 1023);
QTest::newRow("BottomLeft") << KWin::ElectricBottomLeft << QPoint(0, 1023);
QTest::newRow("Left") << KWin::ElectricLeft << QPoint(0, 512);
QTest::newRow("TopLeft") << KWin::ElectricTopLeft << QPoint(0, 0);
//repeat a row to show previously unloading and re-registering works
QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0);
// repeat a row to show previously unloading and re-registering works
QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0);
}
void ScreenEdgeTest::testEdge()
@ -158,13 +159,13 @@ void ScreenEdgeTest::testTouchEdge_data()
QTest::addColumn<QPoint>("triggerPos");
QTest::addColumn<QPoint>("motionPos");
QTest::newRow("Top") << KWin::ElectricTop << QPoint(50, 0) << QPoint(50, 500);
QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 50) << QPoint(500, 50);
QTest::newRow("Top") << KWin::ElectricTop << QPoint(50, 0) << QPoint(50, 500);
QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 50) << QPoint(500, 50);
QTest::newRow("Bottom") << KWin::ElectricBottom << QPoint(512, 1023) << QPoint(512, 500);
QTest::newRow("Left") << KWin::ElectricLeft << QPoint(0, 50) << QPoint(500, 50);
//repeat a row to show previously unloading and re-registering works
QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0) << QPoint(512, 500);
// repeat a row to show previously unloading and re-registering works
QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0) << QPoint(512, 500);
}
void ScreenEdgeTest::testTouchEdge()
@ -206,7 +207,8 @@ void ScreenEdgeTest::testTouchEdge()
QVERIFY(workspace()->showingDesktop());
}
void ScreenEdgeTest::triggerConfigReload() {
void ScreenEdgeTest::triggerConfigReload()
{
workspace()->slotReconfigure();
}
@ -229,31 +231,31 @@ void ScreenEdgeTest::testEdgeUnregister()
QSignalSpy showDesktopSpy(workspace(), &Workspace::showingDesktopChanged);
QVERIFY(showDesktopSpy.isValid());
//trigger the edge
// trigger the edge
KWin::Cursors::self()->mouse()->setPos(triggerPos);
QCOMPARE(showDesktopSpy.count(), 1);
//reset
KWin::Cursors::self()->mouse()->setPos(500,500);
// reset
KWin::Cursors::self()->mouse()->setPos(500, 500);
workspace()->slotToggleShowDesktop();
showDesktopSpy.clear();
//trigger again, to show that retriggering works
// trigger again, to show that retriggering works
KWin::Cursors::self()->mouse()->setPos(triggerPos);
QCOMPARE(showDesktopSpy.count(), 1);
//reset
KWin::Cursors::self()->mouse()->setPos(500,500);
// reset
KWin::Cursors::self()->mouse()->setPos(500, 500);
workspace()->slotToggleShowDesktop();
showDesktopSpy.clear();
//make the script unregister the edge
// make the script unregister the edge
configGroup.writeEntry("mode", "unregister");
triggerConfigReload();
KWin::Cursors::self()->mouse()->setPos(triggerPos);
QCOMPARE(showDesktopSpy.count(), 0); //not triggered
QCOMPARE(showDesktopSpy.count(), 0); // not triggered
//force the script to unregister a non-registered edge to prove it doesn't explode
// force the script to unregister a non-registered edge to prove it doesn't explode
triggerConfigReload();
}

View file

@ -7,12 +7,13 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "cursor.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <kwineffects.h>
#include <KDecoration2/Decoration>
@ -36,7 +37,7 @@ private Q_SLOTS:
void ShadeTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "platform.h"
#include "wayland_server.h"
@ -34,7 +35,7 @@ private Q_SLOTS:
void ShowingDesktopTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -11,12 +11,12 @@
#include "abstract_client.h"
#include "atoms.h"
#include "x11client.h"
#include "deleted.h"
#include "main.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/surface.h>
@ -48,7 +48,6 @@ private Q_SLOTS:
void testKeepAbove();
void testKeepBelow();
};
void StackingOrderTest::initTestCase()
@ -197,7 +196,8 @@ void StackingOrderTest::testRaiseTransient()
struct WindowUnrefDeleter
{
static inline void cleanup(Deleted *d) {
static inline void cleanup(Deleted *d)
{
if (d != nullptr) {
d->unrefWindow();
}
@ -265,11 +265,10 @@ void StackingOrderTest::testDeletedTransient()
// Close the top-most transient.
connect(transient2, &AbstractClient::windowClosed, this,
[](Toplevel *toplevel, Deleted *deleted) {
Q_UNUSED(toplevel)
deleted->refWindow();
}
);
[](Toplevel *toplevel, Deleted *deleted) {
Q_UNUSED(toplevel)
deleted->refWindow();
});
QSignalSpy windowClosedSpy(transient2, &AbstractClient::windowClosed);
QVERIFY(windowClosedSpy.isValid());
@ -293,19 +292,19 @@ static xcb_window_t createGroupWindow(xcb_connection_t *conn,
{
xcb_window_t wid = xcb_generate_id(conn);
xcb_create_window(
conn, // c
XCB_COPY_FROM_PARENT, // depth
wid, // wid
rootWindow(), // parent
geometry.x(), // x
geometry.y(), // y
geometry.width(), // width
geometry.height(), // height
0, // border_width
conn, // c
XCB_COPY_FROM_PARENT, // depth
wid, // wid
rootWindow(), // parent
geometry.x(), // x
geometry.y(), // y
geometry.width(), // width
geometry.height(), // height
0, // border_width
XCB_WINDOW_CLASS_INPUT_OUTPUT, // _class
XCB_COPY_FROM_PARENT, // visual
0, // value_mask
nullptr // value_list
XCB_COPY_FROM_PARENT, // visual
0, // value_mask
nullptr // value_list
);
xcb_size_hints_t sizeHints = {};
@ -318,14 +317,14 @@ static xcb_window_t createGroupWindow(xcb_connection_t *conn,
}
xcb_change_property(
conn, // c
XCB_PROP_MODE_REPLACE, // mode
wid, // window
conn, // c
XCB_PROP_MODE_REPLACE, // mode
wid, // window
atoms->wm_client_leader, // property
XCB_ATOM_WINDOW, // type
32, // format
1, // data_len
&leaderWid // data
XCB_ATOM_WINDOW, // type
32, // format
1, // data_len
&leaderWid // data
);
return wid;
@ -333,7 +332,8 @@ static xcb_window_t createGroupWindow(xcb_connection_t *conn,
struct XcbConnectionDeleter
{
static inline void cleanup(xcb_connection_t *c) {
static inline void cleanup(xcb_connection_t *c)
{
xcb_disconnect(c);
}
};
@ -412,13 +412,13 @@ void StackingOrderTest::testGroupTransientIsAboveWindowGroup()
xcb_atom_t net_wm_window_type_normal = Xcb::Atom(
QByteArrayLiteral("_NET_WM_WINDOW_TYPE_NORMAL"), false, conn.data());
xcb_change_property(
conn.data(), // c
XCB_PROP_MODE_REPLACE, // mode
transientWid, // window
net_wm_window_type, // property
XCB_ATOM_ATOM, // type
32, // format
1, // data_len
conn.data(), // c
XCB_PROP_MODE_REPLACE, // mode
transientWid, // window
net_wm_window_type, // property
XCB_ATOM_ATOM, // type
32, // format
1, // data_len
&net_wm_window_type_normal // data
);
@ -526,13 +526,13 @@ void StackingOrderTest::testRaiseGroupTransient()
xcb_atom_t net_wm_window_type_normal = Xcb::Atom(
QByteArrayLiteral("_NET_WM_WINDOW_TYPE_NORMAL"), false, conn.data());
xcb_change_property(
conn.data(), // c
XCB_PROP_MODE_REPLACE, // mode
transientWid, // window
net_wm_window_type, // property
XCB_ATOM_ATOM, // type
32, // format
1, // data_len
conn.data(), // c
XCB_PROP_MODE_REPLACE, // mode
transientWid, // window
net_wm_window_type, // property
XCB_ATOM_ATOM, // type
32, // format
1, // data_len
&net_wm_window_type_normal // data
);
@ -660,13 +660,13 @@ void StackingOrderTest::testDeletedGroupTransient()
xcb_atom_t net_wm_window_type_normal = Xcb::Atom(
QByteArrayLiteral("_NET_WM_WINDOW_TYPE_NORMAL"), false, conn.data());
xcb_change_property(
conn.data(), // c
XCB_PROP_MODE_REPLACE, // mode
transientWid, // window
net_wm_window_type, // property
XCB_ATOM_ATOM, // type
32, // format
1, // data_len
conn.data(), // c
XCB_PROP_MODE_REPLACE, // mode
transientWid, // window
net_wm_window_type, // property
XCB_ATOM_ATOM, // type
32, // format
1, // data_len
&net_wm_window_type_normal // data
);
@ -687,11 +687,10 @@ void StackingOrderTest::testDeletedGroupTransient()
// Unmap the transient.
connect(transient, &X11Client::windowClosed, this,
[](Toplevel *toplevel, Deleted *deleted) {
Q_UNUSED(toplevel)
deleted->refWindow();
}
);
[](Toplevel *toplevel, Deleted *deleted) {
Q_UNUSED(toplevel)
deleted->refWindow();
});
QSignalSpy windowClosedSpy(transient, &X11Client::windowClosed);
QVERIFY(windowClosedSpy.isValid());

View file

@ -7,16 +7,17 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "platform.h"
#include "screenedge.h"
#include "screens.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <kwineffects.h>
#include <KWayland/Client/compositor.h>
@ -57,8 +58,8 @@ private:
void StrutsTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -107,24 +108,24 @@ void StrutsTest::testWaylandStruts_data()
QTest::addColumn<QRect>("workArea");
QTest::addColumn<QRegion>("restrictedMoveArea");
QTest::newRow("bottom/0") << QVector<QRect>{QRect(0, 992, 1280, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(0, 992, 1280, 32);
QTest::newRow("bottom/1") << QVector<QRect>{QRect(1280, 992, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1280, 992, 1280, 32);
QTest::newRow("top/0") << QVector<QRect>{QRect(0, 0, 1280, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(0, 0, 1280, 32);
QTest::newRow("top/1") << QVector<QRect>{QRect(1280, 0, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1280, 0, 1280, 32);
QTest::newRow("left/0") << QVector<QRect>{QRect(0, 0, 32, 1024)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 0, 32, 1024);
QTest::newRow("left/1") << QVector<QRect>{QRect(1280, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 0, 32, 1024);
QTest::newRow("right/0") << QVector<QRect>{QRect(1248, 0, 32, 1024)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 0, 32, 1024);
QTest::newRow("right/1") << QVector<QRect>{QRect(2528, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 0, 32, 1024);
QTest::newRow("bottom/0") << QVector<QRect>{QRect(0, 992, 1280, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(0, 992, 1280, 32);
QTest::newRow("bottom/1") << QVector<QRect>{QRect(1280, 992, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1280, 992, 1280, 32);
QTest::newRow("top/0") << QVector<QRect>{QRect(0, 0, 1280, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(0, 0, 1280, 32);
QTest::newRow("top/1") << QVector<QRect>{QRect(1280, 0, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1280, 0, 1280, 32);
QTest::newRow("left/0") << QVector<QRect>{QRect(0, 0, 32, 1024)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 0, 32, 1024);
QTest::newRow("left/1") << QVector<QRect>{QRect(1280, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 0, 32, 1024);
QTest::newRow("right/0") << QVector<QRect>{QRect(1248, 0, 32, 1024)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 0, 32, 1024);
QTest::newRow("right/1") << QVector<QRect>{QRect(2528, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 0, 32, 1024);
// same with partial panels not covering the whole area
QTest::newRow("part bottom/0") << QVector<QRect>{QRect(100, 992, 1080, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(100, 992, 1080, 32);
QTest::newRow("part bottom/1") << QVector<QRect>{QRect(1380, 992, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1380, 992, 1080, 32);
QTest::newRow("part top/0") << QVector<QRect>{QRect(100, 0, 1080, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(100, 0, 1080, 32);
QTest::newRow("part top/1") << QVector<QRect>{QRect(1380, 0, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1380, 0, 1080, 32);
QTest::newRow("part left/0") << QVector<QRect>{QRect(0, 100, 32, 824)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 100, 32, 824);
QTest::newRow("part left/1") << QVector<QRect>{QRect(1280, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 100, 32, 824);
QTest::newRow("part right/0") << QVector<QRect>{QRect(1248, 100, 32, 824)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 100, 32, 824);
QTest::newRow("part right/1") << QVector<QRect>{QRect(2528, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 100, 32, 824);
QTest::newRow("part bottom/0") << QVector<QRect>{QRect(100, 992, 1080, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(100, 992, 1080, 32);
QTest::newRow("part bottom/1") << QVector<QRect>{QRect(1380, 992, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1380, 992, 1080, 32);
QTest::newRow("part top/0") << QVector<QRect>{QRect(100, 0, 1080, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(100, 0, 1080, 32);
QTest::newRow("part top/1") << QVector<QRect>{QRect(1380, 0, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1380, 0, 1080, 32);
QTest::newRow("part left/0") << QVector<QRect>{QRect(0, 100, 32, 824)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 100, 32, 824);
QTest::newRow("part left/1") << QVector<QRect>{QRect(1280, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 100, 32, 824);
QTest::newRow("part right/0") << QVector<QRect>{QRect(1248, 100, 32, 824)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 100, 32, 824);
QTest::newRow("part right/1") << QVector<QRect>{QRect(2528, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 100, 32, 824);
// multiple panels
QTest::newRow("two bottom panels") << QVector<QRect>{QRect(100, 992, 1080, 32), QRect(1380, 984, 1080, 40)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 984) << QRect(0, 0, 2560, 984) << QRegion(100, 992, 1080, 32).united(QRegion(1380, 984, 1080, 40));
@ -162,7 +163,7 @@ void StrutsTest::testWaylandStruts()
QFETCH(QVector<QRect>, windowGeometries);
// create the panels
QHash<KWayland::Client::Surface*, AbstractClient *> clients;
QHash<KWayland::Client::Surface *, AbstractClient *> clients;
for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) {
const QRect windowGeometry = *it;
KWayland::Client::Surface *surface = Test::createSurface(m_compositor);
@ -249,8 +250,8 @@ void StrutsTest::testMoveWaylandPanel()
QVERIFY(c->hasStrut());
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(PlacementArea,outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(MaximizeArea,outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1000));
QSignalSpy frameGeometryChangedSpy(c, &AbstractClient::frameGeometryChanged);
@ -260,8 +261,8 @@ void StrutsTest::testMoveWaylandPanel()
QCOMPARE(c->frameGeometry(), QRect(1280, 1000, 1280, 24));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(PlacementArea,outputs[1], desktop), QRect(1280, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(MaximizeArea,outputs[1], desktop), QRect(1280, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1000));
}
@ -272,7 +273,7 @@ void StrutsTest::testWaylandMobilePanel()
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
const QVector<AbstractOutput *> outputs = kwinApp()->platform()->enabledOutputs();
//First enable maxmizing policy
// First enable maxmizing policy
KConfigGroup group = kwinApp()->config()->group("Windows");
group.writeEntry("Placement", "Maximizing");
group.sync();
@ -383,106 +384,106 @@ void StrutsTest::testX11Struts_data()
<< QRect(0, 0, 2560, 980)
<< QRegion(0, 980, 1279, 44);
QTest::newRow("top panel/no strut") << QRect(0, 0, 1280, 44)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("top panel/strut") << QRect(0, 0, 1280, 44)
<< 0 << 0 << 44 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 44, 1280, 980)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 44, 2560, 980)
<< QRegion(0, 0, 1279, 44);
<< 0 << 0 << 44 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 44, 1280, 980)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 44, 2560, 980)
<< QRegion(0, 0, 1279, 44);
QTest::newRow("left panel/no strut") << QRect(0, 0, 60, 1024)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("left panel/strut") << QRect(0, 0, 60, 1024)
<< 60 << 0 << 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(60, 0, 1220, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(60, 0, 2500, 1024)
<< QRegion(0, 0, 60, 1023);
<< 60 << 0 << 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(60, 0, 1220, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(60, 0, 2500, 1024)
<< QRegion(0, 0, 60, 1023);
QTest::newRow("right panel/no strut") << QRect(1220, 0, 60, 1024)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("right panel/strut") << QRect(1220, 0, 60, 1024)
<< 0 << 1340 << 0 << 0
<< 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1220, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(1220, 0, 60, 1023);
<< 0 << 1340 << 0 << 0
<< 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1220, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(1220, 0, 60, 1023);
// second screen
QTest::newRow("bottom panel 1/no strut") << QRect(1280, 980, 1280, 44)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("bottom panel 1/strut") << QRect(1280, 980, 1280, 44)
<< 0 << 0 << 0 << 44
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 1280 << 2559
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 980)
<< QRect(0, 0, 2560, 980)
<< QRegion(1280, 980, 1279, 44);
<< 0 << 0 << 0 << 44
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 1280 << 2559
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 980)
<< QRect(0, 0, 2560, 980)
<< QRegion(1280, 980, 1279, 44);
QTest::newRow("top panel 1/no strut") << QRect(1280, 0, 1280, 44)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("top panel 1 /strut") << QRect(1280, 0, 1280, 44)
<< 0 << 0 << 44 << 0
<< 0 << 0
<< 0 << 0
<< 1280 << 2559
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 44, 1280, 980)
<< QRect(0, 44, 2560, 980)
<< QRegion(1280, 0, 1279, 44);
<< 0 << 0 << 44 << 0
<< 0 << 0
<< 0 << 0
<< 1280 << 2559
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 44, 1280, 980)
<< QRect(0, 44, 2560, 980)
<< QRegion(1280, 0, 1279, 44);
QTest::newRow("left panel 1/no strut") << QRect(1280, 0, 60, 1024)
<< 0 << 0 << 0 << 0
<< 0 << 0
@ -494,46 +495,46 @@ void StrutsTest::testX11Struts_data()
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("left panel 1/strut") << QRect(1280, 0, 60, 1024)
<< 1340 << 0 << 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1340, 0, 1220, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(1280, 0, 60, 1023);
<< 1340 << 0 << 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1340, 0, 1220, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(1280, 0, 60, 1023);
// invalid struts
QTest::newRow("bottom panel/ invalid strut") << QRect(0, 980, 1280, 44)
<< 1280 << 0 << 0 << 44
<< 980 << 1024
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(0, 980, 1280, 44);
<< 1280 << 0 << 0 << 44
<< 980 << 1024
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(0, 980, 1280, 44);
QTest::newRow("top panel/ invalid strut") << QRect(0, 0, 1280, 44)
<< 1280 << 0 << 44 << 0
<< 0 << 44
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(0, 0, 1280, 44);
<< 1280 << 0 << 44 << 0
<< 0 << 44
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(0, 0, 1280, 44);
QTest::newRow("top panel/invalid strut 2") << QRect(0, 0, 1280, 44)
<< 0 << 0 << 1024 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
<< 0 << 0 << 1024 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
}
struct XcbConnectionDeleter
@ -925,7 +926,7 @@ void StrutsTest::testWindowMoveWithPanelBetweenScreens()
NETExtendedStrut strut;
strut.left_start = 0;
strut.left_end = 1050;
strut.left_width = 1366+24;
strut.left_width = 1366 + 24;
strut.right_start = 0;
strut.right_end = 0;
strut.right_width = 0;

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "cursor.h"
#include "input.h"
@ -15,8 +16,8 @@
#include "wayland_server.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
#include <KConfigGroup>
#include <KWayland/Client/surface.h>
#include <linux/input.h>
@ -40,7 +41,7 @@ private Q_SLOTS:
void TabBoxTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));

View file

@ -7,34 +7,36 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include "kwin_wayland_test.h"
#if KWIN_BUILD_SCREENLOCKER
#include "screenlockerwatcher.h"
#endif
#include "inputmethod.h"
#include "wayland_server.h"
#include "workspace.h"
#include "inputmethod.h"
#include <KWayland/Client/appmenu.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/event_queue.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/output.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/pointerconstraints.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/shadow.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/output.h>
#include <KWayland/Client/subcompositor.h>
#include <KWayland/Client/subsurface.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/textinput.h>
#include <KWayland/Client/appmenu.h>
#include <KWaylandServer/display.h>
//screenlocker
// screenlocker
#if KWIN_BUILD_SCREENLOCKER
#include <KScreenLocker/KsldApp>
#endif
@ -42,8 +44,8 @@
#include <QThread>
// system
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
using namespace KWayland::Client;
@ -223,7 +225,8 @@ IdleInhibitorV1::~IdleInhibitorV1()
destroy();
}
static struct {
static struct
{
ConnectionThread *connection = nullptr;
EventQueue *queue = nullptr;
KWayland::Client::Compositor *compositor = nullptr;
@ -239,7 +242,7 @@ static struct {
Registry *registry = nullptr;
WaylandOutputManagementV2 *outputManagementV2 = nullptr;
QThread *thread = nullptr;
QVector<Output*> outputs;
QVector<Output *> outputs;
QVector<WaylandOutputDeviceV2 *> outputDevicesV2;
IdleInhibitManagerV1 *idleInhibitManagerV1 = nullptr;
AppMenuManager *appMenu = nullptr;
@ -270,7 +273,6 @@ KWayland::Client::Surface *inputPanelSurface()
MockInputMethod::MockInputMethod(struct wl_registry *registry, int id, int version)
: QtWayland::zwp_input_method_v1(registry, id, version)
{
}
MockInputMethod::~MockInputMethod()
{
@ -344,7 +346,7 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags)
registry->setEventQueue(s_waylandConnection.queue);
QObject::connect(registry, &Registry::outputAnnounced, [=](quint32 name, quint32 version) {
Output* output = registry->createOutput(name, version, s_waylandConnection.registry);
Output *output = registry->createOutput(name, version, s_waylandConnection.registry);
s_waylandConnection.outputs << output;
QObject::connect(output, &Output::removed, [=]() {
output->deleteLater();
@ -464,28 +466,28 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags)
}
if (flags.testFlag(AdditionalWaylandInterface::Decoration)) {
s_waylandConnection.decoration = registry->createServerSideDecorationManager(registry->interface(Registry::Interface::ServerSideDecorationManager).name,
registry->interface(Registry::Interface::ServerSideDecorationManager).version);
registry->interface(Registry::Interface::ServerSideDecorationManager).version);
if (!s_waylandConnection.decoration->isValid()) {
return false;
}
}
if (flags.testFlag(AdditionalWaylandInterface::PlasmaShell)) {
s_waylandConnection.plasmaShell = registry->createPlasmaShell(registry->interface(Registry::Interface::PlasmaShell).name,
registry->interface(Registry::Interface::PlasmaShell).version);
registry->interface(Registry::Interface::PlasmaShell).version);
if (!s_waylandConnection.plasmaShell->isValid()) {
return false;
}
}
if (flags.testFlag(AdditionalWaylandInterface::WindowManagement)) {
s_waylandConnection.windowManagement = registry->createPlasmaWindowManagement(registry->interface(Registry::Interface::PlasmaWindowManagement).name,
registry->interface(Registry::Interface::PlasmaWindowManagement).version);
registry->interface(Registry::Interface::PlasmaWindowManagement).version);
if (!s_waylandConnection.windowManagement->isValid()) {
return false;
}
}
if (flags.testFlag(AdditionalWaylandInterface::PointerConstraints)) {
s_waylandConnection.pointerConstraints = registry->createPointerConstraints(registry->interface(Registry::Interface::PointerConstraintsUnstableV1).name,
registry->interface(Registry::Interface::PointerConstraintsUnstableV1).version);
registry->interface(Registry::Interface::PointerConstraintsUnstableV1).version);
if (!s_waylandConnection.pointerConstraints->isValid()) {
return false;
}
@ -614,7 +616,7 @@ PointerConstraints *waylandPointerConstraints()
return s_waylandConnection.pointerConstraints;
}
AppMenuManager* waylandAppMenuManager()
AppMenuManager *waylandAppMenuManager()
{
return s_waylandConnection.appMenu;
}

View file

@ -14,11 +14,11 @@
#include "virtualkeyboard_dbus.h"
#include "wayland_server.h"
#include <QTest>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingReply>
#include <QSignalSpy>
#include <QTest>
#include <virtualkeyboardinterface.h>
@ -54,10 +54,7 @@ void VirtualKeyboardDBusTest::initTestCase()
QVERIFY(applicationStartedSpy.wait());
Test::initWaylandWorkspace();
QVERIFY(setupWaylandConnection(AdditionalWaylandInterface::Seat |
AdditionalWaylandInterface::InputMethodV1 |
AdditionalWaylandInterface::TextInputManagerV2 |
AdditionalWaylandInterface::TextInputManagerV3));
QVERIFY(setupWaylandConnection(AdditionalWaylandInterface::Seat | AdditionalWaylandInterface::InputMethodV1 | AdditionalWaylandInterface::TextInputManagerV2 | AdditionalWaylandInterface::TextInputManagerV3));
}
void VirtualKeyboardDBusTest::init()

View file

@ -7,11 +7,12 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "platform.h"
#include "touch_input.h"
#include "cursor.h"
#include "wayland_server.h"
#include "workspace.h"
@ -48,7 +49,7 @@ private:
void TouchInputTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -67,8 +68,7 @@ void TouchInputTest::initTestCase()
void TouchInputTest::init()
{
using namespace KWayland::Client;
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat |
Test::AdditionalWaylandInterface::XdgDecorationV1));
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::XdgDecorationV1));
QVERIFY(Test::waitForWaylandTouch());
m_touch = Test::waylandSeat()->createTouch(Test::waylandSeat());
QVERIFY(m_touch);
@ -88,11 +88,11 @@ void TouchInputTest::cleanup()
AbstractClient *TouchInputTest::showWindow(bool decorated)
{
using namespace KWayland::Client;
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) \
return nullptr;
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \
return nullptr;
KWayland::Client::Surface *surface = Test::createSurface(Test::waylandCompositor());

View file

@ -7,22 +7,23 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
#include "platform.h"
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include <kwineffects.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/event_queue.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/shm_pool.h>
@ -60,7 +61,7 @@ private Q_SLOTS:
void TransientPlacementTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -104,82 +105,82 @@ void TransientPlacementTest::testXdgPopup_data()
// ----------------------------------------------------------------
// window in the middle, plenty of room either side: Changing anchor
const PopupLayout layoutAnchorCenter {
const PopupLayout layoutAnchorCenter{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_none,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorCentre") << QSize(500, 500) << QPoint(300,300) << layoutAnchorCenter << QRect(550, 550, 200, 200);
QTest::newRow("anchorCentre") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorCenter << QRect(550, 550, 200, 200);
const PopupLayout layoutAnchorTopLeft {
const PopupLayout layoutAnchorTopLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_top_left,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorTopLeft") << QSize(500, 500) << QPoint(300,300) << layoutAnchorTopLeft << QRect(350,350, 200, 200);
QTest::newRow("anchorTopLeft") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorTopLeft << QRect(350, 350, 200, 200);
const PopupLayout layoutAnchorTop {
const PopupLayout layoutAnchorTop{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_top,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorTop") << QSize(500, 500) << QPoint(300,300) << layoutAnchorTop << QRect(550, 350, 200, 200);
QTest::newRow("anchorTop") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorTop << QRect(550, 350, 200, 200);
const PopupLayout layoutAnchorTopRight {
const PopupLayout layoutAnchorTopRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_top_right,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorTopRight") << QSize(500, 500) << QPoint(300,300) << layoutAnchorTopRight << QRect(750, 350, 200, 200);
QTest::newRow("anchorTopRight") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorTopRight << QRect(750, 350, 200, 200);
const PopupLayout layoutAnchorRight {
const PopupLayout layoutAnchorRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_right,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorRight") << QSize(500, 500) << QPoint(300,300) << layoutAnchorRight << QRect(750, 550, 200, 200);
QTest::newRow("anchorRight") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorRight << QRect(750, 550, 200, 200);
const PopupLayout layoutAnchorBottomRight {
const PopupLayout layoutAnchorBottomRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorBottomRight") << QSize(500,500) << QPoint(300,300) << layoutAnchorBottomRight << QRect(750, 750, 200, 200);
QTest::newRow("anchorBottomRight") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorBottomRight << QRect(750, 750, 200, 200);
const PopupLayout layoutAnchorBottom {
const PopupLayout layoutAnchorBottom{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorBottom") << QSize(500, 500) << QPoint(300,300) << layoutAnchorBottom << QRect(550, 750, 200, 200);
QTest::newRow("anchorBottom") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorBottom << QRect(550, 750, 200, 200);
const PopupLayout layoutAnchorBottomLeft {
const PopupLayout layoutAnchorBottomLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_left,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorBottomLeft") << QSize(500, 500) << QPoint(300,300) << layoutAnchorBottomLeft << QRect(350, 750, 200, 200);
QTest::newRow("anchorBottomLeft") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorBottomLeft << QRect(350, 750, 200, 200);
const PopupLayout layoutAnchorLeft {
const PopupLayout layoutAnchorLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_left,
.gravity = Test::XdgPositioner::gravity_bottom_right,
};
QTest::newRow("anchorLeft") << QSize(500, 500) << QPoint(300,300) << layoutAnchorLeft << QRect(350, 550, 200, 200);
QTest::newRow("anchorLeft") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorLeft << QRect(350, 550, 200, 200);
// ----------------------------------------------------------------
// window in the middle, plenty of room either side: Changing gravity around the bottom right anchor
const PopupLayout layoutGravityCenter {
const PopupLayout layoutGravityCenter{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -187,7 +188,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityCentre") << QSize(500, 500) << QPoint(300, 300) << layoutGravityCenter << QRect(650, 650, 200, 200);
const PopupLayout layoutGravityTopLeft {
const PopupLayout layoutGravityTopLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -195,7 +196,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityTopLeft") << QSize(500, 500) << QPoint(300, 300) << layoutGravityTopLeft << QRect(550, 550, 200, 200);
const PopupLayout layoutGravityTop {
const PopupLayout layoutGravityTop{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -203,7 +204,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityTop") << QSize(500, 500) << QPoint(300, 300) << layoutGravityTop << QRect(650, 550, 200, 200);
const PopupLayout layoutGravityTopRight {
const PopupLayout layoutGravityTopRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -211,7 +212,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityTopRight") << QSize(500, 500) << QPoint(300, 300) << layoutGravityTopRight << QRect(750, 550, 200, 200);
const PopupLayout layoutGravityRight {
const PopupLayout layoutGravityRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -219,7 +220,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityRight") << QSize(500, 500) << QPoint(300, 300) << layoutGravityRight << QRect(750, 650, 200, 200);
const PopupLayout layoutGravityBottomRight {
const PopupLayout layoutGravityBottomRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -227,7 +228,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityBottomRight") << QSize(500, 500) << QPoint(300, 300) << layoutGravityBottomRight << QRect(750, 750, 200, 200);
const PopupLayout layoutGravityBottom {
const PopupLayout layoutGravityBottom{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -235,7 +236,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityBottom") << QSize(500, 500) << QPoint(300, 300) << layoutGravityBottom << QRect(650, 750, 200, 200);
const PopupLayout layoutGravityBottomLeft {
const PopupLayout layoutGravityBottomLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -243,7 +244,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("gravityBottomLeft") << QSize(500, 500) << QPoint(300, 300) << layoutGravityBottomLeft << QRect(550, 750, 200, 200);
const PopupLayout layoutGravityLeft {
const PopupLayout layoutGravityLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -255,7 +256,7 @@ void TransientPlacementTest::testXdgPopup_data()
// constrain and slide
// popup is still 200,200. window moved near edge of screen, popup always comes out towards the screen edge
const PopupLayout layoutSlideTop {
const PopupLayout layoutSlideTop{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_top,
@ -264,7 +265,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintSlideTop") << QSize(500, 500) << QPoint(80, 80) << layoutSlideTop << QRect(80 + 250 - 100, 0, 200, 200);
const PopupLayout layoutSlideLeft {
const PopupLayout layoutSlideLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_left,
@ -273,7 +274,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintSlideLeft") << QSize(500, 500) << QPoint(80, 80) << layoutSlideLeft << QRect(0, 80 + 250 - 100, 200, 200);
const PopupLayout layoutSlideRight {
const PopupLayout layoutSlideRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_right,
@ -282,7 +283,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintSlideRight") << QSize(500, 500) << QPoint(700, 80) << layoutSlideRight << QRect(1280 - 200, 80 + 250 - 100, 200, 200);
const PopupLayout layoutSlideBottom {
const PopupLayout layoutSlideBottom{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom,
@ -291,7 +292,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintSlideBottom") << QSize(500, 500) << QPoint(80, 500) << layoutSlideBottom << QRect(80 + 250 - 100, 1024 - 200, 200, 200);
const PopupLayout layoutSlideBottomRight {
const PopupLayout layoutSlideBottomRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -303,7 +304,7 @@ void TransientPlacementTest::testXdgPopup_data()
// ----------------------------------------------------------------
// constrain and flip
const PopupLayout layoutFlipTop {
const PopupLayout layoutFlipTop{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_top,
@ -312,7 +313,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintFlipTop") << QSize(500, 500) << QPoint(80, 80) << layoutFlipTop << QRect(230, 80 + 500 - 50, 200, 200);
const PopupLayout layoutFlipLeft {
const PopupLayout layoutFlipLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_left,
@ -321,7 +322,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintFlipLeft") << QSize(500, 500) << QPoint(80, 80) << layoutFlipLeft << QRect(80 + 500 - 50, 230, 200, 200);
const PopupLayout layoutFlipRight {
const PopupLayout layoutFlipRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_right,
@ -330,7 +331,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintFlipRight") << QSize(500, 500) << QPoint(700, 80) << layoutFlipRight << QRect(700 + 50 - 200, 230, 200, 200);
const PopupLayout layoutFlipBottom {
const PopupLayout layoutFlipBottom{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom,
@ -339,7 +340,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintFlipBottom") << QSize(500, 500) << QPoint(80, 500) << layoutFlipBottom << QRect(230, 500 + 50 - 200, 200, 200);
const PopupLayout layoutFlipBottomRight {
const PopupLayout layoutFlipBottomRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom_right,
@ -348,9 +349,9 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintFlipBottomRight") << QSize(500, 500) << QPoint(700, 500) << layoutFlipBottomRight << QRect(700 + 50 - 200, 500 + 50 - 200, 200, 200);
const PopupLayout layoutFlipRightNoAnchor {
const PopupLayout layoutFlipRightNoAnchor{
.anchorRect = QRect(50, 50, 400, 400),
//as popup is positioned in the middle of the parent we need a massive popup to be able to overflow
// as popup is positioned in the middle of the parent we need a massive popup to be able to overflow
.size = QSize(400, 400),
.anchor = Test::XdgPositioner::anchor_top,
.gravity = Test::XdgPositioner::gravity_right,
@ -358,7 +359,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("constraintFlipRightNoAnchor") << QSize(500, 500) << QPoint(700, 80) << layoutFlipRightNoAnchor << QRect(700 + 250 - 400, 330, 400, 400);
const PopupLayout layoutFlipRightNoGravity {
const PopupLayout layoutFlipRightNoGravity{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(300, 200),
.anchor = Test::XdgPositioner::anchor_right,
@ -370,7 +371,7 @@ void TransientPlacementTest::testXdgPopup_data()
// ----------------------------------------------------------------
// resize
const PopupLayout layoutResizeTop {
const PopupLayout layoutResizeTop{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_top,
@ -379,7 +380,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("resizeTop") << QSize(500, 500) << QPoint(80, 80) << layoutResizeTop << QRect(80 + 250 - 100, 0, 200, 130);
const PopupLayout layoutResizeLeft {
const PopupLayout layoutResizeLeft{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_left,
@ -388,7 +389,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("resizeLeft") << QSize(500, 500) << QPoint(80, 80) << layoutResizeLeft << QRect(0, 80 + 250 - 100, 130, 200);
const PopupLayout layoutResizeRight {
const PopupLayout layoutResizeRight{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_right,
@ -397,7 +398,7 @@ void TransientPlacementTest::testXdgPopup_data()
};
QTest::newRow("resizeRight") << QSize(500, 500) << QPoint(700, 80) << layoutResizeRight << QRect(700 + 50 + 400, 80 + 250 - 100, 130, 200);
const PopupLayout layoutResizeBottom {
const PopupLayout layoutResizeBottom{
.anchorRect = QRect(50, 50, 400, 400),
.size = QSize(200, 200),
.anchor = Test::XdgPositioner::anchor_bottom,
@ -430,7 +431,7 @@ void TransientPlacementTest::testXdgPopup()
parent->move(parentPosition);
QCOMPARE(parent->frameGeometry(), QRect(parentPosition, parentSize));
//create popup
// create popup
QFETCH(PopupLayout, layout);
KWayland::Client::Surface *transientSurface = Test::createSurface(Test::waylandCompositor());
@ -486,7 +487,7 @@ void TransientPlacementTest::testXdgPopupWithPanel()
QCOMPARE(dock->hasStrut(), true);
QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) != workspace()->clientArea(FullScreenArea, 0, 1));
//create parent
// create parent
QScopedPointer<KWayland::Client::Surface> parentSurface(Test::createSurface());
QVERIFY(parentSurface);
auto parentShellSurface = Test::createXdgToplevelSurface(parentSurface.data());
@ -536,7 +537,7 @@ void TransientPlacementTest::testXdgPopupWithPanel()
transientSurface.reset(Test::createSurface());
QVERIFY(transientSurface);
const QRect anchorRect2(50, screens()->geometry(0).height()-100, 200,200);
const QRect anchorRect2(50, screens()->geometry(0).height() - 100, 200, 200);
QScopedPointer<Test::XdgPositioner> positioner2(Test::createXdgPositioner());
positioner2->set_size(200, 200);
positioner2->set_anchor_rect(anchorRect2.x(), anchorRect2.y(), anchorRect2.width(), anchorRect2.height());

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "main.h"
#include "platform.h"
@ -37,7 +38,7 @@ private Q_SLOTS:
void VirtualDesktopTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -174,7 +175,7 @@ void VirtualDesktopTest::testWindowOnMultipleDesktops()
QCOMPARE(client->desktops().count(), 1u);
QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first());
//Set the window on desktop 2 as well
// Set the window on desktop 2 as well
client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(2));
QCOMPARE(client->desktops().count(), 2u);
QCOMPARE(VirtualDesktopManager::self()->desktops()[2], client->desktops()[0]);
@ -182,45 +183,45 @@ void VirtualDesktopTest::testWindowOnMultipleDesktops()
QVERIFY(client->isOnDesktop(2));
QVERIFY(client->isOnDesktop(3));
//leave desktop 3
// leave desktop 3
client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(3));
QCOMPARE(client->desktops().count(), 1u);
//leave desktop 2
// leave desktop 2
client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(2));
QCOMPARE(client->desktops().count(), 0u);
//we should be on all desktops now
// we should be on all desktops now
QVERIFY(client->isOnAllDesktops());
//put on desktop 1
// put on desktop 1
client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(1));
QVERIFY(client->isOnDesktop(1));
QVERIFY(!client->isOnDesktop(2));
QVERIFY(!client->isOnDesktop(3));
QCOMPARE(client->desktops().count(), 1u);
//put on desktop 2
// put on desktop 2
client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(2));
QVERIFY(client->isOnDesktop(1));
QVERIFY(client->isOnDesktop(2));
QVERIFY(!client->isOnDesktop(3));
QCOMPARE(client->desktops().count(), 2u);
//put on desktop 3
// put on desktop 3
client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(3));
QVERIFY(client->isOnDesktop(1));
QVERIFY(client->isOnDesktop(2));
QVERIFY(client->isOnDesktop(3));
QCOMPARE(client->desktops().count(), 3u);
//entering twice dooes nothing
// entering twice dooes nothing
client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(3));
QCOMPARE(client->desktops().count(), 3u);
//adding to "all desktops" results in just that one desktop
// adding to "all desktops" results in just that one desktop
client->setOnAllDesktops(true);
QCOMPARE(client->desktops().count(), 0u);
client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(3));
QVERIFY(client->isOnDesktop(3));
QCOMPARE(client->desktops().count(), 1u);
//leaving a desktop on "all desktops" puts on everything else
// leaving a desktop on "all desktops" puts on everything else
client->setOnAllDesktops(true);
QCOMPARE(client->desktops().count(), 0u);
client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(3));
@ -253,7 +254,7 @@ void VirtualDesktopTest::testRemoveDesktopWithWindow()
QCOMPARE(client->desktops().count(), 1u);
QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first());
//Set the window on desktop 2 as well
// Set the window on desktop 2 as well
client->enterDesktop(VirtualDesktopManager::self()->desktops()[1]);
QCOMPARE(client->desktops().count(), 2u);
QCOMPARE(VirtualDesktopManager::self()->desktops()[2], client->desktops()[0]);
@ -261,25 +262,25 @@ void VirtualDesktopTest::testRemoveDesktopWithWindow()
QVERIFY(client->isOnDesktop(2));
QVERIFY(client->isOnDesktop(3));
//remove desktop 3
// remove desktop 3
VirtualDesktopManager::self()->setCount(2);
QCOMPARE(client->desktops().count(), 1u);
//window is only on desktop 2
// window is only on desktop 2
QCOMPARE(VirtualDesktopManager::self()->desktops()[1], client->desktops()[0]);
//Again 3 desktops
// Again 3 desktops
VirtualDesktopManager::self()->setCount(3);
//move window to be only on desktop 3
// move window to be only on desktop 3
client->enterDesktop(VirtualDesktopManager::self()->desktops()[2]);
client->leaveDesktop(VirtualDesktopManager::self()->desktops()[1]);
QCOMPARE(client->desktops().count(), 1u);
//window is only on desktop 3
// window is only on desktop 3
QCOMPARE(VirtualDesktopManager::self()->desktops()[2], client->desktops()[0]);
//remove desktop 3
// remove desktop 3
VirtualDesktopManager::self()->setCount(2);
QCOMPARE(client->desktops().count(), 1u);
//window is only on desktop 2
// window is only on desktop 2
QCOMPARE(VirtualDesktopManager::self()->desktops()[1], client->desktops()[0]);
}

View file

@ -7,15 +7,16 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "atoms.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "platform.h"
#include "rules.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <netwm.h>
#include <xcb/xcb_icccm.h>
@ -39,8 +40,8 @@ private Q_SLOTS:
void WindowRuleTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -102,9 +103,7 @@ void WindowRuleTest::testApplyInitialMaximizeVert()
xcb_window_t w = xcb_generate_id(c.data());
const QRect windowGeometry = QRect(0, 0, 10, 20);
const uint32_t values[] = {
XCB_EVENT_MASK_ENTER_WINDOW |
XCB_EVENT_MASK_LEAVE_WINDOW
};
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW};
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
@ -172,9 +171,7 @@ void WindowRuleTest::testWindowClassChange()
xcb_window_t w = xcb_generate_id(c.data());
const QRect windowGeometry = QRect(0, 0, 10, 20);
const uint32_t values[] = {
XCB_EVENT_MASK_ENTER_WINDOW |
XCB_EVENT_MASK_LEAVE_WINDOW
};
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW};
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),

View file

@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "cursor.h"
@ -52,7 +53,7 @@ private Q_SLOTS:
void TestWindowSelection::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -107,7 +108,7 @@ void TestWindowSelection::testSelectOnWindowPointer()
QVERIFY(pointerEnteredSpy.wait());
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow] (Toplevel *t) {
auto callback = [&selectedWindow](Toplevel *t) {
selectedWindow = t;
};
@ -191,7 +192,7 @@ void TestWindowSelection::testSelectOnWindowKeyboard()
QVERIFY(!client->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos()));
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow] (Toplevel *t) {
auto callback = [&selectedWindow](Toplevel *t) {
selectedWindow = t;
};
@ -255,7 +256,7 @@ void TestWindowSelection::testSelectOnWindowTouch()
QVERIFY(client);
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow] (Toplevel *t) {
auto callback = [&selectedWindow](Toplevel *t) {
selectedWindow = t;
};
@ -328,7 +329,7 @@ void TestWindowSelection::testCancelOnWindowPointer()
QVERIFY(pointerEnteredSpy.wait());
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow] (Toplevel *t) {
auto callback = [&selectedWindow](Toplevel *t) {
selectedWindow = t;
};
@ -387,7 +388,7 @@ void TestWindowSelection::testCancelOnWindowKeyboard()
QVERIFY(pointerEnteredSpy.wait());
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow] (Toplevel *t) {
auto callback = [&selectedWindow](Toplevel *t) {
selectedWindow = t;
};
@ -446,7 +447,7 @@ void TestWindowSelection::testSelectPointPointer()
QVERIFY(pointerEnteredSpy.wait());
QPoint point;
auto callback = [&point] (const QPoint &p) {
auto callback = [&point](const QPoint &p) {
point = p;
};
@ -465,7 +466,7 @@ void TestWindowSelection::testSelectPointPointer()
// trying again should not be allowed
QPoint point2;
kwinApp()->platform()->startInteractivePositionSelection([&point2] (const QPoint &p) {
kwinApp()->platform()->startInteractivePositionSelection([&point2](const QPoint &p) {
point2 = p;
});
QCOMPARE(point2, QPoint(-1, -1));
@ -510,7 +511,7 @@ void TestWindowSelection::testSelectPointTouch()
{
// this test verifies point selection through touch works
QPoint point;
auto callback = [&point] (const QPoint &p) {
auto callback = [&point](const QPoint &p) {
point = p;
};

View file

@ -7,17 +7,18 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "atoms.h"
#include "x11client.h"
#include "composite.h"
#include "effects.h"
#include "effectloader.h"
#include "cursor.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "platform.h"
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KWayland/Client/surface.h>
@ -30,7 +31,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_x11_client-0");
class X11ClientTest : public QObject
{
Q_OBJECT
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
@ -55,8 +56,8 @@ private Q_SLOTS:
void X11ClientTest::initTestCase()
{
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -726,8 +727,9 @@ void X11ClientTest::testX11WindowId()
QUuid deletedUuid;
QCOMPARE(deletedUuid.isNull(), true);
connect(client, &X11Client::windowClosed, this, [&deletedUuid] (Toplevel *, Deleted *d) { deletedUuid = d->internalId(); });
connect(client, &X11Client::windowClosed, this, [&deletedUuid](Toplevel *, Deleted *d) {
deletedUuid = d->internalId();
});
NETRootInfo rootInfo(c.data(), NET::WMAllProperties);
QCOMPARE(rootInfo.activeWindow(), client->window());
@ -909,7 +911,6 @@ void X11ClientTest::testCaptionMultipleWindows()
QTRY_COMPARE(QByteArray(info5.visibleIconName()), QByteArray());
}
void X11ClientTest::testFullscreenWindowGroups()
{
// this test creates an X11 window and puts it to full screen

View file

@ -147,7 +147,8 @@ private Q_SLOTS:
void testMatchAfterNameChange();
private:
template <typename T> void setWindowRule(const QString &property, const T &value, int policy);
template<typename T>
void setWindowRule(const QString &property, const T &value, int policy);
private:
KSharedConfig::Ptr m_config;
@ -220,7 +221,7 @@ std::tuple<AbstractClient *, KWayland::Client::Surface *, Test::XdgToplevel *> c
return {client, surface, shellSurface};
}
template <typename T>
template<typename T>
void TestXdgShellClientRules::setWindowRule(const QString &property, const T &value, int policy)
{
// Initialize RuleBook with the test rule.

View file

@ -8,13 +8,14 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_wayland_output.h"
#include "cursor.h"
#include "decorations/decorationbridge.h"
#include "decorations/settings.h"
#include "effects.h"
#include "deleted.h"
#include "effects.h"
#include "platform.h"
#include "screens.h"
#include "virtualdesktops.h"
@ -25,15 +26,15 @@
#include <KDecoration2/Decoration>
#include <KDecoration2/DecorationSettings>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/appmenu.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/output.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/subsurface.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/appmenu.h>
#include <KWaylandServer/clientconnection.h>
#include <KWaylandServer/display.h>
@ -41,8 +42,8 @@
#include <QDBusConnection>
// system
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <csignal>
@ -165,9 +166,9 @@ void TestXdgShellClient::testXdgWindowRepositioning()
void TestXdgShellClient::initTestCase()
{
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWayland::Client::Output*>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWayland::Client::Output *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
@ -186,13 +187,11 @@ void TestXdgShellClient::initTestCase()
void TestXdgShellClient::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat |
Test::AdditionalWaylandInterface::XdgDecorationV1 |
Test::AdditionalWaylandInterface::AppMenu));
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::XdgDecorationV1 | Test::AdditionalWaylandInterface::AppMenu));
QVERIFY(Test::waitForWaylandPointer());
workspace()->setActiveOutput(QPoint(640, 512));
//put mouse in the middle of screen one
// put mouse in the middle of screen one
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
@ -288,11 +287,11 @@ void TestXdgShellClient::testDesktopPresenceChanged()
QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1);
// verify the arguments
QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value<AbstractClient*>(), c);
QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value<AbstractClient *>(), c);
QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1);
QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<AbstractClient*>(), c);
QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<AbstractClient *>(), c);
QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1);
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow*>(), c->effectWindow());
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow *>(), c->effectWindow());
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1);
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2);
}
@ -301,37 +300,37 @@ void TestXdgShellClient::testWindowOutputs()
{
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
auto size = QSize(200,200);
auto size = QSize(200, 200);
QSignalSpy outputEnteredSpy(surface.data(), &KWayland::Client::Surface::outputEntered);
QSignalSpy outputLeftSpy(surface.data(), &KWayland::Client::Surface::outputLeft);
auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue);
//move to be in the first screen
c->moveResize(QRect(QPoint(100,100), size));
//we don't don't know where the compositor first placed this window,
//this might fire, it might not
// move to be in the first screen
c->moveResize(QRect(QPoint(100, 100), size));
// we don't don't know where the compositor first placed this window,
// this might fire, it might not
outputEnteredSpy.wait(5);
outputEnteredSpy.clear();
QCOMPARE(surface->outputs().count(), 1);
QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(0,0));
QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(0, 0));
//move to overlapping both first and second screen
c->moveResize(QRect(QPoint(1250,100), size));
// move to overlapping both first and second screen
c->moveResize(QRect(QPoint(1250, 100), size));
QVERIFY(outputEnteredSpy.wait());
QCOMPARE(outputEnteredSpy.count(), 1);
QCOMPARE(outputLeftSpy.count(), 0);
QCOMPARE(surface->outputs().count(), 2);
QVERIFY(surface->outputs()[0] != surface->outputs()[1]);
//move entirely into second screen
c->moveResize(QRect(QPoint(1400,100), size));
// move entirely into second screen
c->moveResize(QRect(QPoint(1400, 100), size));
QVERIFY(outputLeftSpy.wait());
QCOMPARE(outputEnteredSpy.count(), 1);
QCOMPARE(outputLeftSpy.count(), 1);
QCOMPARE(surface->outputs().count(), 1);
QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0));
QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280, 0));
}
void TestXdgShellClient::testMinimizeActiveWindow()
@ -642,7 +641,7 @@ void TestXdgShellClient::testHidden()
QVERIFY(c->wantsInput());
QVERIFY(c->wantsTabFocus());
//QCOMPARE(workspace()->activeClient(), c);
// QCOMPARE(workspace()->activeClient(), c);
}
void TestXdgShellClient::testDesktopFileName()
@ -746,7 +745,7 @@ void TestXdgShellClient::testCaptionMultipleWindows()
void TestXdgShellClient::testUnresponsiveWindow_data()
{
QTest::addColumn<QString>("shellInterface");//see env selection in qwaylandintegration.cpp
QTest::addColumn<QString>("shellInterface"); // see env selection in qwaylandintegration.cpp
QTest::addColumn<bool>("socketMode");
QTest::newRow("xdg display") << "xdg-shell" << false;
@ -793,45 +792,45 @@ void TestXdgShellClient::testUnresponsiveWindow()
}
::kill(process->processId(), SIGUSR1); // send a signal to freeze the process
killClient = clientAddedSpy.first().first().value<AbstractClient*>();
killClient = clientAddedSpy.first().first().value<AbstractClient *>();
QVERIFY(killClient);
QSignalSpy unresponsiveSpy(killClient, &AbstractClient::unresponsiveChanged);
QSignalSpy killedSpy(process.data(), static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished));
QSignalSpy killedSpy(process.data(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QSignalSpy deletedSpy(killClient, &QObject::destroyed);
qint64 startTime = QDateTime::currentMSecsSinceEpoch();
//wait for the process to be frozen
// wait for the process to be frozen
QTest::qWait(10);
//pretend the user clicked the close button
// pretend the user clicked the close button
killClient->closeWindow();
//client should not yet be marked unresponsive nor killed
// client should not yet be marked unresponsive nor killed
QVERIFY(!killClient->unresponsive());
QVERIFY(killedSpy.isEmpty());
QVERIFY(unresponsiveSpy.wait());
//client should be marked unresponsive but not killed
// client should be marked unresponsive but not killed
auto elapsed1 = QDateTime::currentMSecsSinceEpoch() - startTime;
QVERIFY(elapsed1 > 900 && elapsed1 < 1200); //ping timer is 1s, but coarse timers on a test across two processes means we need a fuzzy compare
QVERIFY(elapsed1 > 900 && elapsed1 < 1200); // ping timer is 1s, but coarse timers on a test across two processes means we need a fuzzy compare
QVERIFY(killClient->unresponsive());
QVERIFY(killedSpy.isEmpty());
QVERIFY(deletedSpy.wait());
if (!socketMode) {
//process was killed - because we're across process this could happen in either order
// process was killed - because we're across process this could happen in either order
QVERIFY(killedSpy.count() || killedSpy.wait());
}
auto elapsed2 = QDateTime::currentMSecsSinceEpoch() - startTime;
QVERIFY(elapsed2 > 1800); //second ping comes in a second later
QVERIFY(elapsed2 > 1800); // second ping comes in a second later
}
void TestXdgShellClient::testAppMenu()
{
//register a faux appmenu client
QVERIFY (QDBusConnection::sessionBus().registerService("org.kde.kappmenu"));
// register a faux appmenu client
QVERIFY(QDBusConnection::sessionBus().registerService("org.kde.kappmenu"));
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
@ -845,7 +844,7 @@ void TestXdgShellClient::testAppMenu()
QCOMPARE(c->applicationMenuServiceName(), QString("service.name"));
QCOMPARE(c->applicationMenuObjectPath(), QString("object/path"));
QVERIFY (QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu"));
QVERIFY(QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu"));
}
void TestXdgShellClient::testSendClientWithTransientToDesktop()
@ -938,7 +937,7 @@ void TestXdgShellClient::testXdgDecoration_data()
QTest::addColumn<Test::XdgToplevelDecorationV1::mode>("expectedMode");
QTest::newRow("client side requested") << Test::XdgToplevelDecorationV1::mode_client_side << Test::XdgToplevelDecorationV1::mode_client_side;
QTest::newRow("server side requested") << Test::XdgToplevelDecorationV1::mode_server_side << Test::XdgToplevelDecorationV1::mode_server_side;
QTest::newRow("server side requested") << Test::XdgToplevelDecorationV1::mode_server_side << Test::XdgToplevelDecorationV1::mode_server_side;
}
void TestXdgShellClient::testXdgDecoration()
@ -953,10 +952,10 @@ void TestXdgShellClient::testXdgDecoration()
QFETCH(Test::XdgToplevelDecorationV1::mode, requestedMode);
QFETCH(Test::XdgToplevelDecorationV1::mode, expectedMode);
//request a mode
// request a mode
deco->set_mode(requestedMode);
//kwin will send a configure
// kwin will send a configure
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(decorationConfigureRequestedSpy.count(), 1);
@ -970,7 +969,7 @@ void TestXdgShellClient::testXdgDecoration()
void TestXdgShellClient::testXdgNeverCommitted()
{
//check we don't crash if we create a shell object but delete the XdgShellClient before committing it
// check we don't crash if we create a shell object but delete the XdgShellClient before committing it
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data(), Test::CreationSetup::CreateOnly));
}
@ -988,11 +987,11 @@ void TestXdgShellClient::testXdgInitialState()
const auto size = toplevelConfigureRequestedSpy.first()[0].value<QSize>();
QCOMPARE(size, QSize(0, 0)); //client should chose it's preferred size
QCOMPARE(size, QSize(0, 0)); // client should chose it's preferred size
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.first()[0].toUInt());
auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue);
auto c = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::blue);
QCOMPARE(c->size(), QSize(200, 100));
}

View file

@ -7,13 +7,14 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "platform.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "platform.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11client.h"
#include <KWaylandServer/seat_interface.h>
@ -39,8 +40,8 @@ private Q_SLOTS:
void XWaylandInputTest::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
@ -105,14 +106,16 @@ void X11EventReaderHelper::processXcbEvents()
while (auto event = xcb_poll_for_event(m_connection)) {
const uint8_t eventType = event->response_type & ~0x80;
switch (eventType) {
case XCB_ENTER_NOTIFY: {
auto enterEvent = reinterpret_cast<xcb_enter_notify_event_t *>(event);
Q_EMIT entered(QPoint(enterEvent->event_x, enterEvent->event_y));
break; }
case XCB_LEAVE_NOTIFY: {
auto leaveEvent = reinterpret_cast<xcb_leave_notify_event_t *>(event);
Q_EMIT left(QPoint(leaveEvent->event_x, leaveEvent->event_y));
break; }
case XCB_ENTER_NOTIFY: {
auto enterEvent = reinterpret_cast<xcb_enter_notify_event_t *>(event);
Q_EMIT entered(QPoint(enterEvent->event_x, enterEvent->event_y));
break;
}
case XCB_LEAVE_NOTIFY: {
auto leaveEvent = reinterpret_cast<xcb_leave_notify_event_t *>(event);
Q_EMIT left(QPoint(leaveEvent->event_x, leaveEvent->event_y));
break;
}
}
free(event);
}
@ -140,9 +143,7 @@ void XWaylandInputTest::testPointerEnterLeaveSsd()
xcb_window_t w = xcb_generate_id(c.data());
const QRect windowGeometry = QRect(0, 0, 100, 200);
const uint32_t values[] = {
XCB_EVENT_MASK_ENTER_WINDOW |
XCB_EVENT_MASK_LEAVE_WINDOW
};
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW};
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
@ -231,9 +232,7 @@ void XWaylandInputTest::testPointerEventLeaveCsd()
xcb_window_t window = xcb_generate_id(c.data());
const uint32_t values[] = {
XCB_EVENT_MASK_ENTER_WINDOW |
XCB_EVENT_MASK_LEAVE_WINDOW
};
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW};
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, window, rootWindow(),
boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height,
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, XCB_CW_EVENT_MASK, values);

View file

@ -8,6 +8,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "abstract_client.h"
#include "abstract_output.h"
#include "platform.h"
@ -24,7 +25,8 @@ using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_xwayland_selections-0");
struct ProcessKillBeforeDeleter {
struct ProcessKillBeforeDeleter
{
static inline void cleanup(QProcess *pointer)
{
if (pointer)
@ -44,14 +46,14 @@ private Q_SLOTS:
void XwaylandSelectionsTest::initTestCase()
{
// QSKIP("Skipped as it fails for unknown reasons on build.kde.org");
qRegisterMetaType<KWin::AbstractClient*>();
// QSKIP("Skipped as it fails for unknown reasons on build.kde.org");
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<QProcess::ExitStatus>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
// QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated};
// QVERIFY(clipboardSyncDevicedCreated.isValid());
// QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated};
// QVERIFY(clipboardSyncDevicedCreated.isValid());
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
@ -62,10 +64,10 @@ void XwaylandSelectionsTest::initTestCase()
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
Test::initWaylandWorkspace();
// // wait till the xclipboard sync data device is created
// if (clipboardSyncDevicedCreated.empty()) {
// QVERIFY(clipboardSyncDevicedCreated.wait());
// }
// // wait till the xclipboard sync data device is created
// if (clipboardSyncDevicedCreated.empty()) {
// QVERIFY(clipboardSyncDevicedCreated.wait());
// }
}
void XwaylandSelectionsTest::testSync_data()
@ -115,7 +117,7 @@ void XwaylandSelectionsTest::testSync()
// start the paste process
QScopedPointer<QProcess, ProcessKillBeforeDeleter> pasteProcess(new QProcess());
QSignalSpy finishedSpy(pasteProcess.data(), static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished));
QSignalSpy finishedSpy(pasteProcess.data(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(finishedSpy.isValid());
QFETCH(QString, pastePlatform);
environment.insert(QStringLiteral("QT_QPA_PLATFORM"), pastePlatform);

View file

@ -5,6 +5,7 @@
*/
#include "kwin_wayland_test.h"
#include "abstract_output.h"
#include "composite.h"
#include "main.h"
@ -100,7 +101,7 @@ void XwaylandServerCrashTest::testCrash()
// Create an override-redirect window.
xcb_window_t window2 = xcb_generate_id(c.data());
const uint32_t values[] = { true };
const uint32_t values[] = {true};
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, window2, rootWindow(),
windowGeometry.x(), windowGeometry.y(),
windowGeometry.width(), windowGeometry.height(), 0,

View file

@ -5,6 +5,7 @@
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "main.h"
#include "platform.h"

View file

@ -6,14 +6,15 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "mock_libinput.h"
#include "backends/libinput/device.h"
#include <config-kwin.h>
#include "backends/libinput/device.h"
#include "mock_libinput.h"
#include <KSharedConfig>
#include <QDBusInterface>
#include <QDBusConnection>
#include <QDBusInterface>
#include <QtTest>
#include <linux/input.h>
@ -161,13 +162,16 @@ private Q_SLOTS:
void testSwitch();
};
namespace {
template <typename T>
namespace
{
template<typename T>
T dbusProperty(const QString &name, const char *property)
{
QDBusInterface interface{QStringLiteral("org.kde.kwin.tests.libinputdevice"),
QStringLiteral("/org/kde/KWin/InputDevice/") + name,
QStringLiteral("org.kde.KWin.InputDevice")};
QDBusInterface interface {
QStringLiteral("org.kde.kwin.tests.libinputdevice"),
QStringLiteral("/org/kde/KWin/InputDevice/") + name,
QStringLiteral("org.kde.KWin.InputDevice")
};
return interface.property(property).value<T>();
}
}
@ -930,7 +934,7 @@ void TestLibinputDevice::testLeftHanded_data()
QTest::newRow("unsupported/true") << false << false << true << false << false;
QTest::newRow("unsupported/false") << false << false << false << true << false;
QTest::newRow("true -> false") << true << false << true << false << false;
QTest::newRow("false -> true") << true << false << false << true << true;
QTest::newRow("false -> true") << true << false << false << true << true;
QTest::newRow("set fails") << true << true << true << false << true;
QTest::newRow("true -> true") << true << false << true << true << true;
QTest::newRow("false -> false") << true << false << false << false << false;
@ -967,23 +971,23 @@ void TestLibinputDevice::testSupportedButtons_data()
QTest::addColumn<Qt::MouseButtons>("setButtons");
QTest::addColumn<Qt::MouseButtons>("expectedButtons");
QTest::newRow("left") << true << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons(Qt::LeftButton);
QTest::newRow("right") << true << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons(Qt::RightButton);
QTest::newRow("middle") << true << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons(Qt::MiddleButton);
QTest::newRow("extra1") << true << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons(Qt::ExtraButton1);
QTest::newRow("extra2") << true << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons(Qt::ExtraButton2);
QTest::newRow("back") << true << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons(Qt::BackButton);
QTest::newRow("left") << true << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons(Qt::LeftButton);
QTest::newRow("right") << true << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons(Qt::RightButton);
QTest::newRow("middle") << true << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons(Qt::MiddleButton);
QTest::newRow("extra1") << true << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons(Qt::ExtraButton1);
QTest::newRow("extra2") << true << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons(Qt::ExtraButton2);
QTest::newRow("back") << true << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons(Qt::BackButton);
QTest::newRow("forward") << true << Qt::MouseButtons(Qt::ForwardButton) << Qt::MouseButtons(Qt::ForwardButton);
QTest::newRow("task") << true << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons(Qt::TaskButton);
QTest::newRow("task") << true << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons(Qt::TaskButton);
QTest::newRow("no pointer/left") << false << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons();
QTest::newRow("no pointer/right") << false << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons();
QTest::newRow("no pointer/middle") << false << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons();
QTest::newRow("no pointer/extra1") << false << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons();
QTest::newRow("no pointer/extra2") << false << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons();
QTest::newRow("no pointer/back") << false << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons();
QTest::newRow("no pointer/left") << false << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons();
QTest::newRow("no pointer/right") << false << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons();
QTest::newRow("no pointer/middle") << false << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons();
QTest::newRow("no pointer/extra1") << false << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons();
QTest::newRow("no pointer/extra2") << false << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons();
QTest::newRow("no pointer/back") << false << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons();
QTest::newRow("no pointer/forward") << false << Qt::MouseButtons(Qt::ForwardButton) << Qt::MouseButtons();
QTest::newRow("no pointer/task") << false << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons();
QTest::newRow("no pointer/task") << false << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons();
QTest::newRow("all") << true
<< Qt::MouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton | Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::BackButton | Qt::ForwardButton | Qt::TaskButton)
@ -1057,7 +1061,6 @@ void TestLibinputDevice::testAlphaNumericKeyboard()
QTEST(dbusProperty<bool>(d.sysName(), "alphaNumericKeyboard"), "isAlpha");
}
void TestLibinputDevice::testEnabled_data()
{
QTest::addColumn<bool>("supported");
@ -1069,7 +1072,7 @@ void TestLibinputDevice::testEnabled_data()
QTest::newRow("unsupported/true") << false << false << true << false << true;
QTest::newRow("unsupported/false") << false << false << false << true << true;
QTest::newRow("true -> false") << true << false << true << false << false;
QTest::newRow("false -> true") << true << false << false << true << true;
QTest::newRow("false -> true") << true << false << false << true << true;
QTest::newRow("set fails") << true << true << true << false << true;
QTest::newRow("true -> true") << true << false << true << true << true;
QTest::newRow("false -> false") << true << false << false << false << false;
@ -1392,7 +1395,8 @@ void TestLibinputDevice::testScrollTwoFinger()
QFETCH(bool, setShouldFail);
QFETCH(bool, supportsScrollTwoFinger);
device.supportedScrollMethods = (supportsScrollTwoFinger ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_EDGE;
device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE
: LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
device.setScrollMethodReturnValue = setShouldFail;
Device d(&device);
@ -1440,7 +1444,8 @@ void TestLibinputDevice::testScrollEdge()
QFETCH(bool, setShouldFail);
QFETCH(bool, supportsScrollEdge);
device.supportedScrollMethods = (supportsScrollEdge ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG;
device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG
: LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
device.setScrollMethodReturnValue = setShouldFail;
Device d(&device);
@ -1488,7 +1493,8 @@ void TestLibinputDevice::testScrollButtonDown()
QFETCH(bool, setShouldFail);
QFETCH(bool, supportsScrollButtonDown);
device.supportedScrollMethods = (supportsScrollButtonDown ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG;
device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG
: LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
device.setScrollMethodReturnValue = setShouldFail;
Device d(&device);
@ -1612,7 +1618,7 @@ void TestLibinputDevice::testLmrTapButtonMap_data()
QTest::newRow("false -> true, fingerCount 0") << false << true << true << false << 0;
// TODO: is this a fail in libinput?
//QTest::newRow("false -> true, fingerCount 1") << false << true << true << false << 1;
// QTest::newRow("false -> true, fingerCount 1") << false << true << true << false << 1;
}
void TestLibinputDevice::testLmrTapButtonMap()
@ -1777,13 +1783,13 @@ void TestLibinputDevice::testLoadPointerAccelerationProfile_data()
QTest::addColumn<QString>("configValuePropNameString");
QTest::newRow("pointerAccelerationProfileFlat -> pointerAccelerationProfileAdaptive")
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat"
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive";
<< (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat"
<< (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive";
QTest::newRow("pointerAccelerationProfileAdaptive -> pointerAccelerationProfileFlat")
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive"
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat";
<< (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive"
<< (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat";
QTest::newRow("pointerAccelerationProfileAdaptive -> pointerAccelerationProfileAdaptive")
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive" << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive";
<< (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive" << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive";
}
void TestLibinputDevice::testLoadPointerAccelerationProfile()
@ -1802,7 +1808,7 @@ void TestLibinputDevice::testLoadPointerAccelerationProfile()
libinput_device device;
device.supportedPointerAccelerationProfiles = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT | LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
device.pointerAccelerationProfile = (libinput_config_accel_profile) initValue;
device.pointerAccelerationProfile = (libinput_config_accel_profile)initValue;
device.setPointerAccelerationProfileReturnValue = false;
Device d(&device);
@ -1836,17 +1842,17 @@ void TestLibinputDevice::testLoadClickMethod_data()
QTest::addColumn<QString>("configValuePropNameString");
QTest::newRow("clickMethodAreas -> clickMethodClickfinger")
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger";
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger";
QTest::newRow("clickMethodClickfinger -> clickMethodAreas")
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas";
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas";
QTest::newRow("clickMethodAreas -> clickMethodAreas")
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas";
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas";
QTest::newRow("clickMethodClickfinger -> clickMethodClickfinger")
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger";
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"
<< static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger";
}
void TestLibinputDevice::testLoadClickMethod()
@ -1865,7 +1871,7 @@ void TestLibinputDevice::testLoadClickMethod()
libinput_device device;
device.supportedClickMethods = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS | LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
device.clickMethod = (libinput_config_click_method) initValue;
device.clickMethod = (libinput_config_click_method)initValue;
device.setClickMethodReturnValue = false;
Device d(&device);
@ -2106,9 +2112,9 @@ void TestLibinputDevice::testLoadScrollMethod_data()
QTest::addColumn<quint32>("configValue");
QTest::addColumn<QString>("configValuePropNameString");
QTest::newRow("scrollTwoFinger -> scrollEdge") << (quint32) LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger" << (quint32) LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge";
QTest::newRow("scrollOnButtonDown -> scrollTwoFinger") << (quint32) LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN << "scrollOnButtonDown" << (quint32) LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger";
QTest::newRow("scrollEdge -> scrollEdge") << (quint32) LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge" << (quint32) LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge";
QTest::newRow("scrollTwoFinger -> scrollEdge") << (quint32)LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger" << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge";
QTest::newRow("scrollOnButtonDown -> scrollTwoFinger") << (quint32)LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN << "scrollOnButtonDown" << (quint32)LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger";
QTest::newRow("scrollEdge -> scrollEdge") << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge" << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge";
}
void TestLibinputDevice::testLoadScrollMethod()
@ -2127,7 +2133,7 @@ void TestLibinputDevice::testLoadScrollMethod()
libinput_device device;
device.supportedScrollMethods = LIBINPUT_CONFIG_SCROLL_2FG | LIBINPUT_CONFIG_SCROLL_EDGE | LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
device.scrollMethod = (libinput_config_scroll_method) initValue;
device.scrollMethod = (libinput_config_scroll_method)initValue;
device.setScrollMethodReturnValue = false;
Device d(&device);

View file

@ -86,10 +86,10 @@ void TestLibinputGestureEvent::testType()
QCOMPARE(event->type(), type);
QCOMPARE(event->device(), m_device);
QCOMPARE(event->nativeDevice(), m_nativeDevice);
QCOMPARE((libinput_event*)(*event.data()), gestureEvent);
QCOMPARE((libinput_event *)(*event.data()), gestureEvent);
// verify it's a pointer event
QVERIFY(dynamic_cast<GestureEvent*>(event.data()));
QCOMPARE((libinput_event_gesture*)(*dynamic_cast<GestureEvent*>(event.data())), gestureEvent);
QVERIFY(dynamic_cast<GestureEvent *>(event.data()));
QCOMPARE((libinput_event_gesture *)(*dynamic_cast<GestureEvent *>(event.data())), gestureEvent);
}
void TestLibinputGestureEvent::testStart_data()
@ -110,14 +110,14 @@ void TestLibinputGestureEvent::testStart()
gestureEvent->time = 100u;
QScopedPointer<Event> event(Event::create(gestureEvent));
auto ge = dynamic_cast<GestureEvent*>(event.data());
auto ge = dynamic_cast<GestureEvent *>(event.data());
QVERIFY(ge);
QCOMPARE(ge->fingerCount(), gestureEvent->fingerCount);
QVERIFY(!ge->isCancelled());
QCOMPARE(ge->time(), gestureEvent->time);
QCOMPARE(ge->delta(), QSizeF(0, 0));
if (ge->type() == LIBINPUT_EVENT_GESTURE_PINCH_BEGIN) {
auto pe = dynamic_cast<PinchGestureEvent*>(event.data());
auto pe = dynamic_cast<PinchGestureEvent *>(event.data());
QCOMPARE(pe->scale(), 1.0);
QCOMPARE(pe->angleDelta(), 0.0);
}
@ -133,7 +133,7 @@ void TestLibinputGestureEvent::testSwipeUpdate()
gestureEvent->delta = QSizeF(2, 3);
QScopedPointer<Event> event(Event::create(gestureEvent));
auto se = dynamic_cast<SwipeGestureEvent*>(event.data());
auto se = dynamic_cast<SwipeGestureEvent *>(event.data());
QVERIFY(se);
QCOMPARE(se->fingerCount(), gestureEvent->fingerCount);
QVERIFY(!se->isCancelled());
@ -153,7 +153,7 @@ void TestLibinputGestureEvent::testPinchUpdate()
gestureEvent->angleDelta = -30;
QScopedPointer<Event> event(Event::create(gestureEvent));
auto pe = dynamic_cast<PinchGestureEvent*>(event.data());
auto pe = dynamic_cast<PinchGestureEvent *>(event.data());
QVERIFY(pe);
QCOMPARE(pe->fingerCount(), gestureEvent->fingerCount);
QVERIFY(!pe->isCancelled());
@ -187,14 +187,14 @@ void TestLibinputGestureEvent::testEnd()
gestureEvent->scale = 3;
QScopedPointer<Event> event(Event::create(gestureEvent));
auto ge = dynamic_cast<GestureEvent*>(event.data());
auto ge = dynamic_cast<GestureEvent *>(event.data());
QVERIFY(ge);
QCOMPARE(ge->fingerCount(), gestureEvent->fingerCount);
QCOMPARE(ge->isCancelled(), cancelled);
QCOMPARE(ge->time(), gestureEvent->time);
QCOMPARE(ge->delta(), QSizeF(0, 0));
if (ge->type() == LIBINPUT_EVENT_GESTURE_PINCH_END) {
auto pe = dynamic_cast<PinchGestureEvent*>(event.data());
auto pe = dynamic_cast<PinchGestureEvent *>(event.data());
QCOMPARE(pe->scale(), gestureEvent->scale);
QCOMPARE(pe->angleDelta(), 0.0);
}

View file

@ -115,7 +115,7 @@ void InputEventsTest::testInitWheelEvent_data()
QTest::addColumn<QPoint>("expectedAngleDelta");
QTest::newRow("horiz") << Qt::Horizontal << 3.3 << 1 << QPoint(3, 0);
QTest::newRow("vert") << Qt::Vertical << 2.4 << 2 << QPoint(0, 2);
QTest::newRow("vert") << Qt::Vertical << 2.4 << 2 << QPoint(0, 2);
}
void InputEventsTest::testInitWheelEvent()
@ -146,7 +146,6 @@ void InputEventsTest::testInitWheelEvent()
QCOMPARE(event.axisSource(), InputRedirection::PointerAxisSourceWheel);
// and our custom argument
QCOMPARE(event.device(), &d);
}
void InputEventsTest::testInitSwitchEvent_data()

View file

@ -62,10 +62,10 @@ void TestLibinputKeyEvent::testCreate()
QCOMPARE(event->type(), LIBINPUT_EVENT_KEYBOARD_KEY);
QCOMPARE(event->device(), m_device);
QCOMPARE(event->nativeDevice(), m_nativeDevice);
QCOMPARE((libinput_event*)(*event.data()), keyEvent);
QCOMPARE((libinput_event *)(*event.data()), keyEvent);
// verify it's a key event
QVERIFY(dynamic_cast<KeyEvent*>(event.data()));
QCOMPARE((libinput_event_keyboard*)(*dynamic_cast<KeyEvent*>(event.data())), keyEvent);
QVERIFY(dynamic_cast<KeyEvent *>(event.data()));
QCOMPARE((libinput_event_keyboard *)(*dynamic_cast<KeyEvent *>(event.data())), keyEvent);
// verify that a nullptr passed to Event::create returns a nullptr
QVERIFY(!Event::create(nullptr));
@ -95,7 +95,7 @@ void TestLibinputKeyEvent::testEvent()
keyEvent->time = time;
QScopedPointer<Event> event(Event::create(keyEvent));
auto ke = dynamic_cast<KeyEvent*>(event.data());
auto ke = dynamic_cast<KeyEvent *>(event.data());
QVERIFY(ke);
QTEST(ke->state(), "expectedKeyState");
QCOMPARE(ke->key(), key);

View file

@ -6,9 +6,10 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "mock_libinput.h"
#include <config-kwin.h>
#include "mock_libinput.h"
#include <linux/input.h>
int libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code)
@ -258,7 +259,7 @@ enum libinput_config_accel_profile libinput_device_config_accel_get_default_prof
enum libinput_config_status libinput_device_config_accel_set_profile(struct libinput_device *device, enum libinput_config_accel_profile profile)
{
if (device->setPointerAccelerationProfileReturnValue == 0) {
if (!(device->supportedPointerAccelerationProfiles & profile) && profile!= LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) {
if (!(device->supportedPointerAccelerationProfiles & profile) && profile != LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) {
return LIBINPUT_CONFIG_STATUS_INVALID;
}
device->pointerAccelerationProfile = profile;
@ -384,7 +385,6 @@ enum libinput_config_status libinput_device_config_send_events_set_mode(struct l
return LIBINPUT_CONFIG_STATUS_INVALID;
}
enum libinput_event_type libinput_event_get_type(struct libinput_event *event)
{
return event->type;
@ -410,38 +410,44 @@ struct libinput_event_keyboard *libinput_event_get_keyboard_event(struct libinpu
struct libinput_event_pointer *libinput_event_get_pointer_event(struct libinput_event *event)
{
if (event->type == LIBINPUT_EVENT_POINTER_MOTION ||
event->type == LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE ||
event->type == LIBINPUT_EVENT_POINTER_BUTTON ||
event->type == LIBINPUT_EVENT_POINTER_AXIS) {
switch (event->type) {
case LIBINPUT_EVENT_POINTER_MOTION:
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
return reinterpret_cast<libinput_event_pointer *>(event);
default:
return nullptr;
}
return nullptr;
}
struct libinput_event_touch *libinput_event_get_touch_event(struct libinput_event *event)
{
if (event->type == LIBINPUT_EVENT_TOUCH_DOWN ||
event->type == LIBINPUT_EVENT_TOUCH_UP ||
event->type == LIBINPUT_EVENT_TOUCH_MOTION ||
event->type == LIBINPUT_EVENT_TOUCH_CANCEL ||
event->type == LIBINPUT_EVENT_TOUCH_FRAME) {
switch (event->type) {
case LIBINPUT_EVENT_TOUCH_DOWN:
case LIBINPUT_EVENT_TOUCH_UP:
case LIBINPUT_EVENT_TOUCH_MOTION:
case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
return reinterpret_cast<libinput_event_touch *>(event);
default:
return nullptr;
}
return nullptr;
}
struct libinput_event_gesture *libinput_event_get_gesture_event(struct libinput_event *event)
{
if (event->type == LIBINPUT_EVENT_GESTURE_PINCH_BEGIN ||
event->type == LIBINPUT_EVENT_GESTURE_PINCH_UPDATE ||
event->type == LIBINPUT_EVENT_GESTURE_PINCH_END ||
event->type == LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN ||
event->type == LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE ||
event->type == LIBINPUT_EVENT_GESTURE_SWIPE_END) {
switch (event->type) {
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
case LIBINPUT_EVENT_GESTURE_PINCH_END:
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
return reinterpret_cast<libinput_event_gesture *>(event);
default:
return nullptr;
}
return nullptr;
}
int libinput_event_gesture_get_cancelled(struct libinput_event_gesture *event)
@ -866,7 +872,7 @@ int libinput_device_switch_has_switch(struct libinput_device *device, enum libin
struct libinput_event_switch *libinput_event_get_switch_event(struct libinput_event *event)
{
if (event->type == LIBINPUT_EVENT_SWITCH_TOGGLE) {
return reinterpret_cast<libinput_event_switch*>(event);
return reinterpret_cast<libinput_event_switch *>(event);
} else {
return nullptr;
}
@ -886,7 +892,7 @@ enum libinput_switch_state libinput_event_switch_get_switch_state(struct libinpu
uint32_t libinput_event_switch_get_time(struct libinput_event_switch *event)
{
return event->time;;
return event->time;
}
uint64_t libinput_event_switch_get_time_usec(struct libinput_event_switch *event)
@ -905,28 +911,27 @@ struct libinput_event_tablet_pad *libinput_event_get_tablet_pad_event(struct lib
struct libinput_event_tablet_tool *
libinput_event_get_tablet_tool_event(struct libinput_event *event)
{
if (event->type == LIBINPUT_EVENT_TABLET_TOOL_AXIS ||
event->type == LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY ||
event->type == LIBINPUT_EVENT_TABLET_TOOL_TIP) {
switch (event->type) {
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
return reinterpret_cast<libinput_event_tablet_tool *>(event);
default:
return nullptr;
}
return nullptr;
}
int
libinput_device_tablet_pad_get_num_strips(struct libinput_device *device)
int libinput_device_tablet_pad_get_num_strips(struct libinput_device *device)
{
return device->stripCount;
}
int
libinput_device_tablet_pad_get_num_rings(struct libinput_device *device)
int libinput_device_tablet_pad_get_num_rings(struct libinput_device *device)
{
return device->ringCount;
}
int
libinput_device_tablet_pad_get_num_buttons(struct libinput_device *device)
int libinput_device_tablet_pad_get_num_buttons(struct libinput_device *device)
{
return device->buttonCount;
}
@ -945,9 +950,8 @@ libinput_device_group_get_user_data(struct libinput_device_group *group)
return nullptr;
}
void
libinput_device_led_update(struct libinput_device *device,
enum libinput_led leds)
void libinput_device_led_update(struct libinput_device *device,
enum libinput_led leds)
{
Q_UNUSED(device)
Q_UNUSED(leds)

View file

@ -17,7 +17,8 @@
#include <array>
struct libinput_device {
struct libinput_device
{
bool keyboard = false;
bool pointer = false;
bool touch = false;
@ -100,22 +101,28 @@ struct libinput_device {
uint32_t ringCount = 0;
};
struct libinput_event {
virtual ~libinput_event() {}
struct libinput_event
{
virtual ~libinput_event()
{
}
libinput_device *device = nullptr;
libinput_event_type type = LIBINPUT_EVENT_NONE;
quint32 time = 0;
};
struct libinput_event_keyboard : libinput_event {
libinput_event_keyboard() {
struct libinput_event_keyboard : libinput_event
{
libinput_event_keyboard()
{
type = LIBINPUT_EVENT_KEYBOARD_KEY;
}
libinput_key_state state = LIBINPUT_KEY_STATE_RELEASED;
quint32 key = 0;
};
struct libinput_event_pointer : libinput_event {
struct libinput_event_pointer : libinput_event
{
libinput_button_state buttonState = LIBINPUT_BUTTON_STATE_RELEASED;
quint32 button = 0;
bool verticalAxis = false;
@ -129,12 +136,14 @@ struct libinput_event_pointer : libinput_event {
QPointF absolutePos;
};
struct libinput_event_touch : libinput_event {
struct libinput_event_touch : libinput_event
{
qint32 slot = -1;
QPointF absolutePos;
};
struct libinput_event_gesture : libinput_event {
struct libinput_event_gesture : libinput_event
{
int fingerCount = 0;
bool cancelled = false;
QSizeF delta = QSizeF(0, 0);
@ -142,7 +151,8 @@ struct libinput_event_gesture : libinput_event {
qreal angleDelta = 0.0;
};
struct libinput_event_switch : libinput_event {
struct libinput_event_switch : libinput_event
{
enum class State {
Off,
On
@ -151,7 +161,8 @@ struct libinput_event_switch : libinput_event {
quint64 timeMicroseconds = 0;
};
struct libinput {
struct libinput
{
int refCount = 1;
QByteArray seat;
int assignSeatRetVal = 0;

View file

@ -82,10 +82,10 @@ void TestLibinputPointerEvent::testType()
QCOMPARE(event->type(), type);
QCOMPARE(event->device(), m_device);
QCOMPARE(event->nativeDevice(), m_nativeDevice);
QCOMPARE((libinput_event*)(*event.data()), pointerEvent);
QCOMPARE((libinput_event *)(*event.data()), pointerEvent);
// verify it's a pointer event
QVERIFY(dynamic_cast<PointerEvent*>(event.data()));
QCOMPARE((libinput_event_pointer*)(*dynamic_cast<PointerEvent*>(event.data())), pointerEvent);
QVERIFY(dynamic_cast<PointerEvent *>(event.data()));
QCOMPARE((libinput_event_pointer *)(*dynamic_cast<PointerEvent *>(event.data())), pointerEvent);
}
void TestLibinputPointerEvent::testButton_data()
@ -113,7 +113,7 @@ void TestLibinputPointerEvent::testButton()
pointerEvent->time = time;
QScopedPointer<Event> event(Event::create(pointerEvent));
auto pe = dynamic_cast<PointerEvent*>(event.data());
auto pe = dynamic_cast<PointerEvent *>(event.data());
QVERIFY(pe);
QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_BUTTON);
QTEST(pe->buttonState(), "expectedButtonState");
@ -132,20 +132,20 @@ void TestLibinputPointerEvent::testAxis_data()
QTest::addColumn<KWin::InputRedirection::PointerAxisSource>("expectedAxisSource");
QTest::addColumn<quint32>("time");
QTest::newRow("wheel/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(1, 0) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 100u;
QTest::newRow("wheel/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 200u;
QTest::newRow("wheel/both") << true << true << QPointF(1.1, 4.2) << QPoint(1, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 300u;
QTest::newRow("wheel/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(1, 0) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 100u;
QTest::newRow("wheel/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 200u;
QTest::newRow("wheel/both") << true << true << QPointF(1.1, 4.2) << QPoint(1, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 300u;
QTest::newRow("finger/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 400u;
QTest::newRow("stop finger/horizontal") << true << false << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 500u;
QTest::newRow("finger/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 600u;
QTest::newRow("stop finger/vertical") << false << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 700u;
QTest::newRow("finger/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 800u;
QTest::newRow("stop finger/both") << true << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 900u;
QTest::newRow("finger/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 400u;
QTest::newRow("stop finger/horizontal") << true << false << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 500u;
QTest::newRow("finger/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 600u;
QTest::newRow("stop finger/vertical") << false << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 700u;
QTest::newRow("finger/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 800u;
QTest::newRow("stop finger/both") << true << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 900u;
QTest::newRow("continuous/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1000u;
QTest::newRow("continuous/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1100u;
QTest::newRow("continuous/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1200u;
QTest::newRow("continuous/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1000u;
QTest::newRow("continuous/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1100u;
QTest::newRow("continuous/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1200u;
}
void TestLibinputPointerEvent::testAxis()
@ -170,7 +170,7 @@ void TestLibinputPointerEvent::testAxis()
pointerEvent->time = time;
QScopedPointer<Event> event(Event::create(pointerEvent));
auto pe = dynamic_cast<PointerEvent*>(event.data());
auto pe = dynamic_cast<PointerEvent *>(event.data());
QVERIFY(pe);
QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_AXIS);
QCOMPARE(pe->axis().contains(KWin::InputRedirection::PointerAxisHorizontal), horizontal);
@ -193,7 +193,7 @@ void TestLibinputPointerEvent::testMotion()
pointerEvent->time = 500u;
QScopedPointer<Event> event(Event::create(pointerEvent));
auto pe = dynamic_cast<PointerEvent*>(event.data());
auto pe = dynamic_cast<PointerEvent *>(event.data());
QVERIFY(pe);
QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_MOTION);
QCOMPARE(pe->time(), 500u);
@ -210,7 +210,7 @@ void TestLibinputPointerEvent::testAbsoluteMotion()
pointerEvent->time = 500u;
QScopedPointer<Event> event(Event::create(pointerEvent));
auto pe = dynamic_cast<PointerEvent*>(event.data());
auto pe = dynamic_cast<PointerEvent *>(event.data());
QVERIFY(pe);
QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
QCOMPARE(pe->time(), 500u);

View file

@ -75,7 +75,7 @@ void TestLibinputSwitchEvent::testToggled()
nativeEvent->timeMicroseconds = 23456789;
QScopedPointer<Event> event(Event::create(nativeEvent));
auto se = dynamic_cast<SwitchEvent*>(event.data());
auto se = dynamic_cast<SwitchEvent *>(event.data());
QVERIFY(se);
QCOMPARE(se->device(), m_device.get());
QCOMPARE(se->nativeDevice(), m_nativeDevice.get());

View file

@ -79,13 +79,13 @@ void TestLibinputTouchEvent::testType()
QCOMPARE(event->type(), type);
QCOMPARE(event->device(), m_device);
QCOMPARE(event->nativeDevice(), m_nativeDevice);
QCOMPARE((libinput_event*)(*event.data()), touchEvent);
QCOMPARE((libinput_event *)(*event.data()), touchEvent);
// verify it's a pointer event
QVERIFY(dynamic_cast<TouchEvent*>(event.data()));
QCOMPARE((libinput_event_touch*)(*dynamic_cast<TouchEvent*>(event.data())), touchEvent);
QVERIFY(dynamic_cast<TouchEvent *>(event.data()));
QCOMPARE((libinput_event_touch *)(*dynamic_cast<TouchEvent *>(event.data())), touchEvent);
QFETCH(bool, hasId);
if (hasId) {
QCOMPARE(dynamic_cast<TouchEvent*>(event.data())->id(), 0);
QCOMPARE(dynamic_cast<TouchEvent *>(event.data())->id(), 0);
}
}
@ -108,7 +108,7 @@ void TestLibinputTouchEvent::testAbsoluteMotion()
touchEvent->slot = 1;
QScopedPointer<Event> event(Event::create(touchEvent));
auto te = dynamic_cast<TouchEvent*>(event.data());
auto te = dynamic_cast<TouchEvent *>(event.data());
QVERIFY(te);
QCOMPARE(te->type(), type);
QCOMPARE(te->time(), 500u);

View file

@ -18,15 +18,15 @@ static const GLubyte *mock_glGetString(GLenum name)
}
switch (name) {
case GL_VENDOR:
return (const GLubyte*)s_gl->getString.vendor.constData();
return (const GLubyte *)s_gl->getString.vendor.constData();
case GL_RENDERER:
return (const GLubyte*)s_gl->getString.renderer.constData();
return (const GLubyte *)s_gl->getString.renderer.constData();
case GL_VERSION:
return (const GLubyte*)s_gl->getString.version.constData();
return (const GLubyte *)s_gl->getString.version.constData();
case GL_EXTENSIONS:
return (const GLubyte*)s_gl->getString.extensionsString.constData();
return (const GLubyte *)s_gl->getString.extensionsString.constData();
case GL_SHADING_LANGUAGE_VERSION:
return (const GLubyte*)s_gl->getString.shadingLanguageVersion.constData();
return (const GLubyte *)s_gl->getString.shadingLanguageVersion.constData();
default:
return nullptr;
}
@ -38,7 +38,7 @@ static const GLubyte *mock_glGetStringi(GLenum name, GLuint index)
return nullptr;
}
if (name == GL_EXTENSIONS && index < uint(s_gl->getString.extensions.count())) {
return (const GLubyte*)s_gl->getString.extensions.at(index).constData();
return (const GLubyte *)s_gl->getString.extensions.at(index).constData();
}
return nullptr;
}

View file

@ -12,8 +12,10 @@
#include <QByteArray>
#include <QVector>
struct MockGL {
struct {
struct MockGL
{
struct
{
QByteArray vendor;
QByteArray renderer;
QByteArray version;

View file

@ -163,12 +163,12 @@ void TimeLineTest::testSetElapsed_data()
QTest::addColumn<bool>("expectedDone");
QTest::addColumn<bool>("initiallyDone");
QTest::newRow("Less than duration, not finished") << 1000ms << 300ms << 300ms << false << false;
QTest::newRow("Less than duration, finished") << 1000ms << 300ms << 300ms << false << true;
QTest::newRow("Greater than duration, not finished") << 1000ms << 3000ms << 1000ms << true << false;
QTest::newRow("Greater than duration, finished") << 1000ms << 3000ms << 1000ms << true << true;
QTest::newRow("Equal to duration, not finished") << 1000ms << 1000ms << 1000ms << true << false;
QTest::newRow("Equal to duration, finished") << 1000ms << 1000ms << 1000ms << true << true;
QTest::newRow("Less than duration, not finished") << 1000ms << 300ms << 300ms << false << false;
QTest::newRow("Less than duration, finished") << 1000ms << 300ms << 300ms << false << true;
QTest::newRow("Greater than duration, not finished") << 1000ms << 3000ms << 1000ms << true << false;
QTest::newRow("Greater than duration, finished") << 1000ms << 3000ms << 1000ms << true << true;
QTest::newRow("Equal to duration, not finished") << 1000ms << 1000ms << 1000ms << true << false;
QTest::newRow("Equal to duration, finished") << 1000ms << 1000ms << 1000ms << true << true;
}
void TimeLineTest::testSetElapsed()
@ -255,8 +255,8 @@ void TimeLineTest::testStrictRedirectSourceMode_data()
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 0.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 1.0;
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 0.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 1.0;
}
void TimeLineTest::testStrictRedirectSourceMode()
@ -289,8 +289,8 @@ void TimeLineTest::testRelaxedRedirectSourceMode_data()
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
}
void TimeLineTest::testRelaxedRedirectSourceMode()
@ -323,8 +323,8 @@ void TimeLineTest::testStrictRedirectTargetMode_data()
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
}
void TimeLineTest::testStrictRedirectTargetMode()
@ -361,8 +361,8 @@ void TimeLineTest::testRelaxedRedirectTargetMode_data()
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
}
void TimeLineTest::testRelaxedRedirectTargetMode()

View file

@ -6,8 +6,8 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <kwineffects.h>
#include <QTest>
#include <kwineffects.h>
Q_DECLARE_METATYPE(KWin::WindowQuadList)
@ -27,10 +27,10 @@ private:
KWin::WindowQuad WindowQuadListTest::makeQuad(const QRectF &r)
{
KWin::WindowQuad quad;
quad[ 0 ] = KWin::WindowVertex(r.x(), r.y(), r.x(), r.y());
quad[ 1 ] = KWin::WindowVertex(r.x() + r.width(), r.y(), r.x() + r.width(), r.y());
quad[ 2 ] = KWin::WindowVertex(r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height());
quad[ 3 ] = KWin::WindowVertex(r.x(), r.y() + r.height(), r.x(), r.y() + r.height());
quad[0] = KWin::WindowVertex(r.x(), r.y(), r.x(), r.y());
quad[1] = KWin::WindowVertex(r.x() + r.width(), r.y(), r.x() + r.width(), r.y());
quad[2] = KWin::WindowVertex(r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height());
quad[3] = KWin::WindowVertex(r.x(), r.y() + r.height(), r.x(), r.y() + r.height());
return quad;
}
@ -66,17 +66,17 @@ void WindowQuadListTest::testMakeGrid_data()
orig.append(makeQuad(QRectF(0, 10, 4, 3)));
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 4, 4)));
expected.append(makeQuad(QRectF(0, 4, 4, 4)));
expected.append(makeQuad(QRectF(0, 8, 4, 2)));
expected.append(makeQuad(QRectF(0, 0, 4, 4)));
expected.append(makeQuad(QRectF(0, 4, 4, 4)));
expected.append(makeQuad(QRectF(0, 8, 4, 2)));
expected.append(makeQuad(QRectF(0, 10, 4, 2)));
expected.append(makeQuad(QRectF(0, 12, 4, 1)));
expected.append(makeQuad(QRectF(4, 0, 4, 4)));
expected.append(makeQuad(QRectF(4, 4, 4, 4)));
expected.append(makeQuad(QRectF(4, 8, 4, 2)));
expected.append(makeQuad(QRectF(8, 0, 2, 4)));
expected.append(makeQuad(QRectF(8, 4, 2, 4)));
expected.append(makeQuad(QRectF(8, 8, 2, 2)));
expected.append(makeQuad(QRectF(4, 0, 4, 4)));
expected.append(makeQuad(QRectF(4, 4, 4, 4)));
expected.append(makeQuad(QRectF(4, 8, 4, 2)));
expected.append(makeQuad(QRectF(8, 0, 2, 4)));
expected.append(makeQuad(QRectF(8, 4, 2, 4)));
expected.append(makeQuad(QRectF(8, 8, 2, 2)));
QTest::newRow("irregularGrid2") << orig << 4 << 11 << expected;
}
@ -96,10 +96,14 @@ void WindowQuadListTest::testMakeGrid()
auto vertexTest = [actualQuad, expectedQuad](int index) {
const KWin::WindowVertex &actualVertex = actualQuad[index];
const KWin::WindowVertex &expectedVertex = expectedQuad[index];
if (actualVertex.x() != expectedVertex.x()) return false;
if (actualVertex.y() != expectedVertex.y()) return false;
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) return false;
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) return false;
if (actualVertex.x() != expectedVertex.x())
return false;
if (actualVertex.y() != expectedVertex.y())
return false;
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u()))
return false;
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v()))
return false;
return true;
};
found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3);
@ -107,10 +111,7 @@ void WindowQuadListTest::testMakeGrid()
break;
}
}
QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()),
QString::number(actualQuad.top()),
QString::number(actualQuad.right()),
QString::number(actualQuad.bottom()))));
QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), QString::number(actualQuad.top()), QString::number(actualQuad.right()), QString::number(actualQuad.bottom()))));
}
}
@ -150,15 +151,15 @@ void WindowQuadListTest::testMakeRegularGrid_data()
orig.append(makeQuad(QRectF(0, 10, 4, 2)));
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 5, 3)));
expected.append(makeQuad(QRectF(5, 0, 5, 3)));
expected.append(makeQuad(QRectF(0, 3, 5, 3)));
expected.append(makeQuad(QRectF(5, 3, 5, 3)));
expected.append(makeQuad(QRectF(0, 6, 5, 3)));
expected.append(makeQuad(QRectF(5, 6, 5, 3)));
expected.append(makeQuad(QRectF(0, 9, 5, 1)));
expected.append(makeQuad(QRectF(0, 0, 5, 3)));
expected.append(makeQuad(QRectF(5, 0, 5, 3)));
expected.append(makeQuad(QRectF(0, 3, 5, 3)));
expected.append(makeQuad(QRectF(5, 3, 5, 3)));
expected.append(makeQuad(QRectF(0, 6, 5, 3)));
expected.append(makeQuad(QRectF(5, 6, 5, 3)));
expected.append(makeQuad(QRectF(0, 9, 5, 1)));
expected.append(makeQuad(QRectF(0, 10, 4, 2)));
expected.append(makeQuad(QRectF(5, 9, 5, 1)));
expected.append(makeQuad(QRectF(5, 9, 5, 1)));
QTest::newRow("multipleQuads") << orig << 2 << 4 << 9 << expected;
}
@ -179,10 +180,14 @@ void WindowQuadListTest::testMakeRegularGrid()
auto vertexTest = [actualQuad, expectedQuad](int index) {
const KWin::WindowVertex &actualVertex = actualQuad[index];
const KWin::WindowVertex &expectedVertex = expectedQuad[index];
if (actualVertex.x() != expectedVertex.x()) return false;
if (actualVertex.y() != expectedVertex.y()) return false;
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) return false;
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) return false;
if (actualVertex.x() != expectedVertex.x())
return false;
if (actualVertex.y() != expectedVertex.y())
return false;
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u()))
return false;
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v()))
return false;
return true;
};
found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3);
@ -190,10 +195,7 @@ void WindowQuadListTest::testMakeRegularGrid()
break;
}
}
QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()),
QString::number(actualQuad.top()),
QString::number(actualQuad.right()),
QString::number(actualQuad.bottom()))));
QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), QString::number(actualQuad.top()), QString::number(actualQuad.right()), QString::number(actualQuad.bottom()))));
}
}

View file

@ -6,8 +6,8 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QtTest>
#include <QLoggingCategory>
#include <QtTest>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else

View file

@ -7,11 +7,11 @@
#include "onscreennotificationtest.h"
#include "onscreennotification.h"
#include "input.h"
#include "onscreennotification.h"
#include <KSharedConfig>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QQmlEngine>
#include <QSignalSpy>

View file

@ -163,135 +163,153 @@ void OpenGLContextAttributeBuilderTest::testEgl_data()
QTest::addColumn<std::vector<int>>("expectedAttribs");
QTest::newRow("fallback") << false << 0 << 0 << false << false << false << false << false << std::vector<int>{EGL_NONE};
QTest::newRow("legacy/robust") << false << 0 << 0 << true << false << false << false << false <<
std::vector<int>{
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_NONE};
QTest::newRow("legacy/robust/high priority") << false << 0 << 0 << true << false << false << false << true <<
std::vector<int>{
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core") << true << 3 << 1 << false << false << false << false << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_NONE};
QTest::newRow("core/high priority") << true << 3 << 1 << false << false << false << false << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core/robust") << true << 3 << 1 << true << false << false << false << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_NONE};
QTest::newRow("core/robust/high priority") << true << 3 << 1 << true << false << false << false << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core/robust/forward compatible") << true << 3 << 1 << true << true << false << false << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_NONE};
QTest::newRow("core/robust/forward compatible/high priority") << true << 3 << 1 << true << true << false << false << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core/forward compatible") << true << 3 << 1 << false << true << false << false << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_NONE};
QTest::newRow("core/forward compatible/high priority") << true << 3 << 1 << false << true << false << false << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core profile/forward compatible") << true << 3 << 2 << false << true << true << false << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("core profile/forward compatible/high priority") << true << 3 << 2 << false << true << true << false << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("compatibility profile/forward compatible") << true << 3 << 2 << false << true << false << true << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("compatibility profile/forward compatible/high priority") << true << 3 << 2 << false << true << false << true << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core profile/robust/forward compatible") << true << 3 << 2 << true << true << true << false << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("core profile/robust/forward compatible/high priority") << true << 3 << 2 << true << true << true << false << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("compatibility profile/robust/forward compatible") << true << 3 << 2 << true << true << false << true << false <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("compatibility profile/robust/forward compatible/high priority") << true << 3 << 2 << true << true << false << true << true <<
std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("legacy/robust")
<< false << 0 << 0 << true << false << false << false << false
<< std::vector<int>{
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_NONE};
QTest::newRow("legacy/robust/high priority")
<< false << 0 << 0 << true << false << false << false << true
<< std::vector<int>{
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core")
<< true << 3 << 1 << false << false << false << false << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_NONE};
QTest::newRow("core/high priority")
<< true << 3 << 1 << false << false << false << false << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core/robust")
<< true << 3 << 1 << true << false << false << false << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_NONE};
QTest::newRow("core/robust/high priority")
<< true << 3 << 1 << true << false << false << false << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core/robust/forward compatible")
<< true << 3 << 1 << true << true << false << false << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_NONE};
QTest::newRow("core/robust/forward compatible/high priority")
<< true << 3 << 1 << true << true << false << false << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core/forward compatible")
<< true << 3 << 1 << false << true << false << false << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_NONE};
QTest::newRow("core/forward compatible/high priority")
<< true << 3 << 1 << false << true << false << false << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core profile/forward compatible")
<< true << 3 << 2 << false << true << true << false << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("core profile/forward compatible/high priority")
<< true << 3 << 2 << false << true << true << false << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("compatibility profile/forward compatible")
<< true << 3 << 2 << false << true << false << true << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("compatibility profile/forward compatible/high priority")
<< true << 3 << 2 << false << true << false << true << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("core profile/robust/forward compatible")
<< true << 3 << 2 << true << true << true << false << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("core profile/robust/forward compatible/high priority")
<< true << 3 << 2 << true << true << true << false << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("compatibility profile/robust/forward compatible")
<< true << 3 << 2 << true << true << false << true << false
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_NONE};
QTest::newRow("compatibility profile/robust/forward compatible/high priority")
<< true << 3 << 2 << true << true << false << true << true
<< std::vector<int>{
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 2,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
}
void OpenGLContextAttributeBuilderTest::testEgl()
@ -325,24 +343,32 @@ void OpenGLContextAttributeBuilderTest::testGles_data()
QTest::addColumn<bool>("highPriority");
QTest::addColumn<std::vector<int>>("expectedAttribs");
QTest::newRow("robust") << true << false << std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
EGL_NONE};
QTest::newRow("robust/high priority") << true << true << std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("normal") << false << false << std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE};
QTest::newRow("normal/high priority") << false << true << std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("robust")
<< true << false
<< std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
EGL_NONE};
QTest::newRow("robust/high priority")
<< true << true
<< std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE,
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
QTest::newRow("normal")
<< false << false
<< std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE};
QTest::newRow("normal/high priority")
<< false << true
<< std::vector<int>{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
EGL_NONE};
}
void OpenGLContextAttributeBuilderTest::testGles()
@ -369,40 +395,48 @@ void OpenGLContextAttributeBuilderTest::testGlx_data()
QTest::addColumn<bool>("videoPurge");
QTest::addColumn<std::vector<int>>("expectedAttribs");
QTest::newRow("fallback") << true << 2 << 1 << false << false << std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0};
QTest::newRow("legacy/robust") << false << 0 << 0 << true << false << std::vector<int>{
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0
};
QTest::newRow("legacy/robust/videoPurge") << false << 0 << 0 << true << true << std::vector<int>{
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
0
};
QTest::newRow("core") << true << 3 << 1 << false << false << std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0};
QTest::newRow("core/robust") << true << 3 << 1 << true << false << std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0
};
QTest::newRow("core/robust/videoPurge") << true << 3 << 1 << true << true << std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
0
};
QTest::newRow("fallback")
<< true << 2 << 1 << false << false
<< std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0};
QTest::newRow("legacy/robust")
<< false << 0 << 0 << true << false
<< std::vector<int>{
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0};
QTest::newRow("legacy/robust/videoPurge")
<< false << 0 << 0 << true << true
<< std::vector<int>{
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
0};
QTest::newRow("core")
<< true << 3 << 1 << false << false
<< std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
0};
QTest::newRow("core/robust")
<< true << 3 << 1 << true << false
<< std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
0};
QTest::newRow("core/robust/videoPurge")
<< true << 3 << 1 << true << true
<< std::vector<int>{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB,
GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE,
0};
#endif
}

View file

@ -20,7 +20,7 @@ MockTabBoxClient::MockTabBoxClient(QString caption)
void MockTabBoxClient::close()
{
static_cast<MockTabBoxHandler*>(TabBox::tabBox)->closeWindow(this);
static_cast<MockTabBoxHandler *>(TabBox::tabBox)->closeWindow(this);
}
} // namespace KWin

Some files were not shown because too many files have changed in this diff Show more