summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2020-10-05 19:29:29 +0200
committerAleix Pol <aleixpol@kde.org>2020-10-09 18:25:52 +0200
commit65922085c3ba302b9049e62c1e132236b726adf9 (patch)
treebb8f2c7b40a76d6cd7814ec489f29fd7696f3886 /tests
parent1344ca6b5a8fbc1b28727feea6d856af8bf3bc93 (diff)
Implement MockRegion
If we don't mock regions, we get a crash every time that a client calls createRegion. So far regions are untested. Change-Id: I83f20b879ece5cefcf2039d369034516df6a6a62 Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit 2cb631894332eff4604cbb031d77a4fedd461148)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/shared_old/mockcompositor.cpp6
-rw-r--r--tests/auto/client/shared_old/mockcompositor.h19
-rw-r--r--tests/auto/client/shared_old/mockregion.cpp51
-rw-r--r--tests/auto/client/shared_old/mockregion.h62
-rw-r--r--tests/auto/client/shared_old/shared_old.pri2
5 files changed, 137 insertions, 3 deletions
diff --git a/tests/auto/client/shared_old/mockcompositor.cpp b/tests/auto/client/shared_old/mockcompositor.cpp
index 9553076dd..a415cbf56 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 2433ac005..277e7e4e3 100644
--- a/tests/auto/client/shared_old/mockcompositor.h
+++ b/tests/auto/client/shared_old/mockcompositor.h
@@ -32,12 +32,15 @@
#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>
#include <QSharedPointer>
@@ -61,6 +64,7 @@ class Output;
class IviApplication;
class WlShell;
class XdgShellV6;
+class Region;
class Compositor
{
@@ -159,6 +163,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 000000000..78b457fae
--- /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 000000000..f98a25fbb
--- /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 467e98115..7647e1e45 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