autotests: Make SceneQPainterTest more robust to BufferInterface changes
At the moment, the test depends on the implicit client connection flush in BufferInterface::unref(). It will be highly desirable if that connection flush is gone as it allows us batching wayland events better. It also allows us remove a system call from a hot path.
This commit is contained in:
parent
e170c3be7d
commit
46b81be246
1 changed files with 22 additions and 2 deletions
|
@ -285,6 +285,27 @@ struct XcbConnectionDeleter
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool waitForXwaylandBuffer(Toplevel *window, const QSize &size)
|
||||||
|
{
|
||||||
|
// Usually, when an Xwayland surface is created, it has a buffer of size 1x1,
|
||||||
|
// a buffer with the correct size will be committed a bit later.
|
||||||
|
KWaylandServer::SurfaceInterface *surface = window->surface();
|
||||||
|
int attemptCount = 0;
|
||||||
|
do {
|
||||||
|
if (surface->buffer() && surface->buffer()->size() == size) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
QSignalSpy committedSpy(surface, &KWaylandServer::SurfaceInterface::committed);
|
||||||
|
if (!committedSpy.wait()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
++attemptCount;
|
||||||
|
} while (attemptCount <= 3);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SceneQPainterTest::testX11Window()
|
void SceneQPainterTest::testX11Window()
|
||||||
{
|
{
|
||||||
// this test verifies the condition of BUG: 382748
|
// this test verifies the condition of BUG: 382748
|
||||||
|
@ -323,8 +344,7 @@ void SceneQPainterTest::testX11Window()
|
||||||
QCOMPARE(client->window(), w);
|
QCOMPARE(client->window(), w);
|
||||||
QCOMPARE(client->clientSize(), QSize(100, 200));
|
QCOMPARE(client->clientSize(), QSize(100, 200));
|
||||||
QVERIFY(Test::waitForWaylandSurface(client));
|
QVERIFY(Test::waitForWaylandSurface(client));
|
||||||
QTRY_VERIFY(client->surface()->buffer());
|
QVERIFY(waitForXwaylandBuffer(client, client->size()));
|
||||||
QTRY_COMPARE(client->surface()->buffer()->data().size(), client->size());
|
|
||||||
QImage compareImage(client->clientSize(), QImage::Format_RGB32);
|
QImage compareImage(client->clientSize(), QImage::Format_RGB32);
|
||||||
compareImage.fill(Qt::white);
|
compareImage.fill(Qt::white);
|
||||||
QCOMPARE(client->surface()->buffer()->data().copy(QRect(client->clientPos(), client->clientSize())), compareImage);
|
QCOMPARE(client->surface()->buffer()->data().copy(QRect(client->clientPos(), client->clientSize())), compareImage);
|
||||||
|
|
Loading…
Reference in a new issue