KWin
Loading...
Searching...
No Matches
generic_scene_opengl_test.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
10#include "compositor.h"
11#include "core/renderbackend.h"
12#include "cursor.h"
13#include "effect/effectloader.h"
15#include "wayland_server.h"
16#include "window.h"
17
18#include <KConfigGroup>
19#include <QSignalSpy>
20
21using namespace KWin;
22static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_opengl-0");
23
25 : QObject()
26 , m_envVariable(envVariable)
27{
28}
29
33
34void GenericSceneOpenGLTest::cleanup()
35{
37}
38
39void GenericSceneOpenGLTest::initTestCase()
40{
42 QSKIP("no render node available");
43 return;
44 }
45 qRegisterMetaType<KWin::Window *>();
46 QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
47 QVERIFY(waylandServer()->init(s_socketName));
49 QRect(0, 0, 1280, 1024),
50 QRect(1280, 0, 1280, 1024),
51 });
52
53 // disable all effects - we don't want to have it interact with the rendering
54 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
55 KConfigGroup plugins(config, QStringLiteral("Plugins"));
56 const auto builtinNames = EffectLoader().listOfKnownEffects();
57 for (QString name : builtinNames) {
58 plugins.writeEntry(name + QStringLiteral("Enabled"), false);
59 }
60
61 config->sync();
62 kwinApp()->setConfig(config);
63
64 qputenv("XCURSOR_THEME", QByteArrayLiteral("DMZ-White"));
65 qputenv("XCURSOR_SIZE", QByteArrayLiteral("24"));
66 qputenv("KWIN_COMPOSE", m_envVariable);
67
68 kwinApp()->start();
69 QVERIFY(applicationStartedSpy.wait());
70 QVERIFY(Compositor::self());
71
72 QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
73}
74
75void GenericSceneOpenGLTest::testRestart()
76{
77 // simple restart of the OpenGL compositor without any windows being shown
78 QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated);
80 if (sceneCreatedSpy.isEmpty()) {
81 QVERIFY(sceneCreatedSpy.wait());
82 }
83 QCOMPARE(sceneCreatedSpy.count(), 1);
84 QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
85
86 // trigger a repaint
88 // and wait 100 msec to ensure it's rendered
89 // TODO: introduce frameRendered signal in SceneOpenGL
90 QTest::qWait(100);
91}
92
93#include "moc_generic_scene_opengl_test.cpp"
GenericSceneOpenGLTest(const QByteArray &envVariable)
WorkspaceScene * scene() const
Definition compositor.h:60
virtual void reinitialize()
static Compositor * self()
QStringList listOfKnownEffects() const override
All the Effects this loader knows of.
void addRepaintFull()
Definition scene.cpp:81
void destroyWaylandConnection()
void setOutputConfig(const QList< QRect > &geometries)
bool renderNodeAvailable()
void init(xcb_connection_t *connection, xcb_window_t rootWindow)
WaylandServer * waylandServer()
@ OpenGLCompositing
Definition globals.h:37