diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-08-14 17:38:52 +0300 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-08-15 11:16:40 +0200 |
commit | d516f7dc9b41529d7986d3b6a9483d49702734f9 (patch) | |
tree | 4b1a5574b346e3b4c9b094c79d59fe589164f52a /tests | |
parent | 6842ece98dc4b496fca075b6f864d8f78c1057d0 (diff) |
Fix compositor tests
The test compositor was not updated after recent QtCompositor changes.
Make sure to create and use wl_shell and fix the "repaint" loop in the
frameCallback test
Change-Id: I06515f114a3b7b755c22aef7d193d48fda94d7af
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/compositor/mockclient.cpp | 9 | ||||
-rw-r--r-- | tests/auto/compositor/mockclient.h | 2 | ||||
-rw-r--r-- | tests/auto/compositor/testcompositor.cpp | 1 | ||||
-rw-r--r-- | tests/auto/compositor/tst_compositor.cpp | 14 |
4 files changed, 22 insertions, 4 deletions
diff --git a/tests/auto/compositor/mockclient.cpp b/tests/auto/compositor/mockclient.cpp index 4204e3936..2ee997ed5 100644 --- a/tests/auto/compositor/mockclient.cpp +++ b/tests/auto/compositor/mockclient.cpp @@ -61,6 +61,7 @@ MockClient::MockClient() , compositor(0) , output(0) , registry(0) + , wlshell(0) { if (!display) qFatal("MockClient(): wl_display_connect() failed"); @@ -135,6 +136,8 @@ void MockClient::handleGlobal(uint32_t id, const QByteArray &interface) wl_output_add_listener(output, &outputListener, this); } else if (interface == "wl_shm") { shm = static_cast<wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface, 1)); + } else if (interface == "wl_shell") { + wlshell = static_cast<wl_shell *>(wl_registry_bind(registry, id, &wl_shell_interface, 1)); } } @@ -144,6 +147,12 @@ wl_surface *MockClient::createSurface() return wl_compositor_create_surface(compositor); } +wl_shell_surface *MockClient::createShellSurface(wl_surface *surface) +{ + flushDisplay(); + return wl_shell_get_shell_surface(wlshell, surface); +} + ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm) : handle(0) { diff --git a/tests/auto/compositor/mockclient.h b/tests/auto/compositor/mockclient.h index db748df4e..9f7c89d59 100644 --- a/tests/auto/compositor/mockclient.h +++ b/tests/auto/compositor/mockclient.h @@ -65,12 +65,14 @@ public: ~MockClient(); wl_surface *createSurface(); + wl_shell_surface *createShellSurface(wl_surface *surface); wl_display *display; wl_compositor *compositor; wl_output *output; wl_shm *shm; wl_registry *registry; + wl_shell *wlshell; QRect geometry; diff --git a/tests/auto/compositor/testcompositor.cpp b/tests/auto/compositor/testcompositor.cpp index 420c88c0d..cf7c8eb15 100644 --- a/tests/auto/compositor/testcompositor.cpp +++ b/tests/auto/compositor/testcompositor.cpp @@ -43,6 +43,7 @@ TestCompositor::TestCompositor(QWaylandCompositor::ExtensionFlag flags) : QWaylandCompositor(0, 0, flags) { + addDefaultShell(); } void TestCompositor::surfaceCreated(QWaylandSurface *surface) diff --git a/tests/auto/compositor/tst_compositor.cpp b/tests/auto/compositor/tst_compositor.cpp index eae3f2943..e97d3b16d 100644 --- a/tests/auto/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/tst_compositor.cpp @@ -216,8 +216,11 @@ void tst_WaylandCompositor::mapSurface() QSize size(256, 256); ShmBuffer buffer(size, client.shm); + // we need to create a shell surface here or the surface won't be mapped + client.createShellSurface(surface); wl_surface_attach(surface, buffer.handle, 0, 0); wl_surface_damage(surface, 0, 0, size.width(), size.height()); + wl_surface_commit(surface); QTRY_COMPARE(waylandSurface->size(), size); QTRY_COMPARE(waylandSurface->type(), QWaylandSurface::Shm); @@ -265,11 +268,7 @@ void tst_WaylandCompositor::frameCallback() MockClient client; - QSize size(8, 8); - ShmBuffer buffer(size, client.shm); - wl_surface *surface = client.createSurface(); - wl_surface_attach(surface, buffer.handle, 0, 0); int frameCounter = 0; @@ -280,13 +279,20 @@ void tst_WaylandCompositor::frameCallback() QSignalSpy damagedSpy(waylandSurface, SIGNAL(damaged(const QRegion &))); for (int i = 0; i < 10; ++i) { + QSize size(i * 8 + 2, i * 8 + 2); + ShmBuffer buffer(size, client.shm); + + // attach a new buffer every frame, else the damage signal won't be fired + wl_surface_attach(surface, buffer.handle, 0, 0); registerFrameCallback(surface, &frameCounter); wl_surface_damage(surface, 0, 0, size.width(), size.height()); + wl_surface_commit(surface); QTRY_COMPARE(waylandSurface->type(), QWaylandSurface::Shm); QTRY_COMPARE(damagedSpy.count(), i + 1); QCOMPARE(static_cast<BufferAttacher *>(waylandSurface->bufferAttacher())->image(), buffer.image); + compositor.frameStarted(); compositor.sendFrameCallbacks(QList<QWaylandSurface *>() << waylandSurface); QTRY_COMPARE(frameCounter, i + 1); |