Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_windowmanagement.cpp
Show All 40 Lines | 40 | public: | |||
---|---|---|---|---|---|
41 | explicit TestWindowManagement(QObject *parent = nullptr); | 41 | explicit TestWindowManagement(QObject *parent = nullptr); | ||
42 | private Q_SLOTS: | 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(); | ||||
50 | void testDeleteActiveWindow(); | ||||
49 | 51 | | |||
50 | void cleanup(); | 52 | void cleanup(); | ||
51 | 53 | | |||
52 | private: | 54 | private: | ||
53 | KWayland::Server::Display *m_display; | 55 | KWayland::Server::Display *m_display; | ||
54 | KWayland::Server::CompositorInterface *m_compositorInterface; | 56 | KWayland::Server::CompositorInterface *m_compositorInterface; | ||
55 | KWayland::Server::PlasmaWindowManagementInterface *m_windowManagementInterface; | 57 | KWayland::Server::PlasmaWindowManagementInterface *m_windowManagementInterface; | ||
56 | KWayland::Server::PlasmaWindowInterface *m_windowInterface; | 58 | KWayland::Server::PlasmaWindowInterface *m_windowInterface; | ||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Line(s) | 251 | { | |||
253 | QVERIFY(destroyedSpy.isValid()); | 255 | QVERIFY(destroyedSpy.isValid()); | ||
254 | delete m_windowInterface; | 256 | delete m_windowInterface; | ||
255 | m_windowInterface = nullptr; | 257 | m_windowInterface = nullptr; | ||
256 | QVERIFY(unmappedSpy.wait()); | 258 | QVERIFY(unmappedSpy.wait()); | ||
257 | QVERIFY(destroyedSpy.wait()); | 259 | QVERIFY(destroyedSpy.wait()); | ||
258 | m_window = nullptr; | 260 | m_window = nullptr; | ||
259 | } | 261 | } | ||
260 | 262 | | |||
263 | void TestWindowManagement::testActiveWindowOnUnmapped() | ||||
264 | { | ||||
265 | // This test verifies that unmapping the active window changes the active window. | ||||
266 | // first make the window active | ||||
267 | QVERIFY(!m_windowManagement->activeWindow()); | ||||
268 | QVERIFY(!m_window->isActive()); | ||||
269 | QSignalSpy activeWindowChangedSpy(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::activeWindowChanged); | ||||
270 | QVERIFY(activeWindowChangedSpy.isValid()); | ||||
271 | m_windowInterface->setActive(true); | ||||
272 | QVERIFY(activeWindowChangedSpy.wait()); | ||||
273 | QCOMPARE(m_windowManagement->activeWindow(), m_window); | ||||
274 | QVERIFY(m_window->isActive()); | ||||
275 | | ||||
276 | // now unmap should change the active window | ||||
277 | QSignalSpy destroyedSpy(m_window, &QObject::destroyed); | ||||
278 | QVERIFY(destroyedSpy.isValid()); | ||||
279 | QSignalSpy serverDestroyedSpy(m_windowInterface, &QObject::destroyed); | ||||
280 | QVERIFY(serverDestroyedSpy.isValid()); | ||||
281 | m_windowManagementInterface->unmapWindow(m_windowInterface); | ||||
282 | QVERIFY(activeWindowChangedSpy.wait()); | ||||
283 | QVERIFY(!m_windowManagement->activeWindow()); | ||||
284 | QVERIFY(destroyedSpy.wait()); | ||||
285 | QCOMPARE(destroyedSpy.count(), 1); | ||||
286 | m_window = nullptr; | ||||
287 | QVERIFY(serverDestroyedSpy.wait()); | ||||
288 | m_windowInterface = nullptr; | ||||
289 | } | ||||
290 | | ||||
291 | void TestWindowManagement::testDeleteActiveWindow() | ||||
292 | { | ||||
293 | // This test verifies that deleting the active window on client side changes the active window | ||||
294 | // first make the window active | ||||
295 | QVERIFY(!m_windowManagement->activeWindow()); | ||||
296 | QVERIFY(!m_window->isActive()); | ||||
297 | QSignalSpy activeWindowChangedSpy(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::activeWindowChanged); | ||||
298 | QVERIFY(activeWindowChangedSpy.isValid()); | ||||
299 | m_windowInterface->setActive(true); | ||||
300 | QVERIFY(activeWindowChangedSpy.wait()); | ||||
301 | QCOMPARE(activeWindowChangedSpy.count(), 1); | ||||
302 | QCOMPARE(m_windowManagement->activeWindow(), m_window); | ||||
303 | QVERIFY(m_window->isActive()); | ||||
304 | | ||||
305 | // delete the client side window - that's semantically kind of wrong, but shouldn't make our code crash | ||||
306 | delete m_window; | ||||
307 | m_window = nullptr; | ||||
308 | QCOMPARE(activeWindowChangedSpy.count(), 2); | ||||
309 | QVERIFY(!m_windowManagement->activeWindow()); | ||||
310 | } | ||||
311 | | ||||
261 | QTEST_GUILESS_MAIN(TestWindowManagement) | 312 | QTEST_GUILESS_MAIN(TestWindowManagement) | ||
262 | #include "test_wayland_windowmanagement.moc" | 313 | #include "test_wayland_windowmanagement.moc" |