From 4d77c197a9f0582cb6af2ecec0ec4658061bd589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 19 Sep 2014 10:42:44 +0200 Subject: [PATCH] Add convenient create methods to Registry These methods allow to create the Interface objects and set them up directly. --- .../client/test_wayland_fullscreen_shell.cpp | 23 +++++++++++++++++++ .../autotests/client/test_wayland_output.cpp | 9 ++++---- .../autotests/client/test_wayland_seat.cpp | 3 +-- .../autotests/client/test_wayland_shell.cpp | 3 +-- .../autotests/client/test_wayland_surface.cpp | 3 +-- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/wayland/autotests/client/test_wayland_fullscreen_shell.cpp b/src/wayland/autotests/client/test_wayland_fullscreen_shell.cpp index 93cdfe004a..329b329973 100644 --- a/src/wayland/autotests/client/test_wayland_fullscreen_shell.cpp +++ b/src/wayland/autotests/client/test_wayland_fullscreen_shell.cpp @@ -36,6 +36,7 @@ private Q_SLOTS: void cleanup(); void testRegistry(); + void testRegistryCreate(); // TODO: add tests for removal - requires more control over the compositor @@ -119,5 +120,27 @@ void TestWaylandFullscreenShell::testRegistry() QVERIFY(fullscreenShell.isValid()); } +void TestWaylandFullscreenShell::testRegistryCreate() +{ if (m_westonProcess->state() != QProcess::Running) { + QSKIP("This test requires a running wayland server"); + } + KWayland::Client::ConnectionThread connection; + QSignalSpy connectedSpy(&connection, SIGNAL(connected())); + connection.setSocketName(s_socketName); + connection.initConnection(); + QVERIFY(connectedSpy.wait()); + + KWayland::Client::Registry registry; + QSignalSpy announced(®istry, SIGNAL(fullscreenShellAnnounced(quint32,quint32))); + registry.create(connection.display()); + QVERIFY(registry.isValid()); + registry.setup(); + wl_display_flush(connection.display()); + QVERIFY(announced.wait()); + + KWayland::Client::FullscreenShell *fullscreenShell = registry.createFullscreenShell(announced.first().first().value(), 1, ®istry); + QVERIFY(fullscreenShell->isValid()); +} + QTEST_MAIN(TestWaylandFullscreenShell) #include "test_wayland_fullscreen_shell.moc" diff --git a/src/wayland/autotests/client/test_wayland_output.cpp b/src/wayland/autotests/client/test_wayland_output.cpp index 3505fb2dd0..4dd9b77d9b 100644 --- a/src/wayland/autotests/client/test_wayland_output.cpp +++ b/src/wayland/autotests/client/test_wayland_output.cpp @@ -302,16 +302,15 @@ void TestWaylandOutput::testTransform() wl_display_flush(m_connection->display()); QVERIFY(announced.wait()); - KWayland::Client::Output output; - QSignalSpy outputChanged(&output, SIGNAL(changed())); + KWayland::Client::Output *output = registry.createOutput(announced.first().first().value(), announced.first().last().value(), ®istry); + QSignalSpy outputChanged(output, SIGNAL(changed())); QVERIFY(outputChanged.isValid()); - output.setup(registry.bindOutput(announced.first().first().value(), announced.first().last().value())); wl_display_flush(m_connection->display()); if (outputChanged.isEmpty()) { QVERIFY(outputChanged.wait()); } - QTEST(output.transform(), "expected"); + QTEST(output->transform(), "expected"); // change back to normal outputChanged.clear(); @@ -319,7 +318,7 @@ void TestWaylandOutput::testTransform() if (outputChanged.isEmpty()) { QVERIFY(outputChanged.wait()); } - QCOMPARE(output.transform(), Output::Transform::Normal); + QCOMPARE(output->transform(), Output::Transform::Normal); } QTEST_MAIN(TestWaylandOutput) diff --git a/src/wayland/autotests/client/test_wayland_seat.cpp b/src/wayland/autotests/client/test_wayland_seat.cpp index b227999573..28ac9dbb3e 100644 --- a/src/wayland/autotests/client/test_wayland_seat.cpp +++ b/src/wayland/autotests/client/test_wayland_seat.cpp @@ -140,9 +140,8 @@ void TestWaylandSeat::init() m_compositor->setup(registry.bindCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value())); QVERIFY(m_compositor->isValid()); - m_seat = new KWayland::Client::Seat(this); + m_seat = registry.createSeat(seatSpy.first().first().value(), seatSpy.first().last().value(), this); QSignalSpy nameSpy(m_seat, SIGNAL(nameChanged(QString))); - m_seat->setup(registry.bindSeat(seatSpy.first().first().value(), seatSpy.first().last().value())); QVERIFY(nameSpy.wait()); } diff --git a/src/wayland/autotests/client/test_wayland_shell.cpp b/src/wayland/autotests/client/test_wayland_shell.cpp index 09454b5809..a30665d494 100644 --- a/src/wayland/autotests/client/test_wayland_shell.cpp +++ b/src/wayland/autotests/client/test_wayland_shell.cpp @@ -134,8 +134,7 @@ void TestWaylandShell::init() if (shellSpy.isEmpty()) { QVERIFY(shellSpy.wait()); } - m_shell = new KWayland::Client::Shell(this); - m_shell->setup(registry.bindShell(shellSpy.first().first().value(), shellSpy.first().last().value())); + m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this); QVERIFY(m_shell->isValid()); } diff --git a/src/wayland/autotests/client/test_wayland_surface.cpp b/src/wayland/autotests/client/test_wayland_surface.cpp index 1442f54c17..fc0125b7b7 100644 --- a/src/wayland/autotests/client/test_wayland_surface.cpp +++ b/src/wayland/autotests/client/test_wayland_surface.cpp @@ -108,8 +108,7 @@ void TestWaylandSurface::init() registry.setup(); QVERIFY(compositorSpy.wait()); - m_compositor = new KWayland::Client::Compositor(this); - m_compositor->setup(registry.bindCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value())); + m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this); QVERIFY(m_compositor->isValid()); }