From 35e50175fd44d9c9345fbf797f3c6c8e7e5b0b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 21 Mar 2016 09:33:05 +0100 Subject: [PATCH] [client] Add setScale to Surface Summary: The wrapper for wl_surface::set_buffer_scale was still missing. Main reason for implementation is the need for the added auto-test. Reviewers: #plasma Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1188 --- .../autotests/client/test_wayland_surface.cpp | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/wayland/autotests/client/test_wayland_surface.cpp b/src/wayland/autotests/client/test_wayland_surface.cpp index 24191e5fc6..ff9e638e3f 100644 --- a/src/wayland/autotests/client/test_wayland_surface.cpp +++ b/src/wayland/autotests/client/test_wayland_surface.cpp @@ -51,6 +51,7 @@ private Q_SLOTS: void testMultipleSurfaces(); void testOpaque(); void testInput(); + void testScale(); void testDestroy(); private: @@ -631,6 +632,49 @@ void TestWaylandSurface::testInput() QCOMPARE(serverSurface->inputIsInfinite(), true); } +void TestWaylandSurface::testScale() +{ + // this test verifies that updating the scale factor is correctly passed to the Wayland server + using namespace KWayland::Client; + using namespace KWayland::Server; + // create surface + QSignalSpy serverSurfaceCreated(m_compositorInterface, &CompositorInterface::surfaceCreated); + QVERIFY(serverSurfaceCreated.isValid()); + QScopedPointer s(m_compositor->createSurface()); + QCOMPARE(s->scale(), 1); + QVERIFY(serverSurfaceCreated.wait()); + SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value(); + QVERIFY(serverSurface); + QCOMPARE(serverSurface->scale(), 1); + + // let's change the scale factor + QSignalSpy scaleChangedSpy(serverSurface, &SurfaceInterface::scaleChanged); + QVERIFY(scaleChangedSpy.isValid()); + s->setScale(2); + QCOMPARE(s->scale(), 2); + // needs a commit + QVERIFY(!scaleChangedSpy.wait(100)); + s->commit(Surface::CommitFlag::None); + QVERIFY(scaleChangedSpy.wait()); + QCOMPARE(scaleChangedSpy.count(), 1); + QCOMPARE(scaleChangedSpy.first().first().toInt(), 2); + QCOMPARE(serverSurface->scale(), 2); + + // let's try changing to same factor, should not emit changed on server + s->setScale(2); + s->commit(Surface::CommitFlag::None); + QVERIFY(!scaleChangedSpy.wait(100)); + + // but changing to a different value should still work + s->setScale(4); + s->commit(Surface::CommitFlag::None); + QVERIFY(scaleChangedSpy.wait()); + QCOMPARE(scaleChangedSpy.count(), 2); + QCOMPARE(scaleChangedSpy.first().first().toInt(), 2); + QCOMPARE(scaleChangedSpy.last().first().toInt(), 4); + QCOMPARE(serverSurface->scale(), 4); +} + void TestWaylandSurface::testDestroy() { using namespace KWayland::Client;