Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/plasmawindow_test.cpp
Show All 19 Lines | |||||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "platform.h" | 21 | #include "platform.h" | ||
22 | #include "x11client.h" | 22 | #include "x11client.h" | ||
23 | #include "cursor.h" | 23 | #include "cursor.h" | ||
24 | #include "screenedge.h" | 24 | #include "screenedge.h" | ||
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 "xdgshellclient.h" | | |||
29 | #include <kwineffects.h> | 28 | #include <kwineffects.h> | ||
30 | 29 | | |||
31 | #include <KWayland/Client/compositor.h> | 30 | #include <KWayland/Client/compositor.h> | ||
32 | #include <KWayland/Client/plasmawindowmanagement.h> | 31 | #include <KWayland/Client/plasmawindowmanagement.h> | ||
33 | #include <KWayland/Client/surface.h> | 32 | #include <KWayland/Client/surface.h> | ||
34 | #include <KWayland/Server/seat_interface.h> | 33 | #include <KWayland/Server/seat_interface.h> | ||
35 | //screenlocker | 34 | //screenlocker | ||
36 | #include <KScreenLocker/KsldApp> | 35 | #include <KScreenLocker/KsldApp> | ||
Show All 26 Lines | |||||
63 | 62 | | |||
64 | private: | 63 | private: | ||
65 | PlasmaWindowManagement *m_windowManagement = nullptr; | 64 | PlasmaWindowManagement *m_windowManagement = nullptr; | ||
66 | KWayland::Client::Compositor *m_compositor = nullptr; | 65 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
67 | }; | 66 | }; | ||
68 | 67 | | |||
69 | void PlasmaWindowTest::initTestCase() | 68 | void PlasmaWindowTest::initTestCase() | ||
70 | { | 69 | { | ||
71 | qRegisterMetaType<KWin::XdgShellClient *>(); | | |||
72 | qRegisterMetaType<KWin::AbstractClient*>(); | 70 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
73 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 71 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
74 | QVERIFY(workspaceCreatedSpy.isValid()); | 72 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
75 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 73 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
76 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 74 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
77 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 75 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
78 | 76 | | |||
79 | kwinApp()->start(); | 77 | kwinApp()->start(); | ||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Line(s) | |||||
240 | { | 238 | { | ||
241 | // this test verifies that for a popup window no PlasmaWindow is sent to the client | 239 | // this test verifies that for a popup window no PlasmaWindow is sent to the client | ||
242 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | 240 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | ||
243 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | 241 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | ||
244 | 242 | | |||
245 | // first create the parent window | 243 | // first create the parent window | ||
246 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | 244 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | ||
247 | QScopedPointer<XdgShellSurface> parentShellSurface(Test::createXdgShellStableSurface(parentSurface.data())); | 245 | QScopedPointer<XdgShellSurface> parentShellSurface(Test::createXdgShellStableSurface(parentSurface.data())); | ||
248 | XdgShellClient *parentClient = Test::renderAndWaitForShown(parentSurface.data(), QSize(100, 50), Qt::blue); | 246 | AbstractClient *parentClient = Test::renderAndWaitForShown(parentSurface.data(), QSize(100, 50), Qt::blue); | ||
249 | QVERIFY(parentClient); | 247 | QVERIFY(parentClient); | ||
250 | QVERIFY(plasmaWindowCreatedSpy.wait()); | 248 | QVERIFY(plasmaWindowCreatedSpy.wait()); | ||
251 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | 249 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | ||
252 | 250 | | |||
253 | // now let's create a popup window for it | 251 | // now let's create a popup window for it | ||
254 | XdgPositioner positioner(QSize(10, 10), QRect(0, 0, 10, 10)); | 252 | XdgPositioner positioner(QSize(10, 10), QRect(0, 0, 10, 10)); | ||
255 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | 253 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||
256 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | 254 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||
257 | QScopedPointer<Surface> popupSurface(Test::createSurface()); | 255 | QScopedPointer<Surface> popupSurface(Test::createSurface()); | ||
258 | QScopedPointer<XdgShellPopup> popupShellSurface(Test::createXdgShellStablePopup(popupSurface.data(), parentShellSurface.data(), positioner)); | 256 | QScopedPointer<XdgShellPopup> popupShellSurface(Test::createXdgShellStablePopup(popupSurface.data(), parentShellSurface.data(), positioner)); | ||
259 | XdgShellClient *popupClient = Test::renderAndWaitForShown(popupSurface.data(), positioner.initialSize(), Qt::blue); | 257 | AbstractClient *popupClient = Test::renderAndWaitForShown(popupSurface.data(), positioner.initialSize(), Qt::blue); | ||
260 | QVERIFY(popupClient); | 258 | QVERIFY(popupClient); | ||
261 | QVERIFY(!plasmaWindowCreatedSpy.wait(100)); | 259 | QVERIFY(!plasmaWindowCreatedSpy.wait(100)); | ||
262 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | 260 | QCOMPARE(plasmaWindowCreatedSpy.count(), 1); | ||
263 | 261 | | |||
264 | // let's destroy the windows | 262 | // let's destroy the windows | ||
265 | popupShellSurface.reset(); | 263 | popupShellSurface.reset(); | ||
266 | QVERIFY(Test::waitForWindowDestroyed(popupClient)); | 264 | QVERIFY(Test::waitForWindowDestroyed(popupClient)); | ||
267 | parentShellSurface.reset(); | 265 | parentShellSurface.reset(); | ||
268 | QVERIFY(Test::waitForWindowDestroyed(parentClient)); | 266 | QVERIFY(Test::waitForWindowDestroyed(parentClient)); | ||
269 | } | 267 | } | ||
270 | 268 | | |||
271 | void PlasmaWindowTest::testLockScreenNoPlasmaWindow() | 269 | void PlasmaWindowTest::testLockScreenNoPlasmaWindow() | ||
272 | { | 270 | { | ||
273 | // this test verifies that lock screen windows are not exposed to PlasmaWindow | 271 | // this test verifies that lock screen windows are not exposed to PlasmaWindow | ||
274 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | 272 | QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); | ||
275 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | 273 | QVERIFY(plasmaWindowCreatedSpy.isValid()); | ||
276 | 274 | | |||
277 | // this time we use a QSignalSpy on XdgShellClient as it'a a little bit more complex setup | 275 | // this time we use a QSignalSpy on XdgShellClient as it'a a little bit more complex setup | ||
278 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 276 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
279 | QVERIFY(clientAddedSpy.isValid()); | 277 | QVERIFY(clientAddedSpy.isValid()); | ||
280 | // lock | 278 | // lock | ||
281 | ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); | 279 | ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); | ||
282 | QVERIFY(clientAddedSpy.wait()); | 280 | QVERIFY(clientAddedSpy.wait()); | ||
283 | QVERIFY(clientAddedSpy.first().first().value<XdgShellClient *>()->isLockScreen()); | 281 | QVERIFY(clientAddedSpy.first().first().value<AbstractClient *>()->isLockScreen()); | ||
284 | // should not be sent to the client | 282 | // should not be sent to the client | ||
285 | QVERIFY(plasmaWindowCreatedSpy.isEmpty()); | 283 | QVERIFY(plasmaWindowCreatedSpy.isEmpty()); | ||
286 | QVERIFY(!plasmaWindowCreatedSpy.wait()); | 284 | QVERIFY(!plasmaWindowCreatedSpy.wait()); | ||
287 | 285 | | |||
288 | // fake unlock | 286 | // fake unlock | ||
289 | QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); | 287 | QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); | ||
290 | QVERIFY(lockStateChangedSpy.isValid()); | 288 | QVERIFY(lockStateChangedSpy.isValid()); | ||
291 | const auto children = ScreenLocker::KSldApp::self()->children(); | 289 | const auto children = ScreenLocker::KSldApp::self()->children(); | ||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |