Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_test.cpp
Show All 30 Lines | |||||
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 | | |||
37 | #include <KWayland/Client/connection_thread.h> | 37 | #include <KWayland/Client/connection_thread.h> | ||
38 | #include <KWayland/Client/compositor.h> | 38 | #include <KWayland/Client/compositor.h> | ||
39 | #include <KWayland/Client/shell.h> | | |||
40 | #include <KWayland/Client/output.h> | 39 | #include <KWayland/Client/output.h> | ||
41 | #include <KWayland/Client/server_decoration.h> | 40 | #include <KWayland/Client/server_decoration.h> | ||
42 | #include <KWayland/Client/surface.h> | 41 | #include <KWayland/Client/surface.h> | ||
43 | #include <KWayland/Client/xdgshell.h> | 42 | #include <KWayland/Client/xdgshell.h> | ||
44 | #include <KWayland/Client/xdgdecoration.h> | 43 | #include <KWayland/Client/xdgdecoration.h> | ||
45 | #include <KWayland/Client/appmenu.h> | 44 | #include <KWayland/Client/appmenu.h> | ||
46 | 45 | | |||
47 | #include <KWayland/Server/clientconnection.h> | 46 | #include <KWayland/Server/clientconnection.h> | ||
48 | #include <KWayland/Server/display.h> | 47 | #include <KWayland/Server/display.h> | ||
49 | #include <KWayland/Server/shell_interface.h> | | |||
50 | #include <KWayland/Server/xdgdecoration_interface.h> | 48 | #include <KWayland/Server/xdgdecoration_interface.h> | ||
51 | 49 | | |||
52 | #include <QDBusConnection> | 50 | #include <QDBusConnection> | ||
53 | 51 | | |||
54 | // system | 52 | // system | ||
55 | #include <sys/types.h> | 53 | #include <sys/types.h> | ||
56 | #include <sys/socket.h> | 54 | #include <sys/socket.h> | ||
57 | #include <unistd.h> | 55 | #include <unistd.h> | ||
Show All 16 Lines | 67 | private Q_SLOTS: | |||
74 | void testMapUnmapMap_data(); | 72 | void testMapUnmapMap_data(); | ||
75 | void testMapUnmapMap(); | 73 | void testMapUnmapMap(); | ||
76 | void testDesktopPresenceChanged(); | 74 | void testDesktopPresenceChanged(); | ||
77 | void testTransientPositionAfterRemap(); | 75 | void testTransientPositionAfterRemap(); | ||
78 | void testWindowOutputs_data(); | 76 | void testWindowOutputs_data(); | ||
79 | void testWindowOutputs(); | 77 | void testWindowOutputs(); | ||
80 | void testMinimizeActiveWindow_data(); | 78 | void testMinimizeActiveWindow_data(); | ||
81 | void testMinimizeActiveWindow(); | 79 | void testMinimizeActiveWindow(); | ||
82 | void testFullscreenWlShell_data(); | | |||
83 | void testFullscreenWlShell(); | | |||
84 | void testFullscreen_data(); | 80 | void testFullscreen_data(); | ||
85 | void testFullscreen(); | 81 | void testFullscreen(); | ||
86 | 82 | | |||
87 | void testFullscreenRestore_data(); | 83 | void testFullscreenRestore_data(); | ||
88 | void testFullscreenRestore(); | 84 | void testFullscreenRestore(); | ||
89 | void testUserCanSetFullscreen_data(); | 85 | void testUserCanSetFullscreen_data(); | ||
90 | void testUserCanSetFullscreen(); | 86 | void testUserCanSetFullscreen(); | ||
91 | void testUserSetFullscreenWlShell(); | 87 | void testUserSetFullscreen_data(); | ||
92 | void testUserSetFullscreenXdgShell_data(); | 88 | void testUserSetFullscreen(); | ||
93 | void testUserSetFullscreenXdgShell(); | 89 | | ||
94 | 90 | void testMaximizedToFullscreen_data(); | |||
95 | void testMaximizedToFullscreenWlShell_data(); | 91 | void testMaximizedToFullscreen(); | ||
96 | void testMaximizedToFullscreenWlShell(); | | |||
97 | void testMaximizedToFullscreenXdgShell_data(); | | |||
98 | void testMaximizedToFullscreenXdgShell(); | | |||
99 | void testWindowOpensLargerThanScreen_data(); | 92 | void testWindowOpensLargerThanScreen_data(); | ||
100 | void testWindowOpensLargerThanScreen(); | 93 | void testWindowOpensLargerThanScreen(); | ||
101 | void testHidden_data(); | 94 | void testHidden_data(); | ||
102 | void testHidden(); | 95 | void testHidden(); | ||
103 | void testDesktopFileName(); | 96 | void testDesktopFileName(); | ||
104 | void testCaptionSimplified(); | 97 | void testCaptionSimplified(); | ||
105 | void testCaptionMultipleWindows(); | 98 | void testCaptionMultipleWindows(); | ||
106 | void testUnresponsiveWindow_data(); | 99 | void testUnresponsiveWindow_data(); | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
156 | 149 | | |||
157 | void TestShellClient::cleanup() | 150 | void TestShellClient::cleanup() | ||
158 | { | 151 | { | ||
159 | Test::destroyWaylandConnection(); | 152 | Test::destroyWaylandConnection(); | ||
160 | } | 153 | } | ||
161 | 154 | | |||
162 | void TestShellClient::testMapUnmapMap_data() | 155 | void TestShellClient::testMapUnmapMap_data() | ||
163 | { | 156 | { | ||
164 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 157 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
165 | 158 | | |||
166 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 159 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
167 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 160 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
168 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 161 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
169 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
170 | } | 162 | } | ||
171 | 163 | | |||
172 | void TestShellClient::testMapUnmapMap() | 164 | void TestShellClient::testMapUnmapMap() | ||
173 | { | 165 | { | ||
174 | // this test verifies that mapping a previously mapped window works correctly | 166 | // this test verifies that mapping a previously mapped window works correctly | ||
175 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 167 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
176 | QVERIFY(clientAddedSpy.isValid()); | 168 | QVERIFY(clientAddedSpy.isValid()); | ||
177 | QSignalSpy effectsWindowShownSpy(effects, &EffectsHandler::windowShown); | 169 | QSignalSpy effectsWindowShownSpy(effects, &EffectsHandler::windowShown); | ||
178 | QVERIFY(effectsWindowShownSpy.isValid()); | 170 | QVERIFY(effectsWindowShownSpy.isValid()); | ||
179 | QSignalSpy effectsWindowHiddenSpy(effects, &EffectsHandler::windowHidden); | 171 | QSignalSpy effectsWindowHiddenSpy(effects, &EffectsHandler::windowHidden); | ||
180 | QVERIFY(effectsWindowHiddenSpy.isValid()); | 172 | QVERIFY(effectsWindowHiddenSpy.isValid()); | ||
181 | 173 | | |||
182 | QScopedPointer<Surface> surface(Test::createSurface()); | 174 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
183 | QFETCH(Test::ShellSurfaceType, type); | 175 | QFETCH(Test::XdgShellSurfaceType, type); | ||
184 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 176 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
185 | 177 | | |||
186 | // now let's render | 178 | // now let's render | ||
187 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | 179 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
188 | 180 | | |||
189 | QVERIFY(clientAddedSpy.isEmpty()); | 181 | QVERIFY(clientAddedSpy.isEmpty()); | ||
190 | QVERIFY(clientAddedSpy.wait()); | 182 | QVERIFY(clientAddedSpy.wait()); | ||
191 | auto client = clientAddedSpy.first().first().value<ShellClient*>(); | 183 | auto client = clientAddedSpy.first().first().value<ShellClient*>(); | ||
192 | QVERIFY(client); | 184 | QVERIFY(client); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
266 | QCOMPARE(deletedUuid.isNull(), false); | 258 | QCOMPARE(deletedUuid.isNull(), false); | ||
267 | QCOMPARE(deletedUuid, uuid); | 259 | QCOMPARE(deletedUuid, uuid); | ||
268 | } | 260 | } | ||
269 | 261 | | |||
270 | void TestShellClient::testDesktopPresenceChanged() | 262 | void TestShellClient::testDesktopPresenceChanged() | ||
271 | { | 263 | { | ||
272 | // this test verifies that the desktop presence changed signals are properly emitted | 264 | // this test verifies that the desktop presence changed signals are properly emitted | ||
273 | QScopedPointer<Surface> surface(Test::createSurface()); | 265 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
274 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 266 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
275 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 267 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
276 | QVERIFY(c); | 268 | QVERIFY(c); | ||
277 | QCOMPARE(c->desktop(), 1); | 269 | QCOMPARE(c->desktop(), 1); | ||
278 | effects->setNumberOfDesktops(4); | 270 | effects->setNumberOfDesktops(4); | ||
279 | QSignalSpy desktopPresenceChangedClientSpy(c, &ShellClient::desktopPresenceChanged); | 271 | QSignalSpy desktopPresenceChangedClientSpy(c, &ShellClient::desktopPresenceChanged); | ||
280 | QVERIFY(desktopPresenceChangedClientSpy.isValid()); | 272 | QVERIFY(desktopPresenceChangedClientSpy.isValid()); | ||
281 | QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged); | 273 | QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged); | ||
282 | QVERIFY(desktopPresenceChangedWorkspaceSpy.isValid()); | 274 | QVERIFY(desktopPresenceChangedWorkspaceSpy.isValid()); | ||
Show All 17 Lines | |||||
300 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2); | 292 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2); | ||
301 | } | 293 | } | ||
302 | 294 | | |||
303 | void TestShellClient::testTransientPositionAfterRemap() | 295 | void TestShellClient::testTransientPositionAfterRemap() | ||
304 | { | 296 | { | ||
305 | // this test simulates the situation that a transient window gets reused and the parent window | 297 | // this test simulates the situation that a transient window gets reused and the parent window | ||
306 | // moved between the two usages | 298 | // moved between the two usages | ||
307 | QScopedPointer<Surface> surface(Test::createSurface()); | 299 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
308 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 300 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
309 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 301 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
310 | QVERIFY(c); | 302 | QVERIFY(c); | ||
311 | 303 | | |||
312 | // create the Transient window | 304 | // create the Transient window | ||
305 | XdgPositioner positioner(QSize(50, 40), QRect(0, 0, 5, 10)); | ||||
306 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
307 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
313 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | 308 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | ||
314 | QScopedPointer<ShellSurface> transientShellSurface(Test::createShellSurface(transientSurface.data())); | 309 | QScopedPointer<XdgShellPopup> transientShellSurface(Test::createXdgShellStablePopup(transientSurface.data(), shellSurface.data(), positioner)); | ||
315 | transientShellSurface->setTransient(surface.data(), QPoint(5, 10)); | 310 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), positioner.initialSize(), Qt::blue); | ||
316 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), QSize(50, 40), Qt::blue); | | |||
317 | QVERIFY(transient); | 311 | QVERIFY(transient); | ||
318 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | 312 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | ||
319 | 313 | | |||
320 | // unmap the transient | 314 | // unmap the transient | ||
321 | QSignalSpy windowHiddenSpy(transient, &ShellClient::windowHidden); | 315 | QSignalSpy windowHiddenSpy(transient, &ShellClient::windowHidden); | ||
322 | QVERIFY(windowHiddenSpy.isValid()); | 316 | QVERIFY(windowHiddenSpy.isValid()); | ||
323 | transientSurface->attachBuffer(Buffer::Ptr()); | 317 | transientSurface->attachBuffer(Buffer::Ptr()); | ||
324 | transientSurface->commit(Surface::CommitFlag::None); | 318 | transientSurface->commit(Surface::CommitFlag::None); | ||
325 | QVERIFY(windowHiddenSpy.wait()); | 319 | QVERIFY(windowHiddenSpy.wait()); | ||
326 | 320 | | |||
327 | // now move the parent surface | 321 | // now move the parent surface | ||
328 | c->setGeometry(c->geometry().translated(5, 10)); | 322 | c->setGeometry(c->geometry().translated(5, 10)); | ||
329 | 323 | | |||
330 | // now map the transient again | 324 | // now map the transient again | ||
331 | QSignalSpy windowShownSpy(transient, &ShellClient::windowShown); | 325 | QSignalSpy windowShownSpy(transient, &ShellClient::windowShown); | ||
332 | QVERIFY(windowShownSpy.isValid()); | 326 | QVERIFY(windowShownSpy.isValid()); | ||
333 | Test::render(transientSurface.data(), QSize(50, 40), Qt::blue); | 327 | Test::render(transientSurface.data(), QSize(50, 40), Qt::blue); | ||
334 | QVERIFY(windowShownSpy.wait()); | 328 | QVERIFY(windowShownSpy.wait()); | ||
335 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | 329 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | ||
336 | } | 330 | } | ||
337 | 331 | | |||
338 | void TestShellClient::testWindowOutputs_data() | 332 | void TestShellClient::testWindowOutputs_data() | ||
339 | { | 333 | { | ||
340 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 334 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
341 | 335 | | |||
342 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 336 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
343 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 337 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
344 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 338 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
345 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
346 | } | 339 | } | ||
347 | 340 | | |||
348 | void TestShellClient::testWindowOutputs() | 341 | void TestShellClient::testWindowOutputs() | ||
349 | { | 342 | { | ||
350 | QScopedPointer<Surface> surface(Test::createSurface()); | 343 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
351 | QFETCH(Test::ShellSurfaceType, type); | 344 | QFETCH(Test::XdgShellSurfaceType, type); | ||
352 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 345 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
353 | auto size = QSize(200,200); | 346 | auto size = QSize(200,200); | ||
354 | 347 | | |||
355 | QSignalSpy outputEnteredSpy(surface.data(), &Surface::outputEntered); | 348 | QSignalSpy outputEnteredSpy(surface.data(), &Surface::outputEntered); | ||
356 | QSignalSpy outputLeftSpy(surface.data(), &Surface::outputLeft); | 349 | QSignalSpy outputLeftSpy(surface.data(), &Surface::outputLeft); | ||
357 | 350 | | |||
358 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | 351 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||
359 | //move to be in the first screen | 352 | //move to be in the first screen | ||
360 | c->setGeometry(QRect(QPoint(100,100), size)); | 353 | c->setGeometry(QRect(QPoint(100,100), size)); | ||
Show All 19 Lines | |||||
380 | QCOMPARE(outputEnteredSpy.count(), 1); | 373 | QCOMPARE(outputEnteredSpy.count(), 1); | ||
381 | QCOMPARE(outputLeftSpy.count(), 1); | 374 | QCOMPARE(outputLeftSpy.count(), 1); | ||
382 | QCOMPARE(surface->outputs().count(), 1); | 375 | QCOMPARE(surface->outputs().count(), 1); | ||
383 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0)); | 376 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0)); | ||
384 | } | 377 | } | ||
385 | 378 | | |||
386 | void TestShellClient::testMinimizeActiveWindow_data() | 379 | void TestShellClient::testMinimizeActiveWindow_data() | ||
387 | { | 380 | { | ||
388 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 381 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
389 | 382 | | |||
390 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 383 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
391 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 384 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
392 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 385 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
393 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
394 | } | 386 | } | ||
395 | 387 | | |||
396 | void TestShellClient::testMinimizeActiveWindow() | 388 | void TestShellClient::testMinimizeActiveWindow() | ||
397 | { | 389 | { | ||
398 | // this test verifies that when minimizing the active window it gets deactivated | 390 | // this test verifies that when minimizing the active window it gets deactivated | ||
399 | QScopedPointer<Surface> surface(Test::createSurface()); | 391 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
400 | QFETCH(Test::ShellSurfaceType, type); | 392 | QFETCH(Test::XdgShellSurfaceType, type); | ||
401 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 393 | QScopedPointer<QObject> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
402 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 394 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
403 | QVERIFY(c); | 395 | QVERIFY(c); | ||
404 | QVERIFY(c->isActive()); | 396 | QVERIFY(c->isActive()); | ||
405 | QCOMPARE(workspace()->activeClient(), c); | 397 | QCOMPARE(workspace()->activeClient(), c); | ||
406 | QVERIFY(c->wantsInput()); | 398 | QVERIFY(c->wantsInput()); | ||
407 | QVERIFY(c->wantsTabFocus()); | 399 | QVERIFY(c->wantsTabFocus()); | ||
408 | QVERIFY(c->isShown(true)); | 400 | QVERIFY(c->isShown(true)); | ||
409 | 401 | | |||
Show All 10 Lines | |||||
420 | QVERIFY(!c->isMinimized()); | 412 | QVERIFY(!c->isMinimized()); | ||
421 | QVERIFY(c->isActive()); | 413 | QVERIFY(c->isActive()); | ||
422 | QVERIFY(c->wantsInput()); | 414 | QVERIFY(c->wantsInput()); | ||
423 | QVERIFY(c->wantsTabFocus()); | 415 | QVERIFY(c->wantsTabFocus()); | ||
424 | QVERIFY(c->isShown(true)); | 416 | QVERIFY(c->isShown(true)); | ||
425 | QCOMPARE(workspace()->activeClient(), c); | 417 | QCOMPARE(workspace()->activeClient(), c); | ||
426 | } | 418 | } | ||
427 | 419 | | |||
428 | void TestShellClient::testFullscreenWlShell_data() | | |||
429 | { | | |||
430 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | | |||
431 | | ||||
432 | QTest::newRow("wlShell") << ServerSideDecoration::Mode::Client; | | |||
433 | QTest::newRow("wlShell - deco") << ServerSideDecoration::Mode::Server; | | |||
434 | } | | |||
435 | | ||||
436 | void TestShellClient::testFullscreenWlShell() | | |||
437 | { | | |||
438 | // this test verifies that a window can be properly fullscreened | | |||
439 | QScopedPointer<Surface> surface(Test::createSurface()); | | |||
440 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | | |||
441 | QVERIFY(shellSurface); | | |||
442 | | ||||
443 | // create deco | | |||
444 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | | |||
445 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | | |||
446 | QVERIFY(decoSpy.isValid()); | | |||
447 | QVERIFY(decoSpy.wait()); | | |||
448 | QFETCH(ServerSideDecoration::Mode, decoMode); | | |||
449 | deco->requestMode(decoMode); | | |||
450 | QVERIFY(decoSpy.wait()); | | |||
451 | QCOMPARE(deco->mode(), decoMode); | | |||
452 | | ||||
453 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | | |||
454 | QVERIFY(c); | | |||
455 | QVERIFY(c->isActive()); | | |||
456 | QCOMPARE(c->layer(), NormalLayer); | | |||
457 | QVERIFY(!c->isFullScreen()); | | |||
458 | QCOMPARE(c->clientSize(), QSize(100, 50)); | | |||
459 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | | |||
460 | QCOMPARE(c->sizeForClientSize(c->clientSize()), c->geometry().size()); | | |||
461 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | | |||
462 | QVERIFY(fullscreenChangedSpy.isValid()); | | |||
463 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | | |||
464 | QVERIFY(geometryChangedSpy.isValid()); | | |||
465 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &ShellSurface::sizeChanged); | | |||
466 | QVERIFY(sizeChangeRequestedSpy.isValid()); | | |||
467 | | ||||
468 | shellSurface->setFullscreen(); | | |||
469 | | ||||
470 | QVERIFY(fullscreenChangedSpy.wait()); | | |||
471 | QVERIFY(sizeChangeRequestedSpy.wait()); | | |||
472 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | | |||
473 | QCOMPARE(sizeChangeRequestedSpy.first().first().toSize(), QSize(screens()->size(0))); | | |||
474 | // TODO: should switch to fullscreen once it's updated | | |||
475 | QVERIFY(c->isFullScreen()); | | |||
476 | QCOMPARE(c->clientSize(), QSize(100, 50)); | | |||
477 | QVERIFY(geometryChangedSpy.isEmpty()); | | |||
478 | | ||||
479 | Test::render(surface.data(), sizeChangeRequestedSpy.first().first().toSize(), Qt::red); | | |||
480 | QVERIFY(geometryChangedSpy.wait()); | | |||
481 | QCOMPARE(geometryChangedSpy.count(), 1); | | |||
482 | QVERIFY(c->isFullScreen()); | | |||
483 | QVERIFY(!c->isDecorated()); | | |||
484 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.first().first().toSize())); | | |||
485 | QCOMPARE(c->layer(), ActiveLayer); | | |||
486 | | ||||
487 | // swap back to normal | | |||
488 | shellSurface->setToplevel(); | | |||
489 | QVERIFY(fullscreenChangedSpy.wait()); | | |||
490 | QVERIFY(sizeChangeRequestedSpy.wait()); | | |||
491 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | | |||
492 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | | |||
493 | // TODO: should switch to fullscreen once it's updated | | |||
494 | QVERIFY(!c->isFullScreen()); | | |||
495 | QCOMPARE(c->layer(), NormalLayer); | | |||
496 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | | |||
497 | } | | |||
498 | | ||||
499 | void TestShellClient::testFullscreen_data() | 420 | void TestShellClient::testFullscreen_data() | ||
500 | { | 421 | { | ||
501 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 422 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
502 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | 423 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | ||
503 | 424 | | |||
504 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Client; | 425 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Client; | ||
505 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | 426 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | ||
506 | QTest::newRow("xdgShellWmBase") << Test::ShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | 427 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | ||
507 | 428 | | |||
508 | QTest::newRow("xdgShellV5 - deco") << Test::ShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Server; | 429 | QTest::newRow("xdgShellV5 - deco") << Test::XdgShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Server; | ||
509 | QTest::newRow("xdgShellV6 - deco") << Test::ShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | 430 | QTest::newRow("xdgShellV6 - deco") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | ||
510 | QTest::newRow("xdgShellWmBase - deco") << Test::ShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | 431 | QTest::newRow("xdgShellWmBase - deco") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | ||
511 | | ||||
512 | } | 432 | } | ||
513 | 433 | | |||
514 | void TestShellClient::testFullscreen() | 434 | void TestShellClient::testFullscreen() | ||
515 | { | 435 | { | ||
516 | // this test verifies that a window can be properly fullscreened | 436 | // this test verifies that a window can be properly fullscreened | ||
517 | QScopedPointer<Surface> surface(Test::createSurface()); | 437 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
518 | QFETCH(Test::ShellSurfaceType, type); | 438 | QFETCH(Test::XdgShellSurfaceType, type); | ||
519 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 439 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
520 | QVERIFY(shellSurface); | 440 | QVERIFY(shellSurface); | ||
521 | 441 | | |||
522 | // create deco | 442 | // create deco | ||
523 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 443 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
524 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 444 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
525 | QVERIFY(decoSpy.isValid()); | 445 | QVERIFY(decoSpy.isValid()); | ||
526 | QVERIFY(decoSpy.wait()); | 446 | QVERIFY(decoSpy.wait()); | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
574 | // TODO: should switch to fullscreen once it's updated | 494 | // TODO: should switch to fullscreen once it's updated | ||
575 | QVERIFY(!c->isFullScreen()); | 495 | QVERIFY(!c->isFullScreen()); | ||
576 | QCOMPARE(c->layer(), NormalLayer); | 496 | QCOMPARE(c->layer(), NormalLayer); | ||
577 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 497 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
578 | } | 498 | } | ||
579 | 499 | | |||
580 | void TestShellClient::testFullscreenRestore_data() | 500 | void TestShellClient::testFullscreenRestore_data() | ||
581 | { | 501 | { | ||
582 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 502 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
583 | 503 | | |||
584 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 504 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
585 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 505 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
586 | QTest::newRow("xdgShellWmBase") << Test::ShellSurfaceType::XdgShellStable; | 506 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
587 | } | 507 | } | ||
588 | 508 | | |||
589 | void TestShellClient::testFullscreenRestore() | 509 | void TestShellClient::testFullscreenRestore() | ||
590 | { | 510 | { | ||
591 | // this test verifies that windows created fullscreen can be later properly restored | 511 | // this test verifies that windows created fullscreen can be later properly restored | ||
592 | QScopedPointer<Surface> surface(Test::createSurface()); | 512 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
593 | QFETCH(Test::ShellSurfaceType, type); | 513 | QFETCH(Test::XdgShellSurfaceType, type); | ||
594 | XdgShellSurface *xdgShellSurface = Test::createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly); | 514 | XdgShellSurface *xdgShellSurface = Test::createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly); | ||
595 | QSignalSpy configureRequestedSpy(xdgShellSurface, &XdgShellSurface::configureRequested); | 515 | QSignalSpy configureRequestedSpy(xdgShellSurface, &XdgShellSurface::configureRequested); | ||
596 | 516 | | |||
597 | // fullscreen the window | 517 | // fullscreen the window | ||
598 | xdgShellSurface->setFullscreen(true); | 518 | xdgShellSurface->setFullscreen(true); | ||
599 | surface->commit(Surface::CommitFlag::None); | 519 | surface->commit(Surface::CommitFlag::None); | ||
600 | 520 | | |||
601 | configureRequestedSpy.wait(); | 521 | configureRequestedSpy.wait(); | ||
Show All 34 Lines | |||||
636 | QVERIFY(geometryChangedSpy.wait()); | 556 | QVERIFY(geometryChangedSpy.wait()); | ||
637 | QCOMPARE(geometryChangedSpy.count(), 1); | 557 | QCOMPARE(geometryChangedSpy.count(), 1); | ||
638 | QVERIFY(!c->isFullScreen()); | 558 | QVERIFY(!c->isFullScreen()); | ||
639 | QCOMPARE(c->geometry().size(), QSize(100, 50)); | 559 | QCOMPARE(c->geometry().size(), QSize(100, 50)); | ||
640 | } | 560 | } | ||
641 | 561 | | |||
642 | void TestShellClient::testUserCanSetFullscreen_data() | 562 | void TestShellClient::testUserCanSetFullscreen_data() | ||
643 | { | 563 | { | ||
644 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 564 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
645 | QTest::addColumn<bool>("expected"); | | |||
646 | | ||||
647 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell << false; | | |||
648 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5 << true; | | |||
649 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6 << true; | | |||
650 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable << true; | | |||
651 | 565 | | |||
566 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||||
567 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||||
568 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||||
652 | } | 569 | } | ||
653 | 570 | | |||
654 | void TestShellClient::testUserCanSetFullscreen() | 571 | void TestShellClient::testUserCanSetFullscreen() | ||
655 | { | 572 | { | ||
656 | QScopedPointer<Surface> surface(Test::createSurface()); | 573 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
657 | QFETCH(Test::ShellSurfaceType, type); | 574 | QFETCH(Test::XdgShellSurfaceType, type); | ||
658 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 575 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
659 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | | |||
660 | QVERIFY(c); | | |||
661 | QVERIFY(c->isActive()); | | |||
662 | QVERIFY(!c->isFullScreen()); | | |||
663 | QTEST(c->userCanSetFullScreen(), "expected"); | | |||
664 | } | | |||
665 | | ||||
666 | void TestShellClient::testUserSetFullscreenWlShell() | | |||
667 | { | | |||
668 | // wlshell cannot sync fullscreen to the client | | |||
669 | QScopedPointer<Surface> surface(Test::createSurface()); | | |||
670 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | | |||
671 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 576 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
672 | QVERIFY(c); | 577 | QVERIFY(c); | ||
673 | QVERIFY(c->isActive()); | 578 | QVERIFY(c->isActive()); | ||
674 | QVERIFY(!c->isFullScreen()); | 579 | QVERIFY(!c->isFullScreen()); | ||
675 | QSignalSpy fullscreenChangedSpy(c, &AbstractClient::fullScreenChanged); | 580 | QVERIFY(c->userCanSetFullScreen()); | ||
676 | QVERIFY(fullscreenChangedSpy.isValid()); | | |||
677 | c->setFullScreen(true); | | |||
678 | QCOMPARE(fullscreenChangedSpy.count(), 0); | | |||
679 | QVERIFY(!c->isFullScreen()); | | |||
680 | } | 581 | } | ||
681 | 582 | | |||
682 | void TestShellClient::testUserSetFullscreenXdgShell_data() | 583 | void TestShellClient::testUserSetFullscreen_data() | ||
683 | { | 584 | { | ||
684 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 585 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
685 | 586 | | |||
686 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 587 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
687 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 588 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
688 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | 589 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
689 | } | 590 | } | ||
690 | 591 | | |||
691 | void TestShellClient::testUserSetFullscreenXdgShell() | 592 | void TestShellClient::testUserSetFullscreen() | ||
692 | { | 593 | { | ||
693 | QScopedPointer<Surface> surface(Test::createSurface()); | 594 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
694 | QFETCH(Test::ShellSurfaceType, type); | 595 | QFETCH(Test::XdgShellSurfaceType, type); | ||
695 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | 596 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | ||
696 | type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | 597 | type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||
697 | QVERIFY(!shellSurface.isNull()); | 598 | QVERIFY(!shellSurface.isNull()); | ||
698 | 599 | | |||
699 | // wait for the initial configure event | 600 | // wait for the initial configure event | ||
700 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 601 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
701 | QVERIFY(configureRequestedSpy.isValid()); | 602 | QVERIFY(configureRequestedSpy.isValid()); | ||
702 | surface->commit(Surface::CommitFlag::None); | 603 | surface->commit(Surface::CommitFlag::None); | ||
Show All 34 Lines | |||||
737 | QVERIFY(configureRequestedSpy.wait()); | 638 | QVERIFY(configureRequestedSpy.wait()); | ||
738 | QCOMPARE(configureRequestedSpy.count(), 1); | 639 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
739 | QCOMPARE(configureRequestedSpy.first().at(0).toSize(), QSize(100, 50)); | 640 | QCOMPARE(configureRequestedSpy.first().at(0).toSize(), QSize(100, 50)); | ||
740 | QVERIFY(!configureRequestedSpy.first().at(1).value<KWayland::Client::XdgShellSurface::States>().testFlag(KWayland::Client::XdgShellSurface::State::Fullscreen)); | 641 | QVERIFY(!configureRequestedSpy.first().at(1).value<KWayland::Client::XdgShellSurface::States>().testFlag(KWayland::Client::XdgShellSurface::State::Fullscreen)); | ||
741 | QCOMPARE(fullscreenChangedSpy.count(), 2); | 642 | QCOMPARE(fullscreenChangedSpy.count(), 2); | ||
742 | QVERIFY(!c->isFullScreen()); | 643 | QVERIFY(!c->isFullScreen()); | ||
743 | } | 644 | } | ||
744 | 645 | | |||
745 | void TestShellClient::testMaximizedToFullscreenWlShell_data() | 646 | void TestShellClient::testMaximizedToFullscreen_data() | ||
746 | { | 647 | { | ||
648 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||||
747 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | 649 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | ||
748 | 650 | | |||
749 | QTest::newRow("wlShell") << ServerSideDecoration::Mode::Client; | 651 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Client; | ||
750 | QTest::newRow("wlShell - deco") << ServerSideDecoration::Mode::Server; | 652 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | ||
751 | } | 653 | QTest::newRow("xdgShellWmBase") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | ||
752 | 654 | | |||
753 | void TestShellClient::testMaximizedToFullscreenWlShell() | 655 | QTest::newRow("xdgShellV5 - deco") << Test::XdgShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Server; | ||
754 | { | 656 | QTest::newRow("xdgShellV6 - deco") << Test::XdgShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | ||
755 | // this test verifies that a window can be properly fullscreened after maximizing | 657 | QTest::newRow("xdgShellWmBase - deco") << Test::XdgShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | ||
756 | QScopedPointer<Surface> surface(Test::createSurface()); | | |||
757 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | | |||
758 | | ||||
759 | QVERIFY(shellSurface.data()); | | |||
760 | | ||||
761 | // create deco | | |||
762 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | | |||
763 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | | |||
764 | QVERIFY(decoSpy.isValid()); | | |||
765 | QVERIFY(decoSpy.wait()); | | |||
766 | QFETCH(ServerSideDecoration::Mode, decoMode); | | |||
767 | deco->requestMode(decoMode); | | |||
768 | QVERIFY(decoSpy.wait()); | | |||
769 | QCOMPARE(deco->mode(), decoMode); | | |||
770 | | ||||
771 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | | |||
772 | QVERIFY(c); | | |||
773 | QVERIFY(c->isActive()); | | |||
774 | QVERIFY(!c->isFullScreen()); | | |||
775 | QCOMPARE(c->clientSize(), QSize(100, 50)); | | |||
776 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | | |||
777 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | | |||
778 | QVERIFY(fullscreenChangedSpy.isValid()); | | |||
779 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | | |||
780 | QVERIFY(geometryChangedSpy.isValid()); | | |||
781 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &ShellSurface::sizeChanged); | | |||
782 | QVERIFY(sizeChangeRequestedSpy.isValid()); | | |||
783 | | ||||
784 | shellSurface->setMaximized(); | | |||
785 | | ||||
786 | QVERIFY(sizeChangeRequestedSpy.wait()); | | |||
787 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | | |||
788 | | ||||
789 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | | |||
790 | QVERIFY(geometryChangedSpy.wait()); | | |||
791 | | ||||
792 | QCOMPARE(c->maximizeMode(), MaximizeFull); | | |||
793 | QCOMPARE(geometryChangedSpy.isEmpty(), false); | | |||
794 | geometryChangedSpy.clear(); | | |||
795 | | ||||
796 | // fullscreen the window | | |||
797 | shellSurface->setFullscreen(); | | |||
798 | | ||||
799 | QVERIFY(fullscreenChangedSpy.wait()); | | |||
800 | if (decoMode == ServerSideDecoration::Mode::Server) { | | |||
801 | QVERIFY(sizeChangeRequestedSpy.wait()); | | |||
802 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | | |||
803 | } | | |||
804 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(screens()->size(0))); | | |||
805 | // TODO: should switch to fullscreen once it's updated | | |||
806 | QVERIFY(c->isFullScreen()); | | |||
807 | | ||||
808 | // render at the new size | | |||
809 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | | |||
810 | | ||||
811 | QVERIFY(c->isFullScreen()); | | |||
812 | QVERIFY(!c->isDecorated()); | | |||
813 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.last().first().toSize())); | | |||
814 | sizeChangeRequestedSpy.clear(); | | |||
815 | | ||||
816 | // swap back to normal | | |||
817 | shellSurface->setToplevel(); | | |||
818 | | ||||
819 | QVERIFY(fullscreenChangedSpy.wait()); | | |||
820 | if (decoMode == ServerSideDecoration::Mode::Server) { | | |||
821 | QVERIFY(sizeChangeRequestedSpy.wait()); | | |||
822 | | ||||
823 | // TODO: we should test both cases with fixed fake decoration for autotests. | | |||
824 | const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; | | |||
825 | | ||||
826 | // fails if we have borders as we don't correctly call setMaximize(false) | | |||
827 | // but realistically the only toolkits that support the deco also use XDGShell | | |||
828 | if (hasBorders) { | | |||
829 | QEXPECT_FAIL("wlShell - deco", "With decoration incorrect geometry requested", Continue); | | |||
830 | } | | |||
831 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | | |||
832 | } | | |||
833 | // TODO: should switch to fullscreen once it's updated | | |||
834 | QVERIFY(!c->isFullScreen()); | | |||
835 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | | |||
836 | } | 658 | } | ||
837 | 659 | | |||
838 | void TestShellClient::testMaximizedToFullscreenXdgShell_data() | 660 | void TestShellClient::testMaximizedToFullscreen() | ||
839 | { | | |||
840 | QTest::addColumn<Test::ShellSurfaceType>("type"); | | |||
841 | QTest::addColumn<ServerSideDecoration::Mode>("decoMode"); | | |||
842 | | ||||
843 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Client; | | |||
844 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Client; | | |||
845 | QTest::newRow("xdgShellWmBase") << Test::ShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Client; | | |||
846 | | ||||
847 | QTest::newRow("xdgShellV5 - deco") << Test::ShellSurfaceType::XdgShellV5 << ServerSideDecoration::Mode::Server; | | |||
848 | QTest::newRow("xdgShellV6 - deco") << Test::ShellSurfaceType::XdgShellV6 << ServerSideDecoration::Mode::Server; | | |||
849 | QTest::newRow("xdgShellWmBase - deco") << Test::ShellSurfaceType::XdgShellStable << ServerSideDecoration::Mode::Server; | | |||
850 | } | | |||
851 | | ||||
852 | void TestShellClient::testMaximizedToFullscreenXdgShell() | | |||
853 | { | 661 | { | ||
854 | // this test verifies that a window can be properly fullscreened after maximizing | 662 | // this test verifies that a window can be properly fullscreened after maximizing | ||
855 | QScopedPointer<Surface> surface(Test::createSurface()); | 663 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
856 | QFETCH(Test::ShellSurfaceType, type); | 664 | QFETCH(Test::XdgShellSurfaceType, type); | ||
857 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 665 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
858 | QVERIFY(shellSurface); | 666 | QVERIFY(shellSurface); | ||
859 | 667 | | |||
860 | // create deco | 668 | // create deco | ||
861 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 669 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
862 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 670 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
863 | QVERIFY(decoSpy.isValid()); | 671 | QVERIFY(decoSpy.isValid()); | ||
864 | QVERIFY(decoSpy.wait()); | 672 | QVERIFY(decoSpy.wait()); | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
927 | } | 735 | } | ||
928 | // TODO: should switch to fullscreen once it's updated | 736 | // TODO: should switch to fullscreen once it's updated | ||
929 | QVERIFY(!c->isFullScreen()); | 737 | QVERIFY(!c->isFullScreen()); | ||
930 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 738 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
931 | } | 739 | } | ||
932 | 740 | | |||
933 | void TestShellClient::testWindowOpensLargerThanScreen_data() | 741 | void TestShellClient::testWindowOpensLargerThanScreen_data() | ||
934 | { | 742 | { | ||
935 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 743 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
936 | 744 | | |||
937 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 745 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
938 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 746 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
939 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 747 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
940 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
941 | } | 748 | } | ||
942 | 749 | | |||
943 | void TestShellClient::testWindowOpensLargerThanScreen() | 750 | void TestShellClient::testWindowOpensLargerThanScreen() | ||
944 | { | 751 | { | ||
945 | // this test creates a window which is as large as the screen, but is decorated | 752 | // this test creates a window which is as large as the screen, but is decorated | ||
946 | // the window should get resized to fit into the screen, BUG: 366632 | 753 | // the window should get resized to fit into the screen, BUG: 366632 | ||
947 | QScopedPointer<Surface> surface(Test::createSurface()); | 754 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
948 | QFETCH(Test::ShellSurfaceType, type); | 755 | QFETCH(Test::XdgShellSurfaceType, type); | ||
949 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 756 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
950 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | 757 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | ||
951 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 758 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
952 | 759 | | |||
953 | // create deco | 760 | // create deco | ||
954 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 761 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
955 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 762 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
956 | QVERIFY(decoSpy.isValid()); | 763 | QVERIFY(decoSpy.isValid()); | ||
957 | QVERIFY(decoSpy.wait()); | 764 | QVERIFY(decoSpy.wait()); | ||
958 | deco->requestMode(ServerSideDecoration::Mode::Server); | 765 | deco->requestMode(ServerSideDecoration::Mode::Server); | ||
959 | QVERIFY(decoSpy.wait()); | 766 | QVERIFY(decoSpy.wait()); | ||
960 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | 767 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | ||
961 | 768 | | |||
962 | auto c = Test::renderAndWaitForShown(surface.data(), screens()->size(0), Qt::blue); | 769 | auto c = Test::renderAndWaitForShown(surface.data(), screens()->size(0), Qt::blue); | ||
963 | QVERIFY(c); | 770 | QVERIFY(c); | ||
964 | QVERIFY(c->isActive()); | 771 | QVERIFY(c->isActive()); | ||
965 | QCOMPARE(c->clientSize(), screens()->size(0)); | 772 | QCOMPARE(c->clientSize(), screens()->size(0)); | ||
966 | QVERIFY(c->isDecorated()); | 773 | QVERIFY(c->isDecorated()); | ||
967 | QEXPECT_FAIL("", "BUG 366632", Continue); | 774 | QEXPECT_FAIL("", "BUG 366632", Continue); | ||
968 | QVERIFY(sizeChangeRequestedSpy.wait(10)); | 775 | QVERIFY(sizeChangeRequestedSpy.wait(10)); | ||
969 | } | 776 | } | ||
970 | 777 | | |||
971 | void TestShellClient::testHidden_data() | 778 | void TestShellClient::testHidden_data() | ||
972 | { | 779 | { | ||
973 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 780 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
974 | 781 | | |||
975 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 782 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
976 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 783 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
977 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 784 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
978 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
979 | } | 785 | } | ||
980 | 786 | | |||
981 | void TestShellClient::testHidden() | 787 | void TestShellClient::testHidden() | ||
982 | { | 788 | { | ||
983 | // this test verifies that when hiding window it doesn't get shown | 789 | // this test verifies that when hiding window it doesn't get shown | ||
984 | QScopedPointer<Surface> surface(Test::createSurface()); | 790 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
985 | QFETCH(Test::ShellSurfaceType, type); | 791 | QFETCH(Test::XdgShellSurfaceType, type); | ||
986 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 792 | QScopedPointer<QObject> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
987 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 793 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
988 | QVERIFY(c); | 794 | QVERIFY(c); | ||
989 | QVERIFY(c->isActive()); | 795 | QVERIFY(c->isActive()); | ||
990 | QCOMPARE(workspace()->activeClient(), c); | 796 | QCOMPARE(workspace()->activeClient(), c); | ||
991 | QVERIFY(c->wantsInput()); | 797 | QVERIFY(c->wantsInput()); | ||
992 | QVERIFY(c->wantsTabFocus()); | 798 | QVERIFY(c->wantsTabFocus()); | ||
993 | QVERIFY(c->isShown(true)); | 799 | QVERIFY(c->isShown(true)); | ||
994 | 800 | | |||
Show All 13 Lines | |||||
1008 | } | 814 | } | ||
1009 | 815 | | |||
1010 | void TestShellClient::testDesktopFileName() | 816 | void TestShellClient::testDesktopFileName() | ||
1011 | { | 817 | { | ||
1012 | QIcon::setThemeName(QStringLiteral("breeze")); | 818 | QIcon::setThemeName(QStringLiteral("breeze")); | ||
1013 | // this test verifies that desktop file name is passed correctly to the window | 819 | // this test verifies that desktop file name is passed correctly to the window | ||
1014 | QScopedPointer<Surface> surface(Test::createSurface()); | 820 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1015 | // only xdg-shell as ShellSurface misses the setter | 821 | // only xdg-shell as ShellSurface misses the setter | ||
1016 | QScopedPointer<XdgShellSurface> shellSurface(qobject_cast<XdgShellSurface*>(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface.data()))); | 822 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1017 | shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); | 823 | shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); | ||
1018 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 824 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1019 | QVERIFY(c); | 825 | QVERIFY(c); | ||
1020 | QCOMPARE(c->desktopFileName(), QByteArrayLiteral("org.kde.foo")); | 826 | QCOMPARE(c->desktopFileName(), QByteArrayLiteral("org.kde.foo")); | ||
1021 | QCOMPARE(c->resourceClass(), QByteArrayLiteral("org.kde.foo")); | 827 | QCOMPARE(c->resourceClass(), QByteArrayLiteral("org.kde.foo")); | ||
1022 | QVERIFY(c->resourceName().startsWith("testShellClient")); | 828 | QVERIFY(c->resourceName().startsWith("testShellClient")); | ||
1023 | // the desktop file does not exist, so icon should be generic Wayland | 829 | // the desktop file does not exist, so icon should be generic Wayland | ||
1024 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | 830 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | ||
Show All 20 Lines | |||||
1045 | } | 851 | } | ||
1046 | 852 | | |||
1047 | void TestShellClient::testCaptionSimplified() | 853 | void TestShellClient::testCaptionSimplified() | ||
1048 | { | 854 | { | ||
1049 | // this test verifies that caption is properly trimmed | 855 | // this test verifies that caption is properly trimmed | ||
1050 | // see BUG 323798 comment #12 | 856 | // see BUG 323798 comment #12 | ||
1051 | QScopedPointer<Surface> surface(Test::createSurface()); | 857 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1052 | // only done for xdg-shell as ShellSurface misses the setter | 858 | // only done for xdg-shell as ShellSurface misses the setter | ||
1053 | QScopedPointer<XdgShellSurface> shellSurface(qobject_cast<XdgShellSurface*>(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface.data()))); | 859 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1054 | 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")); | 860 | 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")); | ||
1055 | shellSurface->setTitle(origTitle); | 861 | shellSurface->setTitle(origTitle); | ||
1056 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 862 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1057 | QVERIFY(c); | 863 | QVERIFY(c); | ||
1058 | QVERIFY(c->caption() != origTitle); | 864 | QVERIFY(c->caption() != origTitle); | ||
1059 | QCOMPARE(c->caption(), origTitle.simplified()); | 865 | QCOMPARE(c->caption(), origTitle.simplified()); | ||
1060 | } | 866 | } | ||
1061 | 867 | | |||
1062 | void TestShellClient::testCaptionMultipleWindows() | 868 | void TestShellClient::testCaptionMultipleWindows() | ||
1063 | { | 869 | { | ||
1064 | QScopedPointer<Surface> surface(Test::createSurface()); | 870 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1065 | QScopedPointer<XdgShellSurface> shellSurface(qobject_cast<XdgShellSurface*>(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface.data()))); | 871 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1066 | shellSurface->setTitle(QStringLiteral("foo")); | 872 | shellSurface->setTitle(QStringLiteral("foo")); | ||
1067 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 873 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1068 | QVERIFY(c); | 874 | QVERIFY(c); | ||
1069 | QCOMPARE(c->caption(), QStringLiteral("foo")); | 875 | QCOMPARE(c->caption(), QStringLiteral("foo")); | ||
1070 | QCOMPARE(c->captionNormal(), QStringLiteral("foo")); | 876 | QCOMPARE(c->captionNormal(), QStringLiteral("foo")); | ||
1071 | QCOMPARE(c->captionSuffix(), QString()); | 877 | QCOMPARE(c->captionSuffix(), QString()); | ||
1072 | 878 | | |||
1073 | QScopedPointer<Surface> surface2(Test::createSurface()); | 879 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
1074 | QScopedPointer<XdgShellSurface> shellSurface2(qobject_cast<XdgShellSurface*>(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface2.data()))); | 880 | QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data())); | ||
1075 | shellSurface2->setTitle(QStringLiteral("foo")); | 881 | shellSurface2->setTitle(QStringLiteral("foo")); | ||
1076 | auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); | 882 | auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); | ||
1077 | QVERIFY(c2); | 883 | QVERIFY(c2); | ||
1078 | QCOMPARE(c2->caption(), QStringLiteral("foo <2>")); | 884 | QCOMPARE(c2->caption(), QStringLiteral("foo <2>")); | ||
1079 | QCOMPARE(c2->captionNormal(), QStringLiteral("foo")); | 885 | QCOMPARE(c2->captionNormal(), QStringLiteral("foo")); | ||
1080 | QCOMPARE(c2->captionSuffix(), QStringLiteral(" <2>")); | 886 | QCOMPARE(c2->captionSuffix(), QStringLiteral(" <2>")); | ||
1081 | 887 | | |||
1082 | QScopedPointer<Surface> surface3(Test::createSurface()); | 888 | QScopedPointer<Surface> surface3(Test::createSurface()); | ||
1083 | QScopedPointer<XdgShellSurface> shellSurface3(qobject_cast<XdgShellSurface*>(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface3.data()))); | 889 | QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data())); | ||
1084 | shellSurface3->setTitle(QStringLiteral("foo")); | 890 | shellSurface3->setTitle(QStringLiteral("foo")); | ||
1085 | auto c3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue); | 891 | auto c3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue); | ||
1086 | QVERIFY(c3); | 892 | QVERIFY(c3); | ||
1087 | QCOMPARE(c3->caption(), QStringLiteral("foo <3>")); | 893 | QCOMPARE(c3->caption(), QStringLiteral("foo <3>")); | ||
1088 | QCOMPARE(c3->captionNormal(), QStringLiteral("foo")); | 894 | QCOMPARE(c3->captionNormal(), QStringLiteral("foo")); | ||
1089 | QCOMPARE(c3->captionSuffix(), QStringLiteral(" <3>")); | 895 | QCOMPARE(c3->captionSuffix(), QStringLiteral(" <3>")); | ||
1090 | 896 | | |||
1091 | QScopedPointer<Surface> surface4(Test::createSurface()); | 897 | QScopedPointer<Surface> surface4(Test::createSurface()); | ||
1092 | QScopedPointer<XdgShellSurface> shellSurface4(qobject_cast<XdgShellSurface*>(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface4.data()))); | 898 | QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data())); | ||
1093 | shellSurface4->setTitle(QStringLiteral("bar")); | 899 | shellSurface4->setTitle(QStringLiteral("bar")); | ||
1094 | auto c4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue); | 900 | auto c4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue); | ||
1095 | QVERIFY(c4); | 901 | QVERIFY(c4); | ||
1096 | QCOMPARE(c4->caption(), QStringLiteral("bar")); | 902 | QCOMPARE(c4->caption(), QStringLiteral("bar")); | ||
1097 | QCOMPARE(c4->captionNormal(), QStringLiteral("bar")); | 903 | QCOMPARE(c4->captionNormal(), QStringLiteral("bar")); | ||
1098 | QCOMPARE(c4->captionSuffix(), QString()); | 904 | QCOMPARE(c4->captionSuffix(), QString()); | ||
1099 | QSignalSpy captionChangedSpy(c4, &ShellClient::captionChanged); | 905 | QSignalSpy captionChangedSpy(c4, &ShellClient::captionChanged); | ||
1100 | QVERIFY(captionChangedSpy.isValid()); | 906 | QVERIFY(captionChangedSpy.isValid()); | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 932 | { | |||
1194 | } | 1000 | } | ||
1195 | 1001 | | |||
1196 | auto elapsed2 = QDateTime::currentMSecsSinceEpoch() - startTime; | 1002 | auto elapsed2 = QDateTime::currentMSecsSinceEpoch() - startTime; | ||
1197 | QVERIFY(elapsed2 > 1800); //second ping comes in a second later | 1003 | QVERIFY(elapsed2 > 1800); //second ping comes in a second later | ||
1198 | } | 1004 | } | ||
1199 | 1005 | | |||
1200 | void TestShellClient::testX11WindowId_data() | 1006 | void TestShellClient::testX11WindowId_data() | ||
1201 | { | 1007 | { | ||
1202 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 1008 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
1203 | 1009 | | |||
1204 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 1010 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
1205 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 1011 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
1206 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 1012 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
1207 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
1208 | } | 1013 | } | ||
1209 | 1014 | | |||
1210 | void TestShellClient::testX11WindowId() | 1015 | void TestShellClient::testX11WindowId() | ||
1211 | { | 1016 | { | ||
1212 | QScopedPointer<Surface> surface(Test::createSurface()); | 1017 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1213 | QFETCH(Test::ShellSurfaceType, type); | 1018 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1214 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 1019 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
1215 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1020 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1216 | QVERIFY(c); | 1021 | QVERIFY(c); | ||
1217 | QVERIFY(c->windowId() != 0); | 1022 | QVERIFY(c->windowId() != 0); | ||
1218 | QCOMPARE(c->window(), 0u); | 1023 | QCOMPARE(c->window(), 0u); | ||
1219 | } | 1024 | } | ||
1220 | 1025 | | |||
1221 | void TestShellClient::testAppMenu() | 1026 | void TestShellClient::testAppMenu() | ||
1222 | { | 1027 | { | ||
1223 | //register a faux appmenu client | 1028 | //register a faux appmenu client | ||
1224 | QVERIFY (QDBusConnection::sessionBus().registerService("org.kde.kappmenu")); | 1029 | QVERIFY (QDBusConnection::sessionBus().registerService("org.kde.kappmenu")); | ||
1225 | 1030 | | |||
1226 | QScopedPointer<Surface> surface(Test::createSurface()); | 1031 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1227 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV6, surface.data())); | 1032 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1228 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1033 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1229 | QVERIFY(c); | 1034 | QVERIFY(c); | ||
1230 | QScopedPointer<AppMenu> menu(Test::waylandAppMenuManager()->create(surface.data())); | 1035 | QScopedPointer<AppMenu> menu(Test::waylandAppMenuManager()->create(surface.data())); | ||
1231 | QSignalSpy spy(c, &ShellClient::hasApplicationMenuChanged); | 1036 | QSignalSpy spy(c, &ShellClient::hasApplicationMenuChanged); | ||
1232 | menu->setAddress("service.name", "object/path"); | 1037 | menu->setAddress("service.name", "object/path"); | ||
1233 | spy.wait(); | 1038 | spy.wait(); | ||
1234 | QCOMPARE(c->hasApplicationMenu(), true); | 1039 | QCOMPARE(c->hasApplicationMenu(), true); | ||
1235 | QCOMPARE(c->applicationMenuServiceName(), QString("service.name")); | 1040 | QCOMPARE(c->applicationMenuServiceName(), QString("service.name")); | ||
1236 | QCOMPARE(c->applicationMenuObjectPath(), QString("object/path")); | 1041 | QCOMPARE(c->applicationMenuObjectPath(), QString("object/path")); | ||
1237 | 1042 | | |||
1238 | QVERIFY (QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu")); | 1043 | QVERIFY (QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu")); | ||
1239 | } | 1044 | } | ||
1240 | 1045 | | |||
1241 | void TestShellClient::testNoDecorationModeRequested_data() | 1046 | void TestShellClient::testNoDecorationModeRequested_data() | ||
1242 | { | 1047 | { | ||
1243 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 1048 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
1244 | 1049 | | |||
1245 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 1050 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
1246 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 1051 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
1247 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
1248 | } | 1052 | } | ||
1249 | 1053 | | |||
1250 | void TestShellClient::testNoDecorationModeRequested() | 1054 | void TestShellClient::testNoDecorationModeRequested() | ||
1251 | { | 1055 | { | ||
1252 | // this test verifies that the decoration follows the default mode if no mode is explicitly requested | 1056 | // this test verifies that the decoration follows the default mode if no mode is explicitly requested | ||
1253 | QScopedPointer<Surface> surface(Test::createSurface()); | 1057 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1254 | QFETCH(Test::ShellSurfaceType, type); | 1058 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1255 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 1059 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
1256 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 1060 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
1257 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 1061 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
1258 | QVERIFY(decoSpy.isValid()); | 1062 | QVERIFY(decoSpy.isValid()); | ||
1259 | if (deco->mode() != ServerSideDecoration::Mode::Server) { | 1063 | if (deco->mode() != ServerSideDecoration::Mode::Server) { | ||
1260 | QVERIFY(decoSpy.wait()); | 1064 | QVERIFY(decoSpy.wait()); | ||
1261 | } | 1065 | } | ||
1262 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | 1066 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | ||
1263 | 1067 | | |||
1264 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1068 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1265 | QVERIFY(c); | 1069 | QVERIFY(c); | ||
1266 | QCOMPARE(c->noBorder(), false); | 1070 | QCOMPARE(c->noBorder(), false); | ||
1267 | QCOMPARE(c->isDecorated(), true); | 1071 | QCOMPARE(c->isDecorated(), true); | ||
1268 | } | 1072 | } | ||
1269 | 1073 | | |||
1270 | void TestShellClient::testSendClientWithTransientToDesktop_data() | 1074 | void TestShellClient::testSendClientWithTransientToDesktop_data() | ||
1271 | { | 1075 | { | ||
1272 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 1076 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
1273 | 1077 | | |||
1274 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 1078 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
1275 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 1079 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
1276 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | 1080 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
1277 | } | 1081 | } | ||
1278 | 1082 | | |||
1279 | void TestShellClient::testSendClientWithTransientToDesktop() | 1083 | void TestShellClient::testSendClientWithTransientToDesktop() | ||
1280 | { | 1084 | { | ||
1281 | // this test verifies that when sending a client to a desktop all transients are also send to that desktop | 1085 | // this test verifies that when sending a client to a desktop all transients are also send to that desktop | ||
1282 | 1086 | | |||
1283 | VirtualDesktopManager::self()->setCount(2); | 1087 | VirtualDesktopManager::self()->setCount(2); | ||
1284 | QScopedPointer<Surface> surface{Test::createSurface()}; | 1088 | QScopedPointer<Surface> surface{Test::createSurface()}; | ||
1285 | QFETCH(Test::ShellSurfaceType, type); | 1089 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1286 | QScopedPointer<XdgShellSurface> shellSurface{qobject_cast<XdgShellSurface*>(Test::createShellSurface(type, surface.data()))}; | 1090 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
1287 | 1091 | | |||
1288 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1092 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1289 | QVERIFY(c); | 1093 | QVERIFY(c); | ||
1290 | 1094 | | |||
1291 | // let's create a transient window | 1095 | // let's create a transient window | ||
1292 | QScopedPointer<Surface> transientSurface{Test::createSurface()}; | 1096 | QScopedPointer<Surface> transientSurface{Test::createSurface()}; | ||
1293 | QScopedPointer<XdgShellSurface> transientShellSurface{qobject_cast<XdgShellSurface*>(Test::createShellSurface(type, transientSurface.data()))}; | 1097 | QScopedPointer<XdgShellSurface> transientShellSurface(Test::createXdgShellSurface(type, transientSurface.data())); | ||
1294 | transientShellSurface->setTransientFor(shellSurface.data()); | 1098 | transientShellSurface->setTransientFor(shellSurface.data()); | ||
1295 | 1099 | | |||
1296 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), QSize(100, 50), Qt::blue); | 1100 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), QSize(100, 50), Qt::blue); | ||
1297 | QVERIFY(transient); | 1101 | QVERIFY(transient); | ||
1298 | QCOMPARE(workspace()->activeClient(), transient); | 1102 | QCOMPARE(workspace()->activeClient(), transient); | ||
1299 | QCOMPARE(transient->transientFor(), c); | 1103 | QCOMPARE(transient->transientFor(), c); | ||
1300 | QVERIFY(c->transients().contains(transient)); | 1104 | QVERIFY(c->transients().contains(transient)); | ||
1301 | 1105 | | |||
Show All 18 Lines | |||||
1320 | 1124 | | |||
1321 | // which should move the transient back to the desktop | 1125 | // which should move the transient back to the desktop | ||
1322 | QCOMPARE(c->desktop(), 1); | 1126 | QCOMPARE(c->desktop(), 1); | ||
1323 | QCOMPARE(transient->desktop(), 1); | 1127 | QCOMPARE(transient->desktop(), 1); | ||
1324 | } | 1128 | } | ||
1325 | 1129 | | |||
1326 | void TestShellClient::testMinimizeWindowWithTransients_data() | 1130 | void TestShellClient::testMinimizeWindowWithTransients_data() | ||
1327 | { | 1131 | { | ||
1328 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 1132 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
1329 | 1133 | | |||
1330 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 1134 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
1331 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 1135 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
1332 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | 1136 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
1333 | } | 1137 | } | ||
1334 | 1138 | | |||
1335 | void TestShellClient::testMinimizeWindowWithTransients() | 1139 | void TestShellClient::testMinimizeWindowWithTransients() | ||
1336 | { | 1140 | { | ||
1337 | // this test verifies that when minimizing/unminimizing a window all its | 1141 | // this test verifies that when minimizing/unminimizing a window all its | ||
1338 | // transients will be minimized/unminimized as well | 1142 | // transients will be minimized/unminimized as well | ||
1339 | 1143 | | |||
1340 | // create the main window | 1144 | // create the main window | ||
1341 | QScopedPointer<Surface> surface(Test::createSurface()); | 1145 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1342 | QFETCH(Test::ShellSurfaceType, type); | 1146 | QFETCH(Test::XdgShellSurfaceType, type); | ||
1343 | QScopedPointer<XdgShellSurface> shellSurface(qobject_cast<XdgShellSurface *>( | 1147 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
1344 | Test::createShellSurface(type, surface.data()))); | | |||
1345 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1148 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1346 | QVERIFY(c); | 1149 | QVERIFY(c); | ||
1347 | QVERIFY(!c->isMinimized()); | 1150 | QVERIFY(!c->isMinimized()); | ||
1348 | 1151 | | |||
1349 | // create a transient window | 1152 | // create a transient window | ||
1350 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | 1153 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | ||
1351 | QScopedPointer<XdgShellSurface> transientShellSurface(qobject_cast<XdgShellSurface *>( | 1154 | QScopedPointer<XdgShellSurface> transientShellSurface(Test::createXdgShellSurface(type, transientSurface.data())); | ||
1352 | Test::createShellSurface(type, transientSurface.data()))); | | |||
1353 | transientShellSurface->setTransientFor(shellSurface.data()); | 1155 | transientShellSurface->setTransientFor(shellSurface.data()); | ||
1354 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), QSize(100, 50), Qt::red); | 1156 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), QSize(100, 50), Qt::red); | ||
1355 | QVERIFY(transient); | 1157 | QVERIFY(transient); | ||
1356 | QVERIFY(!transient->isMinimized()); | 1158 | QVERIFY(!transient->isMinimized()); | ||
1357 | QCOMPARE(transient->transientFor(), c); | 1159 | QCOMPARE(transient->transientFor(), c); | ||
1358 | QVERIFY(c->hasTransient(transient, false)); | 1160 | QVERIFY(c->hasTransient(transient, false)); | ||
1359 | 1161 | | |||
1360 | // minimize the main window, the transient should be minimized as well | 1162 | // minimize the main window, the transient should be minimized as well | ||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |