summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-09-16 08:16:21 +0200
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-09-16 08:17:12 +0200
commitb4233b2f606617542c594e411640ef2867152d29 (patch)
treefc1fc95fa2df4ab21478e120feba8b34c1585db5 /tests
parent92768cf8d48d6fb62e1a0d124ea9cdec447df4d1 (diff)
parent382e3292aa0eb6addac84ddefeedc98c7f3b41b2 (diff)
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts: src/client/qwaylanddatadevice.cpp src/client/qwaylandinputcontext.cpp src/client/qwaylandinputdevice.cpp src/client/qwaylandwindow.cpp src/compositor/compositor_api/compositor_api.pri src/compositor/compositor_api/qwaylandquickitem.cpp Change-Id: Ice0d8c7d869c9c46113d6ee6ba3adf895a71d58f
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/client.pro1
-rw-r--r--tests/auto/client/datadevicev1/tst_datadevicev1.cpp21
-rw-r--r--tests/auto/client/seatv4/tst_seatv4.cpp25
-rw-r--r--tests/auto/client/xdgdecorationv1/tst_xdgdecorationv1.cpp186
-rw-r--r--tests/auto/client/xdgdecorationv1/xdgdecorationv1.pro7
5 files changed, 238 insertions, 2 deletions
diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro
index 61bf67853..4b1eb2458 100644
--- a/tests/auto/client/client.pro
+++ b/tests/auto/client/client.pro
@@ -11,6 +11,7 @@ SUBDIRS += \
seatv5 \
surface \
wl_connect \
+ xdgdecorationv1 \
xdgoutput \
xdgshell \
xdgshellv6
diff --git a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
index 35ac72528..e3babceb5 100644
--- a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+++ b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
@@ -30,9 +30,8 @@
#include <QtGui/QRasterWindow>
#include <QtGui/QOpenGLWindow>
-
-//TODO: move?
#include <QtGui/QClipboard>
+#include <QtGui/QDrag>
using namespace MockCompositor;
@@ -60,6 +59,7 @@ private slots:
void pasteUtf8();
void destroysPreviousSelection();
void destroysSelectionWithSurface();
+ void dragWithoutFocus();
};
void tst_datadevicev1::initTestCase()
@@ -215,5 +215,22 @@ void tst_datadevicev1::destroysSelectionWithSurface()
QCOMPOSITOR_TRY_COMPARE(dataDevice()->m_sentSelectionOffers.size(), 0);
}
+// The application should not crash if it attempts to start a drag operation
+// when it doesn't have input focus (QTBUG-76368)
+void tst_datadevicev1::dragWithoutFocus()
+{
+ QRasterWindow window;
+ window.resize(64, 64);
+ window.show();
+ QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
+
+ auto *mimeData = new QMimeData;
+ const QByteArray data("testData");
+ mimeData->setData("text/plain", data);
+ QDrag drag(&window);
+ drag.setMimeData(mimeData);
+ drag.exec();
+}
+
QCOMPOSITOR_TEST_MAIN(tst_datadevicev1)
#include "tst_datadevicev1.moc"
diff --git a/tests/auto/client/seatv4/tst_seatv4.cpp b/tests/auto/client/seatv4/tst_seatv4.cpp
index 40f8742a2..2e17bef87 100644
--- a/tests/auto/client/seatv4/tst_seatv4.cpp
+++ b/tests/auto/client/seatv4/tst_seatv4.cpp
@@ -72,6 +72,7 @@ private slots:
void usesEnterSerial();
void focusDestruction();
void mousePress();
+ void mousePressFloat();
void simpleAxis_data();
void simpleAxis();
void invalidPointerEvents();
@@ -208,6 +209,30 @@ void tst_seatv4::mousePress()
QTRY_VERIFY(window.m_pressed);
}
+void tst_seatv4::mousePressFloat()
+{
+ class Window : public QRasterWindow {
+ public:
+ void mousePressEvent(QMouseEvent *e) override { m_position = e->localPos(); }
+ QPointF m_position;
+ };
+
+ Window window;
+ window.resize(64, 64);
+ window.show();
+ QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
+
+ exec([&] {
+ auto *surface = xdgSurface()->m_surface;
+ pointer()->sendEnter(surface, {32.75, 32.25});
+ pointer()->sendButton(client(), BTN_LEFT, 1);
+ pointer()->sendButton(client(), BTN_LEFT, 0);
+ });
+ QMargins m = window.frameMargins();
+ QPointF pressedPosition(32.75 -m.left(), 32.25 - m.top());
+ QTRY_COMPARE(window.m_position, pressedPosition);
+}
+
void tst_seatv4::simpleAxis_data()
{
QTest::addColumn<uint>("axis");
diff --git a/tests/auto/client/xdgdecorationv1/tst_xdgdecorationv1.cpp b/tests/auto/client/xdgdecorationv1/tst_xdgdecorationv1.cpp
new file mode 100644
index 000000000..386713cf5
--- /dev/null
+++ b/tests/auto/client/xdgdecorationv1/tst_xdgdecorationv1.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 <qwayland-server-xdg-decoration-unstable-v1.h>
+
+#include <QtGui/QRasterWindow>
+#include <QtGui/QOpenGLWindow>
+#include <QtGui/QClipboard>
+#include <QtCore/private/qcore_unix_p.h>
+
+#include <fcntl.h>
+
+using namespace MockCompositor;
+
+constexpr int xdgDecorationVersion = 1; // protocol VERSION, not the name suffix (_v1)
+
+class XdgDecorationManagerV1;
+class XdgToplevelDecorationV1 : public QObject, public QtWaylandServer::zxdg_toplevel_decoration_v1
+{
+ Q_OBJECT
+public:
+ explicit XdgToplevelDecorationV1(XdgDecorationManagerV1 *manager, XdgToplevel *toplevel, int id, int version)
+ : zxdg_toplevel_decoration_v1(toplevel->resource()->client(), id, version)
+ , m_manager(manager)
+ , m_toplevel(toplevel)
+ {
+ }
+ void sendConfigure(mode mode)
+ {
+ if (!m_configureSent) {
+ // Attaching buffers before the configure is a protocol error
+ QVERIFY(!m_toplevel->surface()->m_pending.buffer);
+ QVERIFY(!m_toplevel->surface()->m_committed.buffer);
+ }
+ send_configure(mode);
+ m_configureSent = true;
+ }
+ void zxdg_toplevel_decoration_v1_destroy(Resource *resource) override
+ {
+ wl_resource_destroy(resource->handle);
+ }
+ void zxdg_toplevel_decoration_v1_destroy_resource(Resource *resource) override;
+ void zxdg_toplevel_decoration_v1_set_mode(Resource *resource, uint32_t mode) override
+ {
+ Q_UNUSED(resource);
+ m_unsetModeRequested = false;
+ m_requestedMode = XdgToplevelDecorationV1::mode(mode);
+ }
+ void zxdg_toplevel_decoration_v1_unset_mode(Resource *resource) override
+ {
+ Q_UNUSED(resource);
+ m_unsetModeRequested = true;
+ m_requestedMode = mode(0);
+ }
+ XdgDecorationManagerV1 *m_manager = nullptr;
+ XdgToplevel *m_toplevel = nullptr;
+ mode m_requestedMode = mode(0);
+ bool m_unsetModeRequested = false;
+ bool m_configureSent = false;
+};
+
+class XdgDecorationManagerV1 : public Global, public QtWaylandServer::zxdg_decoration_manager_v1
+{
+ Q_OBJECT
+public:
+ explicit XdgDecorationManagerV1(CoreCompositor *compositor, int version = 1)
+ : QtWaylandServer::zxdg_decoration_manager_v1(compositor->m_display, version)
+ , m_version(version)
+ {}
+ bool isClean() override { return m_decorations.empty(); }
+ XdgToplevelDecorationV1 *decorationFor(XdgToplevel *toplevel)
+ {
+ return m_decorations.value(toplevel, nullptr);
+ }
+
+ int m_version = 1; // TODO: Remove on libwayland upgrade
+ QMap<XdgToplevel *, XdgToplevelDecorationV1 *> m_decorations;
+
+protected:
+ void zxdg_decoration_manager_v1_destroy(Resource *resource) override
+ {
+ //TODO: Should the decorations be destroyed at this point?
+ wl_resource_destroy(resource->handle);
+ }
+
+ void zxdg_decoration_manager_v1_get_toplevel_decoration(Resource *resource, uint32_t id, ::wl_resource *toplevelResource) override
+ {
+ auto *toplevel = fromResource<XdgToplevel>(toplevelResource);
+ QVERIFY(toplevel);
+ QVERIFY(!decorationFor(toplevel));
+
+ // Attaching buffers before the configure is a protocol error
+ QVERIFY(!toplevel->surface()->m_pending.buffer);
+ QVERIFY(!toplevel->surface()->m_committed.buffer);
+
+ m_decorations[toplevel] = new XdgToplevelDecorationV1(this, toplevel, id, resource->version());
+ }
+};
+
+void XdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_destroy_resource(QtWaylandServer::zxdg_toplevel_decoration_v1::Resource *resource)
+{
+ Q_UNUSED(resource);
+ int removed = m_manager->m_decorations.remove(m_toplevel);
+ Q_ASSERT(removed == 1);
+ delete this;
+}
+
+class XdgDecorationCompositor : public DefaultCompositor {
+public:
+ explicit XdgDecorationCompositor()
+ {
+ exec([this] {
+ m_config.autoConfigure = true;
+ add<XdgDecorationManagerV1>(xdgDecorationVersion);
+ });
+ }
+ XdgToplevelDecorationV1 *toplevelDecoration(int i = 0) {
+ return get<XdgDecorationManagerV1>()->decorationFor(xdgToplevel(i));
+ }
+};
+
+class tst_xdgdecorationv1 : public QObject, private XdgDecorationCompositor
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void cleanup() { QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage())); }
+ void clientSidePreferredByCompositor();
+};
+
+void tst_xdgdecorationv1::initTestCase()
+{
+ if (qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION"))
+ QSKIP("This test doesn't make sense when QT_WAYLAND_DISABLE_WINDOWDECORATION is set in the environment");
+}
+
+void tst_xdgdecorationv1::clientSidePreferredByCompositor()
+{
+ QRasterWindow window;
+ window.show();
+ QCOMPOSITOR_TRY_COMPARE(get<XdgDecorationManagerV1>()->resourceMap().size(), 1);
+ QCOMPOSITOR_TRY_COMPARE(get<XdgDecorationManagerV1>()->resourceMap().first()->version(), xdgDecorationVersion);
+ QCOMPOSITOR_TRY_VERIFY(toplevelDecoration()); // The client creates a toplevel object
+
+ // Check that we don't assume decorations before the server has configured them
+ QVERIFY(window.frameMargins().isNull());
+
+ QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ QCOMPOSITOR_TRY_VERIFY(toplevelDecoration()->m_unsetModeRequested);
+ QVERIFY(window.frameMargins().isNull()); // We're still waiting for a configure
+ exec([=] {
+ toplevelDecoration()->sendConfigure(XdgToplevelDecorationV1::mode_client_side);
+ xdgToplevel()->sendCompleteConfigure();
+ });
+ QTRY_VERIFY(!window.frameMargins().isNull());
+}
+
+QCOMPOSITOR_TEST_MAIN(tst_xdgdecorationv1)
+#include "tst_xdgdecorationv1.moc"
diff --git a/tests/auto/client/xdgdecorationv1/xdgdecorationv1.pro b/tests/auto/client/xdgdecorationv1/xdgdecorationv1.pro
new file mode 100644
index 000000000..0b5537205
--- /dev/null
+++ b/tests/auto/client/xdgdecorationv1/xdgdecorationv1.pro
@@ -0,0 +1,7 @@
+include (../shared/shared.pri)
+
+WAYLANDSERVERSOURCES += \
+ $$PWD/../../../../src/3rdparty/protocol/xdg-decoration-unstable-v1.xml
+
+TARGET = tst_xdgdecorationv1
+SOURCES += tst_xdgdecorationv1.cpp