Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/effects/scripted_effects_test.cpp
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 57 | private Q_SLOTS: | |||
---|---|---|---|---|---|
61 | 61 | | |||
62 | void testEffectsHandler(); | 62 | void testEffectsHandler(); | ||
63 | void testEffectsContext(); | 63 | void testEffectsContext(); | ||
64 | void testShortcuts(); | 64 | void testShortcuts(); | ||
65 | void testAnimations_data(); | 65 | void testAnimations_data(); | ||
66 | void testAnimations(); | 66 | void testAnimations(); | ||
67 | void testScreenEdge(); | 67 | void testScreenEdge(); | ||
68 | void testScreenEdgeTouch(); | 68 | void testScreenEdgeTouch(); | ||
69 | void testFullScreenEffect_data(); | ||||
70 | void testFullScreenEffect(); | ||||
69 | private: | 71 | private: | ||
70 | ScriptedEffect *loadEffect(const QString &name); | 72 | ScriptedEffect *loadEffect(const QString &name); | ||
71 | }; | 73 | }; | ||
72 | 74 | | |||
73 | class ScriptedEffectWithDebugSpy : public KWin::ScriptedEffect | 75 | class ScriptedEffectWithDebugSpy : public KWin::ScriptedEffect | ||
74 | { | 76 | { | ||
75 | Q_OBJECT | 77 | Q_OBJECT | ||
76 | public: | 78 | public: | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
167 | { | 169 | { | ||
168 | Test::destroyWaylandConnection(); | 170 | Test::destroyWaylandConnection(); | ||
169 | auto *e = static_cast<EffectsHandlerImpl*>(effects); | 171 | auto *e = static_cast<EffectsHandlerImpl*>(effects); | ||
170 | while (!e->loadedEffects().isEmpty()) { | 172 | while (!e->loadedEffects().isEmpty()) { | ||
171 | const QString effect = e->loadedEffects().first(); | 173 | const QString effect = e->loadedEffects().first(); | ||
172 | e->unloadEffect(effect); | 174 | e->unloadEffect(effect); | ||
173 | QVERIFY(!e->isEffectLoaded(effect)); | 175 | QVERIFY(!e->isEffectLoaded(effect)); | ||
174 | } | 176 | } | ||
177 | KWin::VirtualDesktopManager::self()->setCurrent(1); | ||||
175 | } | 178 | } | ||
176 | 179 | | |||
177 | void ScriptedEffectsTest::testEffectsHandler() | 180 | void ScriptedEffectsTest::testEffectsHandler() | ||
178 | { | 181 | { | ||
179 | // this triggers and tests some of the signals in EffectHandler, which is exposed to JS as context property "effects" | 182 | // this triggers and tests some of the signals in EffectHandler, which is exposed to JS as context property "effects" | ||
180 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | 183 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | ||
181 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | 184 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | ||
182 | auto waitFor = [&effectOutputSpy, this](const QString &expected) { | 185 | auto waitFor = [&effectOutputSpy, this](const QString &expected) { | ||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 347 | { | |||
346 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | 349 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | ||
347 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | 350 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | ||
348 | QVERIFY(effect->load("screenEdgeTouchTest")); | 351 | QVERIFY(effect->load("screenEdgeTouchTest")); | ||
349 | auto actions = effect->findChildren<QAction*>(QString(), Qt::FindDirectChildrenOnly); | 352 | auto actions = effect->findChildren<QAction*>(QString(), Qt::FindDirectChildrenOnly); | ||
350 | actions[0]->trigger(); | 353 | actions[0]->trigger(); | ||
351 | QCOMPARE(effectOutputSpy.count(), 1); | 354 | QCOMPARE(effectOutputSpy.count(), 1); | ||
352 | } | 355 | } | ||
353 | 356 | | |||
357 | void ScriptedEffectsTest::testFullScreenEffect_data() | ||||
358 | { | ||||
359 | QTest::addColumn<QString>("file"); | ||||
360 | | ||||
361 | QTest::newRow("single") << "fullScreenEffectTest"; | ||||
362 | QTest::newRow("multi") << "fullScreenEffectTestMulti"; | ||||
363 | } | ||||
364 | | ||||
365 | void ScriptedEffectsTest::testFullScreenEffect() | ||||
366 | { | ||||
367 | QFETCH(QString, file); | ||||
368 | | ||||
369 | auto *effectMain = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | ||||
zzag: please delte extra space | |||||
370 | QSignalSpy effectOutputSpy(effectMain, &ScriptedEffectWithDebugSpy::testOutput); | ||||
371 | QSignalSpy fullScreenEffectActiveSpy(effects, &EffectsHandler::hasActiveFullScreenEffectChanged); | ||||
372 | QSignalSpy isActiveFullScreenEffectSpy(effectMain, &ScriptedEffect::isActiveFullScreenEffectChanged); | ||||
373 | | ||||
374 | QVERIFY(effectMain->load(file)); | ||||
375 | | ||||
zzag: extra space | |||||
376 | //load any random effect from another test to confirm fullscreen effect state is correctly | ||||
377 | //shown as being someone else | ||||
378 | auto effectOther = new ScriptedEffectWithDebugSpy(); | ||||
379 | QVERIFY(effectOther->load("screenEdgeTouchTest")); | ||||
380 | QSignalSpy isActiveFullScreenEffectSpyOther(effectOther, &ScriptedEffect::isActiveFullScreenEffectChanged); | ||||
381 | | ||||
382 | using namespace KWayland::Client; | ||||
383 | auto *surface = Test::createSurface(Test::waylandCompositor()); | ||||
384 | QVERIFY(surface); | ||||
385 | auto *shellSurface = Test::createXdgShellV6Surface(surface, surface); | ||||
386 | QVERIFY(shellSurface); | ||||
387 | shellSurface->setTitle("Window 1"); | ||||
388 | auto *c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); | ||||
389 | QVERIFY(c); | ||||
390 | QCOMPARE(workspace()->activeClient(), c); | ||||
391 | | ||||
392 | QCOMPARE(effects->hasActiveFullScreenEffect(), false); | ||||
393 | QCOMPARE(effectMain->isActiveFullScreenEffect(), false); | ||||
394 | | ||||
395 | //trigger animation | ||||
396 | KWin::VirtualDesktopManager::self()->setCurrent(2); | ||||
397 | | ||||
398 | QCOMPARE(effects->activeFullScreenEffect(), effectMain); | ||||
399 | QCOMPARE(effects->hasActiveFullScreenEffect(), true); | ||||
400 | QCOMPARE(fullScreenEffectActiveSpy.count(), 1); | ||||
401 | | ||||
402 | QCOMPARE(effectMain->isActiveFullScreenEffect(), true); | ||||
403 | QCOMPARE(isActiveFullScreenEffectSpy.count(), 1); | ||||
404 | | ||||
405 | QCOMPARE(effectOther->isActiveFullScreenEffect(), false); | ||||
406 | QCOMPARE(isActiveFullScreenEffectSpyOther.count(), 0); | ||||
407 | | ||||
zzag: extra space before `(` | |||||
408 | //after 500ms trigger another full screen animation | ||||
409 | QTest::qWait(500); | ||||
410 | KWin::VirtualDesktopManager::self()->setCurrent(1); | ||||
411 | QCOMPARE(effects->activeFullScreenEffect(), effectMain); | ||||
412 | | ||||
413 | //after 1000ms (+a safety margin for time based tests) we should still be the active full screen effect | ||||
414 | //despite first animation expiring | ||||
415 | QTest::qWait(500+100); | ||||
416 | QCOMPARE(effects->activeFullScreenEffect(), effectMain); | ||||
417 | | ||||
418 | //after 1500ms (+a safetey margin) we should have no full screen effect | ||||
419 | QTest::qWait(500+100); | ||||
420 | QCOMPARE(effects->activeFullScreenEffect(), nullptr); | ||||
421 | } | ||||
422 | | ||||
423 | | ||||
354 | WAYLANDTEST_MAIN(ScriptedEffectsTest) | 424 | WAYLANDTEST_MAIN(ScriptedEffectsTest) | ||
355 | #include "scripted_effects_test.moc" | 425 | #include "scripted_effects_test.moc" |
please delte extra space