From 8ec451781282d82650167b02acac3d79a51f873a Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 21 Jan 2019 12:57:28 +0100 Subject: Compositor tests: Test xdg-shell stable instead of unstable v5 Change-Id: Ib9dbad2e7312dab94cecbc1a14315dcb47c8c46a Reviewed-by: Paul Olav Tvete --- tests/auto/compositor/compositor/compositor.pro | 2 +- tests/auto/compositor/compositor/mockclient.cpp | 12 +- tests/auto/compositor/compositor/mockclient.h | 5 +- .../auto/compositor/compositor/tst_compositor.cpp | 162 ++++++++++++--------- 4 files changed, 104 insertions(+), 77 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/compositor/compositor/compositor.pro b/tests/auto/compositor/compositor/compositor.pro index 4e5cf50b8..500a92c61 100644 --- a/tests/auto/compositor/compositor/compositor.pro +++ b/tests/auto/compositor/compositor/compositor.pro @@ -11,9 +11,9 @@ qtConfig(xkbcommon): \ QMAKE_USE += xkbcommon WAYLANDCLIENTSOURCES += \ - ../../../../src/3rdparty/protocol/xdg-shell-unstable-v5.xml \ ../../../../src/3rdparty/protocol/ivi-application.xml \ ../../../../src/3rdparty/protocol/wayland.xml \ + ../../../../src/3rdparty/protocol/xdg-shell.xml \ ../../../../src/3rdparty/protocol/viewporter.xml SOURCES += \ diff --git a/tests/auto/compositor/compositor/mockclient.cpp b/tests/auto/compositor/compositor/mockclient.cpp index b6cb4ab46..fa4d4c6b3 100644 --- a/tests/auto/compositor/compositor/mockclient.cpp +++ b/tests/auto/compositor/compositor/mockclient.cpp @@ -177,8 +177,8 @@ void MockClient::handleGlobal(uint32_t id, const QByteArray &interface) viewporter = static_cast(wl_registry_bind(registry, id, &wp_viewporter_interface, 1)); } else if (interface == "wl_shell") { wlshell = static_cast(wl_registry_bind(registry, id, &wl_shell_interface, 1)); - } else if (interface == "xdg_shell") { - xdgShell = static_cast(wl_registry_bind(registry, id, &xdg_shell_interface, 1)); + } else if (interface == "xdg_wm_base") { + xdgWmBase = static_cast(wl_registry_bind(registry, id, &xdg_wm_base_interface, 1)); } else if (interface == "ivi_application") { iviApplication = static_cast(wl_registry_bind(registry, id, &ivi_application_interface, 1)); } else if (interface == "wl_seat") { @@ -207,7 +207,13 @@ wl_shell_surface *MockClient::createShellSurface(wl_surface *surface) xdg_surface *MockClient::createXdgSurface(wl_surface *surface) { flushDisplay(); - return xdg_shell_get_xdg_surface(xdgShell, surface); + return xdg_wm_base_get_xdg_surface(xdgWmBase, surface); +} + +xdg_toplevel *MockClient::createXdgToplevel(xdg_surface *xdgSurface) +{ + flushDisplay(); + return xdg_surface_get_toplevel(xdgSurface); } ivi_surface *MockClient::createIviSurface(wl_surface *surface, uint iviId) diff --git a/tests/auto/compositor/compositor/mockclient.h b/tests/auto/compositor/compositor/mockclient.h index bf5d8fc88..b537e9df1 100644 --- a/tests/auto/compositor/compositor/mockclient.h +++ b/tests/auto/compositor/compositor/mockclient.h @@ -27,7 +27,7 @@ ****************************************************************************/ #include "wayland-wayland-client-protocol.h" -#include +#include #include #include "wayland-viewporter-client-protocol.h" @@ -61,6 +61,7 @@ public: wl_surface *createSurface(); wl_shell_surface *createShellSurface(wl_surface *surface); xdg_surface *createXdgSurface(wl_surface *surface); + xdg_toplevel *createXdgToplevel(xdg_surface *xdgSurface); ivi_surface *createIviSurface(wl_surface *surface, uint iviId); wl_display *display = nullptr; @@ -69,7 +70,7 @@ public: wl_shm *shm = nullptr; wl_registry *registry = nullptr; wl_shell *wlshell = nullptr; - xdg_shell *xdgShell = nullptr; + xdg_wm_base *xdgWmBase = nullptr; wp_viewporter *viewporter = nullptr; ivi_application *iviApplication = nullptr; diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp index d1be87020..c425f2ba1 100644 --- a/tests/auto/compositor/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/compositor/tst_compositor.cpp @@ -38,7 +38,7 @@ #include "qwaylandseat.h" #include -#include +#include #include #include #include @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -898,7 +898,7 @@ class XdgTestCompositor: public TestCompositor { Q_OBJECT public: XdgTestCompositor() : xdgShell(this) {} - QWaylandXdgShellV5 xdgShell; + QWaylandXdgShell xdgShell; }; void tst_WaylandCompositor::advertisesXdgShellSupport() @@ -907,7 +907,7 @@ void tst_WaylandCompositor::advertisesXdgShellSupport() compositor.create(); MockClient client; - QTRY_VERIFY(client.xdgShell); + QTRY_VERIFY(client.xdgWmBase); } void tst_WaylandCompositor::createsXdgSurfaces() @@ -916,19 +916,22 @@ void tst_WaylandCompositor::createsXdgSurfaces() compositor.create(); MockClient client; - QTRY_VERIFY(client.xdgShell); + QTRY_VERIFY(client.xdgWmBase); - QSignalSpy xdgSurfaceCreatedSpy(&compositor.xdgShell, &QWaylandXdgShellV5::xdgSurfaceCreated); - QWaylandXdgSurfaceV5 *xdgSurface = nullptr; - QObject::connect(&compositor.xdgShell, &QWaylandXdgShellV5::xdgSurfaceCreated, [&](QWaylandXdgSurfaceV5 *s) { + QSignalSpy xdgSurfaceCreatedSpy(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated); + QWaylandXdgSurface *xdgSurface = nullptr; + QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated, [&](QWaylandXdgSurface *s) { xdgSurface = s; }); wl_surface *surface = client.createSurface(); - client.createXdgSurface(surface); + xdg_surface *clientXdgSurface = client.createXdgSurface(surface); QTRY_COMPARE(xdgSurfaceCreatedSpy.count(), 1); QTRY_VERIFY(xdgSurface); QTRY_VERIFY(xdgSurface->surface()); + + xdg_surface_destroy(clientXdgSurface); + wl_surface_destroy(surface); } void tst_WaylandCompositor::reportsXdgSurfaceWindowGeometry() @@ -936,27 +939,36 @@ void tst_WaylandCompositor::reportsXdgSurfaceWindowGeometry() XdgTestCompositor compositor; compositor.create(); - QWaylandXdgSurfaceV5 *xdgSurface = nullptr; - QObject::connect(&compositor.xdgShell, &QWaylandXdgShellV5::xdgSurfaceCreated, [&](QWaylandXdgSurfaceV5 *s) { + QWaylandXdgSurface *xdgSurface = nullptr; + QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated, [&](QWaylandXdgSurface *s) { xdgSurface = s; }); MockClient client; wl_surface *surface = client.createSurface(); xdg_surface *clientXdgSurface = client.createXdgSurface(surface); + xdg_toplevel *clientToplevel = client.createXdgToplevel(clientXdgSurface); + QSize size(256, 256); ShmBuffer buffer(size, client.shm); + + QTRY_VERIFY(xdgSurface); + //TODO: Here we should ideally be acking the configure, we're techically making a protocol error + wl_surface_attach(surface, buffer.handle, 0, 0); wl_surface_damage(surface, 0, 0, size.width(), size.height()); wl_surface_commit(surface); - QTRY_VERIFY(xdgSurface); QTRY_COMPARE(xdgSurface->windowGeometry(), QRect(QPoint(0, 0), QSize(256, 256))); xdg_surface_set_window_geometry(clientXdgSurface, 10, 20, 100, 50); wl_surface_commit(surface); QTRY_COMPARE(xdgSurface->windowGeometry(), QRect(QPoint(10, 20), QSize(100, 50))); + + xdg_toplevel_destroy(clientToplevel); + xdg_surface_destroy(clientXdgSurface); + wl_surface_destroy(surface); } void tst_WaylandCompositor::setsXdgAppId() @@ -964,19 +976,20 @@ void tst_WaylandCompositor::setsXdgAppId() XdgTestCompositor compositor; compositor.create(); - QWaylandXdgSurfaceV5 *xdgSurface = nullptr; - QObject::connect(&compositor.xdgShell, &QWaylandXdgShellV5::xdgSurfaceCreated, [&](QWaylandXdgSurfaceV5 *s) { - xdgSurface = s; + QWaylandXdgToplevel *toplevel = nullptr; + QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::toplevelCreated, [&](QWaylandXdgToplevel *t) { + toplevel = t; }); MockClient client; wl_surface *surface = client.createSurface(); xdg_surface *clientXdgSurface = client.createXdgSurface(surface); + xdg_toplevel *clientToplevel = client.createXdgToplevel(clientXdgSurface); - xdg_surface_set_app_id(clientXdgSurface, "org.foo.bar"); + xdg_toplevel_set_app_id(clientToplevel, "org.foo.bar"); - QTRY_VERIFY(xdgSurface); - QTRY_COMPARE(xdgSurface->appId(), QString("org.foo.bar")); + QTRY_VERIFY(toplevel); + QTRY_COMPARE(toplevel->appId(), QString("org.foo.bar")); } void tst_WaylandCompositor::sendsXdgConfigure() @@ -984,111 +997,118 @@ void tst_WaylandCompositor::sendsXdgConfigure() class MockXdgSurface : public QtWayland::xdg_surface { public: - MockXdgSurface(::xdg_surface *xdgSurface) : QtWayland::xdg_surface(xdgSurface) {} - void xdg_surface_configure(int32_t width, int32_t height, wl_array *rawStates, uint32_t serial) override + explicit MockXdgSurface(::xdg_surface *xdgSurface) : QtWayland::xdg_surface(xdgSurface) {} + void xdg_surface_configure(uint32_t serial) override { configureSerial = serial; } + uint configureSerial = 0; + }; + + class MockXdgToplevel : public QtWayland::xdg_toplevel + { + public: + explicit MockXdgToplevel(::xdg_toplevel *toplevel) : QtWayland::xdg_toplevel(toplevel) {} + void xdg_toplevel_configure(int32_t width, int32_t height, wl_array *rawStates) override { configureSize = QSize(width, height); - configureSerial = serial; - uint *states = reinterpret_cast(rawStates->data); configureStates.clear(); size_t numStates = rawStates->size / sizeof(uint); - for (size_t i = 0; i < numStates; ++i) { + for (size_t i = 0; i < numStates; ++i) configureStates.push_back(states[i]); - } } - QList configureStates; QSize configureSize; - uint configureSerial; }; XdgTestCompositor compositor; compositor.create(); - QWaylandXdgSurfaceV5 *xdgSurface = nullptr; - QObject::connect(&compositor.xdgShell, &QWaylandXdgShellV5::xdgSurfaceCreated, [&](QWaylandXdgSurfaceV5 *s) { - xdgSurface = s; + QWaylandXdgToplevel *toplevel = nullptr; + QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::toplevelCreated, [&](QWaylandXdgToplevel *t) { + toplevel = t; }); MockClient client; wl_surface *surface = client.createSurface(); + xdg_surface *clientXdgSurface = client.createXdgSurface(surface); MockXdgSurface mockXdgSurface(clientXdgSurface); - QTRY_VERIFY(xdgSurface); - QTRY_VERIFY(!xdgSurface->activated()); - QTRY_VERIFY(!xdgSurface->maximized()); - QTRY_VERIFY(!xdgSurface->fullscreen()); - QTRY_VERIFY(!xdgSurface->resizing()); + xdg_toplevel *clientToplevel = client.createXdgToplevel(clientXdgSurface); + MockXdgToplevel mockToplevel(clientToplevel); + + QTRY_VERIFY(toplevel); + QTRY_VERIFY(!toplevel->activated()); + QTRY_VERIFY(!toplevel->maximized()); + QTRY_VERIFY(!toplevel->fullscreen()); + QTRY_VERIFY(!toplevel->resizing()); - xdgSurface->sendConfigure(QSize(10, 20), QVector{QWaylandXdgSurfaceV5::State::ActivatedState}); + toplevel->sendConfigure(QSize(10, 20), QVector{QWaylandXdgToplevel::State::ActivatedState}); compositor.flushClients(); - QTRY_COMPARE(mockXdgSurface.configureStates, QList{QWaylandXdgSurfaceV5::State::ActivatedState}); - QTRY_COMPARE(mockXdgSurface.configureSize, QSize(10, 20)); + QTRY_COMPARE(mockToplevel.configureStates, QList{QWaylandXdgToplevel::State::ActivatedState}); + QTRY_COMPARE(mockToplevel.configureSize, QSize(10, 20)); - xdgSurface->sendMaximized(QSize(800, 600)); + toplevel->sendMaximized(QSize(800, 600)); compositor.flushClients(); - QTRY_VERIFY(mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::MaximizedState)); - QTRY_VERIFY(mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::ActivatedState)); - QTRY_COMPARE(mockXdgSurface.configureSize, QSize(800, 600)); + QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::MaximizedState)); + QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState)); + QTRY_COMPARE(mockToplevel.configureSize, QSize(800, 600)); // There hasn't been any ack_configures, so state should still be unchanged - QTRY_VERIFY(!xdgSurface->activated()); - QTRY_VERIFY(!xdgSurface->maximized()); + QTRY_VERIFY(!toplevel->activated()); + QTRY_VERIFY(!toplevel->maximized()); xdg_surface_ack_configure(clientXdgSurface, mockXdgSurface.configureSerial); wl_display_dispatch_pending(client.display); wl_display_flush(client.display); - QTRY_VERIFY(xdgSurface->activated()); - QTRY_VERIFY(xdgSurface->maximized()); + QTRY_VERIFY(toplevel->activated()); + QTRY_VERIFY(toplevel->maximized()); - xdgSurface->sendUnmaximized(); + toplevel->sendUnmaximized(); compositor.flushClients(); - QTRY_VERIFY(!mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::MaximizedState)); - QTRY_VERIFY(mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::ActivatedState)); - QTRY_COMPARE(mockXdgSurface.configureSize, QSize(0, 0)); + QTRY_VERIFY(!mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::MaximizedState)); + QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState)); + QTRY_COMPARE(mockToplevel.configureSize, QSize(0, 0)); // The unmaximized configure hasn't been acked, so maximized should still be true - QTRY_VERIFY(xdgSurface->maximized()); - QTRY_VERIFY(xdgSurface->activated()); + QTRY_VERIFY(toplevel->maximized()); + QTRY_VERIFY(toplevel->activated()); - xdgSurface->sendResizing(QSize(800, 600)); + toplevel->sendResizing(QSize(800, 600)); compositor.flushClients(); - QTRY_VERIFY(mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::ResizingState)); - QTRY_COMPARE(mockXdgSurface.configureSize, QSize(800, 600)); + QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ResizingState)); + QTRY_COMPARE(mockToplevel.configureSize, QSize(800, 600)); - xdgSurface->sendFullscreen(QSize(1024, 768)); + toplevel->sendFullscreen(QSize(1024, 768)); compositor.flushClients(); - QTRY_VERIFY(mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::ActivatedState)); - QTRY_VERIFY(mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::FullscreenState)); - QTRY_COMPARE(mockXdgSurface.configureSize, QSize(1024, 768)); + QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState)); + QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::FullscreenState)); + QTRY_COMPARE(mockToplevel.configureSize, QSize(1024, 768)); uint fullscreenSerial = mockXdgSurface.configureSerial; - xdgSurface->sendUnmaximized(); + toplevel->sendUnmaximized(); compositor.flushClients(); - QTRY_VERIFY(mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::ActivatedState)); - QTRY_VERIFY(!mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::FullscreenState)); + QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState)); + QTRY_VERIFY(!mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::FullscreenState)); - xdgSurface->sendConfigure(QSize(0, 0), QVector{}); + toplevel->sendConfigure(QSize(0, 0), QVector{}); compositor.flushClients(); - QTRY_VERIFY(!mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::ActivatedState)); + QTRY_VERIFY(!mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState)); - xdgSurface->sendMaximized(QSize(800, 600)); + toplevel->sendMaximized(QSize(800, 600)); compositor.flushClients(); - QTRY_VERIFY(!mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::ActivatedState)); + QTRY_VERIFY(!mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState)); - xdgSurface->sendFullscreen(QSize(800, 600)); + toplevel->sendFullscreen(QSize(800, 600)); compositor.flushClients(); - QTRY_VERIFY(!mockXdgSurface.configureStates.contains(QWaylandXdgSurfaceV5::State::MaximizedState)); + QTRY_VERIFY(!mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::MaximizedState)); // Verify that acking a configure that's not the most recently sent works xdg_surface_ack_configure(clientXdgSurface, fullscreenSerial); wl_display_dispatch_pending(client.display); wl_display_flush(client.display); - QTRY_VERIFY(xdgSurface->fullscreen()); - QTRY_VERIFY(xdgSurface->activated()); - QTRY_VERIFY(!xdgSurface->maximized()); - QTRY_VERIFY(!xdgSurface->resizing()); + QTRY_VERIFY(toplevel->fullscreen()); + QTRY_VERIFY(toplevel->activated()); + QTRY_VERIFY(!toplevel->maximized()); + QTRY_VERIFY(!toplevel->resizing()); } class IviTestCompositor: public TestCompositor { -- cgit v1.2.3