diff --git a/autotests/integration/CMakeLists.txt b/autotests/integration/CMakeLists.txt index 60000224e0..1543ec778a 100644 --- a/autotests/integration/CMakeLists.txt +++ b/autotests/integration/CMakeLists.txt @@ -33,7 +33,8 @@ integrationTest(NAME testMaximized SRCS maximize_test.cpp) integrationTest(NAME testShellClient SRCS shell_client_test.cpp) integrationTest(NAME testDontCrashNoBorder SRCS dont_crash_no_border.cpp) integrationTest(NAME testXClipboardSync SRCS xclipboardsync_test.cpp) -integrationTest(NAME testSceneOpenGL SRCS scene_opengl_test.cpp) +integrationTest(NAME testSceneOpenGL SRCS scene_opengl_test.cpp generic_scene_opengl_test.cpp) +integrationTest(NAME testSceneOpenGLES SRCS scene_opengl_es_test.cpp generic_scene_opengl_test.cpp) integrationTest(NAME testSceneQPainter SRCS scene_qpainter_test.cpp) integrationTest(NAME testNoXdgRuntimeDir SRCS no_xdg_runtime_dir_test.cpp) integrationTest(NAME testScreenChanges SRCS screen_changes_test.cpp) diff --git a/autotests/integration/generic_scene_opengl_test.cpp b/autotests/integration/generic_scene_opengl_test.cpp new file mode 100644 index 0000000000..1855a69e45 --- /dev/null +++ b/autotests/integration/generic_scene_opengl_test.cpp @@ -0,0 +1,101 @@ +/******************************************************************** +KWin - the KDE window manager +This file is part of the KDE project. + +Copyright (C) 2016 Martin Gräßlin + +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 . +*********************************************************************/ +#include "generic_scene_opengl_test.h" +#include "composite.h" +#include "effectloader.h" +#include "cursor.h" +#include "platform.h" +#include "scene_opengl.h" +#include "shell_client.h" +#include "wayland_server.h" +#include "effect_builtins.h" + +#include + +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 (!QFile::exists(QStringLiteral("/dev/dri/card0"))) { + QSKIP("Needs a dri device"); + } + qRegisterMetaType(); + qRegisterMetaType(); + QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); + QVERIFY(workspaceCreatedSpy.isValid()); + 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(); + QVERIFY(workspaceCreatedSpy.wait()); + QVERIFY(Compositor::self()); +} + +void GenericSceneOpenGLTest::testRestart() +{ + // simple restart of the OpenGL compositor without any windows being shown + QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated); + QVERIFY(sceneCreatedSpy.isValid()); + KWin::Compositor::self()->slotReinitialize(); + if (sceneCreatedSpy.isEmpty()) { + QVERIFY(sceneCreatedSpy.wait()); + } + QCOMPARE(sceneCreatedSpy.count(), 1); + auto scene = qobject_cast(KWin::Compositor::self()->scene()); + QVERIFY(scene); + + // 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); +} diff --git a/autotests/integration/generic_scene_opengl_test.h b/autotests/integration/generic_scene_opengl_test.h new file mode 100644 index 0000000000..2ef4ba9a1c --- /dev/null +++ b/autotests/integration/generic_scene_opengl_test.h @@ -0,0 +1,39 @@ +/******************************************************************** +KWin - the KDE window manager +This file is part of the KDE project. + +Copyright (C) 2017 Martin Flöser + +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 . +*********************************************************************/ +#pragma once +#include "kwin_wayland_test.h" + +#include + +class GenericSceneOpenGLTest : public QObject +{ +Q_OBJECT +public: + ~GenericSceneOpenGLTest() override; +protected: + GenericSceneOpenGLTest(const QByteArray &envVariable); +private Q_SLOTS: + void initTestCase(); + void cleanup(); + void testRestart(); + +private: + QByteArray m_envVariable; +}; diff --git a/autotests/integration/scene_opengl_es_test.cpp b/autotests/integration/scene_opengl_es_test.cpp new file mode 100644 index 0000000000..1904322b9c --- /dev/null +++ b/autotests/integration/scene_opengl_es_test.cpp @@ -0,0 +1,30 @@ +/******************************************************************** +KWin - the KDE window manager +This file is part of the KDE project. + +Copyright (C) 2017 Martin Flöser + +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 . +*********************************************************************/ +#include "generic_scene_opengl_test.h" + +class SceneOpenGLESTest : public GenericSceneOpenGLTest +{ + Q_OBJECT +public: + SceneOpenGLESTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2ES")) {} +}; + +WAYLANDTEST_MAIN(SceneOpenGLESTest) +#include "scene_opengl_es_test.moc" diff --git a/autotests/integration/scene_opengl_test.cpp b/autotests/integration/scene_opengl_test.cpp index 825b99a696..faaed016f0 100644 --- a/autotests/integration/scene_opengl_test.cpp +++ b/autotests/integration/scene_opengl_test.cpp @@ -17,87 +17,14 @@ 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 . *********************************************************************/ -#include "kwin_wayland_test.h" -#include "composite.h" -#include "effectloader.h" -#include "cursor.h" -#include "platform.h" -#include "scene_opengl.h" -#include "shell_client.h" -#include "wayland_server.h" -#include "effect_builtins.h" +#include "generic_scene_opengl_test.h" -#include - -using namespace KWin; -static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_opengl-0"); - -class SceneOpenGLTest : public QObject +class SceneOpenGLTest : public GenericSceneOpenGLTest { -Q_OBJECT -private Q_SLOTS: - void initTestCase(); - void cleanup(); - void testRestart(); + Q_OBJECT +public: + SceneOpenGLTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2")) {} }; -void SceneOpenGLTest::cleanup() -{ - Test::destroyWaylandConnection(); -} - -void SceneOpenGLTest::initTestCase() -{ - if (!QFile::exists(QStringLiteral("/dev/dri/card0"))) { - QSKIP("Needs a dri device"); - } - qRegisterMetaType(); - qRegisterMetaType(); - QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); - QVERIFY(workspaceCreatedSpy.isValid()); - 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", QByteArrayLiteral("O2")); - - kwinApp()->start(); - QVERIFY(workspaceCreatedSpy.wait()); - QVERIFY(Compositor::self()); -} - -void SceneOpenGLTest::testRestart() -{ - // simple restart of the OpenGL compositor without any windows being shown - QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated); - QVERIFY(sceneCreatedSpy.isValid()); - KWin::Compositor::self()->slotReinitialize(); - if (sceneCreatedSpy.isEmpty()) { - QVERIFY(sceneCreatedSpy.wait()); - } - QCOMPARE(sceneCreatedSpy.count(), 1); - auto scene = qobject_cast(KWin::Compositor::self()->scene()); - QVERIFY(scene); - - // 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); -} - WAYLANDTEST_MAIN(SceneOpenGLTest) #include "scene_opengl_test.moc"