Commit c157e948 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

autotests: Fix TestWaylandSurface

The API of SurfaceInterface was changed so it always maintains an opaque
region.

At the surface commit, if the attached buffer is opaque, the whole
surface will be marked opaque. Otherwise, the specified opaque region
will be intersected with the surface rect.
parent bb28c84e
......@@ -625,6 +625,10 @@ void TestWaylandSurface::testOpaque()
QCOMPARE(opaqueRegionChangedSpy.count(), 0);
// so let's commit to get the new region
QImage black(20, 40, QImage::Format_ARGB32_Premultiplied);
black.fill(Qt::black);
QSharedPointer<KWayland::Client::Buffer> buffer1 = m_shm->createBuffer(black).toStrongRef();
s->attachBuffer(buffer1);
s->commit(Surface::CommitFlag::None);
QVERIFY(opaqueRegionChangedSpy.wait());
QCOMPARE(opaqueRegionChangedSpy.count(), 1);
......@@ -638,13 +642,13 @@ void TestWaylandSurface::testOpaque()
QCOMPARE(opaqueRegionChangedSpy.count(), 1);
QCOMPARE(serverSurface->opaque(), QRegion(0, 10, 20, 30));
// let's change the opaque region
// let's change the opaque region, it will be clipped with rect(0, 0, 20, 40)
s->setOpaqueRegion(m_compositor->createRegion(QRegion(10, 20, 30, 40)).get());
s->commit(Surface::CommitFlag::None);
QVERIFY(opaqueRegionChangedSpy.wait());
QCOMPARE(opaqueRegionChangedSpy.count(), 2);
QCOMPARE(opaqueRegionChangedSpy.last().first().value<QRegion>(), QRegion(10, 20, 30, 40));
QCOMPARE(serverSurface->opaque(), QRegion(10, 20, 30, 40));
QCOMPARE(opaqueRegionChangedSpy.last().first().value<QRegion>(), QRegion(10, 20, 10, 20));
QCOMPARE(serverSurface->opaque(), QRegion(10, 20, 10, 20));
// and let's go back to an empty region
s->setOpaqueRegion();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment