Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/lockscreen.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/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/keyboard.h> | 33 | #include <KWayland/Client/keyboard.h> | ||
35 | #include <KWayland/Client/registry.h> | 34 | #include <KWayland/Client/registry.h> | ||
36 | #include <KWayland/Client/pointer.h> | 35 | #include <KWayland/Client/pointer.h> | ||
37 | #include <KWayland/Client/shell.h> | 36 | #include <KWayland/Client/shell.h> | ||
38 | #include <KWayland/Client/seat.h> | 37 | #include <KWayland/Client/seat.h> | ||
39 | #include <KWayland/Client/shm_pool.h> | 38 | #include <KWayland/Client/shm_pool.h> | ||
40 | #include <KWayland/Client/surface.h> | 39 | #include <KWayland/Client/surface.h> | ||
41 | #include <KWayland/Client/touch.h> | 40 | #include <KWayland/Client/touch.h> | ||
Show All 36 Lines | |||||
78 | private: | 77 | private: | ||
79 | void unlock(); | 78 | void unlock(); | ||
80 | AbstractClient *showWindow(); | 79 | AbstractClient *showWindow(); | ||
81 | KWayland::Client::ConnectionThread *m_connection = nullptr; | 80 | KWayland::Client::ConnectionThread *m_connection = nullptr; | ||
82 | KWayland::Client::Compositor *m_compositor = nullptr; | 81 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
83 | KWayland::Client::Seat *m_seat = nullptr; | 82 | KWayland::Client::Seat *m_seat = nullptr; | ||
84 | KWayland::Client::ShmPool *m_shm = nullptr; | 83 | KWayland::Client::ShmPool *m_shm = nullptr; | ||
85 | KWayland::Client::Shell *m_shell = nullptr; | 84 | KWayland::Client::Shell *m_shell = nullptr; | ||
86 | KWayland::Client::EventQueue *m_queue = nullptr; | | |||
87 | QThread *m_thread = nullptr; | | |||
88 | }; | 85 | }; | ||
89 | 86 | | |||
90 | class HelperEffect : public Effect | 87 | class HelperEffect : public Effect | ||
91 | { | 88 | { | ||
92 | Q_OBJECT | 89 | Q_OBJECT | ||
93 | public: | 90 | public: | ||
94 | HelperEffect() {} | 91 | HelperEffect() {} | ||
95 | ~HelperEffect() {} | 92 | ~HelperEffect() {} | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 158 | #define VERIFY(statement) \ | |||
162 | if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ | 159 | if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ | ||
163 | return nullptr; | 160 | return nullptr; | ||
164 | #define COMPARE(actual, expected) \ | 161 | #define COMPARE(actual, expected) \ | ||
165 | if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ | 162 | if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ | ||
166 | return nullptr; | 163 | return nullptr; | ||
167 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 164 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
168 | VERIFY(clientAddedSpy.isValid()); | 165 | VERIFY(clientAddedSpy.isValid()); | ||
169 | 166 | | |||
170 | Surface *surface = m_compositor->createSurface(m_compositor); | 167 | Surface *surface = Test::createSurface(m_compositor); | ||
171 | VERIFY(surface); | 168 | VERIFY(surface); | ||
172 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 169 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
173 | VERIFY(shellSurface); | 170 | VERIFY(shellSurface); | ||
174 | // let's render | 171 | // let's render | ||
175 | QImage img(QSize(100, 50), QImage::Format_ARGB32); | 172 | Test::render(surface, QSize(100, 50), Qt::blue); | ||
176 | img.fill(Qt::blue); | | |||
177 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
178 | surface->damage(QRect(0, 0, 100, 50)); | | |||
179 | surface->commit(Surface::CommitFlag::None); | | |||
180 | 173 | | |||
181 | m_connection->flush(); | 174 | m_connection->flush(); | ||
182 | VERIFY(clientAddedSpy.wait()); | 175 | VERIFY(clientAddedSpy.wait()); | ||
183 | AbstractClient *c = workspace()->activeClient(); | 176 | AbstractClient *c = workspace()->activeClient(); | ||
184 | VERIFY(c); | 177 | VERIFY(c); | ||
185 | COMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | 178 | COMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c); | ||
186 | 179 | | |||
187 | #undef VERIFY | 180 | #undef VERIFY | ||
Show All 19 Lines | 187 | { | |||
207 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 200 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
208 | setenv("QT_QPA_PLATFORM", "wayland", true); | 201 | setenv("QT_QPA_PLATFORM", "wayland", true); | ||
209 | setenv("QMLSCENE_DEVICE", "softwarecontext", true); | 202 | setenv("QMLSCENE_DEVICE", "softwarecontext", true); | ||
210 | waylandServer()->initWorkspace(); | 203 | waylandServer()->initWorkspace(); | ||
211 | } | 204 | } | ||
212 | 205 | | |||
213 | void LockScreenTest::init() | 206 | void LockScreenTest::init() | ||
214 | { | 207 | { | ||
215 | using namespace KWayland::Client; | 208 | QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat)); | ||
216 | // setup connection | 209 | QVERIFY(Test::waitForWaylandPointer()); | ||
217 | m_connection = new ConnectionThread; | 210 | m_connection = Test::waylandConnection(); | ||
218 | QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected); | 211 | m_compositor = Test::waylandCompositor(); | ||
219 | QVERIFY(connectedSpy.isValid()); | 212 | m_shell = Test::waylandShell(); | ||
220 | m_connection->setSocketName(s_socketName); | 213 | m_shm = Test::waylandShmPool(); | ||
221 | 214 | m_seat = Test::waylandSeat(); | |||
222 | m_thread = new QThread(this); | | |||
223 | m_connection->moveToThread(m_thread); | | |||
224 | m_thread->start(); | | |||
225 | | ||||
226 | m_connection->initConnection(); | | |||
227 | QVERIFY(connectedSpy.wait()); | | |||
228 | | ||||
229 | m_queue = new EventQueue(this); | | |||
230 | QVERIFY(!m_queue->isValid()); | | |||
231 | m_queue->setup(m_connection); | | |||
232 | QVERIFY(m_queue->isValid()); | | |||
233 | | ||||
234 | Registry registry; | | |||
235 | registry.setEventQueue(m_queue); | | |||
236 | QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced); | | |||
237 | QSignalSpy shmSpy(®istry, &Registry::shmAnnounced); | | |||
238 | QSignalSpy shellSpy(®istry, &Registry::shellAnnounced); | | |||
239 | QSignalSpy seatSpy(®istry, &Registry::seatAnnounced); | | |||
240 | QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced); | | |||
241 | QVERIFY(allAnnounced.isValid()); | | |||
242 | QVERIFY(shmSpy.isValid()); | | |||
243 | QVERIFY(shellSpy.isValid()); | | |||
244 | QVERIFY(compositorSpy.isValid()); | | |||
245 | QVERIFY(seatSpy.isValid()); | | |||
246 | registry.create(m_connection->display()); | | |||
247 | QVERIFY(registry.isValid()); | | |||
248 | registry.setup(); | | |||
249 | QVERIFY(allAnnounced.wait()); | | |||
250 | QVERIFY(!compositorSpy.isEmpty()); | | |||
251 | QVERIFY(!shmSpy.isEmpty()); | | |||
252 | QVERIFY(!shellSpy.isEmpty()); | | |||
253 | QVERIFY(!seatSpy.isEmpty()); | | |||
254 | | ||||
255 | m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this); | | |||
256 | QVERIFY(m_compositor->isValid()); | | |||
257 | m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this); | | |||
258 | QVERIFY(m_shm->isValid()); | | |||
259 | m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this); | | |||
260 | QVERIFY(m_shell->isValid()); | | |||
261 | m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this); | | |||
262 | QVERIFY(m_seat->isValid()); | | |||
263 | QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged); | | |||
264 | QVERIFY(hasPointerSpy.isValid()); | | |||
265 | QVERIFY(hasPointerSpy.wait()); | | |||
266 | 215 | | |||
267 | screens()->setCurrent(0); | 216 | screens()->setCurrent(0); | ||
268 | Cursor::setPos(QPoint(640, 512)); | 217 | Cursor::setPos(QPoint(640, 512)); | ||
269 | } | 218 | } | ||
270 | 219 | | |||
271 | void LockScreenTest::cleanup() | 220 | void LockScreenTest::cleanup() | ||
272 | { | 221 | { | ||
273 | delete m_compositor; | 222 | Test::destroyWaylandConnection(); | ||
274 | m_compositor = nullptr; | | |||
275 | delete m_seat; | | |||
276 | m_seat = nullptr; | | |||
277 | delete m_shm; | | |||
278 | m_shm = nullptr; | | |||
279 | delete m_shell; | | |||
280 | m_shell = nullptr; | | |||
281 | delete m_queue; | | |||
282 | m_queue = nullptr; | | |||
283 | if (m_thread) { | | |||
284 | m_connection->deleteLater(); | | |||
285 | m_thread->quit(); | | |||
286 | m_thread->wait(); | | |||
287 | delete m_thread; | | |||
288 | m_thread = nullptr; | | |||
289 | m_connection = nullptr; | | |||
290 | } | | |||
291 | } | 223 | } | ||
292 | 224 | | |||
293 | void LockScreenTest::testPointer() | 225 | void LockScreenTest::testPointer() | ||
294 | { | 226 | { | ||
295 | using namespace KWayland::Client; | 227 | using namespace KWayland::Client; | ||
296 | 228 | | |||
297 | QScopedPointer<Pointer> pointer(m_seat->createPointer()); | 229 | QScopedPointer<Pointer> pointer(m_seat->createPointer()); | ||
298 | QVERIFY(!pointer.isNull()); | 230 | QVERIFY(!pointer.isNull()); | ||
▲ Show 20 Lines • Show All 523 Lines • Show Last 20 Lines |