diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-08-27 07:51:18 +0300 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-08-27 07:51:18 +0300 |
commit | 7a88090775dd666af318cd715988cfaa02109ff1 (patch) | |
tree | e23f5d516ade02fd284c6b28f496f266bcf4f799 /tests | |
parent | da5e5e6c8ec0f311b33731b56d77181f8244a2e6 (diff) | |
parent | 8b3a2124c97358d1e57089fc86818965e9a28497 (diff) |
Merge dev into 5.14
Change-Id: Iaf121f1db2fea08dd4ce16136b8d68c94b182084
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 11 | ||||
-rw-r--r-- | tests/auto/client/inputcontext/inputcontext.pro | 2 | ||||
-rw-r--r-- | tests/auto/compositor/compositor/compositor.pro | 9 | ||||
-rw-r--r-- | tests/auto/compositor/compositor/mockclient.cpp | 13 | ||||
-rw-r--r-- | tests/auto/compositor/compositor/mockclient.h | 5 | ||||
-rw-r--r-- | tests/auto/compositor/compositor/mockxdgoutputv1.cpp | 68 | ||||
-rw-r--r-- | tests/auto/compositor/compositor/mockxdgoutputv1.h | 64 | ||||
-rw-r--r-- | tests/auto/compositor/compositor/tst_compositor.cpp | 76 |
8 files changed, 238 insertions, 10 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d81339e86..032ae47a4 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,10 +1,11 @@ TEMPLATE=subdirs QT_FOR_CONFIG += waylandclient-private -!qtHaveModule(waylandcompositor): \ - return() +qtHaveModule(waylandclient): \ + SUBDIRS += client -SUBDIRS += compositor +qtHaveModule(waylandclient):qtHaveModule(waylandcompositor): \ + SUBDIRS += cmake -qtConfig(wayland-client): \ - SUBDIRS += client cmake +qtHaveModule(waylandcompositor): \ + SUBDIRS += compositor diff --git a/tests/auto/client/inputcontext/inputcontext.pro b/tests/auto/client/inputcontext/inputcontext.pro index 4419b3e77..1971d455e 100644 --- a/tests/auto/client/inputcontext/inputcontext.pro +++ b/tests/auto/client/inputcontext/inputcontext.pro @@ -1,6 +1,4 @@ include (../shared/shared.pri) -QT += waylandcompositor - TARGET = tst_inputcontext SOURCES += tst_inputcontext.cpp diff --git a/tests/auto/compositor/compositor/compositor.pro b/tests/auto/compositor/compositor/compositor.pro index 8a364e52c..270016597 100644 --- a/tests/auto/compositor/compositor/compositor.pro +++ b/tests/auto/compositor/compositor/compositor.pro @@ -15,7 +15,8 @@ WAYLANDCLIENTSOURCES += \ ../../../../src/3rdparty/protocol/wayland.xml \ ../../../../src/3rdparty/protocol/xdg-shell.xml \ ../../../../src/3rdparty/protocol/viewporter.xml \ - ../../../../src/3rdparty/protocol/idle-inhibit-unstable-v1.xml + ../../../../src/3rdparty/protocol/idle-inhibit-unstable-v1.xml \ + ../../../../src/3rdparty/protocol/xdg-output-unstable-v1.xml SOURCES += \ tst_compositor.cpp \ @@ -25,7 +26,8 @@ SOURCES += \ mockseat.cpp \ testseat.cpp \ mockkeyboard.cpp \ - mockpointer.cpp + mockpointer.cpp \ + mockxdgoutputv1.cpp HEADERS += \ testcompositor.h \ @@ -34,4 +36,5 @@ HEADERS += \ mockseat.h \ testseat.h \ mockkeyboard.h \ - mockpointer.h + mockpointer.h \ + mockxdgoutputv1.h diff --git a/tests/auto/compositor/compositor/mockclient.cpp b/tests/auto/compositor/compositor/mockclient.cpp index 4ae04998e..27d1eed89 100644 --- a/tests/auto/compositor/compositor/mockclient.cpp +++ b/tests/auto/compositor/compositor/mockclient.cpp @@ -186,11 +186,17 @@ void MockClient::handleGlobal(uint32_t id, const QByteArray &interface) m_seats << new MockSeat(s); } else if (interface == "zwp_idle_inhibit_manager_v1") { idleInhibitManager = static_cast<zwp_idle_inhibit_manager_v1 *>(wl_registry_bind(registry, id, &zwp_idle_inhibit_manager_v1_interface, 1)); + } else if (interface == "zxdg_output_manager_v1") { + xdgOutputManager = new QtWayland::zxdg_output_manager_v1(registry, id, 2); } } void MockClient::handleGlobalRemove(uint32_t id) { + auto *output = m_outputs[id]; + if (m_xdgOutputs.contains(output)) + delete m_xdgOutputs.take(output); + m_outputs.remove(id); } @@ -234,6 +240,13 @@ zwp_idle_inhibitor_v1 *MockClient::createIdleInhibitor(wl_surface *surface) return idleInhibitor; } +MockXdgOutputV1 *MockClient::createXdgOutput(wl_output *output) +{ + auto *xdgOutput = new MockXdgOutputV1(xdgOutputManager->get_xdg_output(output)); + m_xdgOutputs[output] = xdgOutput; + return xdgOutput; +} + ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm) { int stride = size.width() * 4; diff --git a/tests/auto/compositor/compositor/mockclient.h b/tests/auto/compositor/compositor/mockclient.h index aa20a7ac7..69a0e47cf 100644 --- a/tests/auto/compositor/compositor/mockclient.h +++ b/tests/auto/compositor/compositor/mockclient.h @@ -38,6 +38,8 @@ #include <QList> #include <QWaylandOutputMode> +#include "mockxdgoutputv1.h" + class MockSeat; class ShmBuffer @@ -65,10 +67,12 @@ public: xdg_toplevel *createXdgToplevel(xdg_surface *xdgSurface); ivi_surface *createIviSurface(wl_surface *surface, uint iviId); zwp_idle_inhibitor_v1 *createIdleInhibitor(wl_surface *surface); + MockXdgOutputV1 *createXdgOutput(wl_output *output); wl_display *display = nullptr; wl_compositor *compositor = nullptr; QMap<uint, wl_output *> m_outputs; + QMap<wl_output *, MockXdgOutputV1 *> m_xdgOutputs; wl_shm *shm = nullptr; wl_registry *registry = nullptr; wl_shell *wlshell = nullptr; @@ -76,6 +80,7 @@ public: wp_viewporter *viewporter = nullptr; ivi_application *iviApplication = nullptr; zwp_idle_inhibit_manager_v1 *idleInhibitManager = nullptr; + QtWayland::zxdg_output_manager_v1 *xdgOutputManager = nullptr; QList<MockSeat *> m_seats; diff --git a/tests/auto/compositor/compositor/mockxdgoutputv1.cpp b/tests/auto/compositor/compositor/mockxdgoutputv1.cpp new file mode 100644 index 000000000..eebc55bbb --- /dev/null +++ b/tests/auto/compositor/compositor/mockxdgoutputv1.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +** 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 "mockxdgoutputv1.h" + +MockXdgOutputV1::MockXdgOutputV1(struct ::zxdg_output_v1 *object) + : QtWayland::zxdg_output_v1(object) +{ +} + +MockXdgOutputV1::~MockXdgOutputV1() +{ + destroy(); +} + +void MockXdgOutputV1::zxdg_output_v1_logical_position(int32_t x, int32_t y) +{ + pending.logicalPosition = QPoint(x, y); +} + +void MockXdgOutputV1::zxdg_output_v1_logical_size(int32_t width, int32_t height) +{ + pending.logicalSize = QSize(width, height); +} + +void MockXdgOutputV1::zxdg_output_v1_done() +{ + // In version 3 we'll have to do this for wl_output.done as well + name = pending.name; + description = pending.description; + logicalPosition = pending.logicalPosition; + logicalSize = pending.logicalSize; +} + +void MockXdgOutputV1::zxdg_output_v1_name(const QString &name) +{ + pending.name = name; +} + +void MockXdgOutputV1::zxdg_output_v1_description(const QString &description) +{ + pending.description = description; +} diff --git a/tests/auto/compositor/compositor/mockxdgoutputv1.h b/tests/auto/compositor/compositor/mockxdgoutputv1.h new file mode 100644 index 000000000..db5820698 --- /dev/null +++ b/tests/auto/compositor/compositor/mockxdgoutputv1.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +** 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 MOCKXDGOUTPUTV1_H +#define MOCKXDGOUTPUTV1_H + +#include <QPoint> +#include <QSize> +#include <QString> + +#include "qwayland-xdg-output-unstable-v1.h" + +class MockXdgOutputV1 : public QtWayland::zxdg_output_v1 +{ +public: + explicit MockXdgOutputV1(struct ::zxdg_output_v1 *object); + ~MockXdgOutputV1(); + + QString name; + QString description; + QPoint logicalPosition; + QSize logicalSize; + + struct { + QString name; + QString description; + QPoint logicalPosition; + QSize logicalSize; + } pending; + +protected: + void zxdg_output_v1_logical_position(int32_t x, int32_t y) override; + void zxdg_output_v1_logical_size(int32_t width, int32_t height) override; + void zxdg_output_v1_done() override; + void zxdg_output_v1_name(const QString &name) override; + void zxdg_output_v1_description(const QString &description) override; +}; + +#endif // MOCKXDGOUTPUTV1_H diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp index 6a12fef49..f4f63228c 100644 --- a/tests/auto/compositor/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/compositor/tst_compositor.cpp @@ -29,6 +29,7 @@ #include "mockclient.h" #include "mockseat.h" #include "mockpointer.h" +#include "mockxdgoutputv1.h" #include "testcompositor.h" #include "testkeyboardgrabber.h" #include "testseat.h" @@ -48,8 +49,10 @@ #include <QtWaylandCompositor/QWaylandKeymap> #include <QtWaylandCompositor/QWaylandViewporter> #include <QtWaylandCompositor/QWaylandIdleInhibitManagerV1> +#include <QtWaylandCompositor/QWaylandXdgOutputManagerV1> #include <qwayland-xdg-shell.h> #include <qwayland-ivi-application.h> +#include <QtWaylandCompositor/private/qwaylandoutput_p.h> #include <QtWaylandCompositor/private/qwaylandsurface_p.h> #include <QtTest/QtTest> @@ -116,6 +119,8 @@ private slots: void viewportHiDpi(); void idleInhibit(); + + void xdgOutput(); }; void tst_WaylandCompositor::init() { @@ -535,8 +540,13 @@ void tst_WaylandCompositor::mapSurfaceHiDpi() QObject::connect(waylandSurface, &QWaylandSurface::hasContentChanged, verifyComittedState); QSignalSpy hasContentSpy(waylandSurface, SIGNAL(hasContentChanged())); +#if QT_DEPRECATED_SINCE(5, 13) QObject::connect(waylandSurface, &QWaylandSurface::sizeChanged, verifyComittedState); QSignalSpy sizeSpy(waylandSurface, SIGNAL(sizeChanged())); +#endif + + QObject::connect(waylandSurface, &QWaylandSurface::bufferSizeChanged, verifyComittedState); + QSignalSpy bufferSizeSpy(waylandSurface, SIGNAL(bufferSizeChanged())); QObject::connect(waylandSurface, &QWaylandSurface::destinationSizeChanged, verifyComittedState); QSignalSpy destinationSizeSpy(waylandSurface, SIGNAL(destinationSizeChanged())); @@ -560,7 +570,10 @@ void tst_WaylandCompositor::mapSurfaceHiDpi() wl_surface_commit(surface); QTRY_COMPARE(hasContentSpy.count(), 1); +#if QT_DEPRECATED_SINCE(5, 13) QTRY_COMPARE(sizeSpy.count(), 1); +#endif + QTRY_COMPARE(bufferSizeSpy.count(), 1); QTRY_COMPARE(destinationSizeSpy.count(), 1); QTRY_COMPARE(bufferScaleSpy.count(), 1); QTRY_COMPARE(offsetSpy.count(), 1); @@ -1785,5 +1798,68 @@ void tst_WaylandCompositor::idleInhibit() QTRY_COMPARE(changedSpy.count(), 1); } +class XdgOutputCompositor : public TestCompositor +{ + Q_OBJECT +public: + XdgOutputCompositor() : xdgOutputManager(this) {} + QWaylandXdgOutputManagerV1 xdgOutputManager; +}; + +void tst_WaylandCompositor::xdgOutput() +{ + XdgOutputCompositor compositor; + compositor.create(); + + QWaylandOutputMode mode(QSize(1024, 768), 60000); + compositor.defaultOutput()->addMode(mode, true); + compositor.defaultOutput()->setCurrentMode(mode); + + MockClient client; + QTRY_VERIFY(client.xdgOutputManager); + QTRY_COMPARE(client.m_outputs.size(), 1); + + auto *wlOutput = client.m_outputs.first(); + QVERIFY(wlOutput); + + // Output is not associated yet + QCOMPARE(QWaylandOutputPrivate::get(compositor.defaultOutput())->xdgOutput.isNull(), true); + + // Create xdg-output on the server + auto *xdgOutputServer = new QWaylandXdgOutputV1(compositor.defaultOutput(), &compositor.xdgOutputManager); + QVERIFY(xdgOutputServer); + xdgOutputServer->setName(QStringLiteral("OUTPUT1")); + xdgOutputServer->setDescription(QStringLiteral("This is a test output")); + + // Create it on the client + auto *xdgOutput = client.createXdgOutput(wlOutput); + QVERIFY(xdgOutput); + QVERIFY(client.m_xdgOutputs.contains(wlOutput)); + + // Now it should be associated + QCOMPARE(QWaylandOutputPrivate::get(compositor.defaultOutput())->xdgOutput.isNull(), false); + + // Verify initial values + QTRY_COMPARE(xdgOutput->name, "OUTPUT1"); + QTRY_COMPARE(xdgOutput->logicalPosition, QPoint()); + QTRY_COMPARE(xdgOutput->logicalSize, QSize()); + + // Change properties + xdgOutputServer->setName(QStringLiteral("OUTPUT2")); + xdgOutputServer->setDescription(QStringLiteral("New description")); + xdgOutputServer->setLogicalPosition(QPoint(100, 100)); + xdgOutputServer->setLogicalSize(QSize(1000, 1000)); + compositor.flushClients(); + + // Name and description can't be changed after initialization, + // so we expect them to be the same + // TODO: With protocol version 3 the description will be allowed to change, + // but we implement version 2 now + QTRY_COMPARE(xdgOutput->name, "OUTPUT1"); + QTRY_COMPARE(xdgOutput->description, "This is a test output"); + QTRY_COMPARE(xdgOutput->logicalPosition, QPoint(100, 100)); + QTRY_COMPARE(xdgOutput->logicalSize, QSize(1000, 1000)); +} + #include <tst_compositor.moc> QTEST_MAIN(tst_WaylandCompositor); |