Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/xdgshellclient_test.cpp
- This file was moved from autotests/integration/shell_client_test.cpp.
Show All 19 Lines | |||||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | #include "kwin_wayland_test.h" | 21 | #include "kwin_wayland_test.h" | ||
22 | #include "cursor.h" | 22 | #include "cursor.h" | ||
23 | #include "decorations/decorationbridge.h" | 23 | #include "decorations/decorationbridge.h" | ||
24 | #include "decorations/settings.h" | 24 | #include "decorations/settings.h" | ||
25 | #include "effects.h" | 25 | #include "effects.h" | ||
26 | #include "deleted.h" | 26 | #include "deleted.h" | ||
27 | #include "platform.h" | 27 | #include "platform.h" | ||
28 | #include "shell_client.h" | 28 | #include "xdgshellclient.h" | ||
29 | #include "screens.h" | 29 | #include "screens.h" | ||
30 | #include "wayland_server.h" | 30 | #include "wayland_server.h" | ||
31 | #include "workspace.h" | 31 | #include "workspace.h" | ||
32 | 32 | | |||
33 | #include <KDecoration2/DecoratedClient> | 33 | #include <KDecoration2/DecoratedClient> | ||
34 | #include <KDecoration2/Decoration> | 34 | #include <KDecoration2/Decoration> | ||
35 | #include <KDecoration2/DecorationSettings> | 35 | #include <KDecoration2/DecorationSettings> | ||
36 | 36 | | |||
Show All 17 Lines | |||||
54 | #include <sys/socket.h> | 54 | #include <sys/socket.h> | ||
55 | #include <unistd.h> | 55 | #include <unistd.h> | ||
56 | 56 | | |||
57 | #include <csignal> | 57 | #include <csignal> | ||
58 | 58 | | |||
59 | using namespace KWin; | 59 | using namespace KWin; | ||
60 | using namespace KWayland::Client; | 60 | using namespace KWayland::Client; | ||
61 | 61 | | |||
62 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_shell_client-0"); | 62 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_xdgshellclient-0"); | ||
63 | 63 | | |||
64 | class TestShellClient : public QObject | 64 | class TestXdgShellClient : public QObject | ||
65 | { | 65 | { | ||
66 | Q_OBJECT | 66 | Q_OBJECT | ||
67 | private Q_SLOTS: | 67 | private Q_SLOTS: | ||
68 | void initTestCase(); | 68 | void initTestCase(); | ||
69 | void init(); | 69 | void init(); | ||
70 | void cleanup(); | 70 | void cleanup(); | ||
71 | 71 | | |||
72 | void testMapUnmapMap_data(); | 72 | void testMapUnmapMap_data(); | ||
Show All 38 Lines | |||||
111 | void testXdgDecoration(); | 111 | void testXdgDecoration(); | ||
112 | void testXdgNeverCommitted(); | 112 | void testXdgNeverCommitted(); | ||
113 | void testXdgInitialState(); | 113 | void testXdgInitialState(); | ||
114 | void testXdgInitiallyMaximised(); | 114 | void testXdgInitiallyMaximised(); | ||
115 | void testXdgInitiallyMinimized(); | 115 | void testXdgInitiallyMinimized(); | ||
116 | void testXdgWindowGeometry(); | 116 | void testXdgWindowGeometry(); | ||
117 | }; | 117 | }; | ||
118 | 118 | | |||
119 | void TestShellClient::initTestCase() | 119 | void TestXdgShellClient::initTestCase() | ||
120 | { | 120 | { | ||
121 | qRegisterMetaType<KWin::Deleted*>(); | 121 | qRegisterMetaType<KWin::Deleted*>(); | ||
122 | qRegisterMetaType<KWin::ShellClient*>(); | 122 | qRegisterMetaType<KWin::XdgShellClient *>(); | ||
123 | qRegisterMetaType<KWin::AbstractClient*>(); | 123 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
124 | qRegisterMetaType<KWayland::Client::Output*>(); | 124 | qRegisterMetaType<KWayland::Client::Output*>(); | ||
125 | 125 | | |||
126 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 126 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
127 | QVERIFY(workspaceCreatedSpy.isValid()); | 127 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
128 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 128 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
129 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 129 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
130 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 130 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
131 | 131 | | |||
132 | kwinApp()->start(); | 132 | kwinApp()->start(); | ||
133 | QVERIFY(workspaceCreatedSpy.wait()); | 133 | QVERIFY(workspaceCreatedSpy.wait()); | ||
134 | QCOMPARE(screens()->count(), 2); | 134 | QCOMPARE(screens()->count(), 2); | ||
135 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 135 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
136 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 136 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
137 | waylandServer()->initWorkspace(); | 137 | waylandServer()->initWorkspace(); | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | void TestShellClient::init() | 140 | void TestXdgShellClient::init() | ||
141 | { | 141 | { | ||
142 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | | 142 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | | ||
143 | Test::AdditionalWaylandInterface::XdgDecoration | | 143 | Test::AdditionalWaylandInterface::XdgDecoration | | ||
144 | Test::AdditionalWaylandInterface::AppMenu)); | 144 | Test::AdditionalWaylandInterface::AppMenu)); | ||
145 | 145 | | |||
146 | screens()->setCurrent(0); | 146 | screens()->setCurrent(0); | ||
147 | KWin::Cursor::setPos(QPoint(1280, 512)); | 147 | KWin::Cursor::setPos(QPoint(1280, 512)); | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | void TestShellClient::cleanup() | 150 | void TestXdgShellClient::cleanup() | ||
151 | { | 151 | { | ||
152 | Test::destroyWaylandConnection(); | 152 | Test::destroyWaylandConnection(); | ||
153 | } | 153 | } | ||
154 | 154 | | |||
155 | void TestShellClient::testMapUnmapMap_data() | 155 | void TestXdgShellClient::testMapUnmapMap_data() | ||
156 | { | 156 | { | ||
157 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 157 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
158 | 158 | | |||
159 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 159 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
160 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 160 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
161 | } | 161 | } | ||
162 | 162 | | |||
163 | void TestShellClient::testMapUnmapMap() | 163 | void TestXdgShellClient::testMapUnmapMap() | ||
164 | { | 164 | { | ||
165 | // this test verifies that mapping a previously mapped window works correctly | 165 | // this test verifies that mapping a previously mapped window works correctly | ||
166 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 166 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
167 | QVERIFY(clientAddedSpy.isValid()); | 167 | QVERIFY(clientAddedSpy.isValid()); | ||
168 | QSignalSpy effectsWindowShownSpy(effects, &EffectsHandler::windowShown); | 168 | QSignalSpy effectsWindowShownSpy(effects, &EffectsHandler::windowShown); | ||
169 | QVERIFY(effectsWindowShownSpy.isValid()); | 169 | QVERIFY(effectsWindowShownSpy.isValid()); | ||
170 | QSignalSpy effectsWindowHiddenSpy(effects, &EffectsHandler::windowHidden); | 170 | QSignalSpy effectsWindowHiddenSpy(effects, &EffectsHandler::windowHidden); | ||
171 | QVERIFY(effectsWindowHiddenSpy.isValid()); | 171 | QVERIFY(effectsWindowHiddenSpy.isValid()); | ||
172 | 172 | | |||
173 | QScopedPointer<Surface> surface(Test::createSurface()); | 173 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
174 | QFETCH(Test::XdgShellSurfaceType, type); | 174 | QFETCH(Test::XdgShellSurfaceType, type); | ||
175 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 175 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
176 | 176 | | |||
177 | // now let's render | 177 | // now let's render | ||
178 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | 178 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
179 | 179 | | |||
180 | QVERIFY(clientAddedSpy.isEmpty()); | 180 | QVERIFY(clientAddedSpy.isEmpty()); | ||
181 | QVERIFY(clientAddedSpy.wait()); | 181 | QVERIFY(clientAddedSpy.wait()); | ||
182 | auto client = clientAddedSpy.first().first().value<ShellClient*>(); | 182 | auto client = clientAddedSpy.first().first().value<XdgShellClient *>(); | ||
183 | QVERIFY(client); | 183 | QVERIFY(client); | ||
184 | QVERIFY(client->isShown(true)); | 184 | QVERIFY(client->isShown(true)); | ||
185 | QCOMPARE(client->isHiddenInternal(), false); | 185 | QCOMPARE(client->isHiddenInternal(), false); | ||
186 | QCOMPARE(client->readyForPainting(), true); | 186 | QCOMPARE(client->readyForPainting(), true); | ||
187 | QCOMPARE(client->depth(), 32); | 187 | QCOMPARE(client->depth(), 32); | ||
188 | QVERIFY(client->hasAlpha()); | 188 | QVERIFY(client->hasAlpha()); | ||
189 | QCOMPARE(client->icon().name(), QStringLiteral("wayland")); | 189 | QCOMPARE(client->icon().name(), QStringLiteral("wayland")); | ||
190 | QCOMPARE(workspace()->activeClient(), client); | 190 | QCOMPARE(workspace()->activeClient(), client); | ||
Show All 9 Lines | |||||
200 | QCOMPARE(client->isInternal(), false); | 200 | QCOMPARE(client->isInternal(), false); | ||
201 | QVERIFY(client->effectWindow()); | 201 | QVERIFY(client->effectWindow()); | ||
202 | QVERIFY(!client->effectWindow()->internalWindow()); | 202 | QVERIFY(!client->effectWindow()->internalWindow()); | ||
203 | QCOMPARE(client->internalId().isNull(), false); | 203 | QCOMPARE(client->internalId().isNull(), false); | ||
204 | const auto uuid = client->internalId(); | 204 | const auto uuid = client->internalId(); | ||
205 | QUuid deletedUuid; | 205 | QUuid deletedUuid; | ||
206 | QCOMPARE(deletedUuid.isNull(), true); | 206 | QCOMPARE(deletedUuid.isNull(), true); | ||
207 | 207 | | |||
208 | connect(client, &ShellClient::windowClosed, this, [&deletedUuid] (Toplevel *, Deleted *d) { deletedUuid = d->internalId(); }); | 208 | connect(client, &XdgShellClient::windowClosed, this, [&deletedUuid] (Toplevel *, Deleted *d) { deletedUuid = d->internalId(); }); | ||
209 | 209 | | |||
210 | // now unmap | 210 | // now unmap | ||
211 | QSignalSpy hiddenSpy(client, &ShellClient::windowHidden); | 211 | QSignalSpy hiddenSpy(client, &XdgShellClient::windowHidden); | ||
212 | QVERIFY(hiddenSpy.isValid()); | 212 | QVERIFY(hiddenSpy.isValid()); | ||
213 | QSignalSpy windowClosedSpy(client, &ShellClient::windowClosed); | 213 | QSignalSpy windowClosedSpy(client, &XdgShellClient::windowClosed); | ||
214 | QVERIFY(windowClosedSpy.isValid()); | 214 | QVERIFY(windowClosedSpy.isValid()); | ||
215 | surface->attachBuffer(Buffer::Ptr()); | 215 | surface->attachBuffer(Buffer::Ptr()); | ||
216 | surface->commit(Surface::CommitFlag::None); | 216 | surface->commit(Surface::CommitFlag::None); | ||
217 | QVERIFY(hiddenSpy.wait()); | 217 | QVERIFY(hiddenSpy.wait()); | ||
218 | QCOMPARE(client->readyForPainting(), true); | 218 | QCOMPARE(client->readyForPainting(), true); | ||
219 | QCOMPARE(client->isHiddenInternal(), true); | 219 | QCOMPARE(client->isHiddenInternal(), true); | ||
220 | QVERIFY(windowClosedSpy.isEmpty()); | 220 | QVERIFY(windowClosedSpy.isEmpty()); | ||
221 | QVERIFY(!workspace()->activeClient()); | 221 | QVERIFY(!workspace()->activeClient()); | ||
222 | QCOMPARE(effectsWindowHiddenSpy.count(), 1); | 222 | QCOMPARE(effectsWindowHiddenSpy.count(), 1); | ||
223 | QCOMPARE(effectsWindowHiddenSpy.first().first().value<EffectWindow*>(), client->effectWindow()); | 223 | QCOMPARE(effectsWindowHiddenSpy.first().first().value<EffectWindow*>(), client->effectWindow()); | ||
224 | 224 | | |||
225 | QSignalSpy windowShownSpy(client, &ShellClient::windowShown); | 225 | QSignalSpy windowShownSpy(client, &XdgShellClient::windowShown); | ||
226 | QVERIFY(windowShownSpy.isValid()); | 226 | QVERIFY(windowShownSpy.isValid()); | ||
227 | Test::render(surface.data(), QSize(100, 50), Qt::blue, QImage::Format_RGB32); | 227 | Test::render(surface.data(), QSize(100, 50), Qt::blue, QImage::Format_RGB32); | ||
228 | QCOMPARE(clientAddedSpy.count(), 1); | 228 | QCOMPARE(clientAddedSpy.count(), 1); | ||
229 | QVERIFY(windowShownSpy.wait()); | 229 | QVERIFY(windowShownSpy.wait()); | ||
230 | QCOMPARE(windowShownSpy.count(), 1); | 230 | QCOMPARE(windowShownSpy.count(), 1); | ||
231 | QCOMPARE(clientAddedSpy.count(), 1); | 231 | QCOMPARE(clientAddedSpy.count(), 1); | ||
232 | QCOMPARE(client->readyForPainting(), true); | 232 | QCOMPARE(client->readyForPainting(), true); | ||
233 | QCOMPARE(client->isHiddenInternal(), false); | 233 | QCOMPARE(client->isHiddenInternal(), false); | ||
Show All 19 Lines | |||||
253 | surface.reset(); | 253 | surface.reset(); | ||
254 | QVERIFY(windowClosedSpy.wait()); | 254 | QVERIFY(windowClosedSpy.wait()); | ||
255 | QCOMPARE(windowClosedSpy.count(), 1); | 255 | QCOMPARE(windowClosedSpy.count(), 1); | ||
256 | QCOMPARE(effectsWindowHiddenSpy.count(), 2); | 256 | QCOMPARE(effectsWindowHiddenSpy.count(), 2); | ||
257 | QCOMPARE(deletedUuid.isNull(), false); | 257 | QCOMPARE(deletedUuid.isNull(), false); | ||
258 | QCOMPARE(deletedUuid, uuid); | 258 | QCOMPARE(deletedUuid, uuid); | ||
259 | } | 259 | } | ||
260 | 260 | | |||
261 | void TestShellClient::testDesktopPresenceChanged() | 261 | void TestXdgShellClient::testDesktopPresenceChanged() | ||
262 | { | 262 | { | ||
263 | // this test verifies that the desktop presence changed signals are properly emitted | 263 | // this test verifies that the desktop presence changed signals are properly emitted | ||
264 | QScopedPointer<Surface> surface(Test::createSurface()); | 264 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
265 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 265 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
266 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 266 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
267 | QVERIFY(c); | 267 | QVERIFY(c); | ||
268 | QCOMPARE(c->desktop(), 1); | 268 | QCOMPARE(c->desktop(), 1); | ||
269 | effects->setNumberOfDesktops(4); | 269 | effects->setNumberOfDesktops(4); | ||
270 | QSignalSpy desktopPresenceChangedClientSpy(c, &ShellClient::desktopPresenceChanged); | 270 | QSignalSpy desktopPresenceChangedClientSpy(c, &XdgShellClient::desktopPresenceChanged); | ||
271 | QVERIFY(desktopPresenceChangedClientSpy.isValid()); | 271 | QVERIFY(desktopPresenceChangedClientSpy.isValid()); | ||
272 | QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged); | 272 | QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged); | ||
273 | QVERIFY(desktopPresenceChangedWorkspaceSpy.isValid()); | 273 | QVERIFY(desktopPresenceChangedWorkspaceSpy.isValid()); | ||
274 | QSignalSpy desktopPresenceChangedEffectsSpy(effects, &EffectsHandler::desktopPresenceChanged); | 274 | QSignalSpy desktopPresenceChangedEffectsSpy(effects, &EffectsHandler::desktopPresenceChanged); | ||
275 | QVERIFY(desktopPresenceChangedEffectsSpy.isValid()); | 275 | QVERIFY(desktopPresenceChangedEffectsSpy.isValid()); | ||
276 | 276 | | |||
277 | // let's change the desktop | 277 | // let's change the desktop | ||
278 | workspace()->sendClientToDesktop(c, 2, false); | 278 | workspace()->sendClientToDesktop(c, 2, false); | ||
279 | QCOMPARE(c->desktop(), 2); | 279 | QCOMPARE(c->desktop(), 2); | ||
280 | QCOMPARE(desktopPresenceChangedClientSpy.count(), 1); | 280 | QCOMPARE(desktopPresenceChangedClientSpy.count(), 1); | ||
281 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.count(), 1); | 281 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.count(), 1); | ||
282 | QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1); | 282 | QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1); | ||
283 | 283 | | |||
284 | // verify the arguments | 284 | // verify the arguments | ||
285 | QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value<AbstractClient*>(), c); | 285 | QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value<AbstractClient*>(), c); | ||
286 | QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1); | 286 | QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1); | ||
287 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<AbstractClient*>(), c); | 287 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<AbstractClient*>(), c); | ||
288 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1); | 288 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1); | ||
289 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow*>(), c->effectWindow()); | 289 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow*>(), c->effectWindow()); | ||
290 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1); | 290 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1); | ||
291 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2); | 291 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2); | ||
292 | } | 292 | } | ||
293 | 293 | | |||
294 | void TestShellClient::testTransientPositionAfterRemap() | 294 | void TestXdgShellClient::testTransientPositionAfterRemap() | ||
295 | { | 295 | { | ||
296 | // this test simulates the situation that a transient window gets reused and the parent window | 296 | // this test simulates the situation that a transient window gets reused and the parent window | ||
297 | // moved between the two usages | 297 | // moved between the two usages | ||
298 | QScopedPointer<Surface> surface(Test::createSurface()); | 298 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
299 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 299 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
300 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 300 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
301 | QVERIFY(c); | 301 | QVERIFY(c); | ||
302 | 302 | | |||
303 | // create the Transient window | 303 | // create the Transient window | ||
304 | XdgPositioner positioner(QSize(50, 40), QRect(0, 0, 5, 10)); | 304 | XdgPositioner positioner(QSize(50, 40), QRect(0, 0, 5, 10)); | ||
305 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | 305 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||
306 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | 306 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||
307 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | 307 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | ||
308 | QScopedPointer<XdgShellPopup> transientShellSurface(Test::createXdgShellStablePopup(transientSurface.data(), shellSurface.data(), positioner)); | 308 | QScopedPointer<XdgShellPopup> transientShellSurface(Test::createXdgShellStablePopup(transientSurface.data(), shellSurface.data(), positioner)); | ||
309 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), positioner.initialSize(), Qt::blue); | 309 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), positioner.initialSize(), Qt::blue); | ||
310 | QVERIFY(transient); | 310 | QVERIFY(transient); | ||
311 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | 311 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | ||
312 | 312 | | |||
313 | // unmap the transient | 313 | // unmap the transient | ||
314 | QSignalSpy windowHiddenSpy(transient, &ShellClient::windowHidden); | 314 | QSignalSpy windowHiddenSpy(transient, &XdgShellClient::windowHidden); | ||
315 | QVERIFY(windowHiddenSpy.isValid()); | 315 | QVERIFY(windowHiddenSpy.isValid()); | ||
316 | transientSurface->attachBuffer(Buffer::Ptr()); | 316 | transientSurface->attachBuffer(Buffer::Ptr()); | ||
317 | transientSurface->commit(Surface::CommitFlag::None); | 317 | transientSurface->commit(Surface::CommitFlag::None); | ||
318 | QVERIFY(windowHiddenSpy.wait()); | 318 | QVERIFY(windowHiddenSpy.wait()); | ||
319 | 319 | | |||
320 | // now move the parent surface | 320 | // now move the parent surface | ||
321 | c->setGeometry(c->geometry().translated(5, 10)); | 321 | c->setGeometry(c->geometry().translated(5, 10)); | ||
322 | 322 | | |||
323 | // now map the transient again | 323 | // now map the transient again | ||
324 | QSignalSpy windowShownSpy(transient, &ShellClient::windowShown); | 324 | QSignalSpy windowShownSpy(transient, &XdgShellClient::windowShown); | ||
325 | QVERIFY(windowShownSpy.isValid()); | 325 | QVERIFY(windowShownSpy.isValid()); | ||
326 | Test::render(transientSurface.data(), QSize(50, 40), Qt::blue); | 326 | Test::render(transientSurface.data(), QSize(50, 40), Qt::blue); | ||
327 | QVERIFY(windowShownSpy.wait()); | 327 | QVERIFY(windowShownSpy.wait()); | ||
328 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | 328 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | ||
329 | } | 329 | } | ||
330 | 330 | | |||
331 | void TestShellClient::testWindowOutputs_data() | 331 | void TestXdgShellClient::testWindowOutputs_data() | ||
332 | { | 332 | { | ||
333 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 333 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
334 | 334 | | |||
335 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 335 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
336 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 336 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
337 | } | 337 | } | ||
338 | 338 | | |||
339 | void TestShellClient::testWindowOutputs() | 339 | void TestXdgShellClient::testWindowOutputs() | ||
340 | { | 340 | { | ||
341 | QScopedPointer<Surface> surface(Test::createSurface()); | 341 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
342 | QFETCH(Test::XdgShellSurfaceType, type); | 342 | QFETCH(Test::XdgShellSurfaceType, type); | ||
343 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 343 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
344 | auto size = QSize(200,200); | 344 | auto size = QSize(200,200); | ||
345 | 345 | | |||
346 | QSignalSpy outputEnteredSpy(surface.data(), &Surface::outputEntered); | 346 | QSignalSpy outputEnteredSpy(surface.data(), &Surface::outputEntered); | ||
347 | QSignalSpy outputLeftSpy(surface.data(), &Surface::outputLeft); | 347 | QSignalSpy outputLeftSpy(surface.data(), &Surface::outputLeft); | ||
Show All 21 Lines | |||||
369 | c->setGeometry(QRect(QPoint(1400,100), size)); | 369 | c->setGeometry(QRect(QPoint(1400,100), size)); | ||
370 | QVERIFY(outputLeftSpy.wait()); | 370 | QVERIFY(outputLeftSpy.wait()); | ||
371 | QCOMPARE(outputEnteredSpy.count(), 1); | 371 | QCOMPARE(outputEnteredSpy.count(), 1); | ||
372 | QCOMPARE(outputLeftSpy.count(), 1); | 372 | QCOMPARE(outputLeftSpy.count(), 1); | ||
373 | QCOMPARE(surface->outputs().count(), 1); | 373 | QCOMPARE(surface->outputs().count(), 1); | ||
374 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0)); | 374 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0)); | ||
375 | } | 375 | } | ||
376 | 376 | | |||
377 | void TestShellClient::testMinimizeActiveWindow_data() | 377 | void TestXdgShellClient::testMinimizeActiveWindow_data() | ||
378 | { | 378 | { | ||
379 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 379 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
380 | 380 | | |||
381 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 381 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
382 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 382 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
383 | } | 383 | } | ||
384 | 384 | | |||
385 | void TestShellClient::testMinimizeActiveWindow() | 385 | void TestXdgShellClient::testMinimizeActiveWindow() | ||
386 | { | 386 | { | ||
387 | // this test verifies that when minimizing the active window it gets deactivated | 387 | // this test verifies that when minimizing the active window it gets deactivated | ||
388 | QScopedPointer<Surface> surface(Test::createSurface()); | 388 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
389 | QFETCH(Test::XdgShellSurfaceType, type); | 389 | QFETCH(Test::XdgShellSurfaceType, type); | ||
390 | QScopedPointer<QObject> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 390 | QScopedPointer<QObject> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
391 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 391 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
392 | QVERIFY(c); | 392 | QVERIFY(c); | ||
393 | QVERIFY(c->isActive()); | 393 | QVERIFY(c->isActive()); | ||
Show All 15 Lines | |||||
409 | QVERIFY(!c->isMinimized()); | 409 | QVERIFY(!c->isMinimized()); | ||
410 | QVERIFY(c->isActive()); | 410 | QVERIFY(c->isActive()); | ||
411 | QVERIFY(c->wantsInput()); | 411 | QVERIFY(c->wantsInput()); | ||
412 | QVERIFY(c->wantsTabFocus()); | 412 | QVERIFY(c->wantsTabFocus()); | ||
413 | QVERIFY(c->isShown(true)); | 413 | QVERIFY(c->isShown(true)); | ||
414 | QCOMPARE(workspace()->activeClient(), c); | 414 | QCOMPARE(workspace()->activeClient(), c); | ||
415 | } | 415 | } | ||
416 | 416 | | |||
417 | void TestShellClient::testFullscreen_data() | 417 | void TestXdgShellClient::testFullscreen_data() | ||
418 | { | 418 | { | ||
419 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 419 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
420 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | 420 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | ||
421 | 421 | | |||
422 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | 422 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | ||
423 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | 423 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | ||
424 | 424 | | |||
425 | QTest::newRow("xdgShellV6 - deco") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | 425 | QTest::newRow("xdgShellV6 - deco") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | ||
426 | QTest::newRow("xdgShellWmBase - deco") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | 426 | QTest::newRow("xdgShellWmBase - deco") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | ||
427 | } | 427 | } | ||
428 | 428 | | |||
429 | void TestShellClient::testFullscreen() | 429 | void TestXdgShellClient::testFullscreen() | ||
430 | { | 430 | { | ||
431 | // this test verifies that a window can be properly fullscreened | 431 | // this test verifies that a window can be properly fullscreened | ||
432 | QScopedPointer<Surface> surface(Test::createSurface()); | 432 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
433 | QFETCH(Test::XdgShellSurfaceType, type); | 433 | QFETCH(Test::XdgShellSurfaceType, type); | ||
434 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 434 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
435 | QVERIFY(shellSurface); | 435 | QVERIFY(shellSurface); | ||
436 | 436 | | |||
437 | // create deco | 437 | // create deco | ||
Show All 9 Lines | |||||
447 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 447 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
448 | QVERIFY(c); | 448 | QVERIFY(c); | ||
449 | QVERIFY(c->isActive()); | 449 | QVERIFY(c->isActive()); | ||
450 | QCOMPARE(c->layer(), NormalLayer); | 450 | QCOMPARE(c->layer(), NormalLayer); | ||
451 | QVERIFY(!c->isFullScreen()); | 451 | QVERIFY(!c->isFullScreen()); | ||
452 | QCOMPARE(c->clientSize(), QSize(100, 50)); | 452 | QCOMPARE(c->clientSize(), QSize(100, 50)); | ||
453 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 453 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
454 | QCOMPARE(c->sizeForClientSize(c->clientSize()), c->geometry().size()); | 454 | QCOMPARE(c->sizeForClientSize(c->clientSize()), c->geometry().size()); | ||
455 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | 455 | QSignalSpy fullscreenChangedSpy(c, &XdgShellClient::fullScreenChanged); | ||
456 | QVERIFY(fullscreenChangedSpy.isValid()); | 456 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
457 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | 457 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | ||
458 | QVERIFY(geometryChangedSpy.isValid()); | 458 | QVERIFY(geometryChangedSpy.isValid()); | ||
459 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | 459 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | ||
460 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 460 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
461 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 461 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
462 | QVERIFY(configureRequestedSpy.isValid()); | 462 | QVERIFY(configureRequestedSpy.isValid()); | ||
463 | 463 | | |||
464 | shellSurface->setFullscreen(true); | 464 | shellSurface->setFullscreen(true); | ||
465 | QVERIFY(fullscreenChangedSpy.wait()); | 465 | QVERIFY(fullscreenChangedSpy.wait()); | ||
Show All 21 Lines | |||||
487 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | 487 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | ||
488 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | 488 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | ||
489 | // TODO: should switch to fullscreen once it's updated | 489 | // TODO: should switch to fullscreen once it's updated | ||
490 | QVERIFY(!c->isFullScreen()); | 490 | QVERIFY(!c->isFullScreen()); | ||
491 | QCOMPARE(c->layer(), NormalLayer); | 491 | QCOMPARE(c->layer(), NormalLayer); | ||
492 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 492 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
493 | } | 493 | } | ||
494 | 494 | | |||
495 | void TestShellClient::testFullscreenRestore_data() | 495 | void TestXdgShellClient::testFullscreenRestore_data() | ||
496 | { | 496 | { | ||
497 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 497 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
498 | 498 | | |||
499 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 499 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
500 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 500 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
501 | } | 501 | } | ||
502 | 502 | | |||
503 | void TestShellClient::testFullscreenRestore() | 503 | void TestXdgShellClient::testFullscreenRestore() | ||
504 | { | 504 | { | ||
505 | // this test verifies that windows created fullscreen can be later properly restored | 505 | // this test verifies that windows created fullscreen can be later properly restored | ||
506 | QScopedPointer<Surface> surface(Test::createSurface()); | 506 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
507 | QFETCH(Test::XdgShellSurfaceType, type); | 507 | QFETCH(Test::XdgShellSurfaceType, type); | ||
508 | XdgShellSurface *xdgShellSurface = Test::createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly); | 508 | XdgShellSurface *xdgShellSurface = Test::createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly); | ||
509 | QSignalSpy configureRequestedSpy(xdgShellSurface, &XdgShellSurface::configureRequested); | 509 | QSignalSpy configureRequestedSpy(xdgShellSurface, &XdgShellSurface::configureRequested); | ||
510 | 510 | | |||
511 | // fullscreen the window | 511 | // fullscreen the window | ||
Show All 11 Lines | |||||
523 | xdgShellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | 523 | xdgShellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||
524 | 524 | | |||
525 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | 525 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||
526 | QVERIFY(c); | 526 | QVERIFY(c); | ||
527 | QVERIFY(c->isFullScreen()); | 527 | QVERIFY(c->isFullScreen()); | ||
528 | 528 | | |||
529 | configureRequestedSpy.wait(100); | 529 | configureRequestedSpy.wait(100); | ||
530 | 530 | | |||
531 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | 531 | QSignalSpy fullscreenChangedSpy(c, &XdgShellClient::fullScreenChanged); | ||
532 | QVERIFY(fullscreenChangedSpy.isValid()); | 532 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
533 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | 533 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | ||
534 | QVERIFY(geometryChangedSpy.isValid()); | 534 | QVERIFY(geometryChangedSpy.isValid()); | ||
535 | 535 | | |||
536 | // swap back to normal | 536 | // swap back to normal | ||
537 | configureRequestedSpy.clear(); | 537 | configureRequestedSpy.clear(); | ||
538 | xdgShellSurface->setFullscreen(false); | 538 | xdgShellSurface->setFullscreen(false); | ||
539 | 539 | | |||
540 | QVERIFY(fullscreenChangedSpy.wait()); | 540 | QVERIFY(fullscreenChangedSpy.wait()); | ||
541 | QVERIFY(configureRequestedSpy.wait()); | 541 | QVERIFY(configureRequestedSpy.wait()); | ||
542 | QCOMPARE(configureRequestedSpy.last().first().toSize(), QSize(0, 0)); | 542 | QCOMPARE(configureRequestedSpy.last().first().toSize(), QSize(0, 0)); | ||
543 | QVERIFY(!c->isFullScreen()); | 543 | QVERIFY(!c->isFullScreen()); | ||
544 | 544 | | |||
545 | for (const auto &it: configureRequestedSpy) { | 545 | for (const auto &it: configureRequestedSpy) { | ||
546 | xdgShellSurface->ackConfigure(it[2].toUInt()); | 546 | xdgShellSurface->ackConfigure(it[2].toUInt()); | ||
547 | } | 547 | } | ||
548 | 548 | | |||
549 | Test::render(surface.data(), QSize(100, 50), Qt::red); | 549 | Test::render(surface.data(), QSize(100, 50), Qt::red); | ||
550 | QVERIFY(geometryChangedSpy.wait()); | 550 | QVERIFY(geometryChangedSpy.wait()); | ||
551 | QCOMPARE(geometryChangedSpy.count(), 1); | 551 | QCOMPARE(geometryChangedSpy.count(), 1); | ||
552 | QVERIFY(!c->isFullScreen()); | 552 | QVERIFY(!c->isFullScreen()); | ||
553 | QCOMPARE(c->geometry().size(), QSize(100, 50)); | 553 | QCOMPARE(c->geometry().size(), QSize(100, 50)); | ||
554 | } | 554 | } | ||
555 | 555 | | |||
556 | void TestShellClient::testUserCanSetFullscreen_data() | 556 | void TestXdgShellClient::testUserCanSetFullscreen_data() | ||
557 | { | 557 | { | ||
558 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 558 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
559 | 559 | | |||
560 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 560 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
561 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 561 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
562 | } | 562 | } | ||
563 | 563 | | |||
564 | void TestShellClient::testUserCanSetFullscreen() | 564 | void TestXdgShellClient::testUserCanSetFullscreen() | ||
565 | { | 565 | { | ||
566 | QScopedPointer<Surface> surface(Test::createSurface()); | 566 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
567 | QFETCH(Test::XdgShellSurfaceType, type); | 567 | QFETCH(Test::XdgShellSurfaceType, type); | ||
568 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 568 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
569 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 569 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
570 | QVERIFY(c); | 570 | QVERIFY(c); | ||
571 | QVERIFY(c->isActive()); | 571 | QVERIFY(c->isActive()); | ||
572 | QVERIFY(!c->isFullScreen()); | 572 | QVERIFY(!c->isFullScreen()); | ||
573 | QVERIFY(c->userCanSetFullScreen()); | 573 | QVERIFY(c->userCanSetFullScreen()); | ||
574 | } | 574 | } | ||
575 | 575 | | |||
576 | void TestShellClient::testUserSetFullscreen_data() | 576 | void TestXdgShellClient::testUserSetFullscreen_data() | ||
577 | { | 577 | { | ||
578 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 578 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
579 | 579 | | |||
580 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 580 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
581 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 581 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
582 | } | 582 | } | ||
583 | 583 | | |||
584 | void TestShellClient::testUserSetFullscreen() | 584 | void TestXdgShellClient::testUserSetFullscreen() | ||
585 | { | 585 | { | ||
586 | QScopedPointer<Surface> surface(Test::createSurface()); | 586 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
587 | QFETCH(Test::XdgShellSurfaceType, type); | 587 | QFETCH(Test::XdgShellSurfaceType, type); | ||
588 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | 588 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | ||
589 | type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | 589 | type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||
590 | QVERIFY(!shellSurface.isNull()); | 590 | QVERIFY(!shellSurface.isNull()); | ||
591 | 591 | | |||
592 | // wait for the initial configure event | 592 | // wait for the initial configure event | ||
Show All 37 Lines | |||||
630 | QVERIFY(configureRequestedSpy.wait()); | 630 | QVERIFY(configureRequestedSpy.wait()); | ||
631 | QCOMPARE(configureRequestedSpy.count(), 1); | 631 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
632 | QCOMPARE(configureRequestedSpy.first().at(0).toSize(), QSize(100, 50)); | 632 | QCOMPARE(configureRequestedSpy.first().at(0).toSize(), QSize(100, 50)); | ||
633 | QVERIFY(!configureRequestedSpy.first().at(1).value<KWayland::Client::XdgShellSurface::States>().testFlag(KWayland::Client::XdgShellSurface::State::Fullscreen)); | 633 | QVERIFY(!configureRequestedSpy.first().at(1).value<KWayland::Client::XdgShellSurface::States>().testFlag(KWayland::Client::XdgShellSurface::State::Fullscreen)); | ||
634 | QCOMPARE(fullscreenChangedSpy.count(), 2); | 634 | QCOMPARE(fullscreenChangedSpy.count(), 2); | ||
635 | QVERIFY(!c->isFullScreen()); | 635 | QVERIFY(!c->isFullScreen()); | ||
636 | } | 636 | } | ||
637 | 637 | | |||
638 | void TestShellClient::testMaximizedToFullscreen_data() | 638 | void TestXdgShellClient::testMaximizedToFullscreen_data() | ||
639 | { | 639 | { | ||
640 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 640 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
641 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | 641 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | ||
642 | 642 | | |||
643 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | 643 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | ||
644 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | 644 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | ||
645 | 645 | | |||
646 | QTest::newRow("xdgShellV6 - deco") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | 646 | QTest::newRow("xdgShellV6 - deco") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | ||
647 | QTest::newRow("xdgShellWmBase - deco") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | 647 | QTest::newRow("xdgShellWmBase - deco") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | ||
648 | } | 648 | } | ||
649 | 649 | | |||
650 | void TestShellClient::testMaximizedToFullscreen() | 650 | void TestXdgShellClient::testMaximizedToFullscreen() | ||
651 | { | 651 | { | ||
652 | // this test verifies that a window can be properly fullscreened after maximizing | 652 | // this test verifies that a window can be properly fullscreened after maximizing | ||
653 | QScopedPointer<Surface> surface(Test::createSurface()); | 653 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
654 | QFETCH(Test::XdgShellSurfaceType, type); | 654 | QFETCH(Test::XdgShellSurfaceType, type); | ||
655 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 655 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
656 | QVERIFY(shellSurface); | 656 | QVERIFY(shellSurface); | ||
657 | 657 | | |||
658 | // create deco | 658 | // create deco | ||
659 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 659 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
660 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 660 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
661 | QVERIFY(decoSpy.isValid()); | 661 | QVERIFY(decoSpy.isValid()); | ||
662 | QVERIFY(decoSpy.wait()); | 662 | QVERIFY(decoSpy.wait()); | ||
663 | QFETCH(ServerSideDecoration::Mode, decoMode); | 663 | QFETCH(ServerSideDecoration::Mode, decoMode); | ||
664 | deco->requestMode(decoMode); | 664 | deco->requestMode(decoMode); | ||
665 | QVERIFY(decoSpy.wait()); | 665 | QVERIFY(decoSpy.wait()); | ||
666 | QCOMPARE(deco->mode(), decoMode); | 666 | QCOMPARE(deco->mode(), decoMode); | ||
667 | 667 | | |||
668 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 668 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
669 | QVERIFY(c); | 669 | QVERIFY(c); | ||
670 | QVERIFY(c->isActive()); | 670 | QVERIFY(c->isActive()); | ||
671 | QVERIFY(!c->isFullScreen()); | 671 | QVERIFY(!c->isFullScreen()); | ||
672 | QCOMPARE(c->clientSize(), QSize(100, 50)); | 672 | QCOMPARE(c->clientSize(), QSize(100, 50)); | ||
673 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 673 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
674 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | 674 | QSignalSpy fullscreenChangedSpy(c, &XdgShellClient::fullScreenChanged); | ||
675 | QVERIFY(fullscreenChangedSpy.isValid()); | 675 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
676 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | 676 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | ||
677 | QVERIFY(geometryChangedSpy.isValid()); | 677 | QVERIFY(geometryChangedSpy.isValid()); | ||
678 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | 678 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | ||
679 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 679 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
680 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 680 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
681 | QVERIFY(configureRequestedSpy.isValid()); | 681 | QVERIFY(configureRequestedSpy.isValid()); | ||
682 | shellSurface->setMaximized(true); | 682 | shellSurface->setMaximized(true); | ||
683 | QVERIFY(sizeChangeRequestedSpy.wait()); | 683 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
684 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | 684 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | ||
Show All 38 Lines | 718 | if (decoMode == ServerSideDecoration::Mode::Server) { | |||
723 | } | 723 | } | ||
724 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | 724 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | ||
725 | } | 725 | } | ||
726 | // TODO: should switch to fullscreen once it's updated | 726 | // TODO: should switch to fullscreen once it's updated | ||
727 | QVERIFY(!c->isFullScreen()); | 727 | QVERIFY(!c->isFullScreen()); | ||
728 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 728 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
729 | } | 729 | } | ||
730 | 730 | | |||
731 | void TestShellClient::testWindowOpensLargerThanScreen_data() | 731 | void TestXdgShellClient::testWindowOpensLargerThanScreen_data() | ||
732 | { | 732 | { | ||
733 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 733 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
734 | 734 | | |||
735 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 735 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
736 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 736 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
737 | } | 737 | } | ||
738 | 738 | | |||
739 | void TestShellClient::testWindowOpensLargerThanScreen() | 739 | void TestXdgShellClient::testWindowOpensLargerThanScreen() | ||
740 | { | 740 | { | ||
741 | // this test creates a window which is as large as the screen, but is decorated | 741 | // this test creates a window which is as large as the screen, but is decorated | ||
742 | // the window should get resized to fit into the screen, BUG: 366632 | 742 | // the window should get resized to fit into the screen, BUG: 366632 | ||
743 | QScopedPointer<Surface> surface(Test::createSurface()); | 743 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
744 | QFETCH(Test::XdgShellSurfaceType, type); | 744 | QFETCH(Test::XdgShellSurfaceType, type); | ||
745 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 745 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
746 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | 746 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | ||
747 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 747 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
Show All 11 Lines | |||||
759 | QVERIFY(c); | 759 | QVERIFY(c); | ||
760 | QVERIFY(c->isActive()); | 760 | QVERIFY(c->isActive()); | ||
761 | QCOMPARE(c->clientSize(), screens()->size(0)); | 761 | QCOMPARE(c->clientSize(), screens()->size(0)); | ||
762 | QVERIFY(c->isDecorated()); | 762 | QVERIFY(c->isDecorated()); | ||
763 | QEXPECT_FAIL("", "BUG 366632", Continue); | 763 | QEXPECT_FAIL("", "BUG 366632", Continue); | ||
764 | QVERIFY(sizeChangeRequestedSpy.wait(10)); | 764 | QVERIFY(sizeChangeRequestedSpy.wait(10)); | ||
765 | } | 765 | } | ||
766 | 766 | | |||
767 | void TestShellClient::testHidden_data() | 767 | void TestXdgShellClient::testHidden_data() | ||
768 | { | 768 | { | ||
769 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 769 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
770 | 770 | | |||
771 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 771 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
772 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 772 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
773 | } | 773 | } | ||
774 | 774 | | |||
775 | void TestShellClient::testHidden() | 775 | void TestXdgShellClient::testHidden() | ||
776 | { | 776 | { | ||
777 | // this test verifies that when hiding window it doesn't get shown | 777 | // this test verifies that when hiding window it doesn't get shown | ||
778 | QScopedPointer<Surface> surface(Test::createSurface()); | 778 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
779 | QFETCH(Test::XdgShellSurfaceType, type); | 779 | QFETCH(Test::XdgShellSurfaceType, type); | ||
780 | QScopedPointer<QObject> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 780 | QScopedPointer<QObject> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
781 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 781 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
782 | QVERIFY(c); | 782 | QVERIFY(c); | ||
783 | QVERIFY(c->isActive()); | 783 | QVERIFY(c->isActive()); | ||
Show All 12 Lines | |||||
796 | c->hideClient(false); | 796 | c->hideClient(false); | ||
797 | QVERIFY(c->isShown(true)); | 797 | QVERIFY(c->isShown(true)); | ||
798 | QVERIFY(c->wantsInput()); | 798 | QVERIFY(c->wantsInput()); | ||
799 | QVERIFY(c->wantsTabFocus()); | 799 | QVERIFY(c->wantsTabFocus()); | ||
800 | 800 | | |||
801 | //QCOMPARE(workspace()->activeClient(), c); | 801 | //QCOMPARE(workspace()->activeClient(), c); | ||
802 | } | 802 | } | ||
803 | 803 | | |||
804 | void TestShellClient::testDesktopFileName() | 804 | void TestXdgShellClient::testDesktopFileName() | ||
805 | { | 805 | { | ||
806 | QIcon::setThemeName(QStringLiteral("breeze")); | 806 | QIcon::setThemeName(QStringLiteral("breeze")); | ||
807 | // this test verifies that desktop file name is passed correctly to the window | 807 | // this test verifies that desktop file name is passed correctly to the window | ||
808 | QScopedPointer<Surface> surface(Test::createSurface()); | 808 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
809 | // only xdg-shell as ShellSurface misses the setter | 809 | // only xdg-shell as ShellSurface misses the setter | ||
810 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 810 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
811 | shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); | 811 | shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); | ||
812 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 812 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
813 | QVERIFY(c); | 813 | QVERIFY(c); | ||
814 | QCOMPARE(c->desktopFileName(), QByteArrayLiteral("org.kde.foo")); | 814 | QCOMPARE(c->desktopFileName(), QByteArrayLiteral("org.kde.foo")); | ||
815 | QCOMPARE(c->resourceClass(), QByteArrayLiteral("org.kde.foo")); | 815 | QCOMPARE(c->resourceClass(), QByteArrayLiteral("org.kde.foo")); | ||
816 | QVERIFY(c->resourceName().startsWith("testShellClient")); | 816 | QVERIFY(c->resourceName().startsWith("testXdgShellClient")); | ||
817 | // the desktop file does not exist, so icon should be generic Wayland | 817 | // the desktop file does not exist, so icon should be generic Wayland | ||
818 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | 818 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | ||
819 | 819 | | |||
820 | QSignalSpy desktopFileNameChangedSpy(c, &AbstractClient::desktopFileNameChanged); | 820 | QSignalSpy desktopFileNameChangedSpy(c, &AbstractClient::desktopFileNameChanged); | ||
821 | QVERIFY(desktopFileNameChangedSpy.isValid()); | 821 | QVERIFY(desktopFileNameChangedSpy.isValid()); | ||
822 | QSignalSpy iconChangedSpy(c, &ShellClient::iconChanged); | 822 | QSignalSpy iconChangedSpy(c, &XdgShellClient::iconChanged); | ||
823 | QVERIFY(iconChangedSpy.isValid()); | 823 | QVERIFY(iconChangedSpy.isValid()); | ||
824 | shellSurface->setAppId(QByteArrayLiteral("org.kde.bar")); | 824 | shellSurface->setAppId(QByteArrayLiteral("org.kde.bar")); | ||
825 | QVERIFY(desktopFileNameChangedSpy.wait()); | 825 | QVERIFY(desktopFileNameChangedSpy.wait()); | ||
826 | QCOMPARE(c->desktopFileName(), QByteArrayLiteral("org.kde.bar")); | 826 | QCOMPARE(c->desktopFileName(), QByteArrayLiteral("org.kde.bar")); | ||
827 | QCOMPARE(c->resourceClass(), QByteArrayLiteral("org.kde.bar")); | 827 | QCOMPARE(c->resourceClass(), QByteArrayLiteral("org.kde.bar")); | ||
828 | QVERIFY(c->resourceName().startsWith("testShellClient")); | 828 | QVERIFY(c->resourceName().startsWith("testXdgShellClient")); | ||
829 | // icon should still be wayland | 829 | // icon should still be wayland | ||
830 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | 830 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | ||
831 | QVERIFY(iconChangedSpy.isEmpty()); | 831 | QVERIFY(iconChangedSpy.isEmpty()); | ||
832 | 832 | | |||
833 | const QString dfPath = QFINDTESTDATA("data/example.desktop"); | 833 | const QString dfPath = QFINDTESTDATA("data/example.desktop"); | ||
834 | shellSurface->setAppId(dfPath.toUtf8()); | 834 | shellSurface->setAppId(dfPath.toUtf8()); | ||
835 | QVERIFY(desktopFileNameChangedSpy.wait()); | 835 | QVERIFY(desktopFileNameChangedSpy.wait()); | ||
836 | QCOMPARE(iconChangedSpy.count(), 1); | 836 | QCOMPARE(iconChangedSpy.count(), 1); | ||
837 | QCOMPARE(QString::fromUtf8(c->desktopFileName()), dfPath); | 837 | QCOMPARE(QString::fromUtf8(c->desktopFileName()), dfPath); | ||
838 | QCOMPARE(c->icon().name(), QStringLiteral("kwin")); | 838 | QCOMPARE(c->icon().name(), QStringLiteral("kwin")); | ||
839 | } | 839 | } | ||
840 | 840 | | |||
841 | void TestShellClient::testCaptionSimplified() | 841 | void TestXdgShellClient::testCaptionSimplified() | ||
842 | { | 842 | { | ||
843 | // this test verifies that caption is properly trimmed | 843 | // this test verifies that caption is properly trimmed | ||
844 | // see BUG 323798 comment #12 | 844 | // see BUG 323798 comment #12 | ||
845 | QScopedPointer<Surface> surface(Test::createSurface()); | 845 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
846 | // only done for xdg-shell as ShellSurface misses the setter | 846 | // only done for xdg-shell as ShellSurface misses the setter | ||
847 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 847 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
848 | const QString origTitle = QString::fromUtf8(QByteArrayLiteral("Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies Hübner - Mozilla Firefox")); | 848 | const QString origTitle = QString::fromUtf8(QByteArrayLiteral("Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies Hübner - Mozilla Firefox")); | ||
849 | shellSurface->setTitle(origTitle); | 849 | shellSurface->setTitle(origTitle); | ||
850 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 850 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
851 | QVERIFY(c); | 851 | QVERIFY(c); | ||
852 | QVERIFY(c->caption() != origTitle); | 852 | QVERIFY(c->caption() != origTitle); | ||
853 | QCOMPARE(c->caption(), origTitle.simplified()); | 853 | QCOMPARE(c->caption(), origTitle.simplified()); | ||
854 | } | 854 | } | ||
855 | 855 | | |||
856 | void TestShellClient::testCaptionMultipleWindows() | 856 | void TestXdgShellClient::testCaptionMultipleWindows() | ||
857 | { | 857 | { | ||
858 | QScopedPointer<Surface> surface(Test::createSurface()); | 858 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
859 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 859 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
860 | shellSurface->setTitle(QStringLiteral("foo")); | 860 | shellSurface->setTitle(QStringLiteral("foo")); | ||
861 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 861 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
862 | QVERIFY(c); | 862 | QVERIFY(c); | ||
863 | QCOMPARE(c->caption(), QStringLiteral("foo")); | 863 | QCOMPARE(c->caption(), QStringLiteral("foo")); | ||
864 | QCOMPARE(c->captionNormal(), QStringLiteral("foo")); | 864 | QCOMPARE(c->captionNormal(), QStringLiteral("foo")); | ||
Show All 20 Lines | |||||
885 | QScopedPointer<Surface> surface4(Test::createSurface()); | 885 | QScopedPointer<Surface> surface4(Test::createSurface()); | ||
886 | QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data())); | 886 | QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data())); | ||
887 | shellSurface4->setTitle(QStringLiteral("bar")); | 887 | shellSurface4->setTitle(QStringLiteral("bar")); | ||
888 | auto c4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue); | 888 | auto c4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue); | ||
889 | QVERIFY(c4); | 889 | QVERIFY(c4); | ||
890 | QCOMPARE(c4->caption(), QStringLiteral("bar")); | 890 | QCOMPARE(c4->caption(), QStringLiteral("bar")); | ||
891 | QCOMPARE(c4->captionNormal(), QStringLiteral("bar")); | 891 | QCOMPARE(c4->captionNormal(), QStringLiteral("bar")); | ||
892 | QCOMPARE(c4->captionSuffix(), QString()); | 892 | QCOMPARE(c4->captionSuffix(), QString()); | ||
893 | QSignalSpy captionChangedSpy(c4, &ShellClient::captionChanged); | 893 | QSignalSpy captionChangedSpy(c4, &XdgShellClient::captionChanged); | ||
894 | QVERIFY(captionChangedSpy.isValid()); | 894 | QVERIFY(captionChangedSpy.isValid()); | ||
895 | shellSurface4->setTitle(QStringLiteral("foo")); | 895 | shellSurface4->setTitle(QStringLiteral("foo")); | ||
896 | QVERIFY(captionChangedSpy.wait()); | 896 | QVERIFY(captionChangedSpy.wait()); | ||
897 | QCOMPARE(captionChangedSpy.count(), 1); | 897 | QCOMPARE(captionChangedSpy.count(), 1); | ||
898 | QCOMPARE(c4->caption(), QStringLiteral("foo <4>")); | 898 | QCOMPARE(c4->caption(), QStringLiteral("foo <4>")); | ||
899 | QCOMPARE(c4->captionNormal(), QStringLiteral("foo")); | 899 | QCOMPARE(c4->captionNormal(), QStringLiteral("foo")); | ||
900 | QCOMPARE(c4->captionSuffix(), QStringLiteral(" <4>")); | 900 | QCOMPARE(c4->captionSuffix(), QStringLiteral(" <4>")); | ||
901 | } | 901 | } | ||
902 | 902 | | |||
903 | void TestShellClient::testUnresponsiveWindow_data() | 903 | void TestXdgShellClient::testUnresponsiveWindow_data() | ||
904 | { | 904 | { | ||
905 | QTest::addColumn<QString>("shellInterface");//see env selection in qwaylandintegration.cpp | 905 | QTest::addColumn<QString>("shellInterface");//see env selection in qwaylandintegration.cpp | ||
906 | QTest::addColumn<bool>("socketMode"); | 906 | QTest::addColumn<bool>("socketMode"); | ||
907 | 907 | | |||
908 | QTest::newRow("xdgv6 display") << "xdg-shell-v6" << false; | 908 | QTest::newRow("xdgv6 display") << "xdg-shell-v6" << false; | ||
909 | QTest::newRow("xdgv6 socket") << "xdg-shell-v6" << true; | 909 | QTest::newRow("xdgv6 socket") << "xdg-shell-v6" << true; | ||
910 | 910 | | |||
911 | //TODO add XDG WM Base when Kwin relies on Qt 5.12 | 911 | //TODO add XDG WM Base when Kwin relies on Qt 5.12 | ||
912 | } | 912 | } | ||
913 | 913 | | |||
914 | void TestShellClient::testUnresponsiveWindow() | 914 | void TestXdgShellClient::testUnresponsiveWindow() | ||
915 | { | 915 | { | ||
916 | // this test verifies that killWindow properly terminates a process | 916 | // this test verifies that killWindow properly terminates a process | ||
917 | // for this an external binary is launched | 917 | // for this an external binary is launched | ||
918 | const QString kill = QFINDTESTDATA(QStringLiteral("kill")); | 918 | const QString kill = QFINDTESTDATA(QStringLiteral("kill")); | ||
919 | QVERIFY(!kill.isEmpty()); | 919 | QVERIFY(!kill.isEmpty()); | ||
920 | QSignalSpy shellClientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 920 | QSignalSpy shellClientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
921 | QVERIFY(shellClientAddedSpy.isValid()); | 921 | QVERIFY(shellClientAddedSpy.isValid()); | ||
922 | 922 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 980 | if (!socketMode) { | |||
981 | //process was killed - because we're across process this could happen in either order | 981 | //process was killed - because we're across process this could happen in either order | ||
982 | QVERIFY(killedSpy.count() || killedSpy.wait()); | 982 | QVERIFY(killedSpy.count() || killedSpy.wait()); | ||
983 | } | 983 | } | ||
984 | 984 | | |||
985 | auto elapsed2 = QDateTime::currentMSecsSinceEpoch() - startTime; | 985 | auto elapsed2 = QDateTime::currentMSecsSinceEpoch() - startTime; | ||
986 | QVERIFY(elapsed2 > 1800); //second ping comes in a second later | 986 | QVERIFY(elapsed2 > 1800); //second ping comes in a second later | ||
987 | } | 987 | } | ||
988 | 988 | | |||
989 | void TestShellClient::testX11WindowId_data() | 989 | void TestXdgShellClient::testX11WindowId_data() | ||
990 | { | 990 | { | ||
991 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 991 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
992 | 992 | | |||
993 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 993 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
994 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 994 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
995 | } | 995 | } | ||
996 | 996 | | |||
997 | void TestShellClient::testX11WindowId() | 997 | void TestXdgShellClient::testX11WindowId() | ||
998 | { | 998 | { | ||
999 | QScopedPointer<Surface> surface(Test::createSurface()); | 999 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1000 | QFETCH(Test::XdgShellSurfaceType, type); | 1000 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1001 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 1001 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
1002 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1002 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1003 | QVERIFY(c); | 1003 | QVERIFY(c); | ||
1004 | QVERIFY(c->windowId() != 0); | 1004 | QVERIFY(c->windowId() != 0); | ||
1005 | QCOMPARE(c->window(), 0u); | 1005 | QCOMPARE(c->window(), 0u); | ||
1006 | } | 1006 | } | ||
1007 | 1007 | | |||
1008 | void TestShellClient::testAppMenu() | 1008 | void TestXdgShellClient::testAppMenu() | ||
1009 | { | 1009 | { | ||
1010 | //register a faux appmenu client | 1010 | //register a faux appmenu client | ||
1011 | QVERIFY (QDBusConnection::sessionBus().registerService("org.kde.kappmenu")); | 1011 | QVERIFY (QDBusConnection::sessionBus().registerService("org.kde.kappmenu")); | ||
1012 | 1012 | | |||
1013 | QScopedPointer<Surface> surface(Test::createSurface()); | 1013 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1014 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 1014 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1015 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1015 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1016 | QVERIFY(c); | 1016 | QVERIFY(c); | ||
1017 | QScopedPointer<AppMenu> menu(Test::waylandAppMenuManager()->create(surface.data())); | 1017 | QScopedPointer<AppMenu> menu(Test::waylandAppMenuManager()->create(surface.data())); | ||
1018 | QSignalSpy spy(c, &ShellClient::hasApplicationMenuChanged); | 1018 | QSignalSpy spy(c, &XdgShellClient::hasApplicationMenuChanged); | ||
1019 | menu->setAddress("service.name", "object/path"); | 1019 | menu->setAddress("service.name", "object/path"); | ||
1020 | spy.wait(); | 1020 | spy.wait(); | ||
1021 | QCOMPARE(c->hasApplicationMenu(), true); | 1021 | QCOMPARE(c->hasApplicationMenu(), true); | ||
1022 | QCOMPARE(c->applicationMenuServiceName(), QString("service.name")); | 1022 | QCOMPARE(c->applicationMenuServiceName(), QString("service.name")); | ||
1023 | QCOMPARE(c->applicationMenuObjectPath(), QString("object/path")); | 1023 | QCOMPARE(c->applicationMenuObjectPath(), QString("object/path")); | ||
1024 | 1024 | | |||
1025 | QVERIFY (QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu")); | 1025 | QVERIFY (QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu")); | ||
1026 | } | 1026 | } | ||
1027 | 1027 | | |||
1028 | void TestShellClient::testNoDecorationModeRequested_data() | 1028 | void TestXdgShellClient::testNoDecorationModeRequested_data() | ||
1029 | { | 1029 | { | ||
1030 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 1030 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
1031 | 1031 | | |||
1032 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 1032 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
1033 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 1033 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
1034 | } | 1034 | } | ||
1035 | 1035 | | |||
1036 | void TestShellClient::testNoDecorationModeRequested() | 1036 | void TestXdgShellClient::testNoDecorationModeRequested() | ||
1037 | { | 1037 | { | ||
1038 | // this test verifies that the decoration follows the default mode if no mode is explicitly requested | 1038 | // this test verifies that the decoration follows the default mode if no mode is explicitly requested | ||
1039 | QScopedPointer<Surface> surface(Test::createSurface()); | 1039 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1040 | QFETCH(Test::XdgShellSurfaceType, type); | 1040 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1041 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 1041 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
1042 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 1042 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
1043 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 1043 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
1044 | QVERIFY(decoSpy.isValid()); | 1044 | QVERIFY(decoSpy.isValid()); | ||
1045 | if (deco->mode() != ServerSideDecoration::Mode::Server) { | 1045 | if (deco->mode() != ServerSideDecoration::Mode::Server) { | ||
1046 | QVERIFY(decoSpy.wait()); | 1046 | QVERIFY(decoSpy.wait()); | ||
1047 | } | 1047 | } | ||
1048 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | 1048 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | ||
1049 | 1049 | | |||
1050 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1050 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1051 | QVERIFY(c); | 1051 | QVERIFY(c); | ||
1052 | QCOMPARE(c->noBorder(), false); | 1052 | QCOMPARE(c->noBorder(), false); | ||
1053 | QCOMPARE(c->isDecorated(), true); | 1053 | QCOMPARE(c->isDecorated(), true); | ||
1054 | } | 1054 | } | ||
1055 | 1055 | | |||
1056 | void TestShellClient::testSendClientWithTransientToDesktop_data() | 1056 | void TestXdgShellClient::testSendClientWithTransientToDesktop_data() | ||
1057 | { | 1057 | { | ||
1058 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 1058 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
1059 | 1059 | | |||
1060 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 1060 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
1061 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 1061 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
1062 | } | 1062 | } | ||
1063 | 1063 | | |||
1064 | void TestShellClient::testSendClientWithTransientToDesktop() | 1064 | void TestXdgShellClient::testSendClientWithTransientToDesktop() | ||
1065 | { | 1065 | { | ||
1066 | // this test verifies that when sending a client to a desktop all transients are also send to that desktop | 1066 | // this test verifies that when sending a client to a desktop all transients are also send to that desktop | ||
1067 | 1067 | | |||
1068 | VirtualDesktopManager::self()->setCount(2); | 1068 | VirtualDesktopManager::self()->setCount(2); | ||
1069 | QScopedPointer<Surface> surface{Test::createSurface()}; | 1069 | QScopedPointer<Surface> surface{Test::createSurface()}; | ||
1070 | QFETCH(Test::XdgShellSurfaceType, type); | 1070 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1071 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 1071 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
1072 | 1072 | | |||
Show All 30 Lines | |||||
1103 | QCOMPARE(transient->desktop(), 2); | 1103 | QCOMPARE(transient->desktop(), 2); | ||
1104 | workspace()->slotWindowToDesktop(1); | 1104 | workspace()->slotWindowToDesktop(1); | ||
1105 | 1105 | | |||
1106 | // which should move the transient back to the desktop | 1106 | // which should move the transient back to the desktop | ||
1107 | QCOMPARE(c->desktop(), 1); | 1107 | QCOMPARE(c->desktop(), 1); | ||
1108 | QCOMPARE(transient->desktop(), 1); | 1108 | QCOMPARE(transient->desktop(), 1); | ||
1109 | } | 1109 | } | ||
1110 | 1110 | | |||
1111 | void TestShellClient::testMinimizeWindowWithTransients_data() | 1111 | void TestXdgShellClient::testMinimizeWindowWithTransients_data() | ||
1112 | { | 1112 | { | ||
1113 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 1113 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
1114 | 1114 | | |||
1115 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 1115 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
1116 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 1116 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
1117 | } | 1117 | } | ||
1118 | 1118 | | |||
1119 | void TestShellClient::testMinimizeWindowWithTransients() | 1119 | void TestXdgShellClient::testMinimizeWindowWithTransients() | ||
1120 | { | 1120 | { | ||
1121 | // this test verifies that when minimizing/unminimizing a window all its | 1121 | // this test verifies that when minimizing/unminimizing a window all its | ||
1122 | // transients will be minimized/unminimized as well | 1122 | // transients will be minimized/unminimized as well | ||
1123 | 1123 | | |||
1124 | // create the main window | 1124 | // create the main window | ||
1125 | QScopedPointer<Surface> surface(Test::createSurface()); | 1125 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1126 | QFETCH(Test::XdgShellSurfaceType, type); | 1126 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1127 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 1127 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
Show All 17 Lines | |||||
1145 | QVERIFY(transient->isMinimized()); | 1145 | QVERIFY(transient->isMinimized()); | ||
1146 | 1146 | | |||
1147 | // unminimize the main window, the transient should be unminimized as well | 1147 | // unminimize the main window, the transient should be unminimized as well | ||
1148 | c->unminimize(); | 1148 | c->unminimize(); | ||
1149 | QVERIFY(!c->isMinimized()); | 1149 | QVERIFY(!c->isMinimized()); | ||
1150 | QVERIFY(!transient->isMinimized()); | 1150 | QVERIFY(!transient->isMinimized()); | ||
1151 | } | 1151 | } | ||
1152 | 1152 | | |||
1153 | void TestShellClient::testXdgDecoration_data() | 1153 | void TestXdgShellClient::testXdgDecoration_data() | ||
1154 | { | 1154 | { | ||
1155 | QTest::addColumn<KWayland::Client::XdgDecoration::Mode>("requestedMode"); | 1155 | QTest::addColumn<KWayland::Client::XdgDecoration::Mode>("requestedMode"); | ||
1156 | QTest::addColumn<KWayland::Client::XdgDecoration::Mode>("expectedMode"); | 1156 | QTest::addColumn<KWayland::Client::XdgDecoration::Mode>("expectedMode"); | ||
1157 | 1157 | | |||
1158 | QTest::newRow("client side requested") << XdgDecoration::Mode::ClientSide << XdgDecoration::Mode::ClientSide; | 1158 | QTest::newRow("client side requested") << XdgDecoration::Mode::ClientSide << XdgDecoration::Mode::ClientSide; | ||
1159 | QTest::newRow("server side requested") << XdgDecoration::Mode::ServerSide << XdgDecoration::Mode::ServerSide; | 1159 | QTest::newRow("server side requested") << XdgDecoration::Mode::ServerSide << XdgDecoration::Mode::ServerSide; | ||
1160 | } | 1160 | } | ||
1161 | 1161 | | |||
1162 | void TestShellClient::testXdgDecoration() | 1162 | void TestXdgShellClient::testXdgDecoration() | ||
1163 | { | 1163 | { | ||
1164 | QScopedPointer<Surface> surface(Test::createSurface()); | 1164 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1165 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 1165 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1166 | QScopedPointer<XdgDecoration> deco(Test::xdgDecorationManager()->getToplevelDecoration(shellSurface.data())); | 1166 | QScopedPointer<XdgDecoration> deco(Test::xdgDecorationManager()->getToplevelDecoration(shellSurface.data())); | ||
1167 | 1167 | | |||
1168 | QSignalSpy decorationConfiguredSpy(deco.data(), &XdgDecoration::modeChanged); | 1168 | QSignalSpy decorationConfiguredSpy(deco.data(), &XdgDecoration::modeChanged); | ||
1169 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 1169 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
1170 | 1170 | | |||
Show All 13 Lines | |||||
1184 | 1184 | | |||
1185 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | 1185 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||
1186 | 1186 | | |||
1187 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1187 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1188 | QCOMPARE(c->userCanSetNoBorder(), expectedMode == XdgDecoration::Mode::ServerSide); | 1188 | QCOMPARE(c->userCanSetNoBorder(), expectedMode == XdgDecoration::Mode::ServerSide); | ||
1189 | QCOMPARE(c->isDecorated(), expectedMode == XdgDecoration::Mode::ServerSide); | 1189 | QCOMPARE(c->isDecorated(), expectedMode == XdgDecoration::Mode::ServerSide); | ||
1190 | } | 1190 | } | ||
1191 | 1191 | | |||
1192 | void TestShellClient::testXdgNeverCommitted() | 1192 | void TestXdgShellClient::testXdgNeverCommitted() | ||
1193 | { | 1193 | { | ||
1194 | //check we don't crash if we create a shell object but delete the ShellClient before committing it | 1194 | //check we don't crash if we create a shell object but delete the XdgShellClient before committing it | ||
1195 | QScopedPointer<Surface> surface(Test::createSurface()); | 1195 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1196 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | 1196 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||
1197 | } | 1197 | } | ||
1198 | 1198 | | |||
1199 | void TestShellClient::testXdgInitialState() | 1199 | void TestXdgShellClient::testXdgInitialState() | ||
1200 | { | 1200 | { | ||
1201 | QScopedPointer<Surface> surface(Test::createSurface()); | 1201 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1202 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | 1202 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||
1203 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 1203 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
1204 | surface->commit(Surface::CommitFlag::None); | 1204 | surface->commit(Surface::CommitFlag::None); | ||
1205 | 1205 | | |||
1206 | configureRequestedSpy.wait(); | 1206 | configureRequestedSpy.wait(); | ||
1207 | 1207 | | |||
1208 | QCOMPARE(configureRequestedSpy.count(), 1); | 1208 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
1209 | 1209 | | |||
1210 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | 1210 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||
1211 | 1211 | | |||
1212 | QCOMPARE(size, QSize(0, 0)); //client should chose it's preferred size | 1212 | QCOMPARE(size, QSize(0, 0)); //client should chose it's preferred size | ||
1213 | 1213 | | |||
1214 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | 1214 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||
1215 | 1215 | | |||
1216 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | 1216 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | ||
1217 | QCOMPARE(c->size(), QSize(200, 100)); | 1217 | QCOMPARE(c->size(), QSize(200, 100)); | ||
1218 | } | 1218 | } | ||
1219 | 1219 | | |||
1220 | void TestShellClient::testXdgInitiallyMaximised() | 1220 | void TestXdgShellClient::testXdgInitiallyMaximised() | ||
1221 | { | 1221 | { | ||
1222 | QScopedPointer<Surface> surface(Test::createSurface()); | 1222 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1223 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | 1223 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||
1224 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 1224 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
1225 | 1225 | | |||
1226 | shellSurface->setMaximized(true); | 1226 | shellSurface->setMaximized(true); | ||
1227 | surface->commit(Surface::CommitFlag::None); | 1227 | surface->commit(Surface::CommitFlag::None); | ||
1228 | 1228 | | |||
Show All 9 Lines | |||||
1238 | 1238 | | |||
1239 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | 1239 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||
1240 | 1240 | | |||
1241 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | 1241 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||
1242 | QCOMPARE(c->maximizeMode(), MaximizeFull); | 1242 | QCOMPARE(c->maximizeMode(), MaximizeFull); | ||
1243 | QCOMPARE(c->size(), QSize(1280, 1024)); | 1243 | QCOMPARE(c->size(), QSize(1280, 1024)); | ||
1244 | } | 1244 | } | ||
1245 | 1245 | | |||
1246 | void TestShellClient::testXdgInitiallyMinimized() | 1246 | void TestXdgShellClient::testXdgInitiallyMinimized() | ||
1247 | { | 1247 | { | ||
1248 | QScopedPointer<Surface> surface(Test::createSurface()); | 1248 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1249 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | 1249 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||
1250 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 1250 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
1251 | 1251 | | |||
1252 | shellSurface->requestMinimize(); | 1252 | shellSurface->requestMinimize(); | ||
1253 | surface->commit(Surface::CommitFlag::None); | 1253 | surface->commit(Surface::CommitFlag::None); | ||
1254 | 1254 | | |||
Show All 10 Lines | |||||
1265 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | 1265 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||
1266 | 1266 | | |||
1267 | QEXPECT_FAIL("", "Client created in a minimised state is not exposed to kwin bug 404838", Abort); | 1267 | QEXPECT_FAIL("", "Client created in a minimised state is not exposed to kwin bug 404838", Abort); | ||
1268 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue, QImage::Format_ARGB32, 10); | 1268 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue, QImage::Format_ARGB32, 10); | ||
1269 | QVERIFY(c); | 1269 | QVERIFY(c); | ||
1270 | QVERIFY(c->isMinimized()); | 1270 | QVERIFY(c->isMinimized()); | ||
1271 | } | 1271 | } | ||
1272 | 1272 | | |||
1273 | void TestShellClient::testXdgWindowGeometry() | 1273 | void TestXdgShellClient::testXdgWindowGeometry() | ||
1274 | { | 1274 | { | ||
1275 | QScopedPointer<Surface> surface(Test::createSurface()); | 1275 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1276 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | 1276 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||
1277 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 1277 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
1278 | surface->commit(Surface::CommitFlag::None); | 1278 | surface->commit(Surface::CommitFlag::None); | ||
1279 | 1279 | | |||
1280 | configureRequestedSpy.wait(); | 1280 | configureRequestedSpy.wait(); | ||
1281 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | 1281 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||
1282 | 1282 | | |||
1283 | // Create a 160x140 window in with a margin of 10(left), 20(top), 30(right), 40(bottom). Giving a total buffer size 200, 100 | 1283 | // Create a 160x140 window in with a margin of 10(left), 20(top), 30(right), 40(bottom). Giving a total buffer size 200, 100 | ||
1284 | shellSurface->setWindowGeometry(QRect(10, 20, 160, 40)); | 1284 | shellSurface->setWindowGeometry(QRect(10, 20, 160, 40)); | ||
1285 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | 1285 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | ||
1286 | configureRequestedSpy.wait(); //window activated after being shown | 1286 | configureRequestedSpy.wait(); //window activated after being shown | ||
1287 | 1287 | | |||
1288 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | 1288 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | ||
1289 | // resize to 300,200 in kwin terms | 1289 | // resize to 300,200 in kwin terms | ||
1290 | c->setGeometry(QRect(100, 100, 300, 200)); | 1290 | c->setGeometry(QRect(100, 100, 300, 200)); | ||
1291 | QVERIFY(configureRequestedSpy.wait()); | 1291 | QVERIFY(configureRequestedSpy.wait()); | ||
1292 | // requested geometry should not include the margins we had above | 1292 | // requested geometry should not include the margins we had above | ||
1293 | const QSize requestedSize = configureRequestedSpy.last()[0].value<QSize>(); | 1293 | const QSize requestedSize = configureRequestedSpy.last()[0].value<QSize>(); | ||
1294 | QCOMPARE(requestedSize, QSize(300, 200) - QSize(10 + 30, 20 + 40)); | 1294 | QCOMPARE(requestedSize, QSize(300, 200) - QSize(10 + 30, 20 + 40)); | ||
1295 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toUInt()); | 1295 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toUInt()); | ||
1296 | Test::render(surface.data(), requestedSize + QSize(10 + 30, 20 + 40), Qt::blue); | 1296 | Test::render(surface.data(), requestedSize + QSize(10 + 30, 20 + 40), Qt::blue); | ||
1297 | geometryChangedSpy.wait(); | 1297 | geometryChangedSpy.wait(); | ||
1298 | 1298 | | |||
1299 | // kwin's concept of geometry should remain the same | 1299 | // kwin's concept of geometry should remain the same | ||
1300 | QCOMPARE(c->geometry(), QRect(100, 100, 300, 200)); | 1300 | QCOMPARE(c->geometry(), QRect(100, 100, 300, 200)); | ||
1301 | 1301 | | |||
1302 | c->setFullScreen(true); | 1302 | c->setFullScreen(true); | ||
1303 | configureRequestedSpy.wait(); | 1303 | configureRequestedSpy.wait(); | ||
1304 | // when full screen, the window geometry (i.e without margins) should fill the screen | 1304 | // when full screen, the window geometry (i.e without margins) should fill the screen | ||
1305 | const QSize requestedFullScreenSize = configureRequestedSpy.last()[0].value<QSize>(); | 1305 | const QSize requestedFullScreenSize = configureRequestedSpy.last()[0].value<QSize>(); | ||
1306 | QCOMPARE(requestedFullScreenSize, QSize(1280, 1024)); | 1306 | QCOMPARE(requestedFullScreenSize, QSize(1280, 1024)); | ||
1307 | } | 1307 | } | ||
1308 | 1308 | | |||
1309 | WAYLANDTEST_MAIN(TestShellClient) | 1309 | WAYLANDTEST_MAIN(TestXdgShellClient) | ||
1310 | #include "shell_client_test.moc" | 1310 | #include "xdgshellclient_test.moc" |