From 2cb631894332eff4604cbb031d77a4fedd461148 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 5 Oct 2020 19:29:29 +0200 Subject: Implement MockRegion If we don't mock regions, we get a crash every time that a client calls createRegion. So far regions are untested. Pick-to: 5.15 Change-Id: I83f20b879ece5cefcf2039d369034516df6a6a62 Reviewed-by: David Edmundson --- tests/auto/client/client/.prev_CMakeLists.txt | 1 + tests/auto/client/client/CMakeLists.txt | 1 + .../client/fullscreenshellv1/.prev_CMakeLists.txt | 1 + tests/auto/client/fullscreenshellv1/CMakeLists.txt | 1 + .../client/iviapplication/.prev_CMakeLists.txt | 1 + tests/auto/client/iviapplication/CMakeLists.txt | 1 + tests/auto/client/shared_old/mockcompositor.cpp | 6 +-- tests/auto/client/shared_old/mockcompositor.h | 18 +++++++ tests/auto/client/shared_old/mockregion.cpp | 51 ++++++++++++++++++ tests/auto/client/shared_old/mockregion.h | 62 ++++++++++++++++++++++ tests/auto/client/shared_old/shared_old.pri | 2 + tests/auto/client/xdgshellv6/.prev_CMakeLists.txt | 1 + tests/auto/client/xdgshellv6/CMakeLists.txt | 1 + 13 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 tests/auto/client/shared_old/mockregion.cpp create mode 100644 tests/auto/client/shared_old/mockregion.h diff --git a/tests/auto/client/client/.prev_CMakeLists.txt b/tests/auto/client/client/.prev_CMakeLists.txt index ece394fcc..cdcae2ff1 100644 --- a/tests/auto/client/client/.prev_CMakeLists.txt +++ b/tests/auto/client/client/.prev_CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h diff --git a/tests/auto/client/client/CMakeLists.txt b/tests/auto/client/client/CMakeLists.txt index 919bf064d..86eb420e5 100644 --- a/tests/auto/client/client/CMakeLists.txt +++ b/tests/auto/client/client/CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h diff --git a/tests/auto/client/fullscreenshellv1/.prev_CMakeLists.txt b/tests/auto/client/fullscreenshellv1/.prev_CMakeLists.txt index 7cf9624c0..c3e375c0f 100644 --- a/tests/auto/client/fullscreenshellv1/.prev_CMakeLists.txt +++ b/tests/auto/client/fullscreenshellv1/.prev_CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client_fullscreenshellv1 ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h diff --git a/tests/auto/client/fullscreenshellv1/CMakeLists.txt b/tests/auto/client/fullscreenshellv1/CMakeLists.txt index 7a5a72c24..42d328a64 100644 --- a/tests/auto/client/fullscreenshellv1/CMakeLists.txt +++ b/tests/auto/client/fullscreenshellv1/CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client_fullscreenshellv1 ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h diff --git a/tests/auto/client/iviapplication/.prev_CMakeLists.txt b/tests/auto/client/iviapplication/.prev_CMakeLists.txt index 2aaed6bab..ce9c8fd91 100644 --- a/tests/auto/client/iviapplication/.prev_CMakeLists.txt +++ b/tests/auto/client/iviapplication/.prev_CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client_iviapplication ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h diff --git a/tests/auto/client/iviapplication/CMakeLists.txt b/tests/auto/client/iviapplication/CMakeLists.txt index cf6ebeab5..ca9679af8 100644 --- a/tests/auto/client/iviapplication/CMakeLists.txt +++ b/tests/auto/client/iviapplication/CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client_iviapplication ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h diff --git a/tests/auto/client/shared_old/mockcompositor.cpp b/tests/auto/client/shared_old/mockcompositor.cpp index 61494cbb5..6fd2ec6bb 100644 --- a/tests/auto/client/shared_old/mockcompositor.cpp +++ b/tests/auto/client/shared_old/mockcompositor.cpp @@ -382,9 +382,9 @@ static void compositor_create_surface(wl_client *client, wl_resource *compositor static void compositor_create_region(wl_client *client, wl_resource *compositorResource, uint32_t id) { - Q_UNUSED(client); - Q_UNUSED(compositorResource); - Q_UNUSED(id); + Compositor *compositor = + static_cast(wl_resource_get_user_data(compositorResource)); + new Region(client, id, wl_resource_get_version(compositorResource), compositor); } void Compositor::bindCompositor(wl_client *client, void *compositorData, uint32_t version, uint32_t id) diff --git a/tests/auto/client/shared_old/mockcompositor.h b/tests/auto/client/shared_old/mockcompositor.h index 323803996..cbcf34cbd 100644 --- a/tests/auto/client/shared_old/mockcompositor.h +++ b/tests/auto/client/shared_old/mockcompositor.h @@ -32,12 +32,14 @@ #include "mockxdgshellv6.h" #include "mockiviapplication.h" #include "mockfullscreenshellv1.h" +#include "mockregion.h" #include #include #include #include +#include #include #include #include @@ -61,6 +63,7 @@ class Output; class IviApplication; class WlShell; class XdgShellV6; +class Region; class Compositor { @@ -159,6 +162,21 @@ private: Q_DECLARE_METATYPE(QSharedPointer) +class MockRegion +{ +public: + Impl::Region *handle() const { return m_region; } + +private: + MockRegion(Impl::Region *region); + friend class Impl::Compositor; + friend class Impl::Region; + + Impl::Region *m_region = nullptr; +}; + +Q_DECLARE_METATYPE(QSharedPointer) + class MockIviSurface { public: diff --git a/tests/auto/client/shared_old/mockregion.cpp b/tests/auto/client/shared_old/mockregion.cpp new file mode 100644 index 000000000..78b457fae --- /dev/null +++ b/tests/auto/client/shared_old/mockregion.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Aleix Pol Gonzalez +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mockregion.h" +#include "mockcompositor.h" + +namespace Impl { + +Region::Region(wl_client *client, uint32_t id, int v, Compositor *compositor) + : QtWaylandServer::wl_region(client, id, v), + m_compositor(compositor), + m_mockRegion(new MockRegion(this)) +{ +} + +Region::~Region() = default; + +void Region::region_destroy_resource(Resource *resource) +{ + Q_UNUSED(resource) + delete this; +} + +} + +MockRegion::MockRegion(Impl::Region *region) : m_region(region) { } diff --git a/tests/auto/client/shared_old/mockregion.h b/tests/auto/client/shared_old/mockregion.h new file mode 100644 index 000000000..f98a25fbb --- /dev/null +++ b/tests/auto/client/shared_old/mockregion.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Aleix Pol Gonzalez +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MOCKREGION_H +#define MOCKREGION_H + +#include +#include + +#include "qwayland-server-wayland.h" + +class MockRegion; + +namespace Impl { + +class Compositor; + +class Region : public QtWaylandServer::wl_region +{ +public: + Region(wl_client *client, uint32_t id, int v, Compositor *compositor); + ~Region(); + + Compositor *compositor() const { return m_compositor; } + static Region *fromResource(struct ::wl_resource *resource); + +protected: + void region_destroy_resource(Resource *resource) override; + +private: + Compositor *m_compositor = nullptr; + QSharedPointer m_mockRegion; +}; + +} + +#endif // MOCKREGION_H diff --git a/tests/auto/client/shared_old/shared_old.pri b/tests/auto/client/shared_old/shared_old.pri index 6989e613e..899e6b309 100644 --- a/tests/auto/client/shared_old/shared_old.pri +++ b/tests/auto/client/shared_old/shared_old.pri @@ -21,6 +21,7 @@ SOURCES += \ ../shared_old/mockwlshell.cpp \ ../shared_old/mockxdgshellv6.cpp \ ../shared_old/mocksurface.cpp \ + ../shared_old/mockregion.cpp \ ../shared_old/mockoutput.cpp HEADERS += \ @@ -31,4 +32,5 @@ HEADERS += \ ../shared_old/mockwlshell.h \ ../shared_old/mockxdgshellv6.h \ ../shared_old/mocksurface.h \ + ../shared_old/mockregion.h \ ../shared_old/mockoutput.h diff --git a/tests/auto/client/xdgshellv6/.prev_CMakeLists.txt b/tests/auto/client/xdgshellv6/.prev_CMakeLists.txt index 12f3ee190..dc40fd637 100644 --- a/tests/auto/client/xdgshellv6/.prev_CMakeLists.txt +++ b/tests/auto/client/xdgshellv6/.prev_CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client_xdgshellv6 ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h diff --git a/tests/auto/client/xdgshellv6/CMakeLists.txt b/tests/auto/client/xdgshellv6/CMakeLists.txt index cc8b154b4..0e1704ea4 100644 --- a/tests/auto/client/xdgshellv6/CMakeLists.txt +++ b/tests/auto/client/xdgshellv6/CMakeLists.txt @@ -11,6 +11,7 @@ qt_internal_add_test(tst_client_xdgshellv6 ../shared_old/mockinput.cpp ../shared_old/mockinput.h ../shared_old/mockiviapplication.cpp ../shared_old/mockiviapplication.h ../shared_old/mockoutput.cpp ../shared_old/mockoutput.h + ../shared_old/mockregion.cpp ../shared_old/mockregion.h ../shared_old/mocksurface.cpp ../shared_old/mocksurface.h ../shared_old/mockwlshell.cpp ../shared_old/mockwlshell.h ../shared_old/mockxdgshellv6.cpp ../shared_old/mockxdgshellv6.h -- cgit v1.2.3