diff options
author | Aleix Pol <aleixpol@kde.org> | 2020-10-05 19:29:29 +0200 |
---|---|---|
committer | Aleix Pol <aleixpol@kde.org> | 2020-10-09 13:34:58 +0200 |
commit | 2cb631894332eff4604cbb031d77a4fedd461148 (patch) | |
tree | c9ab08708b3e53bc9bd79abcb1db9fe0bb9168d5 | |
parent | 98aea22d839000a377d0fc646133f76e08b44f6e (diff) | |
download | qtwayland-2cb631894332eff4604cbb031d77a4fedd461148.tar.gz |
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 <davidedmundson@kde.org>
-rw-r--r-- | tests/auto/client/client/.prev_CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/client/client/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/client/fullscreenshellv1/.prev_CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/client/fullscreenshellv1/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/client/iviapplication/.prev_CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/client/iviapplication/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/client/shared_old/mockcompositor.cpp | 6 | ||||
-rw-r--r-- | tests/auto/client/shared_old/mockcompositor.h | 18 | ||||
-rw-r--r-- | tests/auto/client/shared_old/mockregion.cpp | 51 | ||||
-rw-r--r-- | tests/auto/client/shared_old/mockregion.h | 62 | ||||
-rw-r--r-- | tests/auto/client/shared_old/shared_old.pri | 2 | ||||
-rw-r--r-- | tests/auto/client/xdgshellv6/.prev_CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/client/xdgshellv6/CMakeLists.txt | 1 |
13 files changed, 144 insertions, 3 deletions
diff --git a/tests/auto/client/client/.prev_CMakeLists.txt b/tests/auto/client/client/.prev_CMakeLists.txt index ece394fc..cdcae2ff 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 919bf064..86eb420e 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 7cf9624c..c3e375c0 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 7a5a72c2..42d328a6 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 2aaed6ba..ce9c8fd9 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 cf6ebeab..ca9679af 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 61494cbb..6fd2ec6b 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<Compositor *>(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 32380399..cbcf34cb 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 <pthread.h> #include <qglobal.h> #include <wayland-server-core.h> #include <QImage> +#include <QRegion> #include <QList> #include <QMutex> #include <QRect> @@ -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<MockSurface>) +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<MockRegion>) + 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 00000000..78b457fa --- /dev/null +++ b/tests/auto/client/shared_old/mockregion.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org> +** 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 00000000..f98a25fb --- /dev/null +++ b/tests/auto/client/shared_old/mockregion.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org> +** 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 <qglobal.h> +#include <QSharedPointer> + +#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<MockRegion> 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 6989e613..899e6b30 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 12f3ee19..dc40fd63 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 cc8b154b..0e1704ea 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 |