autotests: Drop effect loader tests
Effect loading is already tested using integration tests, for example the maximize test verifies that the maximize effect is loaded _and_ it actually does something useful when a window is maximized or restored, testScriptedEffectLoader only verifies that the effect is loaded, which is less helpful than what integration tests provide us. But perhaps the main problem with these tests is that they require us building a mockverse around them. This litters code with ifdef preprocessor directives and makes changing such code a living nightmare. Another problem with these two tests is that they cannot use OpenGL because it means mocking OpenGL, which we obviously not going to do. With integration tests, it's not a problem. The bottom line is that unit tests can be useful but they make life notoriously difficult when it comes to testing components that depend on other components.
This commit is contained in:
parent
494ef1c930
commit
7b1bbf6e0a
18 changed files with 0 additions and 1654 deletions
|
@ -133,82 +133,7 @@ target_link_libraries(testXcbWindow
|
|||
add_test(NAME kwin-testXcbWindow COMMAND testXcbWindow)
|
||||
ecm_mark_as_test(testXcbWindow)
|
||||
|
||||
########################################################
|
||||
# Test ScriptedEffectLoader
|
||||
########################################################
|
||||
include_directories(${KWin_SOURCE_DIR}/src)
|
||||
set(testScriptedEffectLoader_SRCS
|
||||
../src/effectloader.cpp
|
||||
../src/cursor.cpp
|
||||
../src/screens.cpp
|
||||
../src/scripting/scriptedeffect.cpp
|
||||
../src/scripting/scripting_logging.cpp
|
||||
../src/scripting/scriptingutils.cpp
|
||||
mock_abstract_client.cpp
|
||||
mock_effectshandler.cpp
|
||||
mock_workspace.cpp
|
||||
test_scripted_effectloader.cpp
|
||||
)
|
||||
kconfig_add_kcfg_files(testScriptedEffectLoader_SRCS ../src/settings.kcfgc)
|
||||
add_executable(testScriptedEffectLoader ${testScriptedEffectLoader_SRCS})
|
||||
|
||||
target_link_libraries(testScriptedEffectLoader
|
||||
Qt::Concurrent
|
||||
Qt::Qml
|
||||
Qt::Test
|
||||
Qt::X11Extras
|
||||
|
||||
KF5::ConfigGui
|
||||
KF5::GlobalAccel
|
||||
KF5::I18n
|
||||
KF5::Notifications
|
||||
KF5::Package
|
||||
|
||||
XCB::CURSOR
|
||||
|
||||
kwineffects
|
||||
)
|
||||
|
||||
add_test(NAME kwin-testScriptedEffectLoader COMMAND testScriptedEffectLoader)
|
||||
ecm_mark_as_test(testScriptedEffectLoader)
|
||||
|
||||
########################################################
|
||||
# Test PluginEffectLoader
|
||||
########################################################
|
||||
set(testPluginEffectLoader_SRCS
|
||||
../src/effectloader.cpp
|
||||
mock_effectshandler.cpp
|
||||
test_plugin_effectloader.cpp
|
||||
)
|
||||
add_executable(testPluginEffectLoader ${testPluginEffectLoader_SRCS})
|
||||
|
||||
target_link_libraries(testPluginEffectLoader
|
||||
Qt::Concurrent
|
||||
Qt::Qml
|
||||
Qt::Test
|
||||
Qt::X11Extras
|
||||
|
||||
KF5::Package
|
||||
|
||||
kwineffects
|
||||
)
|
||||
|
||||
add_test(NAME kwin-testPluginEffectLoader COMMAND testPluginEffectLoader)
|
||||
ecm_mark_as_test(testPluginEffectLoader)
|
||||
|
||||
########################################################
|
||||
# FakeEffectPlugin
|
||||
########################################################
|
||||
add_library(fakeeffectplugin MODULE fakeeffectplugin.cpp)
|
||||
set_target_properties(fakeeffectplugin PROPERTIES PREFIX "")
|
||||
target_link_libraries(fakeeffectplugin kwineffects)
|
||||
|
||||
########################################################
|
||||
# FakeEffectPlugin-Version
|
||||
########################################################
|
||||
add_library(effectversionplugin MODULE fakeeffectplugin_version.cpp)
|
||||
set_target_properties(effectversionplugin PROPERTIES PREFIX "")
|
||||
target_link_libraries(effectversionplugin kwineffects)
|
||||
|
||||
########################################################
|
||||
# Test OnScreenNotification
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "mock_abstract_client.h"
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include <kwineffects.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class FakeEffect : public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FakeEffect() {}
|
||||
~FakeEffect() override {}
|
||||
|
||||
static bool supported() {
|
||||
return effects->isOpenGLCompositing();
|
||||
}
|
||||
|
||||
static bool enabledByDefault() {
|
||||
return effects->property("testEnabledByDefault").toBool();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(KWin::FakeEffect,
|
||||
"fakeeffectplugin.json",
|
||||
return KWin::FakeEffect::supported();,
|
||||
return KWin::FakeEffect::enabledByDefault();)
|
||||
|
||||
#include "fakeeffectplugin.moc"
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"KPlugin": {
|
||||
"Id": "fakeeffectplugin"
|
||||
},
|
||||
"Type": "Service",
|
||||
"X-KDE-Library": "fakeeffectplugin",
|
||||
"X-KDE-PluginInfo-EnabledByDefault": true,
|
||||
"X-KDE-PluginInfo-Name": "fakeeffectplugin"
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include <kwineffects.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class FakeVersionEffect : public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FakeVersionEffect() {}
|
||||
~FakeVersionEffect() override {}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class FakeEffectPluginFactory : public KWin::EffectPluginFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "not_a_valid_version" FILE "fakeeffectplugin_version.json")
|
||||
Q_INTERFACES(KPluginFactory)
|
||||
public:
|
||||
FakeEffectPluginFactory() {}
|
||||
~FakeEffectPluginFactory() override {}
|
||||
KWin::Effect *createEffect() const override {
|
||||
return new KWin::FakeVersionEffect();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#include "fakeeffectplugin_version.moc"
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"KPlugin": {
|
||||
"Id": "effectversion"
|
||||
},
|
||||
"Type": "Service",
|
||||
"X-KDE-Library": "effectversionplugin",
|
||||
"X-KDE-PluginInfo-EnabledByDefault": true,
|
||||
"X-KDE-PluginInfo-Name": "effectversion"
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "mock_abstract_client.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
AbstractClient::AbstractClient(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_active(false)
|
||||
, m_screen(0)
|
||||
, m_fullscreen(false)
|
||||
, m_hiddenInternal(false)
|
||||
, m_keepBelow(false)
|
||||
, m_frameGeometry()
|
||||
, m_resize(false)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractClient::~AbstractClient() = default;
|
||||
|
||||
bool AbstractClient::isActive() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
void AbstractClient::setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
}
|
||||
|
||||
void AbstractClient::setScreen(int screen)
|
||||
{
|
||||
m_screen = screen;
|
||||
}
|
||||
|
||||
bool AbstractClient::isOnScreen(int screen) const
|
||||
{
|
||||
// TODO: mock checking client geometry
|
||||
return screen == m_screen;
|
||||
}
|
||||
|
||||
int AbstractClient::screen() const
|
||||
{
|
||||
return m_screen;
|
||||
}
|
||||
|
||||
void AbstractClient::setFullScreen(bool set)
|
||||
{
|
||||
m_fullscreen = set;
|
||||
}
|
||||
|
||||
bool AbstractClient::isFullScreen() const
|
||||
{
|
||||
return m_fullscreen;
|
||||
}
|
||||
|
||||
bool AbstractClient::isHiddenInternal() const
|
||||
{
|
||||
return m_hiddenInternal;
|
||||
}
|
||||
|
||||
void AbstractClient::setHiddenInternal(bool set)
|
||||
{
|
||||
m_hiddenInternal = set;
|
||||
}
|
||||
|
||||
void AbstractClient::moveResize(const QRect &rect)
|
||||
{
|
||||
m_frameGeometry = rect;
|
||||
Q_EMIT geometryChanged();
|
||||
}
|
||||
|
||||
QRect AbstractClient::frameGeometry() const
|
||||
{
|
||||
return m_frameGeometry;
|
||||
}
|
||||
|
||||
bool AbstractClient::keepBelow() const
|
||||
{
|
||||
return m_keepBelow;
|
||||
}
|
||||
|
||||
void AbstractClient::setKeepBelow(bool keepBelow)
|
||||
{
|
||||
m_keepBelow = keepBelow;
|
||||
Q_EMIT keepBelowChanged();
|
||||
}
|
||||
|
||||
bool AbstractClient::isInteractiveResize() const
|
||||
{
|
||||
return m_resize;
|
||||
}
|
||||
|
||||
void AbstractClient::setInteractiveResize(bool set)
|
||||
{
|
||||
m_resize = set;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#ifndef KWIN_MOCK_ABSTRACT_CLIENT_H
|
||||
#define KWIN_MOCK_ABSTRACT_CLIENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class AbstractClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractClient(QObject *parent);
|
||||
~AbstractClient() override;
|
||||
|
||||
int screen() const;
|
||||
bool isOnScreen(int screen) const;
|
||||
bool isActive() const;
|
||||
bool isFullScreen() const;
|
||||
bool isHiddenInternal() const;
|
||||
QRect frameGeometry() const;
|
||||
bool keepBelow() const;
|
||||
|
||||
void setActive(bool active);
|
||||
void setScreen(int screen);
|
||||
void setFullScreen(bool set);
|
||||
void setHiddenInternal(bool set);
|
||||
void moveResize(const QRect &rect);
|
||||
void setKeepBelow(bool);
|
||||
bool isInteractiveResize() const;
|
||||
void setInteractiveResize(bool set);
|
||||
virtual void showOnScreenEdge() = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void geometryChanged();
|
||||
void keepBelowChanged();
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
int m_screen;
|
||||
bool m_fullscreen;
|
||||
bool m_hiddenInternal;
|
||||
bool m_keepBelow;
|
||||
QRect m_frameGeometry;
|
||||
bool m_resize;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "mock_effectshandler.h"
|
||||
|
||||
MockEffectsHandler::MockEffectsHandler(KWin::CompositingType type)
|
||||
: EffectsHandler(type)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
KSharedConfigPtr MockEffectsHandler::config() const
|
||||
{
|
||||
static const KSharedConfigPtr s_config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
return s_config;
|
||||
}
|
||||
|
||||
KSharedConfigPtr MockEffectsHandler::inputConfig() const
|
||||
{
|
||||
static const KSharedConfigPtr s_inputConfig = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
return s_inputConfig;
|
||||
}
|
|
@ -1,286 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#ifndef MOCK_EFFECTS_HANDLER_H
|
||||
#define MOCK_EFFECTS_HANDLER_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <QX11Info>
|
||||
|
||||
class MockEffectsHandler : public KWin::EffectsHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MockEffectsHandler(KWin::CompositingType type);
|
||||
void activateWindow(KWin::EffectWindow *) override {}
|
||||
KWin::Effect *activeFullScreenEffect() const override {
|
||||
return nullptr;
|
||||
}
|
||||
bool hasActiveFullScreenEffect() const override {
|
||||
return false;
|
||||
}
|
||||
KWin::EffectScreen *activeScreen() const override {
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectWindow *activeWindow() const override {
|
||||
return nullptr;
|
||||
}
|
||||
void addRepaint(const QRect &) override {}
|
||||
void addRepaint(const QRegion &) override {}
|
||||
void addRepaint(int, int, int, int) override {}
|
||||
void addRepaintFull() override {}
|
||||
double animationTimeFactor() const override {
|
||||
return 0;
|
||||
}
|
||||
xcb_atom_t announceSupportProperty(const QByteArray &, KWin::Effect *) override {
|
||||
return XCB_ATOM_NONE;
|
||||
}
|
||||
QRect clientArea(KWin::clientAreaOption, const QPoint &, int) const override {
|
||||
return QRect();
|
||||
}
|
||||
QRect clientArea(KWin::clientAreaOption, const KWin::EffectWindow *) const override {
|
||||
return QRect();
|
||||
}
|
||||
QRect clientArea(KWin::clientAreaOption, const KWin::EffectScreen *, int) const override {
|
||||
return QRect();
|
||||
}
|
||||
void closeTabBox() override {}
|
||||
QString currentActivity() const override {
|
||||
return QString();
|
||||
}
|
||||
int currentDesktop() const override {
|
||||
return 0;
|
||||
}
|
||||
int currentTabBoxDesktop() const override {
|
||||
return 0;
|
||||
}
|
||||
QList< int > currentTabBoxDesktopList() const override {
|
||||
return QList<int>();
|
||||
}
|
||||
KWin::EffectWindow *currentTabBoxWindow() const override {
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectWindowList currentTabBoxWindowList() const override {
|
||||
return KWin::EffectWindowList();
|
||||
}
|
||||
QPoint cursorPos() const override {
|
||||
return QPoint();
|
||||
}
|
||||
bool decorationsHaveAlpha() const override {
|
||||
return false;
|
||||
}
|
||||
bool decorationSupportsBlurBehind() const override {
|
||||
return false;
|
||||
}
|
||||
void defineCursor(Qt::CursorShape) override {}
|
||||
int desktopAbove(int, bool) const override {
|
||||
return 0;
|
||||
}
|
||||
int desktopAtCoords(QPoint) const override {
|
||||
return 0;
|
||||
}
|
||||
int desktopBelow(int, bool) const override {
|
||||
return 0;
|
||||
}
|
||||
QPoint desktopCoords(int) const override {
|
||||
return QPoint();
|
||||
}
|
||||
QPoint desktopGridCoords(int) const override {
|
||||
return QPoint();
|
||||
}
|
||||
int desktopGridHeight() const override {
|
||||
return 0;
|
||||
}
|
||||
QSize desktopGridSize() const override {
|
||||
return QSize();
|
||||
}
|
||||
int desktopGridWidth() const override {
|
||||
return 0;
|
||||
}
|
||||
QString desktopName(int) const override {
|
||||
return QString();
|
||||
}
|
||||
int desktopToLeft(int, bool) const override {
|
||||
return 0;
|
||||
}
|
||||
int desktopToRight(int, bool) const override {
|
||||
return 0;
|
||||
}
|
||||
void doneOpenGLContextCurrent() override {}
|
||||
void drawWindow(KWin::EffectWindow *, int, const QRegion &, KWin::WindowPaintData &) override {}
|
||||
KWin::EffectFrame *effectFrame(KWin::EffectFrameStyle, bool, const QPoint &, Qt::Alignment) const override {
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectWindow *findWindow(WId) const override {
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectWindow *findWindow(KWaylandServer::SurfaceInterface *) const override {
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectWindow *findWindow(QWindow *w) const override {
|
||||
Q_UNUSED(w)
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectWindow *findWindow(const QUuid &id) const override {
|
||||
Q_UNUSED(id)
|
||||
return nullptr;
|
||||
}
|
||||
void *getProxy(QString) override {
|
||||
return nullptr;
|
||||
}
|
||||
bool grabKeyboard(KWin::Effect *) override {
|
||||
return false;
|
||||
}
|
||||
bool hasDecorationShadows() const override {
|
||||
return false;
|
||||
}
|
||||
bool isScreenLocked() const override {
|
||||
return false;
|
||||
}
|
||||
QVariant kwinOption(KWin::KWinOption) override {
|
||||
return QVariant();
|
||||
}
|
||||
bool makeOpenGLContextCurrent() override {
|
||||
return false;
|
||||
}
|
||||
void moveWindow(KWin::EffectWindow *, const QPoint &, bool, double) override {}
|
||||
int numberOfDesktops() const override {
|
||||
return 0;
|
||||
}
|
||||
bool optionRollOverDesktops() const override {
|
||||
return false;
|
||||
}
|
||||
void paintEffectFrame(KWin::EffectFrame *, const QRegion &, double, double) override {}
|
||||
void paintScreen(int, const QRegion &, KWin::ScreenPaintData &) override {}
|
||||
void paintWindow(KWin::EffectWindow *, int, const QRegion &, KWin::WindowPaintData &) override {}
|
||||
void postPaintScreen() override {}
|
||||
void postPaintWindow(KWin::EffectWindow *) override {}
|
||||
void prePaintScreen(KWin::ScreenPrePaintData &, std::chrono::milliseconds) override {}
|
||||
void prePaintWindow(KWin::EffectWindow *, KWin::WindowPrePaintData &, std::chrono::milliseconds) override {}
|
||||
QByteArray readRootProperty(long int, long int, int) const override {
|
||||
return QByteArray();
|
||||
}
|
||||
void reconfigure() override {}
|
||||
void refTabBox() override {}
|
||||
void registerAxisShortcut(Qt::KeyboardModifiers, KWin::PointerAxisDirection, QAction *) override {}
|
||||
void registerGlobalShortcut(const QKeySequence &, QAction *) override {}
|
||||
void registerPointerShortcut(Qt::KeyboardModifiers, Qt::MouseButton, QAction *) override {}
|
||||
void registerTouchpadSwipeShortcut(KWin::SwipeDirection, QAction *) override {}
|
||||
void registerRealtimeTouchpadSwipeShortcut(KWin::SwipeDirection, QAction*, std::function<void(qreal)>) override {}
|
||||
void reloadEffect(KWin::Effect *) override {}
|
||||
void removeSupportProperty(const QByteArray &, KWin::Effect *) override {}
|
||||
void reserveElectricBorder(KWin::ElectricBorder, KWin::Effect *) override {}
|
||||
void registerTouchBorder(KWin::ElectricBorder, QAction *) override {}
|
||||
void unregisterTouchBorder(KWin::ElectricBorder, QAction *) override {}
|
||||
QPainter *scenePainter() override {
|
||||
return nullptr;
|
||||
}
|
||||
void setActiveFullScreenEffect(KWin::Effect *) override {}
|
||||
void setCurrentDesktop(int) override {}
|
||||
void setElevatedWindow(KWin::EffectWindow *, bool) override {}
|
||||
void setNumberOfDesktops(int) override {}
|
||||
void setShowingDesktop(bool) override {}
|
||||
void setTabBoxDesktop(int) override {}
|
||||
void setTabBoxWindow(KWin::EffectWindow*) override {}
|
||||
KWin::EffectWindowList stackingOrder() const override {
|
||||
return KWin::EffectWindowList();
|
||||
}
|
||||
void startMouseInterception(KWin::Effect *, Qt::CursorShape) override {}
|
||||
void startMousePolling() override {}
|
||||
void stopMouseInterception(KWin::Effect *) override {}
|
||||
void stopMousePolling() override {}
|
||||
void ungrabKeyboard() override {}
|
||||
void unrefTabBox() override {}
|
||||
void unreserveElectricBorder(KWin::ElectricBorder, KWin::Effect *) override {}
|
||||
QRect virtualScreenGeometry() const override {
|
||||
return QRect();
|
||||
}
|
||||
QSize virtualScreenSize() const override {
|
||||
return QSize();
|
||||
}
|
||||
void windowToDesktop(KWin::EffectWindow *, int) override {}
|
||||
void windowToScreen(KWin::EffectWindow *, KWin::EffectScreen *) override {}
|
||||
int workspaceHeight() const override {
|
||||
return 0;
|
||||
}
|
||||
int workspaceWidth() const override {
|
||||
return 0;
|
||||
}
|
||||
xcb_connection_t *xcbConnection() const override {
|
||||
return QX11Info::connection();
|
||||
}
|
||||
xcb_window_t x11RootWindow() const override {
|
||||
return QX11Info::appRootWindow();
|
||||
}
|
||||
KWaylandServer::Display *waylandDisplay() const override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool animationsSupported() const override {
|
||||
return m_animationsSuported;
|
||||
}
|
||||
void setAnimationsSupported(bool set) {
|
||||
m_animationsSuported = set;
|
||||
}
|
||||
|
||||
KWin::PlatformCursorImage cursorImage() const override {
|
||||
return KWin::PlatformCursorImage();
|
||||
}
|
||||
|
||||
void hideCursor() override {}
|
||||
|
||||
void showCursor() override {}
|
||||
|
||||
void startInteractiveWindowSelection(std::function<void(KWin::EffectWindow*)> callback) override {
|
||||
callback(nullptr);
|
||||
}
|
||||
void startInteractivePositionSelection(std::function<void (const QPoint &)> callback) override {
|
||||
callback(QPoint(-1, -1));
|
||||
}
|
||||
void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override {
|
||||
Q_UNUSED(message)
|
||||
Q_UNUSED(iconName)
|
||||
}
|
||||
void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override { Q_UNUSED(flags)}
|
||||
|
||||
void windowToDesktops(KWin::EffectWindow *w, const QVector<uint> &desktops) override {
|
||||
Q_UNUSED(w)
|
||||
Q_UNUSED(desktops)
|
||||
}
|
||||
|
||||
KSharedConfigPtr config() const override;
|
||||
KSharedConfigPtr inputConfig() const override;
|
||||
void renderOffscreenQuickView(KWin::OffscreenQuickView *quickView) const override {
|
||||
Q_UNUSED(quickView);
|
||||
}
|
||||
KWin::SessionState sessionState() const override {
|
||||
return KWin::SessionState::Normal;
|
||||
}
|
||||
QList<KWin::EffectScreen *> screens() const override {
|
||||
return {};
|
||||
}
|
||||
KWin::EffectScreen *screenAt(const QPoint &point) const override {
|
||||
Q_UNUSED(point)
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectScreen *findScreen(const QString &name) const override {
|
||||
Q_UNUSED(name)
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectScreen *findScreen(int screenId) const override {
|
||||
Q_UNUSED(screenId)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void renderScreen(KWin::EffectScreen *screen) override {
|
||||
Q_UNUSED(screen);
|
||||
}
|
||||
private:
|
||||
bool m_animationsSuported = true;
|
||||
};
|
||||
#endif
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "mock_workspace.h"
|
||||
#include "mock_abstract_client.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
Workspace *MockWorkspace::s_self = nullptr;
|
||||
|
||||
MockWorkspace::MockWorkspace(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_activeClient(nullptr)
|
||||
, m_moveResizeClient(nullptr)
|
||||
, m_showingDesktop(false)
|
||||
{
|
||||
s_self = this;
|
||||
}
|
||||
|
||||
MockWorkspace::~MockWorkspace()
|
||||
{
|
||||
s_self = nullptr;
|
||||
}
|
||||
|
||||
AbstractClient *MockWorkspace::activeClient() const
|
||||
{
|
||||
return m_activeClient;
|
||||
}
|
||||
|
||||
void MockWorkspace::setActiveClient(AbstractClient *c)
|
||||
{
|
||||
m_activeClient = c;
|
||||
}
|
||||
|
||||
AbstractClient *MockWorkspace::moveResizeClient() const
|
||||
{
|
||||
return m_moveResizeClient;
|
||||
}
|
||||
|
||||
void MockWorkspace::setMoveResizeClient(AbstractClient *c)
|
||||
{
|
||||
m_moveResizeClient = c;
|
||||
}
|
||||
|
||||
void MockWorkspace::setShowingDesktop(bool showing)
|
||||
{
|
||||
m_showingDesktop = showing;
|
||||
}
|
||||
|
||||
bool MockWorkspace::showingDesktop() const
|
||||
{
|
||||
return m_showingDesktop;
|
||||
}
|
||||
|
||||
QRect MockWorkspace::geometry() const
|
||||
{
|
||||
return QRect();
|
||||
}
|
||||
|
||||
QRect MockWorkspace::clientArea(clientAreaOption, int screen, int desktop) const
|
||||
{
|
||||
Q_UNUSED(screen)
|
||||
Q_UNUSED(desktop)
|
||||
return QRect();
|
||||
}
|
||||
|
||||
void MockWorkspace::registerEventFilter(X11EventFilter *filter)
|
||||
{
|
||||
Q_UNUSED(filter)
|
||||
}
|
||||
|
||||
void MockWorkspace::unregisterEventFilter(X11EventFilter *filter)
|
||||
{
|
||||
Q_UNUSED(filter)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#ifndef KWIN_MOCK_WORKSPACE_H
|
||||
#define KWIN_MOCK_WORKSPACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <kwinglobals.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class AbstractClient;
|
||||
class X11Client;
|
||||
class X11EventFilter;
|
||||
|
||||
class MockWorkspace;
|
||||
typedef MockWorkspace Workspace;
|
||||
|
||||
class MockWorkspace : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MockWorkspace(QObject *parent = nullptr);
|
||||
~MockWorkspace() override;
|
||||
AbstractClient *activeClient() const;
|
||||
AbstractClient *moveResizeClient() const;
|
||||
void setShowingDesktop(bool showing);
|
||||
bool showingDesktop() const;
|
||||
QRect geometry() const;
|
||||
QRect clientArea(clientAreaOption, int screen, int desktop) const;
|
||||
|
||||
void setActiveClient(AbstractClient *c);
|
||||
void setMoveResizeClient(AbstractClient *c);
|
||||
|
||||
void registerEventFilter(X11EventFilter *filter);
|
||||
void unregisterEventFilter(X11EventFilter *filter);
|
||||
|
||||
static Workspace *self();
|
||||
|
||||
Q_SIGNALS:
|
||||
void clientRemoved(KWin::X11Client *);
|
||||
|
||||
private:
|
||||
AbstractClient *m_activeClient;
|
||||
AbstractClient *m_moveResizeClient;
|
||||
bool m_showingDesktop;
|
||||
static Workspace *s_self;
|
||||
};
|
||||
|
||||
inline
|
||||
Workspace *MockWorkspace::self()
|
||||
{
|
||||
return s_self;
|
||||
}
|
||||
|
||||
inline Workspace *workspace()
|
||||
{
|
||||
return Workspace::self();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,374 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "effectloader.h"
|
||||
#include "mock_effectshandler.h"
|
||||
#include "scripting/scriptedeffect.h" // for mocking ScriptedEffect::create
|
||||
// KDE
|
||||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
// Qt
|
||||
#include <QtTest>
|
||||
#include <QStringList>
|
||||
Q_DECLARE_METATYPE(KWin::CompositingType)
|
||||
Q_DECLARE_METATYPE(KWin::LoadEffectFlag)
|
||||
Q_DECLARE_METATYPE(KWin::LoadEffectFlags)
|
||||
Q_DECLARE_METATYPE(KWin::Effect*)
|
||||
|
||||
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core")
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
ScriptedEffect *ScriptedEffect::create(const KPluginMetaData&)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ScriptedEffect::supported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TestPluginEffectLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testHasEffect_data();
|
||||
void testHasEffect();
|
||||
void testKnownEffects();
|
||||
void testSupported_data();
|
||||
void testSupported();
|
||||
void testLoadEffect_data();
|
||||
void testLoadEffect();
|
||||
void testLoadPluginEffect_data();
|
||||
void testLoadPluginEffect();
|
||||
void testLoadAllEffects();
|
||||
};
|
||||
|
||||
void TestPluginEffectLoader::testHasEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
QTest::addColumn<bool>("expected");
|
||||
|
||||
// all the built-in effects should fail
|
||||
QTest::newRow("blur") << QStringLiteral("blur") << false;
|
||||
QTest::newRow("ColorPicker") << QStringLiteral("colorpicker") << false;
|
||||
QTest::newRow("Contrast") << QStringLiteral("contrast") << false;
|
||||
QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << false;
|
||||
QTest::newRow("DimInactive") << QStringLiteral("diminactive") << false;
|
||||
QTest::newRow("FallApart") << QStringLiteral("fallapart") << false;
|
||||
QTest::newRow("Glide") << QStringLiteral("glide") << false;
|
||||
QTest::newRow("HighlightWindow") << QStringLiteral("highlightwindow") << false;
|
||||
QTest::newRow("Invert") << QStringLiteral("invert") << false;
|
||||
QTest::newRow("Kscreen") << QStringLiteral("kscreen") << false;
|
||||
QTest::newRow("LookingGlass") << QStringLiteral("lookingglass") << false;
|
||||
QTest::newRow("MagicLamp") << QStringLiteral("magiclamp") << false;
|
||||
QTest::newRow("Magnifier") << QStringLiteral("magnifier") << false;
|
||||
QTest::newRow("MouseClick") << QStringLiteral("mouseclick") << false;
|
||||
QTest::newRow("MouseMark") << QStringLiteral("mousemark") << false;
|
||||
QTest::newRow("PresentWindows") << QStringLiteral("presentwindows") << false;
|
||||
QTest::newRow("Resize") << QStringLiteral("resize") << false;
|
||||
QTest::newRow("ScreenEdge") << QStringLiteral("screenedge") << false;
|
||||
QTest::newRow("ScreenShot") << QStringLiteral("screenshot") << false;
|
||||
QTest::newRow("Sheet") << QStringLiteral("sheet") << false;
|
||||
QTest::newRow("ShowFps") << QStringLiteral("showfps") << false;
|
||||
QTest::newRow("ShowPaint") << QStringLiteral("showpaint") << false;
|
||||
QTest::newRow("Slide") << QStringLiteral("slide") << false;
|
||||
QTest::newRow("SlideBack") << QStringLiteral("slideback") << false;
|
||||
QTest::newRow("SlidingPopups") << QStringLiteral("slidingpopups") << false;
|
||||
QTest::newRow("SnapHelper") << QStringLiteral("snaphelper") << false;
|
||||
QTest::newRow("StartupFeedback") << QStringLiteral("startupfeedback") << false;
|
||||
QTest::newRow("ThumbnailAside") << QStringLiteral("thumbnailaside") << false;
|
||||
QTest::newRow("TrackMouse") << QStringLiteral("trackmouse") << false;
|
||||
QTest::newRow("WindowGeometry") << QStringLiteral("windowgeometry") << false;
|
||||
QTest::newRow("WobblyWindows") << QStringLiteral("wobblywindows") << false;
|
||||
QTest::newRow("Zoom") << QStringLiteral("zoom") << false;
|
||||
QTest::newRow("Non Existing") << QStringLiteral("InvalidName") << false;
|
||||
// all the scripted effects should fail
|
||||
QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << false;
|
||||
QTest::newRow("DimScreen") << QStringLiteral("kwin4_effect_dimscreen") << false;
|
||||
QTest::newRow("EyeOnScreen") << QStringLiteral("kwin4_effect_eyeonscreen") << false;
|
||||
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade") << false;
|
||||
QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << false;
|
||||
QTest::newRow("FadingPopups") << QStringLiteral("kwin4_effect_fadingpopups") << false;
|
||||
QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << false;
|
||||
QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << false;
|
||||
QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << false;
|
||||
QTest::newRow("Maximize") << QStringLiteral("kwin4_effect_maximize") << false;
|
||||
QTest::newRow("MorphingPopups") << QStringLiteral("kwin4_effect_morphingpopups") << false;
|
||||
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale") << false;
|
||||
QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash") << false;
|
||||
QTest::newRow("Translucency") << QStringLiteral("kwin4_effect_translucency") << false;
|
||||
QTest::newRow("WindowAperture") << QStringLiteral("kwin4_effect_windowaperture") << false;
|
||||
// and the fake effects we use here
|
||||
QTest::newRow("fakeeffectplugin") << QStringLiteral("fakeeffectplugin") << true;
|
||||
QTest::newRow("fakeeffectplugin CS") << QStringLiteral("fakeEffectPlugin") << true;
|
||||
QTest::newRow("effectversion") << QStringLiteral("effectversion") << true;
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testHasEffect()
|
||||
{
|
||||
QFETCH(QString, name);
|
||||
QFETCH(bool, expected);
|
||||
|
||||
KWin::PluginEffectLoader loader;
|
||||
loader.setPluginSubDirectory(QString());
|
||||
QCOMPARE(loader.hasEffect(name), expected);
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testKnownEffects()
|
||||
{
|
||||
QStringList expectedEffects;
|
||||
expectedEffects << QStringLiteral("fakeeffectplugin") << QStringLiteral("effectversion");
|
||||
|
||||
KWin::PluginEffectLoader loader;
|
||||
loader.setPluginSubDirectory(QString());
|
||||
QStringList result = loader.listOfKnownEffects();
|
||||
// at least as many effects as we expect - system running the test could have more effects
|
||||
QVERIFY(result.size() >= expectedEffects.size());
|
||||
for (const QString &effect : expectedEffects) {
|
||||
QVERIFY(result.contains(effect));
|
||||
}
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testSupported_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
QTest::addColumn<bool>("expected");
|
||||
QTest::addColumn<KWin::CompositingType>("type");
|
||||
|
||||
const KWin::CompositingType qc = KWin::QPainterCompositing;
|
||||
const KWin::CompositingType oc = KWin::OpenGLCompositing;
|
||||
|
||||
QTest::newRow("invalid") << QStringLiteral("blur") << false << qc;
|
||||
QTest::newRow("fake - qpainter") << QStringLiteral("fakeeffectplugin") << false << qc;
|
||||
QTest::newRow("fake - opengl") << QStringLiteral("fakeeffectplugin") << true << oc;
|
||||
QTest::newRow("fake - CS") << QStringLiteral("fakeEffectPlugin") << true << oc;
|
||||
QTest::newRow("version") << QStringLiteral("effectversion") << false << qc;
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testSupported()
|
||||
{
|
||||
QFETCH(QString, name);
|
||||
QFETCH(bool, expected);
|
||||
QFETCH(KWin::CompositingType, type);
|
||||
|
||||
MockEffectsHandler mockHandler(type);
|
||||
KWin::PluginEffectLoader loader;
|
||||
loader.setPluginSubDirectory(QString());
|
||||
QCOMPARE(loader.isEffectSupported(name), expected);
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testLoadEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
QTest::addColumn<bool>("expected");
|
||||
QTest::addColumn<KWin::CompositingType>("type");
|
||||
|
||||
const KWin::CompositingType qc = KWin::QPainterCompositing;
|
||||
const KWin::CompositingType oc = KWin::OpenGLCompositing;
|
||||
|
||||
QTest::newRow("invalid") << QStringLiteral("slide") << false << qc;
|
||||
QTest::newRow("fake - qpainter") << QStringLiteral("fakeeffectplugin") << false << qc;
|
||||
QTest::newRow("fake - opengl") << QStringLiteral("fakeeffectplugin") << true << oc;
|
||||
QTest::newRow("fake - CS") << QStringLiteral("fakeEffectPlugin") << true << oc;
|
||||
QTest::newRow("version") << QStringLiteral("effectversion") << false << qc;
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testLoadEffect()
|
||||
{
|
||||
QFETCH(QString, name);
|
||||
QFETCH(bool, expected);
|
||||
QFETCH(KWin::CompositingType, type);
|
||||
|
||||
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(type));
|
||||
KWin::PluginEffectLoader loader;
|
||||
loader.setPluginSubDirectory(QString());
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
loader.setConfig(config);
|
||||
|
||||
qRegisterMetaType<KWin::Effect*>();
|
||||
QSignalSpy spy(&loader, &KWin::PluginEffectLoader::effectLoaded);
|
||||
// connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent
|
||||
connect(&loader, &KWin::PluginEffectLoader::effectLoaded,
|
||||
[&name](KWin::Effect *effect, const QString &effectName) {
|
||||
QCOMPARE(effectName, name.toLower());
|
||||
effect->deleteLater();
|
||||
}
|
||||
);
|
||||
// try to load the Effect
|
||||
QCOMPARE(loader.loadEffect(name), expected);
|
||||
// loading again should fail
|
||||
QVERIFY(!loader.loadEffect(name));
|
||||
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name.toLower());
|
||||
}
|
||||
spy.clear();
|
||||
QVERIFY(spy.isEmpty());
|
||||
|
||||
// now if we wait for the events being processed, the effect will get deleted and it should load again
|
||||
QTest::qWait(1);
|
||||
QCOMPARE(loader.loadEffect(name), expected);
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name.toLower());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testLoadPluginEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
QTest::addColumn<bool>("expected");
|
||||
QTest::addColumn<KWin::CompositingType>("type");
|
||||
QTest::addColumn<KWin::LoadEffectFlags>("loadFlags");
|
||||
QTest::addColumn<bool>("enabledByDefault");
|
||||
|
||||
const KWin::CompositingType qc = KWin::QPainterCompositing;
|
||||
const KWin::CompositingType oc = KWin::OpenGLCompositing;
|
||||
|
||||
const KWin::LoadEffectFlags checkDefault = KWin::LoadEffectFlag::Load | KWin::LoadEffectFlag::CheckDefaultFunction;
|
||||
const KWin::LoadEffectFlags forceFlags = KWin::LoadEffectFlag::Load;
|
||||
const KWin::LoadEffectFlags dontLoadFlags = KWin::LoadEffectFlags();
|
||||
|
||||
// enabled by default, but not supported
|
||||
QTest::newRow("fakeeffectplugin") << QStringLiteral("fakeeffectplugin") << false << qc << checkDefault << false;
|
||||
// enabled by default, check default false
|
||||
QTest::newRow("supported, check default error") << QStringLiteral("fakeeffectplugin") << false << oc << checkDefault << false;
|
||||
// enabled by default, check default true
|
||||
QTest::newRow("supported, check default") << QStringLiteral("fakeeffectplugin") << true << oc << checkDefault << true;
|
||||
// enabled by default, check default false
|
||||
QTest::newRow("supported, check default error, forced") << QStringLiteral("fakeeffectplugin") << true << oc << forceFlags << false;
|
||||
// enabled by default, check default true
|
||||
QTest::newRow("supported, check default, don't load") << QStringLiteral("fakeeffectplugin") << false << oc << dontLoadFlags << true;
|
||||
// incorrect version
|
||||
QTest::newRow("Version") << QStringLiteral("effectversion") << false << qc << forceFlags << true;
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testLoadPluginEffect()
|
||||
{
|
||||
QFETCH(QString, name);
|
||||
QFETCH(bool, expected);
|
||||
QFETCH(KWin::CompositingType, type);
|
||||
QFETCH(KWin::LoadEffectFlags, loadFlags);
|
||||
QFETCH(bool, enabledByDefault);
|
||||
|
||||
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(type));
|
||||
mockHandler->setProperty("testEnabledByDefault", enabledByDefault);
|
||||
KWin::PluginEffectLoader loader;
|
||||
loader.setPluginSubDirectory(QString());
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
loader.setConfig(config);
|
||||
|
||||
const auto plugins = KPluginMetaData::findPlugins(QString(),
|
||||
[name] (const KPluginMetaData &data) {
|
||||
return data.pluginId().compare(name, Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
);
|
||||
QCOMPARE(plugins.size(), 1);
|
||||
|
||||
qRegisterMetaType<KWin::Effect*>();
|
||||
QSignalSpy spy(&loader, &KWin::PluginEffectLoader::effectLoaded);
|
||||
// connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent
|
||||
connect(&loader, &KWin::PluginEffectLoader::effectLoaded,
|
||||
[&name](KWin::Effect *effect, const QString &effectName) {
|
||||
QCOMPARE(effectName, name);
|
||||
effect->deleteLater();
|
||||
}
|
||||
);
|
||||
// try to load the Effect
|
||||
QCOMPARE(loader.loadEffect(plugins.first(), loadFlags), expected);
|
||||
// loading again should fail
|
||||
QVERIFY(!loader.loadEffect(plugins.first(), loadFlags));
|
||||
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name);
|
||||
}
|
||||
spy.clear();
|
||||
QVERIFY(spy.isEmpty());
|
||||
|
||||
// now if we wait for the events being processed, the effect will get deleted and it should load again
|
||||
QTest::qWait(1);
|
||||
QCOMPARE(loader.loadEffect(plugins.first(), loadFlags), expected);
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name);
|
||||
}
|
||||
}
|
||||
|
||||
void TestPluginEffectLoader::testLoadAllEffects()
|
||||
{
|
||||
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::OpenGLCompositing));
|
||||
mockHandler->setProperty("testEnabledByDefault", true);
|
||||
KWin::PluginEffectLoader loader;
|
||||
loader.setPluginSubDirectory(QString());
|
||||
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
|
||||
// prepare the configuration to hard enable/disable the effects we want to load
|
||||
KConfigGroup plugins = config->group("Plugins");
|
||||
plugins.writeEntry(QStringLiteral("fakeeffectpluginEnabled"), false);
|
||||
plugins.sync();
|
||||
|
||||
loader.setConfig(config);
|
||||
|
||||
qRegisterMetaType<KWin::Effect*>();
|
||||
QSignalSpy spy(&loader, &KWin::PluginEffectLoader::effectLoaded);
|
||||
// connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent
|
||||
connect(&loader, &KWin::PluginEffectLoader::effectLoaded,
|
||||
[](KWin::Effect *effect) {
|
||||
effect->deleteLater();
|
||||
}
|
||||
);
|
||||
|
||||
// the config is prepared so that no Effect gets loaded!
|
||||
loader.queryAndLoadAll();
|
||||
QCOMPARE(spy.size(), 0);
|
||||
|
||||
// now let's prepare a config which has one effect explicitly enabled
|
||||
plugins.writeEntry(QStringLiteral("fakeeffectpluginEnabled"), true);
|
||||
plugins.sync();
|
||||
|
||||
loader.queryAndLoadAll();
|
||||
QCOMPARE(spy.size(), 1);
|
||||
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), QStringLiteral("fakeeffectplugin"));
|
||||
spy.clear();
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestPluginEffectLoader)
|
||||
#include "test_plugin_effectloader.moc"
|
|
@ -1,457 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "effectloader.h"
|
||||
#include "mock_effectshandler.h"
|
||||
#include "scripting/scriptedeffect.h"
|
||||
// for mocking
|
||||
#include "cursor.h"
|
||||
#include "input.h"
|
||||
#include "screenedge.h"
|
||||
// KDE
|
||||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
#include <KPackage/PackageLoader>
|
||||
// Qt
|
||||
#include <QtTest>
|
||||
#include <QStringList>
|
||||
Q_DECLARE_METATYPE(KWin::LoadEffectFlag)
|
||||
Q_DECLARE_METATYPE(KWin::LoadEffectFlags)
|
||||
Q_DECLARE_METATYPE(KWin::Effect*)
|
||||
Q_DECLARE_METATYPE(KSharedConfigPtr)
|
||||
|
||||
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core")
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
ScreenEdges *ScreenEdges::s_self = nullptr;
|
||||
|
||||
void ScreenEdges::reserve(ElectricBorder, QObject *, const char *)
|
||||
{
|
||||
}
|
||||
|
||||
void ScreenEdges::unreserve(ElectricBorder, QObject *)
|
||||
{
|
||||
}
|
||||
|
||||
void ScreenEdges::reserveTouch(ElectricBorder, QAction *)
|
||||
{
|
||||
}
|
||||
|
||||
InputRedirection *InputRedirection::s_self = nullptr;
|
||||
|
||||
void InputRedirection::registerShortcut(const QKeySequence &, QAction *)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TestScriptedEffectLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testHasEffect_data();
|
||||
void testHasEffect();
|
||||
void testKnownEffects();
|
||||
void testLoadEffect_data();
|
||||
void testLoadEffect();
|
||||
void testLoadScriptedEffect_data();
|
||||
void testLoadScriptedEffect();
|
||||
void testLoadAllEffects();
|
||||
void testCancelLoadAllEffects();
|
||||
};
|
||||
|
||||
void TestScriptedEffectLoader::initTestCase()
|
||||
{
|
||||
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
|
||||
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
QCoreApplication::instance()->setProperty("config", QVariant::fromValue(config));
|
||||
|
||||
KWin::Cursors::self()->setMouse(new KWin::Cursor(this));
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testHasEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
QTest::addColumn<bool>("expected");
|
||||
|
||||
// all the built-in effects should fail
|
||||
QTest::newRow("blur") << QStringLiteral("blur") << false;
|
||||
QTest::newRow("Colorpicker") << QStringLiteral("colorpicker") << false;
|
||||
QTest::newRow("Contrast") << QStringLiteral("contrast") << false;
|
||||
QTest::newRow("DesktopGrid") << QStringLiteral("desktopgrid") << false;
|
||||
QTest::newRow("DimInactive") << QStringLiteral("diminactive") << false;
|
||||
QTest::newRow("FallApart") << QStringLiteral("fallapart") << false;
|
||||
QTest::newRow("Glide") << QStringLiteral("glide") << false;
|
||||
QTest::newRow("HighlightWindow") << QStringLiteral("highlightwindow") << false;
|
||||
QTest::newRow("Invert") << QStringLiteral("invert") << false;
|
||||
QTest::newRow("Kscreen") << QStringLiteral("kscreen") << false;
|
||||
QTest::newRow("Logout") << QStringLiteral("logout") << false;
|
||||
QTest::newRow("LookingGlass") << QStringLiteral("lookingglass") << false;
|
||||
QTest::newRow("MagicLamp") << QStringLiteral("magiclamp") << false;
|
||||
QTest::newRow("Magnifier") << QStringLiteral("magnifier") << false;
|
||||
QTest::newRow("MouseClick") << QStringLiteral("mouseclick") << false;
|
||||
QTest::newRow("MouseMark") << QStringLiteral("mousemark") << false;
|
||||
QTest::newRow("PresentWindows") << QStringLiteral("presentwindows") << false;
|
||||
QTest::newRow("Resize") << QStringLiteral("resize") << false;
|
||||
QTest::newRow("ScreenEdge") << QStringLiteral("screenedge") << false;
|
||||
QTest::newRow("ScreenShot") << QStringLiteral("screenshot") << false;
|
||||
QTest::newRow("Sheet") << QStringLiteral("sheet") << false;
|
||||
QTest::newRow("ShowFps") << QStringLiteral("showfps") << false;
|
||||
QTest::newRow("ShowPaint") << QStringLiteral("showpaint") << false;
|
||||
QTest::newRow("Slide") << QStringLiteral("slide") << false;
|
||||
QTest::newRow("SlideBack") << QStringLiteral("slideback") << false;
|
||||
QTest::newRow("SlidingPopups") << QStringLiteral("slidingpopups") << false;
|
||||
QTest::newRow("SnapHelper") << QStringLiteral("snaphelper") << false;
|
||||
QTest::newRow("StartupFeedback") << QStringLiteral("startupfeedback") << false;
|
||||
QTest::newRow("ThumbnailAside") << QStringLiteral("thumbnailaside") << false;
|
||||
QTest::newRow("TrackMouse") << QStringLiteral("trackmouse") << false;
|
||||
QTest::newRow("WindowGeometry") << QStringLiteral("windowgeometry") << false;
|
||||
QTest::newRow("WobblyWindows") << QStringLiteral("wobblywindows") << false;
|
||||
QTest::newRow("Zoom") << QStringLiteral("zoom") << false;
|
||||
QTest::newRow("Non Existing") << QStringLiteral("InvalidName") << false;
|
||||
QTest::newRow("Fade - without kwin4_effect") << QStringLiteral("fade") << false;
|
||||
|
||||
QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true;
|
||||
QTest::newRow("DimScreen") << QStringLiteral("kwin4_effect_dimscreen") << true;
|
||||
QTest::newRow("EyeOnScreen") << QStringLiteral("kwin4_effect_eyeonscreen") << true;
|
||||
QTest::newRow("Fade + kwin4_effect") << QStringLiteral("kwin4_effect_fade") << true;
|
||||
QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true;
|
||||
QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true;
|
||||
QTest::newRow("FadingPopups") << QStringLiteral("kwin4_effect_fadingpopups") << true;
|
||||
QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true;
|
||||
QTest::newRow("FullScreen") << QStringLiteral("kwin4_effect_fullscreen") << true;
|
||||
QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true;
|
||||
QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true;
|
||||
QTest::newRow("Maximize") << QStringLiteral("kwin4_effect_maximize") << true;
|
||||
QTest::newRow("MorphingPopups") << QStringLiteral("kwin4_effect_morphingpopups") << true;
|
||||
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale") << true;
|
||||
QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash") << true;
|
||||
QTest::newRow("Translucency") << QStringLiteral("kwin4_effect_translucency") << true;
|
||||
QTest::newRow("WindowAperture") << QStringLiteral("kwin4_effect_windowaperture") << true;
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testHasEffect()
|
||||
{
|
||||
QFETCH(QString, name);
|
||||
QFETCH(bool, expected);
|
||||
|
||||
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::QPainterCompositing));
|
||||
KWin::ScriptedEffectLoader loader;
|
||||
QCOMPARE(loader.hasEffect(name), expected);
|
||||
|
||||
// each available effect should also be supported
|
||||
QCOMPARE(loader.isEffectSupported(name), expected);
|
||||
|
||||
if (expected) {
|
||||
mockHandler->setAnimationsSupported(false);
|
||||
QVERIFY(!loader.isEffectSupported(name));
|
||||
}
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testKnownEffects()
|
||||
{
|
||||
QStringList expectedEffects;
|
||||
expectedEffects << QStringLiteral("kwin4_effect_dialogparent")
|
||||
<< QStringLiteral("kwin4_effect_dimscreen")
|
||||
<< QStringLiteral("kwin4_effect_eyeonscreen")
|
||||
<< QStringLiteral("kwin4_effect_fade")
|
||||
<< QStringLiteral("kwin4_effect_fadedesktop")
|
||||
<< QStringLiteral("kwin4_effect_fadingpopups")
|
||||
<< QStringLiteral("kwin4_effect_frozenapp")
|
||||
<< QStringLiteral("kwin4_effect_login")
|
||||
<< QStringLiteral("kwin4_effect_logout")
|
||||
<< QStringLiteral("kwin4_effect_maximize")
|
||||
<< QStringLiteral("kwin4_effect_morphingpopups")
|
||||
<< QStringLiteral("kwin4_effect_scale")
|
||||
<< QStringLiteral("kwin4_effect_sessionquit")
|
||||
<< QStringLiteral("kwin4_effect_squash")
|
||||
<< QStringLiteral("kwin4_effect_translucency")
|
||||
<< QStringLiteral("kwin4_effect_windowaperture");
|
||||
|
||||
KWin::ScriptedEffectLoader loader;
|
||||
QStringList result = loader.listOfKnownEffects();
|
||||
// at least as many effects as we expect - system running the test could have more effects
|
||||
QVERIFY(result.size() >= expectedEffects.size());
|
||||
for (const QString &effect : expectedEffects) {
|
||||
QVERIFY(result.contains(effect));
|
||||
}
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testLoadEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
QTest::addColumn<bool>("expected");
|
||||
|
||||
QTest::newRow("Non Existing") << QStringLiteral("InvalidName") << false;
|
||||
QTest::newRow("Fade - without kwin4_effect") << QStringLiteral("fade") << false;
|
||||
QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true;
|
||||
QTest::newRow("DimScreen") << QStringLiteral("kwin4_effect_dimscreen") << true;
|
||||
QTest::newRow("EyeOnScreen") << QStringLiteral("kwin4_effect_eyeonscreen") << true;
|
||||
QTest::newRow("Fade + kwin4_effect") << QStringLiteral("kwin4_effect_fade") << true;
|
||||
QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true;
|
||||
QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true;
|
||||
QTest::newRow("FadingPopups") << QStringLiteral("kwin4_effect_fadingpopups") << true;
|
||||
QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true;
|
||||
QTest::newRow("FullScreen") << QStringLiteral("kwin4_effect_fullscreen") << true;
|
||||
QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true;
|
||||
QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true;
|
||||
QTest::newRow("Maximize") << QStringLiteral("kwin4_effect_maximize") << true;
|
||||
QTest::newRow("MorphingPopups") << QStringLiteral("kwin4_effect_morphingpopups") << true;
|
||||
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale") << true;
|
||||
QTest::newRow("SessionQuit") << QStringLiteral("kwin4_effect_sessionquit") << true;
|
||||
QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash") << true;
|
||||
QTest::newRow("Translucency") << QStringLiteral("kwin4_effect_translucency") << true;
|
||||
QTest::newRow("WindowAperture") << QStringLiteral("kwin4_effect_windowaperture") << true;
|
||||
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testLoadEffect()
|
||||
{
|
||||
QFETCH(QString, name);
|
||||
QFETCH(bool, expected);
|
||||
|
||||
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::QPainterCompositing));
|
||||
KWin::ScriptedEffectLoader loader;
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
loader.setConfig(config);
|
||||
|
||||
qRegisterMetaType<KWin::Effect*>();
|
||||
QSignalSpy spy(&loader, &KWin::ScriptedEffectLoader::effectLoaded);
|
||||
// connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent
|
||||
connect(&loader, &KWin::ScriptedEffectLoader::effectLoaded,
|
||||
[&name](KWin::Effect *effect, const QString &effectName) {
|
||||
QCOMPARE(effectName, name.toLower());
|
||||
effect->deleteLater();
|
||||
}
|
||||
);
|
||||
// try to load the Effect
|
||||
QCOMPARE(loader.loadEffect(name), expected);
|
||||
// loading again should fail
|
||||
QVERIFY(!loader.loadEffect(name));
|
||||
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name.toLower());
|
||||
}
|
||||
spy.clear();
|
||||
QVERIFY(spy.isEmpty());
|
||||
|
||||
// now if we wait for the events being processed, the effect will get deleted and it should load again
|
||||
QTest::qWait(1);
|
||||
QCOMPARE(loader.loadEffect(name), expected);
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name.toLower());
|
||||
}
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testLoadScriptedEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
QTest::addColumn<bool>("expected");
|
||||
QTest::addColumn<KWin::LoadEffectFlags>("loadFlags");
|
||||
|
||||
const KWin::LoadEffectFlags checkDefault = KWin::LoadEffectFlag::Load | KWin::LoadEffectFlag::CheckDefaultFunction;
|
||||
const KWin::LoadEffectFlags forceFlags = KWin::LoadEffectFlag::Load;
|
||||
const KWin::LoadEffectFlags dontLoadFlags = KWin::LoadEffectFlags();
|
||||
|
||||
// enabled by default
|
||||
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade") << true << checkDefault;
|
||||
// not enabled by default
|
||||
QTest::newRow("EyeOnScreen") << QStringLiteral("kwin4_effect_eyeonscreen") << true << checkDefault;
|
||||
// Force an Effect which will load
|
||||
QTest::newRow("EyeOnScreen-Force") << QStringLiteral("kwin4_effect_eyeonscreen") << true << forceFlags;
|
||||
// Enforce no load of effect which is enabled by default
|
||||
QTest::newRow("Fade-DontLoad") << QStringLiteral("kwin4_effect_fade") << false << dontLoadFlags;
|
||||
// Enforce no load of effect which is not enabled by default, but enforced
|
||||
QTest::newRow("EyeOnScreen-DontLoad") << QStringLiteral("kwin4_effect_eyeonscreen") << false << dontLoadFlags;
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testLoadScriptedEffect()
|
||||
{
|
||||
QFETCH(QString, name);
|
||||
QFETCH(bool, expected);
|
||||
QFETCH(KWin::LoadEffectFlags, loadFlags);
|
||||
|
||||
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::QPainterCompositing));
|
||||
KWin::ScriptedEffectLoader loader;
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
loader.setConfig(config);
|
||||
|
||||
const auto services = KPackage::PackageLoader::self()->findPackages(QStringLiteral("KWin/Effect"), QStringLiteral("kwin/effects"),
|
||||
[name] (const KPluginMetaData &metadata) {
|
||||
return metadata.pluginId().compare(name, Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
);
|
||||
QCOMPARE(services.count(), 1);
|
||||
|
||||
qRegisterMetaType<KWin::Effect*>();
|
||||
QSignalSpy spy(&loader, &KWin::ScriptedEffectLoader::effectLoaded);
|
||||
// connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent
|
||||
connect(&loader, &KWin::ScriptedEffectLoader::effectLoaded,
|
||||
[&name](KWin::Effect *effect, const QString &effectName) {
|
||||
QCOMPARE(effectName, name.toLower());
|
||||
effect->deleteLater();
|
||||
}
|
||||
);
|
||||
// try to load the Effect
|
||||
QCOMPARE(loader.loadEffect(services.first(), loadFlags), expected);
|
||||
// loading again should fail
|
||||
QVERIFY(!loader.loadEffect(services.first(), loadFlags));
|
||||
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name.toLower());
|
||||
}
|
||||
spy.clear();
|
||||
QVERIFY(spy.isEmpty());
|
||||
|
||||
// now if we wait for the events being processed, the effect will get deleted and it should load again
|
||||
QTest::qWait(1);
|
||||
QCOMPARE(loader.loadEffect(services.first(), loadFlags), expected);
|
||||
// signal spy should have got the signal if it was expected
|
||||
QCOMPARE(spy.isEmpty(), !expected);
|
||||
if (!spy.isEmpty()) {
|
||||
QCOMPARE(spy.count(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), name.toLower());
|
||||
}
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testLoadAllEffects()
|
||||
{
|
||||
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::QPainterCompositing));
|
||||
KWin::ScriptedEffectLoader loader;
|
||||
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
|
||||
const QString kwin4 = QStringLiteral("kwin4_effect_");
|
||||
|
||||
// prepare the configuration to hard enable/disable the effects we want to load
|
||||
KConfigGroup plugins = config->group("Plugins");
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("dialogparentEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("dimscreenEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("fadeEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("fadedesktopEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("fadingpopupsEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("frozenappEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("fullscreenEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("loginEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("logoutEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("maximizeEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("scaleEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("squashEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("translucencyEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("eyeonscreenEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("windowapertureEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("morphingpopupsEnabled"), false);
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("sessionquitEnabled"), false);
|
||||
|
||||
plugins.sync();
|
||||
|
||||
loader.setConfig(config);
|
||||
|
||||
qRegisterMetaType<KWin::Effect*>();
|
||||
QSignalSpy spy(&loader, &KWin::ScriptedEffectLoader::effectLoaded);
|
||||
// connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent
|
||||
connect(&loader, &KWin::ScriptedEffectLoader::effectLoaded,
|
||||
[](KWin::Effect *effect) {
|
||||
effect->deleteLater();
|
||||
}
|
||||
);
|
||||
|
||||
// the config is prepared so that no Effect gets loaded!
|
||||
loader.queryAndLoadAll();
|
||||
|
||||
// we need to wait some time because it's queued and in a thread
|
||||
QVERIFY(!spy.wait(100));
|
||||
|
||||
// now let's prepare a config which has one effect explicitly enabled
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("eyeonscreenEnabled"), true);
|
||||
plugins.sync();
|
||||
|
||||
loader.queryAndLoadAll();
|
||||
// should load one effect in first go
|
||||
QVERIFY(spy.wait(100));
|
||||
// and afterwards it should not load another one
|
||||
QVERIFY(!spy.wait(10));
|
||||
|
||||
QCOMPARE(spy.size(), 1);
|
||||
// if we caught a signal it should have the effect name we passed in
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.count(), 2);
|
||||
QCOMPARE(arguments.at(1).toString(), kwin4 + QStringLiteral("eyeonscreen"));
|
||||
spy.clear();
|
||||
|
||||
// let's delete one of the default entries
|
||||
plugins.deleteEntry(kwin4 + QStringLiteral("fadeEnabled"));
|
||||
plugins.sync();
|
||||
|
||||
QVERIFY(spy.isEmpty());
|
||||
loader.queryAndLoadAll();
|
||||
|
||||
// let's use qWait as we need to wait for two signals to be emitted
|
||||
QTRY_COMPARE(spy.size(), 2);
|
||||
QStringList loadedEffects;
|
||||
for (auto &list : spy) {
|
||||
QCOMPARE(list.size(), 2);
|
||||
loadedEffects << list.at(1).toString();
|
||||
}
|
||||
std::sort(loadedEffects.begin(), loadedEffects.end());
|
||||
QCOMPARE(loadedEffects.at(0), kwin4 + QStringLiteral("eyeonscreen"));
|
||||
QCOMPARE(loadedEffects.at(1), kwin4 + QStringLiteral("fade"));
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testCancelLoadAllEffects()
|
||||
{
|
||||
// this test verifies that no test gets loaded when the loader gets cleared
|
||||
MockEffectsHandler mockHandler(KWin::QPainterCompositing);
|
||||
KWin::ScriptedEffectLoader loader;
|
||||
|
||||
// prepare the configuration to hard enable/disable the effects we want to load
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
const QString kwin4 = QStringLiteral("kwin4_effect_");
|
||||
KConfigGroup plugins = config->group("Plugins");
|
||||
plugins.writeEntry(kwin4 + QStringLiteral("eyeonscreenEnabled"), true);
|
||||
plugins.sync();
|
||||
|
||||
loader.setConfig(config);
|
||||
|
||||
qRegisterMetaType<KWin::Effect*>();
|
||||
QSignalSpy spy(&loader, &KWin::ScriptedEffectLoader::effectLoaded);
|
||||
QVERIFY(spy.isValid());
|
||||
|
||||
loader.queryAndLoadAll();
|
||||
loader.clear();
|
||||
|
||||
// Should not load any effect
|
||||
QVERIFY(!spy.wait(100));
|
||||
QVERIFY(spy.isEmpty());
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestScriptedEffectLoader)
|
||||
#include "test_scripted_effectloader.moc"
|
|
@ -1 +0,0 @@
|
|||
#include "mock_workspace.h"
|
|
@ -296,9 +296,7 @@ bool PluginEffectLoader::loadEffect(const KPluginMetaData &info, LoadEffectFlags
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifndef KWIN_UNIT_TEST
|
||||
effects->makeOpenGLContextCurrent();
|
||||
#endif
|
||||
if (!effectFactory->isSupported()) {
|
||||
qCDebug(KWIN_CORE) << "Effect is not supported: " << name;
|
||||
return false;
|
||||
|
|
|
@ -34,12 +34,8 @@ Screens::Screens(QObject *parent)
|
|||
, m_count(0)
|
||||
, m_maxScale(1.0)
|
||||
{
|
||||
// TODO: Do something about testScreens and other tests that use MockScreens.
|
||||
// They only make core code more convoluted with ifdefs.
|
||||
#ifndef KWIN_UNIT_TEST
|
||||
connect(kwinApp()->platform(), &Platform::screensQueried, this, &Screens::updateCount);
|
||||
connect(kwinApp()->platform(), &Platform::screensQueried, this, &Screens::changed);
|
||||
#endif
|
||||
}
|
||||
|
||||
Screens::~Screens()
|
||||
|
@ -124,26 +120,12 @@ int Screens::intersecting(const QRect &r) const
|
|||
|
||||
int Screens::number(const QPoint &pos) const
|
||||
{
|
||||
// TODO: Do something about testScreens and other tests that use MockScreens.
|
||||
// They only make core code more convoluted with ifdefs.
|
||||
#ifdef KWIN_UNIT_TEST
|
||||
Q_UNUSED(pos)
|
||||
return -1;
|
||||
#else
|
||||
return kwinApp()->platform()->enabledOutputs().indexOf(kwinApp()->platform()->outputAt(pos));
|
||||
#endif
|
||||
}
|
||||
|
||||
AbstractOutput *Screens::findOutput(int screen) const
|
||||
{
|
||||
// TODO: Do something about testScreens and other tests that use MockScreens.
|
||||
// They only make core code more convoluted with ifdefs.
|
||||
#ifdef KWIN_UNIT_TEST
|
||||
Q_UNUSED(screen)
|
||||
return nullptr;
|
||||
#else
|
||||
return kwinApp()->platform()->findOutput(screen);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -233,10 +233,8 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
|
|||
|
||||
globalObject.setProperty(QStringLiteral("Effect"),
|
||||
m_engine->newQMetaObject(&ScriptedEffect::staticMetaObject));
|
||||
#ifndef KWIN_UNIT_TEST
|
||||
globalObject.setProperty(QStringLiteral("KWin"),
|
||||
m_engine->newQMetaObject(&QtScriptWorkspaceWrapper::staticMetaObject));
|
||||
#endif
|
||||
globalObject.setProperty(QStringLiteral("Globals"),
|
||||
m_engine->newQMetaObject(&KWin::staticMetaObject));
|
||||
globalObject.setProperty(QStringLiteral("QEasingCurve"),
|
||||
|
|
Loading…
Reference in a new issue