From e7c9adccf89ed13dd2a693bf0555062729a624e8 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 1 Nov 2019 10:14:20 +0100 Subject: Add basic client test for subsurfaces Change-Id: I1ef21287933a2afccad989f47e4fe59329b6f537 Reviewed-by: Paul Olav Tvete --- tests/auto/client/shared/coreprotocol.h | 25 ++++++++++++++++++++++++- tests/auto/client/shared/mockcompositor.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'tests/auto/client/shared') diff --git a/tests/auto/client/shared/coreprotocol.h b/tests/auto/client/shared/coreprotocol.h index 5cef476c8..f92842e02 100644 --- a/tests/auto/client/shared/coreprotocol.h +++ b/tests/auto/client/shared/coreprotocol.h @@ -163,6 +163,16 @@ protected: } }; +class Subsurface : public QObject, public QtWaylandServer::wl_subsurface +{ + Q_OBJECT +public: + explicit Subsurface(wl_client *client, int id, int version) + : QtWaylandServer::wl_subsurface(client, id, version) + { + } +}; + class SubCompositor : public Global, public QtWaylandServer::wl_subcompositor { Q_OBJECT @@ -170,7 +180,20 @@ public: explicit SubCompositor(CoreCompositor *compositor, int version = 1) : QtWaylandServer::wl_subcompositor(compositor->m_display, version) {} - // TODO + QVector m_subsurfaces; + +signals: + void subsurfaceCreated(Subsurface *subsurface); + +protected: + void subcompositor_get_subsurface(Resource *resource, uint32_t id, ::wl_resource *surface, ::wl_resource *parent) override + { + QTRY_VERIFY(parent); + QTRY_VERIFY(surface); + auto *subsurface = new Subsurface(resource->client(), id, resource->version()); + m_subsurfaces.append(subsurface); // TODO: clean up? + emit subsurfaceCreated(subsurface); + } }; struct OutputMode { diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h index f5264ccf6..f17c93426 100644 --- a/tests/auto/client/shared/mockcompositor.h +++ b/tests/auto/client/shared/mockcompositor.h @@ -50,6 +50,7 @@ public: // Convenience functions Output *output(int i = 0) { return getAll().value(i, nullptr); } Surface *surface(int i = 0) { return get()->m_surfaces.value(i, nullptr); } + Subsurface *subSurface(int i = 0) { return get()->m_subsurfaces.value(i, nullptr); } XdgSurface *xdgSurface(int i = 0) { return get()->m_xdgSurfaces.value(i, nullptr); } XdgToplevel *xdgToplevel(int i = 0) { return get()->toplevel(i); } XdgPopup *xdgPopup(int i = 0) { return get()->popup(i); } -- cgit v1.2.3