Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/plasmawindow_test.cpp
Show All 24 Lines | |||||
25 | #include "screens.h" | 25 | #include "screens.h" | ||
26 | #include "wayland_server.h" | 26 | #include "wayland_server.h" | ||
27 | #include "workspace.h" | 27 | #include "workspace.h" | ||
28 | #include "shell_client.h" | 28 | #include "shell_client.h" | ||
29 | #include <kwineffects.h> | 29 | #include <kwineffects.h> | ||
30 | 30 | | |||
31 | #include <KWayland/Client/compositor.h> | 31 | #include <KWayland/Client/compositor.h> | ||
32 | #include <KWayland/Client/plasmawindowmanagement.h> | 32 | #include <KWayland/Client/plasmawindowmanagement.h> | ||
33 | #include <KWayland/Client/shell.h> | | |||
34 | #include <KWayland/Client/surface.h> | 33 | #include <KWayland/Client/surface.h> | ||
35 | #include <KWayland/Server/seat_interface.h> | 34 | #include <KWayland/Server/seat_interface.h> | ||
36 | //screenlocker | 35 | //screenlocker | ||
37 | #include <KScreenLocker/KsldApp> | 36 | #include <KScreenLocker/KsldApp> | ||
38 | 37 | | |||
39 | #include <QPainter> | 38 | #include <QPainter> | ||
40 | #include <QRasterWindow> | 39 | #include <QRasterWindow> | ||
41 | 40 | | |||
Show All 18 Lines | 54 | private Q_SLOTS: | |||
60 | void testInternalWindowNoPlasmaWindow(); | 59 | void testInternalWindowNoPlasmaWindow(); | ||
61 | void testPopupWindowNoPlasmaWindow(); | 60 | void testPopupWindowNoPlasmaWindow(); | ||
62 | void testLockScreenNoPlasmaWindow(); | 61 | void testLockScreenNoPlasmaWindow(); | ||
63 | void testDestroyedButNotUnmapped(); | 62 | void testDestroyedButNotUnmapped(); | ||
64 | 63 | | |||
65 | private: | 64 | private: | ||
66 | PlasmaWindowManagement *m_windowManagement = nullptr; | 65 | PlasmaWindowManagement *m_windowManagement = nullptr; | ||
67 | KWayland::Client::Compositor *m_compositor = nullptr; | 66 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
68 | Shell *m_shell = nullptr; | | |||
69 | }; | 67 | }; | ||
70 | 68 | | |||
71 | void PlasmaWindowTest::initTestCase() | 69 | void PlasmaWindowTest::initTestCase() | ||
72 | { | 70 | { | ||
73 | qRegisterMetaType<KWin::ShellClient*>(); | 71 | qRegisterMetaType<KWin::ShellClient*>(); | ||
74 | qRegisterMetaType<KWin::AbstractClient*>(); | 72 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
75 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 73 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
76 | QVERIFY(workspaceCreatedSpy.isValid()); | 74 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
Show All 11 Lines | |||||
88 | waylandServer()->initWorkspace(); | 86 | waylandServer()->initWorkspace(); | ||
89 | } | 87 | } | ||
90 | 88 | | |||
91 | void PlasmaWindowTest::init() | 89 | void PlasmaWindowTest::init() | ||
92 | { | 90 | { | ||
93 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::WindowManagement)); | 91 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::WindowManagement)); | ||
94 | m_windowManagement = Test::waylandWindowManagement(); | 92 | m_windowManagement = Test::waylandWindowManagement(); | ||
95 | m_compositor = Test::waylandCompositor(); | 93 | m_compositor = Test::waylandCompositor(); | ||
96 | m_shell = Test::waylandShell(); | | |||
97 | 94 | | |||
98 | screens()->setCurrent(0); | 95 | screens()->setCurrent(0); | ||
99 | Cursor::setPos(QPoint(640, 512)); | 96 | Cursor::setPos(QPoint(640, 512)); | ||
100 | } | 97 | } | ||
101 | 98 | | |||
102 | void PlasmaWindowTest::cleanup() | 99 | void PlasmaWindowTest::cleanup() | ||
103 | { | 100 | { | ||
104 | Test::destroyWaylandConnection(); | 101 | Test::destroyWaylandConnection(); | ||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Line(s) | |||||
242 | void PlasmaWindowTest::testPopupWindowNoPlasmaWindow() | 239 | void PlasmaWindowTest::testPopupWindowNoPlasmaWindow() | ||
243 | { | 240 | { | ||
244 | // this test verifies that for a popup window no PlasmaWindow is sent to the client | 241 | // this test verifies that for a popup window no PlasmaWindow is sent to the client | ||
245 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | 242 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | ||
246 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | 243 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | ||
247 | 244 | | |||
248 | // first create the parent window | 245 | // first create the parent window | ||
249 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | 246 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | ||
250 | QScopedPointer<ShellSurface> parentShellSurface(Test::createShellSurface(parentSurface.data())); | 247 | QScopedPointer<XdgShellSurface> parentShellSurface(Test::createXdgShellStableSurface(parentSurface.data())); | ||
251 | // map that window | 248 | ShellClient *parentClient = Test::renderAndWaitForShown(parentSurface.data(), QSize(100, 50), Qt::blue); | ||
252 | Test::render(parentSurface.data(), QSize(100, 50), Qt::blue); | 249 | QVERIFY(parentClient); | ||
253 | // this should create a plasma window | | |||
254 | QVERIFY(plasmaWindowCreatedSpy.wait()); | 250 | QVERIFY(plasmaWindowCreatedSpy.wait()); | ||
251 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | ||||
255 | 252 | | |||
256 | // now let's create a popup window for it | 253 | // now let's create a popup window for it | ||
254 | XdgPositioner positioner(QSize(10, 10), QRect(0, 0, 10, 10)); | ||||
255 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
256 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
257 | QScopedPointer<Surface> popupSurface(Test::createSurface()); | 257 | QScopedPointer<Surface> popupSurface(Test::createSurface()); | ||
258 | QScopedPointer<ShellSurface> popupShellSurface(Test::createShellSurface(popupSurface.data())); | 258 | QScopedPointer<XdgShellPopup> popupShellSurface(Test::createXdgShellStablePopup(popupSurface.data(), parentShellSurface.data(), positioner)); | ||
259 | popupShellSurface->setTransient(parentSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus); | 259 | ShellClient *popupClient = Test::renderAndWaitForShown(popupSurface.data(), positioner.initialSize(), Qt::blue); | ||
260 | // let's map it | 260 | QVERIFY(popupClient); | ||
261 | Test::render(popupSurface.data(), QSize(100, 50), Qt::blue); | 261 | QVERIFY(!plasmaWindowCreatedSpy.wait(100)); | ||
262 | 262 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | |||
263 | // this should not create a plasma window | | |||
264 | QVERIFY(!plasmaWindowCreatedSpy.wait()); | | |||
265 | | ||||
266 | // now the same with an already mapped surface when we create the shell surface | | |||
267 | QScopedPointer<Surface> popup2Surface(Test::createSurface()); | | |||
268 | Test::render(popup2Surface.data(), QSize(100, 50), Qt::blue); | | |||
269 | QScopedPointer<ShellSurface> popup2ShellSurface(Test::createShellSurface(popup2Surface.data())); | | |||
270 | popup2ShellSurface->setTransient(popupSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus); | | |||
271 | | ||||
272 | // this should not create a plasma window | | |||
273 | QEXPECT_FAIL("", "The call to setTransient comes to late the window is already mapped then", Continue); | | |||
274 | QVERIFY(!plasmaWindowCreatedSpy.wait()); | | |||
275 | 263 | | |||
276 | // let's destroy the windows | 264 | // let's destroy the windows | ||
277 | QCOMPARE(waylandServer()->clients().count(), 3); | | |||
278 | QSignalSpy destroyed1Spy(waylandServer()->clients().last(), &QObject::destroyed); | | |||
279 | QVERIFY(destroyed1Spy.isValid()); | | |||
280 | popup2Surface->attachBuffer(Buffer::Ptr()); | | |||
281 | popup2Surface->commit(Surface::CommitFlag::None); | | |||
282 | popup2ShellSurface.reset(); | | |||
283 | popup2Surface.reset(); | | |||
284 | QVERIFY(destroyed1Spy.wait()); | | |||
285 | QCOMPARE(waylandServer()->clients().count(), 2); | | |||
286 | QSignalSpy destroyed2Spy(waylandServer()->clients().last(), &QObject::destroyed); | | |||
287 | QVERIFY(destroyed2Spy.isValid()); | | |||
288 | popupSurface->attachBuffer(Buffer::Ptr()); | | |||
289 | popupSurface->commit(Surface::CommitFlag::None); | | |||
290 | popupShellSurface.reset(); | 265 | popupShellSurface.reset(); | ||
291 | popupSurface.reset(); | 266 | QVERIFY(Test::waitForWindowDestroyed(popupClient)); | ||
292 | QVERIFY(destroyed2Spy.wait()); | | |||
293 | QCOMPARE(waylandServer()->clients().count(), 1); | | |||
294 | QSignalSpy destroyed3Spy(waylandServer()->clients().last(), &QObject::destroyed); | | |||
295 | QVERIFY(destroyed3Spy.isValid()); | | |||
296 | parentSurface->attachBuffer(Buffer::Ptr()); | | |||
297 | parentSurface->commit(Surface::CommitFlag::None); | | |||
298 | parentShellSurface.reset(); | 267 | parentShellSurface.reset(); | ||
299 | parentSurface.reset(); | 268 | QVERIFY(Test::waitForWindowDestroyed(parentClient)); | ||
300 | QVERIFY(destroyed3Spy.wait()); | | |||
301 | } | 269 | } | ||
302 | 270 | | |||
303 | void PlasmaWindowTest::testLockScreenNoPlasmaWindow() | 271 | void PlasmaWindowTest::testLockScreenNoPlasmaWindow() | ||
304 | { | 272 | { | ||
305 | // this test verifies that lock screen windows are not exposed to PlasmaWindow | 273 | // this test verifies that lock screen windows are not exposed to PlasmaWindow | ||
306 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | 274 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | ||
307 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | 275 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | ||
308 | 276 | | |||
Show All 27 Lines | |||||
336 | { | 304 | { | ||
337 | // this test verifies that also when a ShellSurface gets destroyed without a prior unmap | 305 | // this test verifies that also when a ShellSurface gets destroyed without a prior unmap | ||
338 | // the PlasmaWindow gets destroyed on Client side | 306 | // the PlasmaWindow gets destroyed on Client side | ||
339 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | 307 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | ||
340 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | 308 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | ||
341 | 309 | | |||
342 | // first create the parent window | 310 | // first create the parent window | ||
343 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | 311 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | ||
344 | QScopedPointer<ShellSurface> parentShellSurface(Test::createShellSurface(parentSurface.data())); | 312 | QScopedPointer<XdgShellSurface> parentShellSurface(Test::createXdgShellStableSurface(parentSurface.data())); | ||
345 | // map that window | 313 | // map that window | ||
346 | Test::render(parentSurface.data(), QSize(100, 50), Qt::blue); | 314 | Test::render(parentSurface.data(), QSize(100, 50), Qt::blue); | ||
347 | // this should create a plasma window | 315 | // this should create a plasma window | ||
348 | QVERIFY(plasmaWindowCreatedSpy.wait()); | 316 | QVERIFY(plasmaWindowCreatedSpy.wait()); | ||
349 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | 317 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | ||
350 | auto window = plasmaWindowCreatedSpy.first().first().value<PlasmaWindow*>(); | 318 | auto window = plasmaWindowCreatedSpy.first().first().value<PlasmaWindow*>(); | ||
351 | QVERIFY(window); | 319 | QVERIFY(window); | ||
352 | QSignalSpy destroyedSpy(window, &QObject::destroyed); | 320 | QSignalSpy destroyedSpy(window, &QObject::destroyed); | ||
Show All 12 Lines |