Fix for failing testScriptedEffectsLoader

By changing the loading of scripted effect config to interact with
kwinApp we broke the tests which do not use a kwinApp.

This change turns the access to the KSharedConfigPtr go through the
property system, so that the tests can also install a dummy
KSharedConfigPtr. With that scripted effects loader test passes and no
longer crashes and the integration/effects tests also still pass.
icc-effect-5.14.5
Martin Gräßlin 2016-11-16 16:53:17 +01:00
parent 1c819c5e86
commit 6184278bec
4 changed files with 15 additions and 2 deletions

View File

@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
Q_DECLARE_METATYPE(KWin::LoadEffectFlag) Q_DECLARE_METATYPE(KWin::LoadEffectFlag)
Q_DECLARE_METATYPE(KWin::LoadEffectFlags) Q_DECLARE_METATYPE(KWin::LoadEffectFlags)
Q_DECLARE_METATYPE(KWin::Effect*) Q_DECLARE_METATYPE(KWin::Effect*)
Q_DECLARE_METATYPE(KSharedConfigPtr)
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core") Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core")
@ -64,6 +65,7 @@ class TestScriptedEffectLoader : public QObject
{ {
Q_OBJECT Q_OBJECT
private Q_SLOTS: private Q_SLOTS:
void initTestCase();
void testHasEffect_data(); void testHasEffect_data();
void testHasEffect(); void testHasEffect();
void testKnownEffects(); void testKnownEffects();
@ -75,6 +77,12 @@ private Q_SLOTS:
void testCancelLoadAllEffects(); void testCancelLoadAllEffects();
}; };
void TestScriptedEffectLoader::initTestCase()
{
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
QCoreApplication::instance()->setProperty("config", QVariant::fromValue(config));
}
void TestScriptedEffectLoader::testHasEffect_data() void TestScriptedEffectLoader::testHasEffect_data()
{ {
QTest::addColumn<QString>("name"); QTest::addColumn<QString>("name");

View File

@ -65,6 +65,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define XCB_GE_GENERIC 35 #define XCB_GE_GENERIC 35
#endif #endif
Q_DECLARE_METATYPE(KSharedConfigPtr)
namespace KWin namespace KWin
{ {
@ -107,6 +109,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation"); qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
qRegisterMetaType<KWin::EffectWindow*>(); qRegisterMetaType<KWin::EffectWindow*>();
qRegisterMetaType<KWayland::Server::SurfaceInterface *>("KWayland::Server::SurfaceInterface *"); qRegisterMetaType<KWayland::Server::SurfaceInterface *>("KWayland::Server::SurfaceInterface *");
qRegisterMetaType<KSharedConfigPtr>();
} }
void Application::setConfigLock(bool lock) void Application::setConfigLock(bool lock)

1
main.h
View File

@ -54,6 +54,7 @@ class KWIN_EXPORT Application : public QApplication
Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT) Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT)
Q_PROPERTY(void *x11Connection READ x11Connection NOTIFY x11ConnectionChanged) Q_PROPERTY(void *x11Connection READ x11Connection NOTIFY x11ConnectionChanged)
Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT) Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT)
Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig)
public: public:
/** /**
* @brief This enum provides the various operation modes of KWin depending on the available * @brief This enum provides the various operation modes of KWin depending on the available

View File

@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "scriptingutils.h" #include "scriptingutils.h"
#include "workspace_wrapper.h" #include "workspace_wrapper.h"
#include "../screenedge.h" #include "../screenedge.h"
#include "../main.h"
#include "scripting_logging.h" #include "scripting_logging.h"
// KDE // KDE
#include <KConfigGroup> #include <KConfigGroup>
@ -37,6 +36,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
typedef KWin::EffectWindow* KEffectWindowRef; typedef KWin::EffectWindow* KEffectWindowRef;
Q_DECLARE_METATYPE(KSharedConfigPtr)
namespace KWin namespace KWin
{ {
@ -483,7 +484,7 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
// does the effect contain an KConfigXT file? // does the effect contain an KConfigXT file?
const QString kconfigXTFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(KWIN_NAME "/effects/") + m_effectName + QLatin1String("/contents/config/main.xml")); const QString kconfigXTFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(KWIN_NAME "/effects/") + m_effectName + QLatin1String("/contents/config/main.xml"));
if (!kconfigXTFile.isNull()) { if (!kconfigXTFile.isNull()) {
KConfigGroup cg = kwinApp()->config()->group(QStringLiteral("Effect-%1").arg(m_effectName)); KConfigGroup cg = QCoreApplication::instance()->property("config").value<KSharedConfigPtr>()->group(QStringLiteral("Effect-%1").arg(m_effectName));
QFile xmlFile(kconfigXTFile); QFile xmlFile(kconfigXTFile);
m_config = new KConfigLoader(cg, &xmlFile, this); m_config = new KConfigLoader(cg, &xmlFile, this);
m_config->load(); m_config->load();