Changeset View
Changeset View
Standalone View
Standalone View
autotests/test_scripted_effectloader.cpp
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 99 | { | |||
---|---|---|---|---|---|
146 | QTest::newRow("Fade + kwin4_effect") << QStringLiteral("kwin4_effect_fade") << true; | 146 | QTest::newRow("Fade + kwin4_effect") << QStringLiteral("kwin4_effect_fade") << true; | ||
147 | QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true; | 147 | QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true; | ||
148 | QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true; | 148 | QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true; | ||
149 | QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true; | 149 | QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true; | ||
150 | QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true; | 150 | QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true; | ||
151 | QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true; | 151 | QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true; | ||
152 | QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true; | 152 | QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true; | ||
153 | QTest::newRow("Maximize") << QStringLiteral("kwin4_effect_maximize") << true; | 153 | QTest::newRow("Maximize") << QStringLiteral("kwin4_effect_maximize") << true; | ||
154 | QTest::newRow("ScaleIn") << QStringLiteral("kwin4_effect_scalein") << true; | | |||
155 | QTest::newRow("Translucency") << QStringLiteral("kwin4_effect_translucency") << true; | 154 | QTest::newRow("Translucency") << QStringLiteral("kwin4_effect_translucency") << true; | ||
156 | } | 155 | } | ||
157 | 156 | | |||
158 | void TestScriptedEffectLoader::testHasEffect() | 157 | void TestScriptedEffectLoader::testHasEffect() | ||
159 | { | 158 | { | ||
160 | QFETCH(QString, name); | 159 | QFETCH(QString, name); | ||
161 | QFETCH(bool, expected); | 160 | QFETCH(bool, expected); | ||
162 | 161 | | |||
Show All 15 Lines | 176 | { | |||
178 | QStringList expectedEffects; | 177 | QStringList expectedEffects; | ||
179 | expectedEffects << QStringLiteral("kwin4_effect_dialogparent") | 178 | expectedEffects << QStringLiteral("kwin4_effect_dialogparent") | ||
180 | << QStringLiteral("kwin4_effect_fade") | 179 | << QStringLiteral("kwin4_effect_fade") | ||
181 | << QStringLiteral("kwin4_effect_fadedesktop") | 180 | << QStringLiteral("kwin4_effect_fadedesktop") | ||
182 | << QStringLiteral("kwin4_effect_frozenapp") | 181 | << QStringLiteral("kwin4_effect_frozenapp") | ||
183 | << QStringLiteral("kwin4_effect_login") | 182 | << QStringLiteral("kwin4_effect_login") | ||
184 | << QStringLiteral("kwin4_effect_logout") | 183 | << QStringLiteral("kwin4_effect_logout") | ||
185 | << QStringLiteral("kwin4_effect_maximize") | 184 | << QStringLiteral("kwin4_effect_maximize") | ||
186 | << QStringLiteral("kwin4_effect_scalein") | | |||
187 | << QStringLiteral("kwin4_effect_translucency"); | 185 | << QStringLiteral("kwin4_effect_translucency"); | ||
188 | 186 | | |||
189 | KWin::ScriptedEffectLoader loader; | 187 | KWin::ScriptedEffectLoader loader; | ||
190 | QStringList result = loader.listOfKnownEffects(); | 188 | QStringList result = loader.listOfKnownEffects(); | ||
191 | // at least as many effects as we expect - system running the test could have more effects | 189 | // at least as many effects as we expect - system running the test could have more effects | ||
192 | QVERIFY(result.size() >= expectedEffects.size()); | 190 | QVERIFY(result.size() >= expectedEffects.size()); | ||
193 | for (const QString &effect : expectedEffects) { | 191 | for (const QString &effect : expectedEffects) { | ||
194 | QVERIFY(result.contains(effect)); | 192 | QVERIFY(result.contains(effect)); | ||
Show All 10 Lines | 197 | { | |||
205 | QTest::newRow("Fade + kwin4_effect") << QStringLiteral("kwin4_effect_fade") << true; | 203 | QTest::newRow("Fade + kwin4_effect") << QStringLiteral("kwin4_effect_fade") << true; | ||
206 | QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true; | 204 | QTest::newRow("Fade + kwin4_effect + CS") << QStringLiteral("kwin4_eFfect_fAde") << true; | ||
207 | QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true; | 205 | QTest::newRow("FadeDesktop") << QStringLiteral("kwin4_effect_fadedesktop") << true; | ||
208 | QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true; | 206 | QTest::newRow("FrozenApp") << QStringLiteral("kwin4_effect_frozenapp") << true; | ||
209 | QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true; | 207 | QTest::newRow("DialogParent") << QStringLiteral("kwin4_effect_dialogparent") << true; | ||
210 | QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true; | 208 | QTest::newRow("Login") << QStringLiteral("kwin4_effect_login") << true; | ||
211 | QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true; | 209 | QTest::newRow("Logout") << QStringLiteral("kwin4_effect_logout") << true; | ||
212 | QTest::newRow("Maximize") << QStringLiteral("kwin4_effect_maximize") << true; | 210 | QTest::newRow("Maximize") << QStringLiteral("kwin4_effect_maximize") << true; | ||
213 | QTest::newRow("ScaleIn") << QStringLiteral("kwin4_effect_scalein") << true; | | |||
214 | QTest::newRow("Translucency") << QStringLiteral("kwin4_effect_translucency") << true; | 211 | QTest::newRow("Translucency") << QStringLiteral("kwin4_effect_translucency") << true; | ||
215 | } | 212 | } | ||
216 | 213 | | |||
217 | void TestScriptedEffectLoader::testLoadEffect() | 214 | void TestScriptedEffectLoader::testLoadEffect() | ||
218 | { | 215 | { | ||
219 | QFETCH(QString, name); | 216 | QFETCH(QString, name); | ||
220 | QFETCH(bool, expected); | 217 | QFETCH(bool, expected); | ||
221 | 218 | | |||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 265 | { | |||
270 | QTest::addColumn<bool>("expected"); | 267 | QTest::addColumn<bool>("expected"); | ||
271 | QTest::addColumn<KWin::LoadEffectFlags>("loadFlags"); | 268 | QTest::addColumn<KWin::LoadEffectFlags>("loadFlags"); | ||
272 | 269 | | |||
273 | const KWin::LoadEffectFlags checkDefault = KWin::LoadEffectFlag::Load | KWin::LoadEffectFlag::CheckDefaultFunction; | 270 | const KWin::LoadEffectFlags checkDefault = KWin::LoadEffectFlag::Load | KWin::LoadEffectFlag::CheckDefaultFunction; | ||
274 | const KWin::LoadEffectFlags forceFlags = KWin::LoadEffectFlag::Load; | 271 | const KWin::LoadEffectFlags forceFlags = KWin::LoadEffectFlag::Load; | ||
275 | const KWin::LoadEffectFlags dontLoadFlags = KWin::LoadEffectFlags(); | 272 | const KWin::LoadEffectFlags dontLoadFlags = KWin::LoadEffectFlags(); | ||
276 | 273 | | |||
277 | // enabled by default | 274 | // enabled by default | ||
278 | QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade") << true << checkDefault; | 275 | QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade") << true << checkDefault; | ||
279 | // not enabled by default | 276 | // not enabled by default | ||
280 | QTest::newRow("Scalein") << QStringLiteral("kwin4_effect_scalein") << true << checkDefault; | 277 | QTest::newRow("EyeOnScreen") << QStringLiteral("kwin4_effect_eyeonscreen") << true << checkDefault; | ||
281 | // Force an Effect which will load | 278 | // Force an Effect which will load | ||
282 | QTest::newRow("Scalein-Force") << QStringLiteral("kwin4_effect_scalein") << true << forceFlags; | 279 | QTest::newRow("EyeOnScreen-Force") << QStringLiteral("kwin4_effect_eyeonscreen") << true << forceFlags; | ||
283 | // Enforce no load of effect which is enabled by default | 280 | // Enforce no load of effect which is enabled by default | ||
284 | QTest::newRow("Fade-DontLoad") << QStringLiteral("kwin4_effect_fade") << false << dontLoadFlags; | 281 | QTest::newRow("Fade-DontLoad") << QStringLiteral("kwin4_effect_fade") << false << dontLoadFlags; | ||
285 | // Enforce no load of effect which is not enabled by default, but enforced | 282 | // Enforce no load of effect which is not enabled by default, but enforced | ||
286 | QTest::newRow("Scalein-DontLoad") << QStringLiteral("kwin4_effect_scalein") << false << dontLoadFlags; | 283 | QTest::newRow("EyeOnScreen-DontLoad") << QStringLiteral("kwin4_effect_eyeonscreen") << false << dontLoadFlags; | ||
287 | } | 284 | } | ||
288 | 285 | | |||
289 | void TestScriptedEffectLoader::testLoadScriptedEffect() | 286 | void TestScriptedEffectLoader::testLoadScriptedEffect() | ||
290 | { | 287 | { | ||
291 | QFETCH(QString, name); | 288 | QFETCH(QString, name); | ||
292 | QFETCH(bool, expected); | 289 | QFETCH(bool, expected); | ||
293 | QFETCH(KWin::LoadEffectFlags, loadFlags); | 290 | QFETCH(KWin::LoadEffectFlags, loadFlags); | ||
294 | 291 | | |||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 345 | { | |||
358 | plugins.writeEntry(kwin4 + QStringLiteral("dialogparentEnabled"), false); | 355 | plugins.writeEntry(kwin4 + QStringLiteral("dialogparentEnabled"), false); | ||
359 | plugins.writeEntry(kwin4 + QStringLiteral("fadeEnabled"), false); | 356 | plugins.writeEntry(kwin4 + QStringLiteral("fadeEnabled"), false); | ||
360 | plugins.writeEntry(kwin4 + QStringLiteral("fadedesktopEnabled"), false); | 357 | plugins.writeEntry(kwin4 + QStringLiteral("fadedesktopEnabled"), false); | ||
361 | plugins.writeEntry(kwin4 + QStringLiteral("frozenappEnabled"), false); | 358 | plugins.writeEntry(kwin4 + QStringLiteral("frozenappEnabled"), false); | ||
362 | plugins.writeEntry(kwin4 + QStringLiteral("loginEnabled"), false); | 359 | plugins.writeEntry(kwin4 + QStringLiteral("loginEnabled"), false); | ||
363 | plugins.writeEntry(kwin4 + QStringLiteral("logoutEnabled"), false); | 360 | plugins.writeEntry(kwin4 + QStringLiteral("logoutEnabled"), false); | ||
364 | plugins.writeEntry(kwin4 + QStringLiteral("maximizeEnabled"), false); | 361 | plugins.writeEntry(kwin4 + QStringLiteral("maximizeEnabled"), false); | ||
365 | plugins.writeEntry(kwin4 + QStringLiteral("minimizeanimationEnabled"), false); | 362 | plugins.writeEntry(kwin4 + QStringLiteral("minimizeanimationEnabled"), false); | ||
366 | plugins.writeEntry(kwin4 + QStringLiteral("scaleinEnabled"), false); | | |||
367 | plugins.writeEntry(kwin4 + QStringLiteral("translucencyEnabled"), false); | 363 | plugins.writeEntry(kwin4 + QStringLiteral("translucencyEnabled"), false); | ||
368 | plugins.writeEntry(kwin4 + QStringLiteral("eyeonscreenEnabled"), false); | 364 | plugins.writeEntry(kwin4 + QStringLiteral("eyeonscreenEnabled"), false); | ||
369 | plugins.writeEntry(kwin4 + QStringLiteral("windowapertureEnabled"), false); | 365 | plugins.writeEntry(kwin4 + QStringLiteral("windowapertureEnabled"), false); | ||
370 | plugins.writeEntry(kwin4 + QStringLiteral("morphingpopupsEnabled"), false); | 366 | plugins.writeEntry(kwin4 + QStringLiteral("morphingpopupsEnabled"), false); | ||
371 | plugins.sync(); | 367 | plugins.sync(); | ||
372 | 368 | | |||
373 | loader.setConfig(config); | 369 | loader.setConfig(config); | ||
374 | 370 | | |||
375 | qRegisterMetaType<KWin::Effect*>(); | 371 | qRegisterMetaType<KWin::Effect*>(); | ||
376 | QSignalSpy spy(&loader, SIGNAL(effectLoaded(KWin::Effect*,QString))); | 372 | QSignalSpy spy(&loader, SIGNAL(effectLoaded(KWin::Effect*,QString))); | ||
377 | // connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent | 373 | // connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent | ||
378 | connect(&loader, &KWin::ScriptedEffectLoader::effectLoaded, | 374 | connect(&loader, &KWin::ScriptedEffectLoader::effectLoaded, | ||
379 | [](KWin::Effect *effect) { | 375 | [](KWin::Effect *effect) { | ||
380 | effect->deleteLater(); | 376 | effect->deleteLater(); | ||
381 | } | 377 | } | ||
382 | ); | 378 | ); | ||
383 | 379 | | |||
384 | // the config is prepared so that no Effect gets loaded! | 380 | // the config is prepared so that no Effect gets loaded! | ||
385 | loader.queryAndLoadAll(); | 381 | loader.queryAndLoadAll(); | ||
386 | 382 | | |||
387 | // we need to wait some time because it's queued and in a thread | 383 | // we need to wait some time because it's queued and in a thread | ||
388 | QVERIFY(!spy.wait(100)); | 384 | QVERIFY(!spy.wait(100)); | ||
389 | 385 | | |||
390 | // now let's prepare a config which has one effect explicitly enabled | 386 | // now let's prepare a config which has one effect explicitly enabled | ||
391 | plugins.writeEntry(kwin4 + QStringLiteral("scaleinEnabled"), true); | 387 | plugins.writeEntry(kwin4 + QStringLiteral("eyeonscreenEnabled"), true); | ||
392 | plugins.sync(); | 388 | plugins.sync(); | ||
393 | 389 | | |||
394 | loader.queryAndLoadAll(); | 390 | loader.queryAndLoadAll(); | ||
395 | // should load one effect in first go | 391 | // should load one effect in first go | ||
396 | QVERIFY(spy.wait(100)); | 392 | QVERIFY(spy.wait(100)); | ||
397 | // and afterwards it should not load another one | 393 | // and afterwards it should not load another one | ||
398 | QVERIFY(!spy.wait(10)); | 394 | QVERIFY(!spy.wait(10)); | ||
399 | 395 | | |||
400 | QCOMPARE(spy.size(), 1); | 396 | QCOMPARE(spy.size(), 1); | ||
401 | // if we caught a signal it should have the effect name we passed in | 397 | // if we caught a signal it should have the effect name we passed in | ||
402 | QList<QVariant> arguments = spy.takeFirst(); | 398 | QList<QVariant> arguments = spy.takeFirst(); | ||
403 | QCOMPARE(arguments.count(), 2); | 399 | QCOMPARE(arguments.count(), 2); | ||
404 | QCOMPARE(arguments.at(1).toString(), kwin4 + QStringLiteral("scalein")); | 400 | QCOMPARE(arguments.at(1).toString(), kwin4 + QStringLiteral("eyeonscreen")); | ||
405 | spy.clear(); | 401 | spy.clear(); | ||
406 | 402 | | |||
407 | // let's delete one of the default entries | 403 | // let's delete one of the default entries | ||
408 | plugins.deleteEntry(kwin4 + QStringLiteral("fadeEnabled")); | 404 | plugins.deleteEntry(kwin4 + QStringLiteral("fadeEnabled")); | ||
409 | plugins.sync(); | 405 | plugins.sync(); | ||
410 | 406 | | |||
411 | QVERIFY(spy.isEmpty()); | 407 | QVERIFY(spy.isEmpty()); | ||
412 | loader.queryAndLoadAll(); | 408 | loader.queryAndLoadAll(); | ||
413 | 409 | | |||
414 | // let's use qWait as we need to wait for two signals to be emitted | 410 | // let's use qWait as we need to wait for two signals to be emitted | ||
415 | QTRY_COMPARE(spy.size(), 2); | 411 | QTRY_COMPARE(spy.size(), 2); | ||
416 | QStringList loadedEffects; | 412 | QStringList loadedEffects; | ||
417 | for (auto &list : spy) { | 413 | for (auto &list : spy) { | ||
418 | QCOMPARE(list.size(), 2); | 414 | QCOMPARE(list.size(), 2); | ||
419 | loadedEffects << list.at(1).toString(); | 415 | loadedEffects << list.at(1).toString(); | ||
420 | } | 416 | } | ||
421 | qSort(loadedEffects); | 417 | qSort(loadedEffects); | ||
422 | QCOMPARE(loadedEffects.at(0), kwin4 + QStringLiteral("fade")); | 418 | QCOMPARE(loadedEffects.at(0), kwin4 + QStringLiteral("eyeonscreen")); | ||
423 | QCOMPARE(loadedEffects.at(1), kwin4 + QStringLiteral("scalein")); | 419 | QCOMPARE(loadedEffects.at(1), kwin4 + QStringLiteral("fade")); | ||
424 | } | 420 | } | ||
425 | 421 | | |||
426 | void TestScriptedEffectLoader::testCancelLoadAllEffects() | 422 | void TestScriptedEffectLoader::testCancelLoadAllEffects() | ||
427 | { | 423 | { | ||
428 | // this test verifies that no test gets loaded when the loader gets cleared | 424 | // this test verifies that no test gets loaded when the loader gets cleared | ||
429 | MockEffectsHandler mockHandler(KWin::XRenderCompositing); | 425 | MockEffectsHandler mockHandler(KWin::XRenderCompositing); | ||
430 | KWin::ScriptedEffectLoader loader; | 426 | KWin::ScriptedEffectLoader loader; | ||
431 | 427 | | |||
432 | // prepare the configuration to hard enable/disable the effects we want to load | 428 | // prepare the configuration to hard enable/disable the effects we want to load | ||
433 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | 429 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||
434 | const QString kwin4 = QStringLiteral("kwin4_effect_"); | 430 | const QString kwin4 = QStringLiteral("kwin4_effect_"); | ||
435 | KConfigGroup plugins = config->group("Plugins"); | 431 | KConfigGroup plugins = config->group("Plugins"); | ||
436 | plugins.writeEntry(kwin4 + QStringLiteral("scaleinEnabled"), true); | 432 | plugins.writeEntry(kwin4 + QStringLiteral("eyeonscreenEnabled"), true); | ||
437 | plugins.sync(); | 433 | plugins.sync(); | ||
438 | 434 | | |||
439 | loader.setConfig(config); | 435 | loader.setConfig(config); | ||
440 | 436 | | |||
441 | qRegisterMetaType<KWin::Effect*>(); | 437 | qRegisterMetaType<KWin::Effect*>(); | ||
442 | QSignalSpy spy(&loader, &KWin::ScriptedEffectLoader::effectLoaded); | 438 | QSignalSpy spy(&loader, &KWin::ScriptedEffectLoader::effectLoaded); | ||
443 | QVERIFY(spy.isValid()); | 439 | QVERIFY(spy.isValid()); | ||
444 | 440 | | |||
Show All 10 Lines |