2016-06-23 09:26:31 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-06-23 09:26:31 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-06-23 09:26:31 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-06-23 09:26:31 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2021-08-31 07:03:05 +00:00
|
|
|
#include "abstract_output.h"
|
2016-06-23 09:26:31 +00:00
|
|
|
#include "platform.h"
|
2019-09-24 08:48:08 +00:00
|
|
|
#include "x11client.h"
|
2019-01-06 15:34:10 +00:00
|
|
|
#include "composite.h"
|
2016-06-23 09:26:31 +00:00
|
|
|
#include "cursor.h"
|
2021-11-10 10:34:18 +00:00
|
|
|
#include "renderbackend.h"
|
2016-06-23 09:26:31 +00:00
|
|
|
#include "screenedge.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
#include <kwineffects.h>
|
|
|
|
|
|
|
|
#include <KWayland/Client/server_decoration.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_no_border-0");
|
|
|
|
|
|
|
|
class DontCrashNoBorder : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
void testCreateWindow();
|
|
|
|
};
|
|
|
|
|
|
|
|
void DontCrashNoBorder::initTestCase()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
2016-06-23 09:26:31 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2019-08-26 21:16:53 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
2016-06-23 09:26:31 +00:00
|
|
|
|
|
|
|
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
|
|
config->group("org.kde.kdecoration2").writeEntry("NoPlugin", true);
|
|
|
|
config->sync();
|
|
|
|
kwinApp()->setConfig(config);
|
|
|
|
|
|
|
|
// this test needs to enforce OpenGL compositing to get into the crashy condition
|
|
|
|
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2021-08-31 07:03:05 +00:00
|
|
|
const auto outputs = kwinApp()->platform()->enabledOutputs();
|
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
|
2016-06-23 09:26:31 +00:00
|
|
|
setenv("QT_QPA_PLATFORM", "wayland", true);
|
2021-05-08 00:08:22 +00:00
|
|
|
Test::initWaylandWorkspace();
|
2019-01-06 15:34:10 +00:00
|
|
|
|
2021-11-10 10:34:18 +00:00
|
|
|
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
|
2016-06-23 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DontCrashNoBorder::init()
|
|
|
|
{
|
2016-12-03 13:31:14 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
|
2016-06-23 09:26:31 +00:00
|
|
|
|
2021-08-28 18:58:29 +00:00
|
|
|
workspace()->setActiveOutput(QPoint(640, 512));
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->setPos(QPoint(640, 512));
|
2016-06-23 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DontCrashNoBorder::cleanup()
|
|
|
|
{
|
2016-06-30 11:32:54 +00:00
|
|
|
Test::destroyWaylandConnection();
|
2016-06-23 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DontCrashNoBorder::testCreateWindow()
|
|
|
|
{
|
|
|
|
// create a window and ensure that this doesn't crash
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-06-30 11:32:54 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2016-06-23 09:26:31 +00:00
|
|
|
QVERIFY(shellSurface);
|
2016-06-30 11:32:54 +00:00
|
|
|
QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data()));
|
|
|
|
QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged);
|
2016-06-23 09:26:31 +00:00
|
|
|
QVERIFY(decoSpy.isValid());
|
|
|
|
QVERIFY(decoSpy.wait());
|
|
|
|
deco->requestMode(ServerSideDecoration::Mode::Server);
|
|
|
|
QVERIFY(decoSpy.wait());
|
|
|
|
QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
|
|
|
// let's render
|
2016-07-01 07:54:44 +00:00
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(500, 50), Qt::blue);
|
2016-06-23 09:26:31 +00:00
|
|
|
QVERIFY(c);
|
2016-07-01 07:54:44 +00:00
|
|
|
QCOMPARE(workspace()->activeClient(), c);
|
2016-06-23 09:26:31 +00:00
|
|
|
QVERIFY(!c->isDecorated());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(KWin::DontCrashNoBorder)
|
|
|
|
#include "dont_crash_no_border.moc"
|