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>
This commit is contained in:
parent
e800b14c8c
commit
5c4f0dea27
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
51
tests/auto/wayland/shared_old/mockregion.cpp
Normal file
51
tests/auto/wayland/shared_old/mockregion.cpp
Normal file
@ -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) { }
|
62
tests/auto/wayland/shared_old/mockregion.h
Normal file
62
tests/auto/wayland/shared_old/mockregion.h
Normal file
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user