kwin/autotests/integration/generic_scene_opengl_test.cpp
Laurent Montel b823747c3b Add explicit moc includes to sources for moc-covered headers
* speeds up incremental builds as changes to a header will not always
  need the full mocs_compilation.cpp for all the target's headers rebuild,
  while having a moc file sourced into a source file only adds minor
  extra costs, due to small own code and the used headers usually
  already covered by the source file, being for the same class/struct
* seems to not slow down clean builds, due to empty mocs_compilation.cpp
  resulting in those quickly processed, while the minor extra cost of the
  sourced moc files does not outweigh that in summary.
  Measured times actually improved by some percent points.
  (ideally CMake would just skip empty mocs_compilation.cpp & its object
  file one day)
* enables compiler to see all methods of a class in same compilation unit
  to do some sanity checks
* potentially more inlining in general, due to more in the compilation unit
* allows to keep using more forward declarations in the header, as with the
  moc code being sourced into the cpp file there definitions can be ensured
  and often are already for the needs of the normal class methods
2023-07-15 08:40:49 +00:00

93 lines
2.8 KiB
C++

/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "generic_scene_opengl_test.h"
#include "composite.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "effectloader.h"
#include "scene/workspacescene.h"
#include "wayland_server.h"
#include "window.h"
#include <KConfigGroup>
#include <QSignalSpy>
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()
{
if (!Test::renderNodeAvailable()) {
QSKIP("no render node available");
return;
}
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
// 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"));
const auto builtinNames = EffectLoader().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();
QVERIFY(applicationStartedSpy.wait());
QVERIFY(Compositor::self());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void GenericSceneOpenGLTest::testRestart()
{
// simple restart of the OpenGL compositor without any windows being shown
QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated);
KWin::Compositor::self()->reinitialize();
if (sceneCreatedSpy.isEmpty()) {
QVERIFY(sceneCreatedSpy.wait());
}
QCOMPARE(sceneCreatedSpy.count(), 1);
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
// trigger a repaint
KWin::Compositor::self()->scene()->addRepaintFull();
// and wait 100 msec to ensure it's rendered
// TODO: introduce frameRendered signal in SceneOpenGL
QTest::qWait(100);
}
#include "moc_generic_scene_opengl_test.cpp"