Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/dbus_interface_test.cpp
Show All 21 Lines | |||||
22 | *********************************************************************/ | 22 | *********************************************************************/ | ||
23 | #include "kwin_wayland_test.h" | 23 | #include "kwin_wayland_test.h" | ||
24 | #include "atoms.h" | 24 | #include "atoms.h" | ||
25 | #include "client.h" | 25 | #include "client.h" | ||
26 | #include "deleted.h" | 26 | #include "deleted.h" | ||
27 | #include "platform.h" | 27 | #include "platform.h" | ||
28 | #include "rules.h" | 28 | #include "rules.h" | ||
29 | #include "screens.h" | 29 | #include "screens.h" | ||
30 | #include "shell_client.h" | 30 | #include "xdgshellclient.h" | ||
31 | #include "virtualdesktops.h" | 31 | #include "virtualdesktops.h" | ||
32 | #include "wayland_server.h" | 32 | #include "wayland_server.h" | ||
33 | #include "workspace.h" | 33 | #include "workspace.h" | ||
34 | 34 | | |||
35 | #include <KWayland/Client/surface.h> | 35 | #include <KWayland/Client/surface.h> | ||
36 | 36 | | |||
37 | #include <QDBusArgument> | 37 | #include <QDBusArgument> | ||
38 | #include <QDBusConnection> | 38 | #include <QDBusConnection> | ||
Show All 17 Lines | |||||
56 | { | 56 | { | ||
57 | Q_OBJECT | 57 | Q_OBJECT | ||
58 | private Q_SLOTS: | 58 | private Q_SLOTS: | ||
59 | void initTestCase(); | 59 | void initTestCase(); | ||
60 | void init(); | 60 | void init(); | ||
61 | void cleanup(); | 61 | void cleanup(); | ||
62 | 62 | | |||
63 | void testGetWindowInfoInvalidUuid(); | 63 | void testGetWindowInfoInvalidUuid(); | ||
64 | void testGetWindowInfoShellClient_data(); | 64 | void testGetWindowInfoXdgShellClient_data(); | ||
65 | void testGetWindowInfoShellClient(); | 65 | void testGetWindowInfoXdgShellClient(); | ||
66 | void testGetWindowInfoX11Client(); | 66 | void testGetWindowInfoX11Client(); | ||
67 | }; | 67 | }; | ||
68 | 68 | | |||
69 | void TestDbusInterface::initTestCase() | 69 | void TestDbusInterface::initTestCase() | ||
70 | { | 70 | { | ||
71 | qRegisterMetaType<KWin::Deleted*>(); | 71 | qRegisterMetaType<KWin::Deleted*>(); | ||
72 | qRegisterMetaType<KWin::ShellClient*>(); | 72 | qRegisterMetaType<KWin::XdgShellClient *>(); | ||
73 | qRegisterMetaType<KWin::AbstractClient*>(); | 73 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
74 | 74 | | |||
75 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 75 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
76 | QVERIFY(workspaceCreatedSpy.isValid()); | 76 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
77 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 77 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
78 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 78 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
79 | 79 | | |||
80 | kwinApp()->start(); | 80 | kwinApp()->start(); | ||
Show All 26 Lines | 106 | { | |||
107 | QDBusPendingReply<QVariantMap> reply{getWindowInfo(QUuid::createUuid())}; | 107 | QDBusPendingReply<QVariantMap> reply{getWindowInfo(QUuid::createUuid())}; | ||
108 | reply.waitForFinished(); | 108 | reply.waitForFinished(); | ||
109 | QVERIFY(reply.isValid()); | 109 | QVERIFY(reply.isValid()); | ||
110 | QVERIFY(!reply.isError()); | 110 | QVERIFY(!reply.isError()); | ||
111 | const auto windowData = reply.value(); | 111 | const auto windowData = reply.value(); | ||
112 | QVERIFY(windowData.empty()); | 112 | QVERIFY(windowData.empty()); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | void TestDbusInterface::testGetWindowInfoShellClient_data() | 115 | void TestDbusInterface::testGetWindowInfoXdgShellClient_data() | ||
116 | { | 116 | { | ||
117 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 117 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
118 | 118 | | |||
119 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 119 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
120 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 120 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | void TestDbusInterface::testGetWindowInfoShellClient() | 123 | void TestDbusInterface::testGetWindowInfoXdgShellClient() | ||
124 | { | 124 | { | ||
125 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 125 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
126 | QVERIFY(clientAddedSpy.isValid()); | 126 | QVERIFY(clientAddedSpy.isValid()); | ||
127 | 127 | | |||
128 | QScopedPointer<Surface> surface(Test::createSurface()); | 128 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
129 | QFETCH(Test::XdgShellSurfaceType, type); | 129 | QFETCH(Test::XdgShellSurfaceType, type); | ||
130 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 130 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
131 | shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); | 131 | shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); | ||
132 | shellSurface->setTitle(QStringLiteral("Test window")); | 132 | shellSurface->setTitle(QStringLiteral("Test window")); | ||
133 | 133 | | |||
134 | // now let's render | 134 | // now let's render | ||
135 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | 135 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
136 | QVERIFY(clientAddedSpy.isEmpty()); | 136 | QVERIFY(clientAddedSpy.isEmpty()); | ||
137 | QVERIFY(clientAddedSpy.wait()); | 137 | QVERIFY(clientAddedSpy.wait()); | ||
138 | auto client = clientAddedSpy.first().first().value<ShellClient*>(); | 138 | auto client = clientAddedSpy.first().first().value<XdgShellClient *>(); | ||
139 | QVERIFY(client); | 139 | QVERIFY(client); | ||
140 | 140 | | |||
141 | // let's get the window info | 141 | // let's get the window info | ||
142 | QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->internalId())}; | 142 | QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->internalId())}; | ||
143 | reply.waitForFinished(); | 143 | reply.waitForFinished(); | ||
144 | QVERIFY(reply.isValid()); | 144 | QVERIFY(reply.isValid()); | ||
145 | QVERIFY(!reply.isError()); | 145 | QVERIFY(!reply.isError()); | ||
146 | auto windowData = reply.value(); | 146 | auto windowData = reply.value(); | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | |||||
221 | reply = getWindowInfo(client->internalId()); | 221 | reply = getWindowInfo(client->internalId()); | ||
222 | reply.waitForFinished(); | 222 | reply.waitForFinished(); | ||
223 | QCOMPARE(reply.value().value(QStringLiteral("x")).toInt(), client->x()); | 223 | QCOMPARE(reply.value().value(QStringLiteral("x")).toInt(), client->x()); | ||
224 | QCOMPARE(reply.value().value(QStringLiteral("y")).toInt(), client->y()); | 224 | QCOMPARE(reply.value().value(QStringLiteral("y")).toInt(), client->y()); | ||
225 | // not testing width, height as that would require window geometry change | 225 | // not testing width, height as that would require window geometry change | ||
226 | 226 | | |||
227 | // finally close window | 227 | // finally close window | ||
228 | const auto id = client->internalId(); | 228 | const auto id = client->internalId(); | ||
229 | QSignalSpy windowClosedSpy(client, &ShellClient::windowClosed); | 229 | QSignalSpy windowClosedSpy(client, &XdgShellClient::windowClosed); | ||
230 | QVERIFY(windowClosedSpy.isValid()); | 230 | QVERIFY(windowClosedSpy.isValid()); | ||
231 | shellSurface.reset(); | 231 | shellSurface.reset(); | ||
232 | surface.reset(); | 232 | surface.reset(); | ||
233 | QVERIFY(windowClosedSpy.wait()); | 233 | QVERIFY(windowClosedSpy.wait()); | ||
234 | QCOMPARE(windowClosedSpy.count(), 1); | 234 | QCOMPARE(windowClosedSpy.count(), 1); | ||
235 | 235 | | |||
236 | reply = getWindowInfo(id); | 236 | reply = getWindowInfo(id); | ||
237 | reply.waitForFinished(); | 237 | reply.waitForFinished(); | ||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |