Test client side xdg shell v6
Apart for some new mocking code for xdg shell v6, this is mostly a refactor of the existing test, to reuse the existing mocking code between the different shell integrations. Change-Id: I68f93ab12ac47e51a50fd69647286cab46a3c595 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
4e0e6db654
commit
b90c278ed8
@ -1,3 +1,5 @@
|
|||||||
TEMPLATE=subdirs
|
TEMPLATE=subdirs
|
||||||
|
|
||||||
SUBDIRS += client
|
SUBDIRS += \
|
||||||
|
client \
|
||||||
|
xdgshellv6
|
||||||
|
@ -1,24 +1,4 @@
|
|||||||
CONFIG += testcase link_pkgconfig
|
include (../shared/shared.pri)
|
||||||
|
|
||||||
TARGET = tst_client
|
TARGET = tst_client
|
||||||
|
SOURCES += tst_client.cpp
|
||||||
QT += testlib
|
|
||||||
QT += core-private gui-private
|
|
||||||
|
|
||||||
QMAKE_USE += wayland-client wayland-server
|
|
||||||
|
|
||||||
CONFIG += wayland-scanner
|
|
||||||
WAYLANDSERVERSOURCES += \
|
|
||||||
../../../../src/3rdparty/protocol/wayland.xml
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
tst_client.cpp \
|
|
||||||
mockcompositor.cpp \
|
|
||||||
mockinput.cpp \
|
|
||||||
mockshell.cpp \
|
|
||||||
mocksurface.cpp \
|
|
||||||
mockoutput.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
mockcompositor.h \
|
|
||||||
mockinput.h \
|
|
||||||
mocksurface.h
|
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "mockinput.h"
|
#include "mockinput.h"
|
||||||
#include "mocksurface.h"
|
#include "mocksurface.h"
|
||||||
|
|
||||||
|
#include <wayland-xdg-shell-unstable-v6-server-protocol.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
MockCompositor::MockCompositor()
|
MockCompositor::MockCompositor()
|
||||||
: m_alive(true)
|
: m_alive(true)
|
||||||
@ -285,6 +287,7 @@ Compositor::Compositor()
|
|||||||
|
|
||||||
wl_global_create(m_display, &wl_output_interface, 1, this, bindOutput);
|
wl_global_create(m_display, &wl_output_interface, 1, this, bindOutput);
|
||||||
wl_global_create(m_display, &wl_shell_interface, 1, this, bindShell);
|
wl_global_create(m_display, &wl_shell_interface, 1, this, bindShell);
|
||||||
|
wl_global_create(m_display, &zxdg_shell_v6_interface, 1, this, bindXdgShellV6);
|
||||||
|
|
||||||
m_loop = wl_display_get_event_loop(m_display);
|
m_loop = wl_display_get_event_loop(m_display);
|
||||||
m_fd = wl_event_loop_get_fd(m_loop);
|
m_fd = wl_event_loop_get_fd(m_loop);
|
@ -94,6 +94,7 @@ private:
|
|||||||
static void bindCompositor(wl_client *client, void *data, uint32_t version, uint32_t id);
|
static void bindCompositor(wl_client *client, void *data, uint32_t version, uint32_t id);
|
||||||
static void bindOutput(wl_client *client, void *data, uint32_t version, uint32_t id);
|
static void bindOutput(wl_client *client, void *data, uint32_t version, uint32_t id);
|
||||||
static void bindShell(wl_client *client, void *data, uint32_t version, uint32_t id);
|
static void bindShell(wl_client *client, void *data, uint32_t version, uint32_t id);
|
||||||
|
static void bindXdgShellV6(wl_client *client, void *compositorData, uint32_t version, uint32_t id);
|
||||||
|
|
||||||
void initShm();
|
void initShm();
|
||||||
|
|
115
tests/auto/wayland/shared/mockxdgshellv6.cpp
Normal file
115
tests/auto/wayland/shared/mockxdgshellv6.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2017 The Qt Company Ltd.
|
||||||
|
** 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 "mockcompositor.h"
|
||||||
|
#include "mocksurface.h"
|
||||||
|
|
||||||
|
#include <qwayland-server-xdg-shell-unstable-v6.h>
|
||||||
|
|
||||||
|
namespace Impl {
|
||||||
|
|
||||||
|
class XdgToplevelV6 : public QtWaylandServer::zxdg_toplevel_v6
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XdgToplevelV6(wl_client *client, uint32_t id, int version)
|
||||||
|
: QtWaylandServer::zxdg_toplevel_v6(client, id, version)
|
||||||
|
{}
|
||||||
|
void zxdg_toplevel_v6_destroy_resource(Resource *resource) override { delete this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class XdgSurfaceV6 : public QtWaylandServer::zxdg_surface_v6
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XdgSurfaceV6(wl_client *client, uint32_t id, int version, Surface *surface);
|
||||||
|
void zxdg_surface_v6_destroy_resource(Resource *resource) override { delete this; }
|
||||||
|
void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id) override;
|
||||||
|
Surface *m_surface = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
XdgSurfaceV6::XdgSurfaceV6(wl_client *client, uint32_t id, int version, Surface *surface)
|
||||||
|
: QtWaylandServer::zxdg_surface_v6(client, id, version)
|
||||||
|
, m_surface(surface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void XdgSurfaceV6::zxdg_surface_v6_get_toplevel(QtWaylandServer::zxdg_surface_v6::Resource *resource, uint32_t id)
|
||||||
|
{
|
||||||
|
int version = wl_resource_get_version(resource->handle);
|
||||||
|
new XdgToplevelV6(resource->client(), id, version);
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
int version = wl_resource_get_version(compositorResource);
|
||||||
|
new XdgSurfaceV6(client, id, version, Surface::fromResource(surfaceResource));
|
||||||
|
}
|
||||||
|
|
||||||
|
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<int>(version), id);
|
||||||
|
wl_resource_set_implementation(resource, &shellInterface, compositorData, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
24
tests/auto/wayland/shared/shared.pri
Normal file
24
tests/auto/wayland/shared/shared.pri
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
CONFIG += testcase link_pkgconfig
|
||||||
|
QT += testlib
|
||||||
|
|
||||||
|
QMAKE_USE += wayland-client wayland-server
|
||||||
|
|
||||||
|
CONFIG += wayland-scanner
|
||||||
|
WAYLANDSERVERSOURCES += \
|
||||||
|
../../../../src/3rdparty/protocol/wayland.xml \
|
||||||
|
../../../../src/3rdparty/protocol/xdg-shell-unstable-v6.xml
|
||||||
|
|
||||||
|
INCLUDEPATH += ../shared
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../shared/mockcompositor.cpp \
|
||||||
|
../shared/mockinput.cpp \
|
||||||
|
../shared/mockshell.cpp \
|
||||||
|
../shared/mockxdgshellv6.cpp \
|
||||||
|
../shared/mocksurface.cpp \
|
||||||
|
../shared/mockoutput.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
../shared/mockcompositor.h \
|
||||||
|
../shared/mockinput.h \
|
||||||
|
../shared/mocksurface.h
|
120
tests/auto/wayland/xdgshellv6/tst_xdgshellv6.cpp
Normal file
120
tests/auto/wayland/xdgshellv6/tst_xdgshellv6.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2017 The Qt Company Ltd.
|
||||||
|
** 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 "mockcompositor.h"
|
||||||
|
|
||||||
|
#include <QBackingStore>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QWindow>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QDrag>
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
static const QSize screenSize(1600, 1200);
|
||||||
|
|
||||||
|
class TestWindow : public QWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestWindow()
|
||||||
|
{
|
||||||
|
setSurfaceType(QSurface::RasterSurface);
|
||||||
|
setGeometry(0, 0, 32, 32);
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class tst_WaylandClientXdgShellV6 : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
tst_WaylandClientXdgShellV6(MockCompositor *c)
|
||||||
|
: m_compositor(c)
|
||||||
|
{
|
||||||
|
QSocketNotifier *notifier = new QSocketNotifier(m_compositor->waylandFileDescriptor(), QSocketNotifier::Read, this);
|
||||||
|
connect(notifier, &QSocketNotifier::activated, this, &tst_WaylandClientXdgShellV6::processWaylandEvents);
|
||||||
|
// connect to the event dispatcher to make sure to flush out the outgoing message queue
|
||||||
|
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &tst_WaylandClientXdgShellV6::processWaylandEvents);
|
||||||
|
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &tst_WaylandClientXdgShellV6::processWaylandEvents);
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void processWaylandEvents()
|
||||||
|
{
|
||||||
|
m_compositor->processWaylandEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cleanup()
|
||||||
|
{
|
||||||
|
// make sure the surfaces from the last test are properly cleaned up
|
||||||
|
// and don't show up as false positives in the next test
|
||||||
|
QTRY_VERIFY(!m_compositor->surface());
|
||||||
|
}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void createDestroyWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MockCompositor *m_compositor;
|
||||||
|
};
|
||||||
|
|
||||||
|
void tst_WaylandClientXdgShellV6::createDestroyWindow()
|
||||||
|
{
|
||||||
|
TestWindow window;
|
||||||
|
window.show();
|
||||||
|
|
||||||
|
QTRY_VERIFY(m_compositor->surface());
|
||||||
|
|
||||||
|
window.destroy();
|
||||||
|
QTRY_VERIFY(!m_compositor->surface());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
setenv("XDG_RUNTIME_DIR", ".", 1);
|
||||||
|
setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
|
||||||
|
setenv("QT_WAYLAND_SHELL_INTEGRATION", "xdg-shell-v6", 1);
|
||||||
|
|
||||||
|
// wayland-egl hangs in the test setup when we try to initialize. Until it gets
|
||||||
|
// figured out, avoid clientBufferIntegration() from being called in
|
||||||
|
// QWaylandWindow::createDecorations().
|
||||||
|
setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1);
|
||||||
|
|
||||||
|
MockCompositor compositor;
|
||||||
|
compositor.setOutputGeometry(QRect(QPoint(), screenSize));
|
||||||
|
|
||||||
|
QGuiApplication app(argc, argv);
|
||||||
|
compositor.applicationInitialized();
|
||||||
|
|
||||||
|
tst_WaylandClientXdgShellV6 tc(&compositor);
|
||||||
|
return QTest::qExec(&tc, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <tst_xdgshellv6.moc>
|
5
tests/auto/wayland/xdgshellv6/xdgshellv6.pro
Normal file
5
tests/auto/wayland/xdgshellv6/xdgshellv6.pro
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
include (../shared/shared.pri)
|
||||||
|
|
||||||
|
TARGET = tst_client_xdgshellv6
|
||||||
|
SOURCES += tst_xdgshellv6.cpp
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user