KWin
Loading...
Searching...
No Matches
platformcursor.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#include "kwin_wayland_test.h"
10
11#include "cursor.h"
12#include "wayland_server.h"
13
14#include <QSignalSpy>
15
16namespace KWin
17{
18
19static const QString s_socketName = QStringLiteral("wayland_test_kwin_platform_cursor-0");
20
21class PlatformCursorTest : public QObject
22{
23 Q_OBJECT
24private Q_SLOTS:
25 void initTestCase();
26 void testPos();
27};
28
29void PlatformCursorTest::initTestCase()
30{
31 QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
32 QVERIFY(waylandServer()->init(s_socketName));
34 QRect(0, 0, 1280, 1024),
35 QRect(1280, 0, 1280, 1024),
36 });
37
38 kwinApp()->start();
39 QVERIFY(applicationStartedSpy.wait());
40}
41
42void PlatformCursorTest::testPos()
43{
44 // this test verifies that the PlatformCursor of the QPA plugin forwards ::pos and ::setPos correctly
45 // that is QCursor should work just like KWin::Cursor
46
47 // cursor should be centered on screen
48 QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(639, 511));
49 QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(639, 511));
50
51 // let's set the pos through QCursor API
52 QCursor::setPos(QPoint(10, 10));
53 QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(10, 10));
54 QCOMPARE(QCursor::pos(), QPoint(10, 10));
55
56 // and let's set the pos through Cursor API
57 QCursor::setPos(QPoint(20, 20));
58 QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(20, 20));
59 QCOMPARE(QCursor::pos(), QPoint(20, 20));
60}
61
62}
63
65#include "platformcursor.moc"
static Cursors * self()
Definition cursor.cpp:35
#define WAYLANDTEST_MAIN(TestObject)
void setOutputConfig(const QList< QRect > &geometries)
WaylandServer * waylandServer()