summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/client/client.pro4
-rw-r--r--tests/auto/client/client/client.pro26
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp (renamed from tests/auto/client/client/mockcompositor.cpp)3
-rw-r--r--tests/auto/client/shared/mockcompositor.h (renamed from tests/auto/client/client/mockcompositor.h)1
-rw-r--r--tests/auto/client/shared/mockinput.cpp (renamed from tests/auto/client/client/mockinput.cpp)0
-rw-r--r--tests/auto/client/shared/mockinput.h (renamed from tests/auto/client/client/mockinput.h)0
-rw-r--r--tests/auto/client/shared/mockoutput.cpp (renamed from tests/auto/client/client/mockoutput.cpp)0
-rw-r--r--tests/auto/client/shared/mockshell.cpp (renamed from tests/auto/client/client/mockshell.cpp)0
-rw-r--r--tests/auto/client/shared/mocksurface.cpp (renamed from tests/auto/client/client/mocksurface.cpp)0
-rw-r--r--tests/auto/client/shared/mocksurface.h (renamed from tests/auto/client/client/mocksurface.h)0
-rw-r--r--tests/auto/client/shared/mockxdgshellv6.cpp115
-rw-r--r--tests/auto/client/shared/shared.pri24
-rw-r--r--tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp120
-rw-r--r--tests/auto/client/xdgshellv6/xdgshellv6.pro5
14 files changed, 274 insertions, 24 deletions
diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro
index 916b3abe4..d19326797 100644
--- a/tests/auto/client/client.pro
+++ b/tests/auto/client/client.pro
@@ -1,3 +1,5 @@
TEMPLATE=subdirs
-SUBDIRS += client
+SUBDIRS += \
+ client \
+ xdgshellv6
diff --git a/tests/auto/client/client/client.pro b/tests/auto/client/client/client.pro
index 34fc67474..edf80bb9b 100644
--- a/tests/auto/client/client/client.pro
+++ b/tests/auto/client/client/client.pro
@@ -1,24 +1,4 @@
-CONFIG += testcase link_pkgconfig
-TARGET = tst_client
-
-QT += testlib
-QT += core-private gui-private
-
-QMAKE_USE += wayland-client wayland-server
+include (../shared/shared.pri)
-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
+TARGET = tst_client
+SOURCES += tst_client.cpp
diff --git a/tests/auto/client/client/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index d8f3222f1..411a89757 100644
--- a/tests/auto/client/client/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -30,6 +30,8 @@
#include "mockinput.h"
#include "mocksurface.h"
+#include <wayland-xdg-shell-unstable-v6-server-protocol.h>
+
#include <stdio.h>
MockCompositor::MockCompositor()
: 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_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_fd = wl_event_loop_get_fd(m_loop);
diff --git a/tests/auto/client/client/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index a9492921e..a304b3792 100644
--- a/tests/auto/client/client/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -94,6 +94,7 @@ private:
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 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();
diff --git a/tests/auto/client/client/mockinput.cpp b/tests/auto/client/shared/mockinput.cpp
index 9e5689210..9e5689210 100644
--- a/tests/auto/client/client/mockinput.cpp
+++ b/tests/auto/client/shared/mockinput.cpp
diff --git a/tests/auto/client/client/mockinput.h b/tests/auto/client/shared/mockinput.h
index 9c217b6ac..9c217b6ac 100644
--- a/tests/auto/client/client/mockinput.h
+++ b/tests/auto/client/shared/mockinput.h
diff --git a/tests/auto/client/client/mockoutput.cpp b/tests/auto/client/shared/mockoutput.cpp
index 86561976f..86561976f 100644
--- a/tests/auto/client/client/mockoutput.cpp
+++ b/tests/auto/client/shared/mockoutput.cpp
diff --git a/tests/auto/client/client/mockshell.cpp b/tests/auto/client/shared/mockshell.cpp
index d5eede22e..d5eede22e 100644
--- a/tests/auto/client/client/mockshell.cpp
+++ b/tests/auto/client/shared/mockshell.cpp
diff --git a/tests/auto/client/client/mocksurface.cpp b/tests/auto/client/shared/mocksurface.cpp
index 61c9ac1b7..61c9ac1b7 100644
--- a/tests/auto/client/client/mocksurface.cpp
+++ b/tests/auto/client/shared/mocksurface.cpp
diff --git a/tests/auto/client/client/mocksurface.h b/tests/auto/client/shared/mocksurface.h
index 5155599bb..5155599bb 100644
--- a/tests/auto/client/client/mocksurface.h
+++ b/tests/auto/client/shared/mocksurface.h
diff --git a/tests/auto/client/shared/mockxdgshellv6.cpp b/tests/auto/client/shared/mockxdgshellv6.cpp
new file mode 100644
index 000000000..fe9d11857
--- /dev/null
+++ b/tests/auto/client/shared/mockxdgshellv6.cpp
@@ -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);
+}
+
+}
diff --git a/tests/auto/client/shared/shared.pri b/tests/auto/client/shared/shared.pri
new file mode 100644
index 000000000..5edfc09c0
--- /dev/null
+++ b/tests/auto/client/shared/shared.pri
@@ -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
diff --git a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp
new file mode 100644
index 000000000..6d0f4a003
--- /dev/null
+++ b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp
@@ -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>
diff --git a/tests/auto/client/xdgshellv6/xdgshellv6.pro b/tests/auto/client/xdgshellv6/xdgshellv6.pro
new file mode 100644
index 000000000..4fec593df
--- /dev/null
+++ b/tests/auto/client/xdgshellv6/xdgshellv6.pro
@@ -0,0 +1,5 @@
+include (../shared/shared.pri)
+
+TARGET = tst_client_xdgshellv6
+SOURCES += tst_xdgshellv6.cpp
+