2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2017-06-24 19:05:49 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2017-06-24 19:05:49 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2017-06-24 19:05:49 +00:00
|
|
|
#include "generic_scene_opengl_test.h"
|
2023-08-31 12:23:42 +00:00
|
|
|
#include "compositor.h"
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/renderbackend.h"
|
2017-06-24 19:05:49 +00:00
|
|
|
#include "cursor.h"
|
2023-11-17 08:59:08 +00:00
|
|
|
#include "effect/effectloader.h"
|
2022-12-18 21:56:41 +00:00
|
|
|
#include "scene/workspacescene.h"
|
2017-06-24 19:05:49 +00:00
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2017-06-24 19:05:49 +00:00
|
|
|
|
|
|
|
#include <KConfigGroup>
|
2023-07-03 19:28:19 +00:00
|
|
|
#include <QSignalSpy>
|
2017-06-24 19:05:49 +00:00
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_opengl-0");
|
|
|
|
|
|
|
|
GenericSceneOpenGLTest::GenericSceneOpenGLTest(const QByteArray &envVariable)
|
|
|
|
: QObject()
|
|
|
|
, m_envVariable(envVariable)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GenericSceneOpenGLTest::~GenericSceneOpenGLTest()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenericSceneOpenGLTest::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenericSceneOpenGLTest::initTestCase()
|
|
|
|
{
|
2023-04-15 19:28:12 +00:00
|
|
|
if (!Test::renderNodeAvailable()) {
|
|
|
|
QSKIP("no render node available");
|
|
|
|
return;
|
|
|
|
}
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig({
|
|
|
|
QRect(0, 0, 1280, 1024),
|
|
|
|
QRect(1280, 0, 1280, 1024),
|
|
|
|
});
|
2017-06-24 19:05:49 +00:00
|
|
|
|
|
|
|
// disable all effects - we don't want to have it interact with the rendering
|
|
|
|
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
|
|
KConfigGroup plugins(config, QStringLiteral("Plugins"));
|
2021-10-09 15:38:14 +00:00
|
|
|
const auto builtinNames = EffectLoader().listOfKnownEffects();
|
2017-06-24 19:05:49 +00:00
|
|
|
for (QString name : builtinNames) {
|
|
|
|
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
config->sync();
|
|
|
|
kwinApp()->setConfig(config);
|
|
|
|
|
2024-07-08 21:49:09 +00:00
|
|
|
qputenv("XCURSOR_THEME", QByteArrayLiteral("breeze_cursors"));
|
2017-06-24 19:05:49 +00:00
|
|
|
qputenv("XCURSOR_SIZE", QByteArrayLiteral("24"));
|
|
|
|
qputenv("KWIN_COMPOSE", m_envVariable);
|
|
|
|
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2017-06-24 19:05:49 +00:00
|
|
|
QVERIFY(Compositor::self());
|
2019-01-06 15:34:10 +00:00
|
|
|
|
2021-11-10 10:34:18 +00:00
|
|
|
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
|
2017-06-24 19:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GenericSceneOpenGLTest::testRestart()
|
|
|
|
{
|
|
|
|
// simple restart of the OpenGL compositor without any windows being shown
|
|
|
|
QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated);
|
2019-07-02 20:30:27 +00:00
|
|
|
KWin::Compositor::self()->reinitialize();
|
2017-06-24 19:05:49 +00:00
|
|
|
if (sceneCreatedSpy.isEmpty()) {
|
|
|
|
QVERIFY(sceneCreatedSpy.wait());
|
|
|
|
}
|
|
|
|
QCOMPARE(sceneCreatedSpy.count(), 1);
|
2021-11-10 10:34:18 +00:00
|
|
|
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
|
2017-06-24 19:05:49 +00:00
|
|
|
|
|
|
|
// trigger a repaint
|
2021-11-09 10:36:24 +00:00
|
|
|
KWin::Compositor::self()->scene()->addRepaintFull();
|
2017-06-24 19:05:49 +00:00
|
|
|
// and wait 100 msec to ensure it's rendered
|
|
|
|
// TODO: introduce frameRendered signal in SceneOpenGL
|
|
|
|
QTest::qWait(100);
|
|
|
|
}
|
2023-07-05 06:30:14 +00:00
|
|
|
|
|
|
|
#include "moc_generic_scene_opengl_test.cpp"
|