Port fullscreen shell autotest away from shared_old
Change-Id: Ic6ef3b46fe6d6abf0f028389174fe4ac09dff60a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
0988640184
commit
dd6ca292da
@ -6,32 +6,7 @@
|
||||
|
||||
qt_internal_add_test(tst_client_fullscreenshellv1
|
||||
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_fullscreenshellv1.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_fullscreenshellv1
|
||||
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
|
||||
)
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 David Edmundson <davidedmundson@kde.org>
|
||||
** Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
@ -29,66 +30,31 @@
|
||||
|
||||
#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, 800, 600);
|
||||
create();
|
||||
}
|
||||
};
|
||||
|
||||
class tst_WaylandClientFullScreenShellV1 : public QObject
|
||||
class tst_WaylandClientFullScreenShellV1 : public QObject, private DefaultCompositor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_WaylandClientFullScreenShellV1(MockCompositor *c)
|
||||
: m_compositor(c)
|
||||
{
|
||||
QSocketNotifier *notifier = new QSocketNotifier(m_compositor->waylandFileDescriptor(), QSocketNotifier::Read, this);
|
||||
connect(notifier, &QSocketNotifier::activated, this, &tst_WaylandClientFullScreenShellV1::processWaylandEvents);
|
||||
// connect to the event dispatcher to make sure to flush out the outgoing message queue
|
||||
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &tst_WaylandClientFullScreenShellV1::processWaylandEvents);
|
||||
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &tst_WaylandClientFullScreenShellV1::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->fullScreenShellV1Surface());
|
||||
}
|
||||
|
||||
private slots:
|
||||
void createDestroyWindow();
|
||||
|
||||
private:
|
||||
MockCompositor *m_compositor = nullptr;
|
||||
};
|
||||
|
||||
void tst_WaylandClientFullScreenShellV1::createDestroyWindow()
|
||||
{
|
||||
TestWindow window;
|
||||
QRasterWindow window;
|
||||
window.resize(800, 600);
|
||||
window.show();
|
||||
|
||||
QTRY_VERIFY(m_compositor->fullScreenShellV1Surface());
|
||||
QCOMPOSITOR_TRY_VERIFY(fullScreenShellV1()->surfaces().count() == 1);
|
||||
QCOMPOSITOR_VERIFY(surface(0));
|
||||
|
||||
window.destroy();
|
||||
QTRY_VERIFY(!m_compositor->fullScreenShellV1Surface());
|
||||
QCOMPOSITOR_TRY_VERIFY(!surface(0));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@ -99,13 +65,9 @@ int main(int argc, char **argv)
|
||||
setenv("QT_WAYLAND_SHELL_INTEGRATION", "fullscreen-shell-v1", 1);
|
||||
setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense here
|
||||
|
||||
MockCompositor compositor;
|
||||
compositor.setOutputMode(screenSize);
|
||||
|
||||
tst_WaylandClientFullScreenShellV1 tc;
|
||||
QGuiApplication app(argc, argv);
|
||||
compositor.applicationInitialized();
|
||||
|
||||
tst_WaylandClientFullScreenShellV1 tc(&compositor);
|
||||
QTEST_SET_MAIN_SOURCE_PATH
|
||||
return QTest::qExec(&tc, argc, argv);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ add_library(SharedClientTest
|
||||
corecompositor.cpp corecompositor.h
|
||||
coreprotocol.cpp coreprotocol.h
|
||||
datadevice.cpp datadevice.h
|
||||
fullscreenshellv1.cpp fullscreenshellv1.h
|
||||
mockcompositor.cpp mockcompositor.h
|
||||
textinput.cpp textinput.h
|
||||
xdgoutputv1.cpp xdgoutputv1.h
|
||||
@ -17,6 +18,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/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
|
||||
|
47
tests/auto/wayland/shared/fullscreenshellv1.cpp
Normal file
47
tests/auto/wayland/shared/fullscreenshellv1.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "fullscreenshellv1.h"
|
||||
|
||||
namespace MockCompositor {
|
||||
|
||||
FullScreenShellV1::FullScreenShellV1(CoreCompositor *compositor)
|
||||
{
|
||||
init(compositor->m_display, 1);
|
||||
}
|
||||
|
||||
void FullScreenShellV1::zwp_fullscreen_shell_v1_present_surface(Resource *resource, struct ::wl_resource *surface, uint32_t method, struct ::wl_resource *output)
|
||||
{
|
||||
Q_UNUSED(resource);
|
||||
Q_UNUSED(method);
|
||||
Q_UNUSED(output);
|
||||
|
||||
m_surfaces.append(fromResource<Surface>(surface));
|
||||
}
|
||||
|
||||
} // namespace MockCompositor
|
59
tests/auto/wayland/shared/fullscreenshellv1.h
Normal file
59
tests/auto/wayland/shared/fullscreenshellv1.h
Normal file
@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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_FULLSCREENSHELLV1_H
|
||||
#define MOCKCOMPOSITOR_FULLSCREENSHELLV1_H
|
||||
|
||||
#include "coreprotocol.h"
|
||||
#include <qwayland-server-fullscreen-shell-unstable-v1.h>
|
||||
|
||||
#include <QList>
|
||||
|
||||
namespace MockCompositor {
|
||||
|
||||
class Surface;
|
||||
class FullScreenShellV1;
|
||||
|
||||
class FullScreenShellV1 : public Global, public QtWaylandServer::zwp_fullscreen_shell_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FullScreenShellV1(CoreCompositor *compositor);
|
||||
|
||||
QList<Surface *> surfaces() const { return m_surfaces; }
|
||||
|
||||
protected:
|
||||
void zwp_fullscreen_shell_v1_present_surface(Resource *resource, struct ::wl_resource *surface, uint32_t method, struct ::wl_resource *output) override;
|
||||
|
||||
private:
|
||||
QList<Surface *> m_surfaces;
|
||||
};
|
||||
|
||||
} // namespace MockCompositor
|
||||
|
||||
#endif // MOCKCOMPOSITOR_FULLSCREENSHELLV1_H
|
@ -44,6 +44,7 @@ DefaultCompositor::DefaultCompositor()
|
||||
add<Seat>(Seat::capability_pointer | Seat::capability_keyboard | Seat::capability_touch);
|
||||
add<XdgWmBase>();
|
||||
add<Shm>();
|
||||
add<FullScreenShellV1>();
|
||||
// TODO: other shells, viewporter, xdgoutput etc
|
||||
|
||||
QObject::connect(get<WlCompositor>(), &WlCompositor::surfaceCreated, [&] (Surface *surface){
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "coreprotocol.h"
|
||||
#include "datadevice.h"
|
||||
#include "xdgshell.h"
|
||||
#include "fullscreenshellv1.h"
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
@ -64,6 +65,7 @@ public:
|
||||
Touch *touch() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_touch; }
|
||||
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>();};
|
||||
uint sendXdgShellPing();
|
||||
void xdgPingAndWaitForPong();
|
||||
// Things that can be changed run-time without confusing the client (i.e. don't require separate tests)
|
||||
|
Loading…
x
Reference in New Issue
Block a user