Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_surface.cpp
Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Line(s) | 263 | { | |||
---|---|---|---|---|---|
266 | KWayland::Client::Surface *s = m_compositor->createSurface(); | 266 | KWayland::Client::Surface *s = m_compositor->createSurface(); | ||
267 | QVERIFY(serverSurfaceCreated.wait()); | 267 | QVERIFY(serverSurfaceCreated.wait()); | ||
268 | KWayland::Server::SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWayland::Server::SurfaceInterface*>(); | 268 | KWayland::Server::SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWayland::Server::SurfaceInterface*>(); | ||
269 | QVERIFY(serverSurface); | 269 | QVERIFY(serverSurface); | ||
270 | QCOMPARE(serverSurface->damage(), QRegion()); | 270 | QCOMPARE(serverSurface->damage(), QRegion()); | ||
271 | QVERIFY(serverSurface->parentResource()); | 271 | QVERIFY(serverSurface->parentResource()); | ||
272 | QVERIFY(!serverSurface->isMapped()); | 272 | QVERIFY(!serverSurface->isMapped()); | ||
273 | 273 | | |||
274 | QSignalSpy committedSpy(serverSurface, SIGNAL(committed())); | ||||
274 | QSignalSpy damageSpy(serverSurface, SIGNAL(damaged(QRegion))); | 275 | QSignalSpy damageSpy(serverSurface, SIGNAL(damaged(QRegion))); | ||
275 | QVERIFY(damageSpy.isValid()); | 276 | QVERIFY(damageSpy.isValid()); | ||
276 | 277 | | |||
277 | // send damage without a buffer | 278 | // send damage without a buffer | ||
278 | s->damage(QRect(0, 0, 100, 100)); | 279 | s->damage(QRect(0, 0, 100, 100)); | ||
279 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 280 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
280 | wl_display_flush(m_connection->display()); | 281 | wl_display_flush(m_connection->display()); | ||
281 | QCoreApplication::processEvents(); | 282 | QCoreApplication::processEvents(); | ||
282 | QCoreApplication::processEvents(); | 283 | QCoreApplication::processEvents(); | ||
283 | QVERIFY(damageSpy.isEmpty()); | 284 | QVERIFY(damageSpy.isEmpty()); | ||
284 | QVERIFY(!serverSurface->isMapped()); | 285 | QVERIFY(!serverSurface->isMapped()); | ||
286 | QCOMPARE(committedSpy.count(), 1); | ||||
285 | 287 | | |||
286 | QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); | 288 | QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); | ||
287 | img.fill(Qt::black); | 289 | img.fill(Qt::black); | ||
288 | auto b = m_shm->createBuffer(img); | 290 | auto b = m_shm->createBuffer(img); | ||
289 | s->attachBuffer(b); | 291 | s->attachBuffer(b); | ||
290 | s->damage(QRect(0, 0, 10, 10)); | 292 | s->damage(QRect(0, 0, 10, 10)); | ||
291 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 293 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
292 | QVERIFY(damageSpy.wait()); | 294 | QVERIFY(damageSpy.wait()); | ||
293 | QCOMPARE(serverSurface->damage(), QRegion(0, 0, 10, 10)); | 295 | QCOMPARE(serverSurface->damage(), QRegion(0, 0, 10, 10)); | ||
294 | QCOMPARE(damageSpy.first().first().value<QRegion>(), QRegion(0, 0, 10, 10)); | 296 | QCOMPARE(damageSpy.first().first().value<QRegion>(), QRegion(0, 0, 10, 10)); | ||
295 | QVERIFY(serverSurface->isMapped()); | 297 | QVERIFY(serverSurface->isMapped()); | ||
298 | QCOMPARE(committedSpy.count(), 2); | ||||
296 | 299 | | |||
297 | // damage multiple times | 300 | // damage multiple times | ||
298 | QRegion testRegion(5, 8, 3, 6); | 301 | QRegion testRegion(5, 8, 3, 6); | ||
299 | testRegion = testRegion.united(QRect(10, 20, 30, 15)); | 302 | testRegion = testRegion.united(QRect(10, 20, 30, 15)); | ||
300 | img = QImage(QSize(40, 35), QImage::Format_ARGB32_Premultiplied); | 303 | img = QImage(QSize(40, 35), QImage::Format_ARGB32_Premultiplied); | ||
301 | img.fill(Qt::black); | 304 | img.fill(Qt::black); | ||
302 | b = m_shm->createBuffer(img); | 305 | b = m_shm->createBuffer(img); | ||
303 | s->attachBuffer(b); | 306 | s->attachBuffer(b); | ||
304 | s->damage(testRegion); | 307 | s->damage(testRegion); | ||
305 | damageSpy.clear(); | 308 | damageSpy.clear(); | ||
306 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 309 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
307 | QVERIFY(damageSpy.wait()); | 310 | QVERIFY(damageSpy.wait()); | ||
308 | QCOMPARE(serverSurface->damage(), testRegion); | 311 | QCOMPARE(serverSurface->damage(), testRegion); | ||
309 | QCOMPARE(damageSpy.first().first().value<QRegion>(), testRegion); | 312 | QCOMPARE(damageSpy.first().first().value<QRegion>(), testRegion); | ||
310 | QVERIFY(serverSurface->isMapped()); | 313 | QVERIFY(serverSurface->isMapped()); | ||
314 | QCOMPARE(committedSpy.count(), 3); | ||||
311 | } | 315 | } | ||
312 | 316 | | |||
313 | void TestWaylandSurface::testFrameCallback() | 317 | void TestWaylandSurface::testFrameCallback() | ||
314 | { | 318 | { | ||
315 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | 319 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | ||
316 | QVERIFY(serverSurfaceCreated.isValid()); | 320 | QVERIFY(serverSurfaceCreated.isValid()); | ||
317 | KWayland::Client::Surface *s = m_compositor->createSurface(); | 321 | KWayland::Client::Surface *s = m_compositor->createSurface(); | ||
318 | QVERIFY(serverSurfaceCreated.wait()); | 322 | QVERIFY(serverSurfaceCreated.wait()); | ||
▲ Show 20 Lines • Show All 854 Lines • Show Last 20 Lines |