Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/move_resize_window_test.cpp
Show All 24 Lines | |||||
25 | #include "effects.h" | 25 | #include "effects.h" | ||
26 | #include "screens.h" | 26 | #include "screens.h" | ||
27 | #include "wayland_server.h" | 27 | #include "wayland_server.h" | ||
28 | #include "workspace.h" | 28 | #include "workspace.h" | ||
29 | #include "shell_client.h" | 29 | #include "shell_client.h" | ||
30 | 30 | | |||
31 | #include <KWayland/Client/connection_thread.h> | 31 | #include <KWayland/Client/connection_thread.h> | ||
32 | #include <KWayland/Client/compositor.h> | 32 | #include <KWayland/Client/compositor.h> | ||
33 | #include <KWayland/Client/event_queue.h> | | |||
34 | #include <KWayland/Client/registry.h> | | |||
35 | #include <KWayland/Client/plasmashell.h> | 33 | #include <KWayland/Client/plasmashell.h> | ||
36 | #include <KWayland/Client/shell.h> | 34 | #include <KWayland/Client/shell.h> | ||
37 | #include <KWayland/Client/shm_pool.h> | | |||
38 | #include <KWayland/Client/surface.h> | 35 | #include <KWayland/Client/surface.h> | ||
39 | 36 | | |||
40 | #include <linux/input.h> | 37 | #include <linux/input.h> | ||
41 | #include <xcb/xcb_icccm.h> | 38 | #include <xcb/xcb_icccm.h> | ||
42 | 39 | | |||
43 | Q_DECLARE_METATYPE(KWin::AbstractClient::QuickTileMode) | 40 | Q_DECLARE_METATYPE(KWin::AbstractClient::QuickTileMode) | ||
44 | Q_DECLARE_METATYPE(KWin::MaximizeMode) | 41 | Q_DECLARE_METATYPE(KWin::MaximizeMode) | ||
45 | 42 | | |||
Show All 20 Lines | 51 | private Q_SLOTS: | |||
66 | void testPointerMoveEnd(); | 63 | void testPointerMoveEnd(); | ||
67 | void testPlasmaShellSurfaceMovable_data(); | 64 | void testPlasmaShellSurfaceMovable_data(); | ||
68 | void testPlasmaShellSurfaceMovable(); | 65 | void testPlasmaShellSurfaceMovable(); | ||
69 | void testNetMove(); | 66 | void testNetMove(); | ||
70 | 67 | | |||
71 | private: | 68 | private: | ||
72 | KWayland::Client::ConnectionThread *m_connection = nullptr; | 69 | KWayland::Client::ConnectionThread *m_connection = nullptr; | ||
73 | KWayland::Client::Compositor *m_compositor = nullptr; | 70 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
74 | KWayland::Client::ShmPool *m_shm = nullptr; | | |||
75 | KWayland::Client::Shell *m_shell = nullptr; | 71 | KWayland::Client::Shell *m_shell = nullptr; | ||
76 | KWayland::Client::PlasmaShell *m_plasmaShell = nullptr; | | |||
77 | KWayland::Client::EventQueue *m_queue = nullptr; | | |||
78 | QThread *m_thread = nullptr; | | |||
79 | }; | 72 | }; | ||
80 | 73 | | |||
81 | void MoveResizeWindowTest::initTestCase() | 74 | void MoveResizeWindowTest::initTestCase() | ||
82 | { | 75 | { | ||
83 | qRegisterMetaType<KWin::ShellClient*>(); | 76 | qRegisterMetaType<KWin::ShellClient*>(); | ||
84 | qRegisterMetaType<KWin::AbstractClient*>(); | 77 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
85 | qRegisterMetaType<KWin::MaximizeMode>("MaximizeMode"); | 78 | qRegisterMetaType<KWin::MaximizeMode>("MaximizeMode"); | ||
86 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 79 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
87 | QVERIFY(workspaceCreatedSpy.isValid()); | 80 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
88 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 81 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
89 | waylandServer()->init(s_socketName.toLocal8Bit()); | 82 | waylandServer()->init(s_socketName.toLocal8Bit()); | ||
90 | kwinApp()->start(); | 83 | kwinApp()->start(); | ||
91 | QVERIFY(workspaceCreatedSpy.wait()); | 84 | QVERIFY(workspaceCreatedSpy.wait()); | ||
92 | QCOMPARE(screens()->count(), 1); | 85 | QCOMPARE(screens()->count(), 1); | ||
93 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 86 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
94 | } | 87 | } | ||
95 | 88 | | |||
96 | void MoveResizeWindowTest::init() | 89 | void MoveResizeWindowTest::init() | ||
97 | { | 90 | { | ||
98 | using namespace KWayland::Client; | 91 | QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::PlasmaShell)); | ||
99 | // setup connection | 92 | m_connection = Test::waylandConnection(); | ||
100 | m_connection = new ConnectionThread; | 93 | m_compositor = Test::waylandCompositor(); | ||
101 | QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected); | 94 | m_shell = Test::waylandShell(); | ||
102 | QVERIFY(connectedSpy.isValid()); | | |||
103 | m_connection->setSocketName(s_socketName); | | |||
104 | | ||||
105 | m_thread = new QThread(this); | | |||
106 | m_connection->moveToThread(m_thread); | | |||
107 | m_thread->start(); | | |||
108 | | ||||
109 | m_connection->initConnection(); | | |||
110 | QVERIFY(connectedSpy.wait()); | | |||
111 | | ||||
112 | m_queue = new EventQueue(this); | | |||
113 | QVERIFY(!m_queue->isValid()); | | |||
114 | m_queue->setup(m_connection); | | |||
115 | QVERIFY(m_queue->isValid()); | | |||
116 | | ||||
117 | Registry registry; | | |||
118 | registry.setEventQueue(m_queue); | | |||
119 | QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced); | | |||
120 | QSignalSpy shmSpy(®istry, &Registry::shmAnnounced); | | |||
121 | QSignalSpy shellSpy(®istry, &Registry::shellAnnounced); | | |||
122 | QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced); | | |||
123 | QVERIFY(allAnnounced.isValid()); | | |||
124 | QVERIFY(shmSpy.isValid()); | | |||
125 | QVERIFY(shellSpy.isValid()); | | |||
126 | QVERIFY(compositorSpy.isValid()); | | |||
127 | registry.create(m_connection->display()); | | |||
128 | QVERIFY(registry.isValid()); | | |||
129 | registry.setup(); | | |||
130 | QVERIFY(allAnnounced.wait()); | | |||
131 | QVERIFY(!compositorSpy.isEmpty()); | | |||
132 | QVERIFY(!shmSpy.isEmpty()); | | |||
133 | QVERIFY(!shellSpy.isEmpty()); | | |||
134 | | ||||
135 | m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this); | | |||
136 | QVERIFY(m_compositor->isValid()); | | |||
137 | m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this); | | |||
138 | QVERIFY(m_shm->isValid()); | | |||
139 | m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this); | | |||
140 | QVERIFY(m_shell->isValid()); | | |||
141 | m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name, registry.interface(Registry::Interface::PlasmaShell).version, this); | | |||
142 | QVERIFY(m_plasmaShell->isValid()); | | |||
143 | 95 | | |||
144 | screens()->setCurrent(0); | 96 | screens()->setCurrent(0); | ||
145 | } | 97 | } | ||
146 | 98 | | |||
147 | void MoveResizeWindowTest::cleanup() | 99 | void MoveResizeWindowTest::cleanup() | ||
148 | { | 100 | { | ||
149 | delete m_compositor; | 101 | Test::destroyWaylandConnection(); | ||
150 | m_compositor = nullptr; | | |||
151 | delete m_shm; | | |||
152 | m_shm = nullptr; | | |||
153 | delete m_shell; | | |||
154 | m_shell = nullptr; | | |||
155 | delete m_plasmaShell; | | |||
156 | m_plasmaShell = nullptr; | | |||
157 | delete m_queue; | | |||
158 | m_queue = nullptr; | | |||
159 | if (m_thread) { | | |||
160 | m_thread->quit(); | | |||
161 | m_thread->wait(); | | |||
162 | delete m_thread; | | |||
163 | m_thread = nullptr; | | |||
164 | } | | |||
165 | | ||||
166 | } | 102 | } | ||
167 | 103 | | |||
168 | void MoveResizeWindowTest::testMove() | 104 | void MoveResizeWindowTest::testMove() | ||
169 | { | 105 | { | ||
170 | using namespace KWayland::Client; | 106 | using namespace KWayland::Client; | ||
171 | 107 | | |||
172 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 108 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
173 | QVERIFY(clientAddedSpy.isValid()); | 109 | QVERIFY(clientAddedSpy.isValid()); | ||
174 | 110 | | |||
175 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 111 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
176 | QVERIFY(!surface.isNull()); | 112 | QVERIFY(!surface.isNull()); | ||
177 | 113 | | |||
178 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 114 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
179 | QVERIFY(!shellSurface.isNull()); | 115 | QVERIFY(!shellSurface.isNull()); | ||
180 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 116 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | ||
181 | QVERIFY(sizeChangeSpy.isValid()); | 117 | QVERIFY(sizeChangeSpy.isValid()); | ||
182 | // let's render | 118 | // let's render | ||
183 | QImage img(QSize(100, 50), QImage::Format_ARGB32); | 119 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
184 | img.fill(Qt::blue); | | |||
185 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
186 | surface->damage(QRect(0, 0, 100, 50)); | | |||
187 | surface->commit(Surface::CommitFlag::None); | | |||
188 | 120 | | |||
189 | m_connection->flush(); | 121 | m_connection->flush(); | ||
190 | QVERIFY(clientAddedSpy.wait()); | 122 | QVERIFY(clientAddedSpy.wait()); | ||
191 | AbstractClient *c = workspace()->activeClient(); | 123 | AbstractClient *c = workspace()->activeClient(); | ||
192 | QVERIFY(c); | 124 | QVERIFY(c); | ||
193 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | 125 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | ||
194 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | 126 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | ||
195 | QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged); | 127 | QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
269 | 201 | | |||
270 | void MoveResizeWindowTest::testPackTo() | 202 | void MoveResizeWindowTest::testPackTo() | ||
271 | { | 203 | { | ||
272 | using namespace KWayland::Client; | 204 | using namespace KWayland::Client; | ||
273 | 205 | | |||
274 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 206 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
275 | QVERIFY(clientAddedSpy.isValid()); | 207 | QVERIFY(clientAddedSpy.isValid()); | ||
276 | 208 | | |||
277 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 209 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
278 | QVERIFY(!surface.isNull()); | 210 | QVERIFY(!surface.isNull()); | ||
279 | 211 | | |||
280 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 212 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
281 | QVERIFY(!shellSurface.isNull()); | 213 | QVERIFY(!shellSurface.isNull()); | ||
282 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 214 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | ||
283 | QVERIFY(sizeChangeSpy.isValid()); | 215 | QVERIFY(sizeChangeSpy.isValid()); | ||
284 | // let's render | 216 | // let's render | ||
285 | QImage img(QSize(100, 50), QImage::Format_ARGB32); | 217 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
286 | img.fill(Qt::blue); | | |||
287 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
288 | surface->damage(QRect(0, 0, 100, 50)); | | |||
289 | surface->commit(Surface::CommitFlag::None); | | |||
290 | 218 | | |||
291 | m_connection->flush(); | 219 | m_connection->flush(); | ||
292 | QVERIFY(clientAddedSpy.wait()); | 220 | QVERIFY(clientAddedSpy.wait()); | ||
293 | AbstractClient *c = workspace()->activeClient(); | 221 | AbstractClient *c = workspace()->activeClient(); | ||
294 | QVERIFY(c); | 222 | QVERIFY(c); | ||
295 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | 223 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | ||
296 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | 224 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | ||
297 | 225 | | |||
Show All 19 Lines | |||||
317 | 245 | | |||
318 | void MoveResizeWindowTest::testPackAgainstClient() | 246 | void MoveResizeWindowTest::testPackAgainstClient() | ||
319 | { | 247 | { | ||
320 | using namespace KWayland::Client; | 248 | using namespace KWayland::Client; | ||
321 | 249 | | |||
322 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 250 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
323 | QVERIFY(clientAddedSpy.isValid()); | 251 | QVERIFY(clientAddedSpy.isValid()); | ||
324 | 252 | | |||
325 | QScopedPointer<Surface> surface1(m_compositor->createSurface()); | 253 | QScopedPointer<Surface> surface1(Test::createSurface()); | ||
326 | QVERIFY(!surface1.isNull()); | 254 | QVERIFY(!surface1.isNull()); | ||
327 | QScopedPointer<Surface> surface2(m_compositor->createSurface()); | 255 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
328 | QVERIFY(!surface2.isNull()); | 256 | QVERIFY(!surface2.isNull()); | ||
329 | QScopedPointer<Surface> surface3(m_compositor->createSurface()); | 257 | QScopedPointer<Surface> surface3(Test::createSurface()); | ||
330 | QVERIFY(!surface3.isNull()); | 258 | QVERIFY(!surface3.isNull()); | ||
331 | QScopedPointer<Surface> surface4(m_compositor->createSurface()); | 259 | QScopedPointer<Surface> surface4(Test::createSurface()); | ||
332 | QVERIFY(!surface4.isNull()); | 260 | QVERIFY(!surface4.isNull()); | ||
333 | 261 | | |||
334 | QScopedPointer<ShellSurface> shellSurface1(m_shell->createSurface(surface1.data())); | 262 | QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data())); | ||
335 | QVERIFY(!shellSurface1.isNull()); | 263 | QVERIFY(!shellSurface1.isNull()); | ||
336 | QScopedPointer<ShellSurface> shellSurface2(m_shell->createSurface(surface2.data())); | 264 | QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data())); | ||
337 | QVERIFY(!shellSurface2.isNull()); | 265 | QVERIFY(!shellSurface2.isNull()); | ||
338 | QScopedPointer<ShellSurface> shellSurface3(m_shell->createSurface(surface3.data())); | 266 | QScopedPointer<ShellSurface> shellSurface3(Test::createShellSurface(surface3.data())); | ||
339 | QVERIFY(!shellSurface3.isNull()); | 267 | QVERIFY(!shellSurface3.isNull()); | ||
340 | QScopedPointer<ShellSurface> shellSurface4(m_shell->createSurface(surface4.data())); | 268 | QScopedPointer<ShellSurface> shellSurface4(Test::createShellSurface(surface4.data())); | ||
341 | QVERIFY(!shellSurface4.isNull()); | 269 | QVERIFY(!shellSurface4.isNull()); | ||
342 | auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { | 270 | auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { | ||
343 | // let's render | 271 | // let's render | ||
344 | QImage img(QSize(10, 10), QImage::Format_ARGB32); | 272 | Test::render(surface, QSize(10, 10), Qt::blue); | ||
345 | img.fill(Qt::blue); | | |||
346 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
347 | surface->damage(QRect(0, 0, 10, 10)); | | |||
348 | surface->commit(Surface::CommitFlag::None); | | |||
349 | 273 | | |||
350 | m_connection->flush(); | 274 | m_connection->flush(); | ||
351 | QVERIFY(clientAddedSpy.wait()); | 275 | QVERIFY(clientAddedSpy.wait()); | ||
352 | AbstractClient *c = workspace()->activeClient(); | 276 | AbstractClient *c = workspace()->activeClient(); | ||
353 | QVERIFY(c); | 277 | QVERIFY(c); | ||
354 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | 278 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | ||
355 | QCOMPARE(c->geometry().size(), QSize(10, 10)); | 279 | QCOMPARE(c->geometry().size(), QSize(10, 10)); | ||
356 | clientAddedSpy.clear(); | 280 | clientAddedSpy.clear(); | ||
357 | // let's place it centered | 281 | // let's place it centered | ||
358 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | 282 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | ||
359 | QCOMPARE(c->geometry(), QRect(635, 507, 10, 10)); | 283 | QCOMPARE(c->geometry(), QRect(635, 507, 10, 10)); | ||
360 | QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); | 284 | QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); | ||
361 | QCOMPARE(c->geometry(), expectedGeometry); | 285 | QCOMPARE(c->geometry(), expectedGeometry); | ||
362 | }; | 286 | }; | ||
363 | renderWindow(surface1.data(), QStringLiteral("slotWindowPackLeft"), QRect(0, 507, 10, 10)); | 287 | renderWindow(surface1.data(), QStringLiteral("slotWindowPackLeft"), QRect(0, 507, 10, 10)); | ||
364 | renderWindow(surface2.data(), QStringLiteral("slotWindowPackUp"), QRect(635, 0, 10, 10)); | 288 | renderWindow(surface2.data(), QStringLiteral("slotWindowPackUp"), QRect(635, 0, 10, 10)); | ||
365 | renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10)); | 289 | renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10)); | ||
366 | renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10)); | 290 | renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10)); | ||
367 | 291 | | |||
368 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 292 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
369 | QVERIFY(!surface.isNull()); | 293 | QVERIFY(!surface.isNull()); | ||
370 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 294 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
371 | QVERIFY(!shellSurface.isNull()); | 295 | QVERIFY(!shellSurface.isNull()); | ||
372 | QImage img(QSize(100, 50), QImage::Format_ARGB32); | 296 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
373 | img.fill(Qt::blue); | | |||
374 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
375 | surface->damage(QRect(0, 0, 100, 50)); | | |||
376 | surface->commit(Surface::CommitFlag::None); | | |||
377 | 297 | | |||
378 | m_connection->flush(); | 298 | m_connection->flush(); | ||
379 | QVERIFY(clientAddedSpy.wait()); | 299 | QVERIFY(clientAddedSpy.wait()); | ||
380 | AbstractClient *c = workspace()->activeClient(); | 300 | AbstractClient *c = workspace()->activeClient(); | ||
381 | QVERIFY(c); | 301 | QVERIFY(c); | ||
382 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | 302 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | ||
383 | // let's place it centered | 303 | // let's place it centered | ||
384 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | 304 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | ||
Show All 17 Lines | |||||
402 | 322 | | |||
403 | void MoveResizeWindowTest::testGrowShrink() | 323 | void MoveResizeWindowTest::testGrowShrink() | ||
404 | { | 324 | { | ||
405 | using namespace KWayland::Client; | 325 | using namespace KWayland::Client; | ||
406 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 326 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
407 | QVERIFY(clientAddedSpy.isValid()); | 327 | QVERIFY(clientAddedSpy.isValid()); | ||
408 | 328 | | |||
409 | // block geometry helper | 329 | // block geometry helper | ||
410 | QScopedPointer<Surface> surface1(m_compositor->createSurface()); | 330 | QScopedPointer<Surface> surface1(Test::createSurface()); | ||
411 | QVERIFY(!surface1.isNull()); | 331 | QVERIFY(!surface1.isNull()); | ||
412 | QScopedPointer<ShellSurface> shellSurface1(m_shell->createSurface(surface1.data())); | 332 | QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data())); | ||
413 | QVERIFY(!shellSurface1.isNull()); | 333 | QVERIFY(!shellSurface1.isNull()); | ||
414 | QImage img1(QSize(650, 514), QImage::Format_ARGB32); | 334 | Test::render(surface1.data(), QSize(650, 514), Qt::blue); | ||
415 | img1.fill(Qt::blue); | | |||
416 | surface1->attachBuffer(m_shm->createBuffer(img1)); | | |||
417 | surface1->damage(QRect(0, 0, 650, 514)); | | |||
418 | surface1->commit(Surface::CommitFlag::None); | | |||
419 | m_connection->flush(); | 335 | m_connection->flush(); | ||
420 | QVERIFY(clientAddedSpy.wait()); | 336 | QVERIFY(clientAddedSpy.wait()); | ||
421 | clientAddedSpy.clear(); | 337 | clientAddedSpy.clear(); | ||
422 | workspace()->slotWindowPackRight(); | 338 | workspace()->slotWindowPackRight(); | ||
423 | workspace()->slotWindowPackDown(); | 339 | workspace()->slotWindowPackDown(); | ||
424 | 340 | | |||
425 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 341 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
426 | QVERIFY(!surface.isNull()); | 342 | QVERIFY(!surface.isNull()); | ||
427 | 343 | | |||
428 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 344 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
429 | QVERIFY(!shellSurface.isNull()); | 345 | QVERIFY(!shellSurface.isNull()); | ||
430 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 346 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | ||
431 | QVERIFY(sizeChangeSpy.isValid()); | 347 | QVERIFY(sizeChangeSpy.isValid()); | ||
432 | // let's render | 348 | // let's render | ||
433 | QImage img(QSize(100, 50), QImage::Format_ARGB32); | 349 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
434 | img.fill(Qt::blue); | | |||
435 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
436 | surface->damage(QRect(0, 0, 100, 50)); | | |||
437 | surface->commit(Surface::CommitFlag::None); | | |||
438 | 350 | | |||
439 | m_connection->flush(); | 351 | m_connection->flush(); | ||
440 | QVERIFY(clientAddedSpy.wait()); | 352 | QVERIFY(clientAddedSpy.wait()); | ||
441 | AbstractClient *c = workspace()->activeClient(); | 353 | AbstractClient *c = workspace()->activeClient(); | ||
442 | QVERIFY(c); | 354 | QVERIFY(c); | ||
443 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | 355 | QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | ||
444 | 356 | | |||
445 | // let's place it centered | 357 | // let's place it centered | ||
446 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | 358 | Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); | ||
447 | QCOMPARE(c->geometry(), QRect(590, 487, 100, 50)); | 359 | QCOMPARE(c->geometry(), QRect(590, 487, 100, 50)); | ||
448 | 360 | | |||
449 | QFETCH(QString, methodCall); | 361 | QFETCH(QString, methodCall); | ||
450 | QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); | 362 | QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); | ||
451 | QVERIFY(sizeChangeSpy.wait()); | 363 | QVERIFY(sizeChangeSpy.wait()); | ||
452 | QImage img2(shellSurface->size(), QImage::Format_ARGB32); | 364 | Test::render(surface.data(), shellSurface->size(), Qt::red); | ||
453 | img2.fill(Qt::red); | | |||
454 | surface->attachBuffer(m_shm->createBuffer(img2)); | | |||
455 | surface->damage(QRect(QPoint(0, 0), shellSurface->size())); | | |||
456 | surface->commit(Surface::CommitFlag::None); | | |||
457 | 365 | | |||
458 | QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged); | 366 | QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged); | ||
459 | QVERIFY(geometryChangedSpy.isValid()); | 367 | QVERIFY(geometryChangedSpy.isValid()); | ||
460 | m_connection->flush(); | 368 | m_connection->flush(); | ||
461 | QVERIFY(geometryChangedSpy.wait()); | 369 | QVERIFY(geometryChangedSpy.wait()); | ||
462 | QTEST(c->geometry(), "expectedGeometry"); | 370 | QTEST(c->geometry(), "expectedGeometry"); | ||
463 | } | 371 | } | ||
464 | 372 | | |||
Show All 16 Lines | |||||
481 | void MoveResizeWindowTest::testPointerMoveEnd() | 389 | void MoveResizeWindowTest::testPointerMoveEnd() | ||
482 | { | 390 | { | ||
483 | // this test verifies that moving a window through pointer only ends if all buttons are released | 391 | // this test verifies that moving a window through pointer only ends if all buttons are released | ||
484 | using namespace KWayland::Client; | 392 | using namespace KWayland::Client; | ||
485 | 393 | | |||
486 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 394 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
487 | QVERIFY(clientAddedSpy.isValid()); | 395 | QVERIFY(clientAddedSpy.isValid()); | ||
488 | 396 | | |||
489 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 397 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
490 | QVERIFY(!surface.isNull()); | 398 | QVERIFY(!surface.isNull()); | ||
491 | 399 | | |||
492 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 400 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
493 | QVERIFY(!shellSurface.isNull()); | 401 | QVERIFY(!shellSurface.isNull()); | ||
494 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | 402 | QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); | ||
495 | QVERIFY(sizeChangeSpy.isValid()); | 403 | QVERIFY(sizeChangeSpy.isValid()); | ||
496 | // let's render | 404 | // let's render | ||
497 | QImage img(QSize(100, 50), QImage::Format_ARGB32); | 405 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
498 | img.fill(Qt::blue); | | |||
499 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
500 | surface->damage(QRect(0, 0, 100, 50)); | | |||
501 | surface->commit(Surface::CommitFlag::None); | | |||
502 | 406 | | |||
503 | m_connection->flush(); | 407 | m_connection->flush(); | ||
504 | QVERIFY(clientAddedSpy.wait()); | 408 | QVERIFY(clientAddedSpy.wait()); | ||
505 | AbstractClient *c = workspace()->activeClient(); | 409 | AbstractClient *c = workspace()->activeClient(); | ||
506 | QVERIFY(c); | 410 | QVERIFY(c); | ||
507 | QVERIFY(!c->isMove()); | 411 | QVERIFY(!c->isMove()); | ||
508 | 412 | | |||
509 | // let's trigger the left button | 413 | // let's trigger the left button | ||
Show All 32 Lines | |||||
542 | 446 | | |||
543 | void MoveResizeWindowTest::testPlasmaShellSurfaceMovable() | 447 | void MoveResizeWindowTest::testPlasmaShellSurfaceMovable() | ||
544 | { | 448 | { | ||
545 | // this test verifies that certain window types from PlasmaShellSurface are not moveable or resizable | 449 | // this test verifies that certain window types from PlasmaShellSurface are not moveable or resizable | ||
546 | using namespace KWayland::Client; | 450 | using namespace KWayland::Client; | ||
547 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 451 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
548 | QVERIFY(clientAddedSpy.isValid()); | 452 | QVERIFY(clientAddedSpy.isValid()); | ||
549 | 453 | | |||
550 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 454 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
551 | QVERIFY(!surface.isNull()); | 455 | QVERIFY(!surface.isNull()); | ||
552 | 456 | | |||
553 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 457 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
554 | QVERIFY(!shellSurface.isNull()); | 458 | QVERIFY(!shellSurface.isNull()); | ||
555 | // and a PlasmaShellSurface | 459 | // and a PlasmaShellSurface | ||
556 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | 460 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data())); | ||
557 | QVERIFY(!plasmaSurface.isNull()); | 461 | QVERIFY(!plasmaSurface.isNull()); | ||
558 | QFETCH(KWayland::Client::PlasmaShellSurface::Role, role); | 462 | QFETCH(KWayland::Client::PlasmaShellSurface::Role, role); | ||
559 | plasmaSurface->setRole(role); | 463 | plasmaSurface->setRole(role); | ||
560 | // let's render | 464 | // let's render | ||
561 | QImage img(QSize(100, 50), QImage::Format_ARGB32); | 465 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
562 | img.fill(Qt::blue); | | |||
563 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
564 | surface->damage(QRect(0, 0, 100, 50)); | | |||
565 | surface->commit(Surface::CommitFlag::None); | | |||
566 | 466 | | |||
567 | m_connection->flush(); | 467 | m_connection->flush(); | ||
568 | QVERIFY(clientAddedSpy.wait()); | 468 | QVERIFY(clientAddedSpy.wait()); | ||
569 | AbstractClient *c = clientAddedSpy.first().first().value<AbstractClient*>(); | 469 | AbstractClient *c = clientAddedSpy.first().first().value<AbstractClient*>(); | ||
570 | QVERIFY(c); | 470 | QVERIFY(c); | ||
571 | QTEST(c->isMovable(), "movable"); | 471 | QTEST(c->isMovable(), "movable"); | ||
572 | QTEST(c->isMovableAcrossScreens(), "movableAcrossScreens"); | 472 | QTEST(c->isMovableAcrossScreens(), "movableAcrossScreens"); | ||
573 | QTEST(c->isResizable(), "resizable"); | 473 | QTEST(c->isResizable(), "resizable"); | ||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |