2017-06-24 19:05:49 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "generic_scene_opengl_test.h"
|
2020-03-04 07:55:26 +00:00
|
|
|
#include "abstract_client.h"
|
2017-06-24 19:05:49 +00:00
|
|
|
#include "composite.h"
|
|
|
|
#include "effectloader.h"
|
|
|
|
#include "cursor.h"
|
|
|
|
#include "platform.h"
|
2017-09-08 14:06:33 +00:00
|
|
|
#include "scene.h"
|
2017-06-24 19:05:49 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "effect_builtins.h"
|
|
|
|
|
|
|
|
#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()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
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));
|
|
|
|
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
|
|
|
|
|
|
|
|
// 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"));
|
|
|
|
ScriptedEffectLoader loader;
|
|
|
|
const auto builtinNames = BuiltInEffects::availableEffectNames() << loader.listOfKnownEffects();
|
|
|
|
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
|
|
|
|
|
|
|
auto scene = KWin::Compositor::self()->scene();
|
|
|
|
QVERIFY(scene);
|
|
|
|
QCOMPARE(scene->compositingType(), KWin::OpenGL2Compositing);
|
2019-02-16 19:50:46 +00:00
|
|
|
QCOMPARE(kwinApp()->platform()->selectedCompositor(), KWin::OpenGLCompositing);
|
2017-06-24 19:05:49 +00:00
|
|
|
}
|
|
|
|
|
2017-06-25 07:48:46 +00:00
|
|
|
void GenericSceneOpenGLTest::testRestart_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("core");
|
|
|
|
|
|
|
|
QTest::newRow("GLCore") << true;
|
|
|
|
QTest::newRow("Legacy") << false;
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:05:49 +00:00
|
|
|
void GenericSceneOpenGLTest::testRestart()
|
|
|
|
{
|
|
|
|
// simple restart of the OpenGL compositor without any windows being shown
|
2017-06-25 07:48:46 +00:00
|
|
|
|
|
|
|
// setup opengl compositing options
|
|
|
|
auto compositingGroup = kwinApp()->config()->group("Compositing");
|
|
|
|
QFETCH(bool, core);
|
|
|
|
compositingGroup.writeEntry("GLCore", core);
|
|
|
|
compositingGroup.sync();
|
|
|
|
|
2017-06-24 19:05:49 +00:00
|
|
|
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);
|
2017-09-08 14:06:33 +00:00
|
|
|
auto scene = KWin::Compositor::self()->scene();
|
2017-06-24 19:05:49 +00:00
|
|
|
QVERIFY(scene);
|
2017-09-08 14:06:33 +00:00
|
|
|
QCOMPARE(scene->compositingType(), KWin::OpenGL2Compositing);
|
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
|
|
|
|
KWin::Compositor::self()->addRepaintFull();
|
|
|
|
// and wait 100 msec to ensure it's rendered
|
|
|
|
// TODO: introduce frameRendered signal in SceneOpenGL
|
|
|
|
QTest::qWait(100);
|
|
|
|
}
|