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"
|
|
|
|
#include "composite.h"
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/platform.h"
|
|
|
|
#include "core/renderbackend.h"
|
2017-06-24 19:05:49 +00:00
|
|
|
#include "cursor.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "effectloader.h"
|
2021-11-09 10:36:24 +00:00
|
|
|
#include "scene.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>
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
2017-06-24 19:05:49 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
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);
|
|
|
|
|
|
|
|
qputenv("XCURSOR_THEME", QByteArrayLiteral("DMZ-White"));
|
|
|
|
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);
|
2019-02-16 19:50:46 +00:00
|
|
|
QCOMPARE(kwinApp()->platform()->selectedCompositor(), 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);
|
|
|
|
QVERIFY(sceneCreatedSpy.isValid());
|
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);
|
2019-02-16 19:50:46 +00:00
|
|
|
QCOMPARE(kwinApp()->platform()->selectedCompositor(), 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);
|
|
|
|
}
|