From 5b69d5f05fdf187ae8a5f08e9a57375cbbd7f142 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 19 Feb 2018 15:28:01 +0100 Subject: Client tests: Use generated classes for mocking shells Removes a lot of boiler-plate code and makes the two shells more similar. This also makes it easier to extend the shells with additional mocking functionality. Change-Id: I4a846b06eeda695527d7c5679df339beae983af6 Reviewed-by: Paul Olav Tvete --- tests/auto/client/shared/mockxdgshellv6.cpp | 59 ++++------------------------- 1 file changed, 7 insertions(+), 52 deletions(-) (limited to 'tests/auto/client/shared/mockxdgshellv6.cpp') diff --git a/tests/auto/client/shared/mockxdgshellv6.cpp b/tests/auto/client/shared/mockxdgshellv6.cpp index b26ac1c8d..f909fa108 100644 --- a/tests/auto/client/shared/mockxdgshellv6.cpp +++ b/tests/auto/client/shared/mockxdgshellv6.cpp @@ -26,11 +26,9 @@ ** ****************************************************************************/ -#include "mockcompositor.h" +#include "mockxdgshellv6.h" #include "mocksurface.h" -#include - namespace Impl { class XdgSurfaceV6; @@ -50,7 +48,7 @@ public: class XdgSurfaceV6 : public QtWaylandServer::zxdg_surface_v6 { public: - XdgSurfaceV6(wl_client *client, uint32_t id, int version, Surface *surface); + XdgSurfaceV6(wl_client *client, uint32_t id, Surface *surface); void zxdg_surface_v6_destroy_resource(Resource *) override { delete this; } void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id) override; void zxdg_surface_v6_destroy(Resource *resource) override @@ -68,8 +66,8 @@ void XdgToplevelV6::zxdg_toplevel_v6_destroy(QtWaylandServer::zxdg_toplevel_v6:: wl_resource_destroy(resource->handle); } -XdgSurfaceV6::XdgSurfaceV6(wl_client *client, uint32_t id, int version, Surface *surface) - : QtWaylandServer::zxdg_surface_v6(client, id, version) +XdgSurfaceV6::XdgSurfaceV6(wl_client *client, uint32_t id, Surface *surface) + : QtWaylandServer::zxdg_surface_v6(client, id, 1) , m_surface(surface) { } @@ -81,52 +79,9 @@ void XdgSurfaceV6::zxdg_surface_v6_get_toplevel(QtWaylandServer::zxdg_surface_v6 m_surface->map(); } - -void shell_destroy(struct wl_client *client, - struct wl_resource *resource) -{ - Q_UNUSED(client); - Q_UNUSED(resource); -} - -void create_positioner(struct wl_client *client, - struct wl_resource *resource, - uint32_t id) -{ - Q_UNUSED(client); - Q_UNUSED(resource); - Q_UNUSED(id); -} - -void get_xdg_surface(struct wl_client *client, - struct wl_resource *compositorResource, - uint32_t id, - struct wl_resource *surfaceResource) +void Impl::XdgShellV6::zxdg_shell_v6_get_xdg_surface(QtWaylandServer::zxdg_shell_v6::Resource *resource, uint32_t id, wl_resource *surface) { - int version = wl_resource_get_version(compositorResource); - new XdgSurfaceV6(client, id, version, Surface::fromResource(surfaceResource)); + new XdgSurfaceV6(resource->client(), id, Surface::fromResource(surface)); } -void pong(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - Q_UNUSED(client); - Q_UNUSED(resource); - Q_UNUSED(serial); -} - -void Compositor::bindXdgShellV6(wl_client *client, void *compositorData, uint32_t version, uint32_t id) -{ - static const struct zxdg_shell_v6_interface shellInterface = { - shell_destroy, - create_positioner, - get_xdg_surface, - pong - }; - - wl_resource *resource = wl_resource_create(client, &zxdg_shell_v6_interface, static_cast(version), id); - wl_resource_set_implementation(resource, &shellInterface, compositorData, nullptr); -} - -} +} // namespace Impl -- cgit v1.2.3