Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_surface.cpp
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Line(s) | 225 | { | |||
---|---|---|---|---|---|
226 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | 226 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | ||
227 | QVERIFY(serverSurfaceCreated.isValid()); | 227 | QVERIFY(serverSurfaceCreated.isValid()); | ||
228 | KWayland::Client::Surface *s = m_compositor->createSurface(); | 228 | KWayland::Client::Surface *s = m_compositor->createSurface(); | ||
229 | QVERIFY(serverSurfaceCreated.wait()); | 229 | QVERIFY(serverSurfaceCreated.wait()); | ||
230 | KWayland::Server::SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWayland::Server::SurfaceInterface*>(); | 230 | KWayland::Server::SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWayland::Server::SurfaceInterface*>(); | ||
231 | QVERIFY(serverSurface); | 231 | QVERIFY(serverSurface); | ||
232 | QCOMPARE(serverSurface->damage(), QRegion()); | 232 | QCOMPARE(serverSurface->damage(), QRegion()); | ||
233 | QVERIFY(serverSurface->parentResource()); | 233 | QVERIFY(serverSurface->parentResource()); | ||
234 | QVERIFY(!serverSurface->isMapped()); | ||||
234 | 235 | | |||
235 | QSignalSpy damageSpy(serverSurface, SIGNAL(damaged(QRegion))); | 236 | QSignalSpy damageSpy(serverSurface, SIGNAL(damaged(QRegion))); | ||
236 | QVERIFY(damageSpy.isValid()); | 237 | QVERIFY(damageSpy.isValid()); | ||
237 | 238 | | |||
238 | // send damage without a buffer | 239 | // send damage without a buffer | ||
239 | s->damage(QRect(0, 0, 100, 100)); | 240 | s->damage(QRect(0, 0, 100, 100)); | ||
240 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 241 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
241 | wl_display_flush(m_connection->display()); | 242 | wl_display_flush(m_connection->display()); | ||
242 | QCoreApplication::processEvents(); | 243 | QCoreApplication::processEvents(); | ||
243 | QCoreApplication::processEvents(); | 244 | QCoreApplication::processEvents(); | ||
244 | QVERIFY(damageSpy.isEmpty()); | 245 | QVERIFY(damageSpy.isEmpty()); | ||
246 | QVERIFY(!serverSurface->isMapped()); | ||||
245 | 247 | | |||
246 | QImage img(QSize(10, 10), QImage::Format_ARGB32); | 248 | QImage img(QSize(10, 10), QImage::Format_ARGB32); | ||
247 | img.fill(Qt::black); | 249 | img.fill(Qt::black); | ||
248 | auto b = m_shm->createBuffer(img); | 250 | auto b = m_shm->createBuffer(img); | ||
249 | s->attachBuffer(b); | 251 | s->attachBuffer(b); | ||
250 | s->damage(QRect(0, 0, 10, 10)); | 252 | s->damage(QRect(0, 0, 10, 10)); | ||
251 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 253 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
252 | QVERIFY(damageSpy.wait()); | 254 | QVERIFY(damageSpy.wait()); | ||
253 | QCOMPARE(serverSurface->damage(), QRegion(0, 0, 10, 10)); | 255 | QCOMPARE(serverSurface->damage(), QRegion(0, 0, 10, 10)); | ||
254 | QCOMPARE(damageSpy.first().first().value<QRegion>(), QRegion(0, 0, 10, 10)); | 256 | QCOMPARE(damageSpy.first().first().value<QRegion>(), QRegion(0, 0, 10, 10)); | ||
257 | QVERIFY(serverSurface->isMapped()); | ||||
255 | 258 | | |||
256 | // damage multiple times | 259 | // damage multiple times | ||
257 | QRegion testRegion(5, 8, 3, 6); | 260 | QRegion testRegion(5, 8, 3, 6); | ||
258 | testRegion = testRegion.united(QRect(10, 20, 30, 15)); | 261 | testRegion = testRegion.united(QRect(10, 20, 30, 15)); | ||
259 | img = QImage(QSize(40, 35), QImage::Format_ARGB32); | 262 | img = QImage(QSize(40, 35), QImage::Format_ARGB32); | ||
260 | img.fill(Qt::black); | 263 | img.fill(Qt::black); | ||
261 | b = m_shm->createBuffer(img); | 264 | b = m_shm->createBuffer(img); | ||
262 | s->attachBuffer(b); | 265 | s->attachBuffer(b); | ||
263 | s->damage(testRegion); | 266 | s->damage(testRegion); | ||
264 | damageSpy.clear(); | 267 | damageSpy.clear(); | ||
265 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 268 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
266 | QVERIFY(damageSpy.wait()); | 269 | QVERIFY(damageSpy.wait()); | ||
267 | QCOMPARE(serverSurface->damage(), testRegion); | 270 | QCOMPARE(serverSurface->damage(), testRegion); | ||
268 | QCOMPARE(damageSpy.first().first().value<QRegion>(), testRegion); | 271 | QCOMPARE(damageSpy.first().first().value<QRegion>(), testRegion); | ||
272 | QVERIFY(serverSurface->isMapped()); | ||||
269 | } | 273 | } | ||
270 | 274 | | |||
271 | void TestWaylandSurface::testFrameCallback() | 275 | void TestWaylandSurface::testFrameCallback() | ||
272 | { | 276 | { | ||
273 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | 277 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | ||
274 | QVERIFY(serverSurfaceCreated.isValid()); | 278 | QVERIFY(serverSurfaceCreated.isValid()); | ||
275 | KWayland::Client::Surface *s = m_compositor->createSurface(); | 279 | KWayland::Client::Surface *s = m_compositor->createSurface(); | ||
276 | QVERIFY(serverSurfaceCreated.wait()); | 280 | QVERIFY(serverSurfaceCreated.wait()); | ||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 303 | { | |||
403 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 407 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
404 | wl_display_flush(m_connection->display()); | 408 | wl_display_flush(m_connection->display()); | ||
405 | QCoreApplication::processEvents(); | 409 | QCoreApplication::processEvents(); | ||
406 | QCoreApplication::processEvents(); | 410 | QCoreApplication::processEvents(); | ||
407 | QCOMPARE(serverSurface->input(), QRegion(0, 0, 24, 24)); | 411 | QCOMPARE(serverSurface->input(), QRegion(0, 0, 24, 24)); | ||
408 | QCOMPARE(serverSurface->buffer(), buffer3); | 412 | QCOMPARE(serverSurface->buffer(), buffer3); | ||
409 | QVERIFY(damageSpy.isEmpty()); | 413 | QVERIFY(damageSpy.isEmpty()); | ||
410 | QVERIFY(unmappedSpy.isEmpty()); | 414 | QVERIFY(unmappedSpy.isEmpty()); | ||
415 | QVERIFY(serverSurface->isMapped()); | ||||
411 | 416 | | |||
412 | // clear the surface | 417 | // clear the surface | ||
413 | s->attachBuffer(blackBuffer); | 418 | s->attachBuffer(blackBuffer); | ||
414 | s->damage(QRect(0, 0, 1, 1)); | 419 | s->damage(QRect(0, 0, 1, 1)); | ||
415 | // TODO: better method | 420 | // TODO: better method | ||
416 | s->attachBuffer((wl_buffer*)nullptr); | 421 | s->attachBuffer((wl_buffer*)nullptr); | ||
417 | s->damage(QRect(0, 0, 10, 10)); | 422 | s->damage(QRect(0, 0, 10, 10)); | ||
418 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 423 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
419 | QVERIFY(unmappedSpy.wait()); | 424 | QVERIFY(unmappedSpy.wait()); | ||
420 | QVERIFY(!unmappedSpy.isEmpty()); | 425 | QVERIFY(!unmappedSpy.isEmpty()); | ||
421 | QCOMPARE(unmappedSpy.count(), 1); | 426 | QCOMPARE(unmappedSpy.count(), 1); | ||
422 | QVERIFY(damageSpy.isEmpty()); | 427 | QVERIFY(damageSpy.isEmpty()); | ||
428 | QVERIFY(!serverSurface->isMapped()); | ||||
423 | 429 | | |||
424 | // TODO: add signal test on release | 430 | // TODO: add signal test on release | ||
425 | buffer->unref(); | 431 | buffer->unref(); | ||
426 | } | 432 | } | ||
427 | 433 | | |||
428 | void TestWaylandSurface::testMultipleSurfaces() | 434 | void TestWaylandSurface::testMultipleSurfaces() | ||
429 | { | 435 | { | ||
430 | using namespace KWayland::Client; | 436 | using namespace KWayland::Client; | ||
▲ Show 20 Lines • Show All 274 Lines • Show Last 20 Lines |