Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_windowmanagement.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 42 | private Q_SLOTS: | |||
---|---|---|---|---|---|
43 | void init(); | 43 | void init(); | ||
44 | 44 | | |||
45 | void testWindowTitle(); | 45 | void testWindowTitle(); | ||
46 | void testMinimizedGeometry(); | 46 | void testMinimizedGeometry(); | ||
47 | void testUseAfterUnmap(); | 47 | void testUseAfterUnmap(); | ||
48 | void testServerDelete(); | 48 | void testServerDelete(); | ||
49 | void testActiveWindowOnUnmapped(); | 49 | void testActiveWindowOnUnmapped(); | ||
50 | void testDeleteActiveWindow(); | 50 | void testDeleteActiveWindow(); | ||
51 | void testCreateAfterUnmap(); | ||||
51 | 52 | | |||
52 | void cleanup(); | 53 | void cleanup(); | ||
53 | 54 | | |||
54 | private: | 55 | private: | ||
55 | KWayland::Server::Display *m_display; | 56 | KWayland::Server::Display *m_display; | ||
56 | KWayland::Server::CompositorInterface *m_compositorInterface; | 57 | KWayland::Server::CompositorInterface *m_compositorInterface; | ||
57 | KWayland::Server::PlasmaWindowManagementInterface *m_windowManagementInterface; | 58 | KWayland::Server::PlasmaWindowManagementInterface *m_windowManagementInterface; | ||
58 | KWayland::Server::PlasmaWindowInterface *m_windowInterface; | 59 | KWayland::Server::PlasmaWindowInterface *m_windowInterface; | ||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | 293 | { | |||
304 | 305 | | |||
305 | // delete the client side window - that's semantically kind of wrong, but shouldn't make our code crash | 306 | // delete the client side window - that's semantically kind of wrong, but shouldn't make our code crash | ||
306 | delete m_window; | 307 | delete m_window; | ||
307 | m_window = nullptr; | 308 | m_window = nullptr; | ||
308 | QCOMPARE(activeWindowChangedSpy.count(), 2); | 309 | QCOMPARE(activeWindowChangedSpy.count(), 2); | ||
309 | QVERIFY(!m_windowManagement->activeWindow()); | 310 | QVERIFY(!m_windowManagement->activeWindow()); | ||
310 | } | 311 | } | ||
311 | 312 | | |||
313 | void TestWindowManagement::testCreateAfterUnmap() | ||||
314 | { | ||||
315 | // this test verifies that we don't get a protocol error on client side when creating an already unmapped window. | ||||
316 | QSignalSpy windowSpy(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated); | ||||
317 | QVERIFY(windowSpy.isValid()); | ||||
318 | // create and unmap in one go | ||||
319 | // client will first handle the create, the unmap will be sent once the server side is bound | ||||
320 | auto serverWindow = m_windowManagementInterface->createWindow(this); | ||||
321 | serverWindow->unmap(); | ||||
322 | QCOMPARE(m_windowManagementInterface->children().count(), 0); | ||||
323 | QVERIFY(windowSpy.wait()); | ||||
324 | QCOMPARE(windowSpy.count(), 1); | ||||
325 | auto window = windowSpy.first().first().value<KWayland::Client::PlasmaWindow*>(); | ||||
326 | QVERIFY(window); | ||||
327 | // now this is not yet on the server, on the server it will be after next roundtrip | ||||
328 | // which we can trigger by waiting for destroy of the newly created window. | ||||
329 | // why destroy? Because we will get the unmap which triggers a destroy | ||||
330 | QSignalSpy clientDestroyedSpy(window, &QObject::destroyed); | ||||
331 | QVERIFY(clientDestroyedSpy.isValid()); | ||||
332 | QVERIFY(clientDestroyedSpy.wait()); | ||||
333 | // the server side created a helper PlasmaWindowInterface with PlasmaWindowManagementInterface as parent | ||||
334 | // it emitted unmapped so we can be sure it will be destroyed directly | ||||
335 | QCOMPARE(m_windowManagementInterface->children().count(), 1); | ||||
336 | auto helperWindow = qobject_cast<KWayland::Server::PlasmaWindowInterface*>(m_windowManagementInterface->children().first()); | ||||
337 | QVERIFY(helperWindow); | ||||
338 | QSignalSpy helperDestroyedSpy(helperWindow, &QObject::destroyed); | ||||
339 | QVERIFY(helperDestroyedSpy.isValid()); | ||||
340 | QVERIFY(helperDestroyedSpy.wait()); | ||||
341 | } | ||||
342 | | ||||
312 | QTEST_GUILESS_MAIN(TestWindowManagement) | 343 | QTEST_GUILESS_MAIN(TestWindowManagement) | ||
313 | #include "test_wayland_windowmanagement.moc" | 344 | #include "test_wayland_windowmanagement.moc" |