summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2021-05-05 23:45:03 +0100
committerDavid Edmundson <davidedmundson@kde.org>2021-05-10 13:43:37 +0100
commit62c915319fbd67f00b44f5a7438854f7dfe9aafd (patch)
tree19b49b5caaf50d745fffd01218abed87ef50439f /tests
parent94b800806790c0bf4a08aebe62f6aa3c51a3815b (diff)
downloadqtwayland-62c915319fbd67f00b44f5a7438854f7dfe9aafd.tar.gz
Port IVI Application test from shared_old
Change-Id: I65fbe66fe75fe4372852deadefea796576860d67 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/iviapplication/CMakeLists.txt27
-rw-r--r--tests/auto/client/iviapplication/tst_iviapplication.cpp88
-rw-r--r--tests/auto/client/shared/CMakeLists.txt2
-rw-r--r--tests/auto/client/shared/iviapplication.cpp69
-rw-r--r--tests/auto/client/shared/iviapplication.h73
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp3
-rw-r--r--tests/auto/client/shared/mockcompositor.h5
7 files changed, 179 insertions, 88 deletions
diff --git a/tests/auto/client/iviapplication/CMakeLists.txt b/tests/auto/client/iviapplication/CMakeLists.txt
index 601b4c91..42732277 100644
--- a/tests/auto/client/iviapplication/CMakeLists.txt
+++ b/tests/auto/client/iviapplication/CMakeLists.txt
@@ -6,32 +6,7 @@
qt_internal_add_test(tst_client_iviapplication
SOURCES
- ../shared_old/mockcompositor.cpp ../shared_old/mockcompositor.h
- ../shared_old/mockfullscreenshellv1.cpp ../shared_old/mockfullscreenshellv1.h
- ../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
tst_iviapplication.cpp
- INCLUDE_DIRECTORIES
- ../shared_old
PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::Gui
- Qt::GuiPrivate
- Qt::OpenGL
- Qt::WaylandClientPrivate
- Wayland::Client
- Wayland::Server
- Threads::Threads # special case
-)
-
-qt6_generate_wayland_protocol_server_sources(tst_client_iviapplication
- FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/fullscreen-shell-unstable-v1.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/ivi-application.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/wayland.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/xdg-shell.xml
+ SharedClientTest
)
diff --git a/tests/auto/client/iviapplication/tst_iviapplication.cpp b/tests/auto/client/iviapplication/tst_iviapplication.cpp
index 8d6ea648..eb0a2115 100644
--- a/tests/auto/client/iviapplication/tst_iviapplication.cpp
+++ b/tests/auto/client/iviapplication/tst_iviapplication.cpp
@@ -28,98 +28,68 @@
#include "mockcompositor.h"
-#include <QWindow>
+#include <QRasterWindow>
#include <QtTest/QtTest>
-static const QSize screenSize(1600, 1200);
+using namespace MockCompositor;
-class TestWindow : public QWindow
-{
-public:
- TestWindow()
- {
- setSurfaceType(QSurface::RasterSurface);
- setGeometry(0, 0, 32, 32);
- create();
- }
-};
-
-class tst_WaylandClientIviApplication : public QObject
+class tst_WaylandClientIviApplication : public QObject, private DefaultCompositor
{
Q_OBJECT
-public:
- tst_WaylandClientIviApplication(MockCompositor *c)
- : m_compositor(c)
- {
- QSocketNotifier *notifier = new QSocketNotifier(m_compositor->waylandFileDescriptor(), QSocketNotifier::Read, this);
- connect(notifier, &QSocketNotifier::activated, this, &tst_WaylandClientIviApplication::processWaylandEvents);
- // connect to the event dispatcher to make sure to flush out the outgoing message queue
- connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &tst_WaylandClientIviApplication::processWaylandEvents);
- connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &tst_WaylandClientIviApplication::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());
- QTRY_VERIFY(!m_compositor->iviSurface());
- }
private slots:
void createDestroyWindow();
void configure();
void uniqueIviIds();
-
-private:
- MockCompositor *m_compositor = nullptr;
};
void tst_WaylandClientIviApplication::createDestroyWindow()
{
- TestWindow window;
+ QRasterWindow window;
+ window.resize(32, 32);
window.show();
- QTRY_VERIFY(m_compositor->surface());
- QTRY_VERIFY(m_compositor->iviSurface());
+ QCOMPOSITOR_TRY_VERIFY(surface());
+ QCOMPOSITOR_TRY_VERIFY(iviSurface());
window.destroy();
- QTRY_VERIFY(!m_compositor->surface());
- QTRY_VERIFY(!m_compositor->iviSurface());
+ QCOMPOSITOR_TRY_VERIFY(!surface());
+ QCOMPOSITOR_TRY_VERIFY(!iviSurface());
}
void tst_WaylandClientIviApplication::configure()
{
- TestWindow window;
+ QRasterWindow window;
+ window.resize(32, 32);
window.show();
- QSharedPointer<MockIviSurface> iviSurface;
- QTRY_VERIFY(iviSurface = m_compositor->iviSurface());
+ QCOMPOSITOR_TRY_VERIFY(iviSurface());
// Unconfigured ivi surfaces decide their own size
QTRY_COMPARE(window.frameGeometry(), QRect(QPoint(), QSize(32, 32)));
- m_compositor->sendIviSurfaceConfigure(iviSurface, {123, 456});
+ exec([=] {
+ iviSurface()->send_configure(123, 456);
+ });
QTRY_COMPARE(window.frameGeometry(), QRect(QPoint(), QSize(123, 456)));
+ window.destroy();
+ QCOMPOSITOR_TRY_VERIFY(!iviSurface());
}
void tst_WaylandClientIviApplication::uniqueIviIds()
{
- TestWindow windowA, windowB;
+ QRasterWindow windowA, windowB;
+ windowA.resize(32, 32);
windowA.show();
+ windowB.resize(32, 32);
windowB.show();
- QSharedPointer<MockIviSurface> iviSurface0, iviSurface1;
- QTRY_VERIFY(iviSurface0 = m_compositor->iviSurface(0));
- QTRY_VERIFY(iviSurface1 = m_compositor->iviSurface(1));
- QTRY_VERIFY(iviSurface0->iviId != iviSurface1->iviId);
+ QCOMPOSITOR_TRY_VERIFY(iviSurface(0));
+ QCOMPOSITOR_TRY_VERIFY(iviSurface(1));
+ exec([=] {
+ QVERIFY(iviSurface(0)->m_iviId != iviSurface(1)->m_iviId);
+ });
}
int main(int argc, char **argv)
@@ -130,13 +100,9 @@ int main(int argc, char **argv)
setenv("QT_WAYLAND_SHELL_INTEGRATION", "ivi-shell", 1);
setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense on ivi-application
- MockCompositor compositor;
- compositor.setOutputMode(screenSize);
-
+ tst_WaylandClientIviApplication tc;
QGuiApplication app(argc, argv);
- compositor.applicationInitialized();
-
- tst_WaylandClientIviApplication tc(&compositor);
+ QTEST_SET_MAIN_SOURCE_PATH
return QTest::qExec(&tc, argc, argv);
}
diff --git a/tests/auto/client/shared/CMakeLists.txt b/tests/auto/client/shared/CMakeLists.txt
index 530acf26..6116688c 100644
--- a/tests/auto/client/shared/CMakeLists.txt
+++ b/tests/auto/client/shared/CMakeLists.txt
@@ -8,6 +8,7 @@ add_library(SharedClientTest
coreprotocol.cpp coreprotocol.h
datadevice.cpp datadevice.h
fullscreenshellv1.cpp fullscreenshellv1.h
+ iviapplication.cpp iviapplication.h
mockcompositor.cpp mockcompositor.h
textinput.cpp textinput.h
xdgoutputv1.cpp xdgoutputv1.h
@@ -19,6 +20,7 @@ set_property(TARGET SharedClientTest PROPERTY AUTOMOC ON)
qt6_generate_wayland_protocol_server_sources(SharedClientTest
FILES
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/fullscreen-shell-unstable-v1.xml
+ ${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/ivi-application.xml
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/wp-primary-selection-unstable-v1.xml
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/tablet-unstable-v2.xml
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/text-input-unstable-v2.xml
diff --git a/tests/auto/client/shared/iviapplication.cpp b/tests/auto/client/shared/iviapplication.cpp
new file mode 100644
index 00000000..98a0b820
--- /dev/null
+++ b/tests/auto/client/shared/iviapplication.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 David Edmundson <davidedmundson@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 "iviapplication.h"
+
+namespace MockCompositor {
+
+IviApplication::IviApplication(CoreCompositor *compositor)
+{
+ init(compositor->m_display, 1);
+}
+
+void IviApplication::ivi_application_surface_create(Resource *resource, uint32_t ivi_id, struct ::wl_resource *surface, uint32_t id)
+{
+ auto *s = fromResource<Surface>(surface);
+ auto *iviSurface = new IviSurface(this, s, ivi_id, resource->client(), id, resource->version());
+ m_iviSurfaces << iviSurface;
+ qDebug() << "count is " << m_iviSurfaces.count();
+}
+
+IviSurface::IviSurface(IviApplication *iviApplication, Surface *surface, uint32_t ivi_id, wl_client *client, int id, int version)
+ : QtWaylandServer::ivi_surface(client, id, version)
+ , m_iviId(ivi_id)
+ , m_iviApplication(iviApplication)
+{
+ Q_UNUSED(surface);
+}
+
+void IviSurface::ivi_surface_destroy_resource(Resource *resource)
+{
+ Q_UNUSED(resource);
+ bool removed = m_iviApplication->m_iviSurfaces.removeOne(this);
+ Q_ASSERT(removed);
+ qDebug() << "destriy";
+
+ delete this;
+}
+
+void IviSurface::ivi_surface_destroy(QtWaylandServer::ivi_surface::Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+} // namespace MockCompositor
diff --git a/tests/auto/client/shared/iviapplication.h b/tests/auto/client/shared/iviapplication.h
new file mode 100644
index 00000000..f92054ca
--- /dev/null
+++ b/tests/auto/client/shared/iviapplication.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 David Edmundson <davidedmundson@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 MOCKCOMPOSITOR_IVIAPPLICATION_H
+#define MOCKCOMPOSITOR_IVIAPPLICATION_H
+
+#include "coreprotocol.h"
+#include <qwayland-server-ivi-application.h>
+
+#include <QList>
+
+namespace MockCompositor {
+
+class Surface;
+class IviApplication;
+class IviSurface;
+
+class IviApplication : public Global, public QtWaylandServer::ivi_application
+{
+ Q_OBJECT
+public:
+ explicit IviApplication(CoreCompositor *compositor);
+
+ QList<IviSurface *> m_iviSurfaces;
+protected:
+ void ivi_application_surface_create(Resource *resource, uint32_t ivi_id, struct ::wl_resource *surface, uint32_t id) override;
+
+};
+
+class IviSurface : public QObject, public QtWaylandServer::ivi_surface
+{
+ Q_OBJECT
+public:
+ IviSurface(IviApplication *iviApplication, Surface *surface, uint32_t ivi_id, wl_client *client, int id, int version);
+
+ void ivi_surface_destroy_resource(Resource *resource) override;
+ void ivi_surface_destroy(Resource *resource) override;
+
+ const uint m_iviId = 0;
+private:
+ IviApplication *m_iviApplication;
+
+};
+
+
+} // namespace MockCompositor
+
+#endif // MOCKCOMPOSITOR_IVIAPPLICATION_H
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index c958e6e8..62fa44f0 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2021 David Edmundson <davidedmundson@kde.org>
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
@@ -45,6 +46,8 @@ DefaultCompositor::DefaultCompositor()
add<XdgWmBase>();
add<Shm>();
add<FullScreenShellV1>();
+ add<IviApplication>();
+
// TODO: other shells, viewporter, xdgoutput etc
QObject::connect(get<WlCompositor>(), &WlCompositor::surfaceCreated, [&] (Surface *surface){
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index 878560a2..44952a08 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2021 David Edmundson <davidedmundson@kde.org>
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
@@ -32,8 +33,9 @@
#include "corecompositor.h"
#include "coreprotocol.h"
#include "datadevice.h"
-#include "xdgshell.h"
#include "fullscreenshellv1.h"
+#include "iviapplication.h"
+#include "xdgshell.h"
#include <QtGui/QGuiApplication>
@@ -66,6 +68,7 @@ public:
Surface *cursorSurface() { auto *p = pointer(); return p ? p->cursorSurface() : nullptr; }
Keyboard *keyboard() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_keyboard; }
FullScreenShellV1 *fullScreenShellV1() {return get<FullScreenShellV1>();};
+ IviSurface *iviSurface(int i = 0) { return get<IviApplication>()->m_iviSurfaces.value(i, nullptr); }
uint sendXdgShellPing();
void xdgPingAndWaitForPong();
// Things that can be changed run-time without confusing the client (i.e. don't require separate tests)