Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 7e7eadb4 authored by David Edmundson's avatar David Edmundson

[autotests] Make lifespan of EffectsHandler outlive Effect

Summary:
In loading tests. Effects are deleted in a deleteLater potentially
outside the scope of our test. Our MockEffectsHandler (which contains
the global static "effects") has the lifespan of the test.

Fixes failing unit test.

Test Plan: Ran test

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15167
parent fd53c7ed
......@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Qt
#include <QtTest>
#include <QStringList>
#include <QScopedPointer>
Q_DECLARE_METATYPE(KWin::CompositingType)
Q_DECLARE_METATYPE(KWin::LoadEffectFlag)
Q_DECLARE_METATYPE(KWin::LoadEffectFlags)
......@@ -362,7 +363,7 @@ void TestBuiltInEffectLoader::testLoadEffect()
QFETCH(bool, expected);
QFETCH(KWin::CompositingType, type);
MockEffectsHandler mockHandler(type);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(type));
KWin::BuiltInEffectLoader loader;
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
loader.setConfig(config);
......@@ -451,7 +452,7 @@ void TestBuiltInEffectLoader::testLoadBuiltInEffect()
QFETCH(KWin::CompositingType, type);
QFETCH(KWin::LoadEffectFlags, loadFlags);
MockEffectsHandler mockHandler(type);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(type));
KWin::BuiltInEffectLoader loader;
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
loader.setConfig(config);
......@@ -498,7 +499,7 @@ void TestBuiltInEffectLoader::testLoadBuiltInEffect()
void TestBuiltInEffectLoader::testLoadAllEffects()
{
MockEffectsHandler mockHandler(KWin::XRenderCompositing);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater>mockHandler(new MockEffectsHandler(KWin::XRenderCompositing));
KWin::BuiltInEffectLoader loader;
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
......
......@@ -201,7 +201,7 @@ void TestPluginEffectLoader::testLoadEffect()
QFETCH(bool, expected);
QFETCH(KWin::CompositingType, type);
MockEffectsHandler mockHandler(type);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(type));
KWin::PluginEffectLoader loader;
loader.setPluginSubDirectory(QString());
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
......@@ -285,8 +285,8 @@ void TestPluginEffectLoader::testLoadPluginEffect()
QFETCH(KWin::LoadEffectFlags, loadFlags);
QFETCH(bool, enabledByDefault);
MockEffectsHandler mockHandler(type);
mockHandler.setProperty("testEnabledByDefault", 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);
......@@ -341,8 +341,8 @@ void TestPluginEffectLoader::testLoadPluginEffect()
void TestPluginEffectLoader::testLoadAllEffects()
{
MockEffectsHandler mockHandler(KWin::OpenGL2Compositing);
mockHandler.setProperty("testEnabledByDefault", true);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::OpenGL2Compositing));
mockHandler->setProperty("testEnabledByDefault", true);
KWin::PluginEffectLoader loader;
loader.setPluginSubDirectory(QString());
......
......@@ -159,7 +159,7 @@ void TestScriptedEffectLoader::testHasEffect()
QFETCH(QString, name);
QFETCH(bool, expected);
MockEffectsHandler mockHandler(KWin::XRenderCompositing);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::XRenderCompositing));
KWin::ScriptedEffectLoader loader;
QCOMPARE(loader.hasEffect(name), expected);
......@@ -167,7 +167,7 @@ void TestScriptedEffectLoader::testHasEffect()
QCOMPARE(loader.isEffectSupported(name), expected);
if (expected) {
mockHandler.setAnimationsSupported(false);
mockHandler->setAnimationsSupported(false);
QVERIFY(!loader.isEffectSupported(name));
}
}
......@@ -216,7 +216,7 @@ void TestScriptedEffectLoader::testLoadEffect()
QFETCH(QString, name);
QFETCH(bool, expected);
MockEffectsHandler mockHandler(KWin::XRenderCompositing);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::XRenderCompositing));
KWin::ScriptedEffectLoader loader;
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
loader.setConfig(config);
......@@ -289,7 +289,7 @@ void TestScriptedEffectLoader::testLoadScriptedEffect()
QFETCH(bool, expected);
QFETCH(KWin::LoadEffectFlags, loadFlags);
MockEffectsHandler mockHandler(KWin::XRenderCompositing);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::XRenderCompositing));
KWin::ScriptedEffectLoader loader;
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
loader.setConfig(config);
......@@ -343,7 +343,7 @@ void TestScriptedEffectLoader::testLoadScriptedEffect()
void TestScriptedEffectLoader::testLoadAllEffects()
{
MockEffectsHandler mockHandler(KWin::XRenderCompositing);
QScopedPointer<MockEffectsHandler, QScopedPointerDeleteLater> mockHandler(new MockEffectsHandler(KWin::XRenderCompositing));
KWin::ScriptedEffectLoader loader;
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment