Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/effects/scripted_effects_test.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 56 | private Q_SLOTS: | |||
---|---|---|---|---|---|
60 | 60 | | |||
61 | void testEffectsHandler(); | 61 | void testEffectsHandler(); | ||
62 | void testEffectsContext(); | 62 | void testEffectsContext(); | ||
63 | void testShortcuts(); | 63 | void testShortcuts(); | ||
64 | void testAnimations_data(); | 64 | void testAnimations_data(); | ||
65 | void testAnimations(); | 65 | void testAnimations(); | ||
66 | void testScreenEdge(); | 66 | void testScreenEdge(); | ||
67 | void testScreenEdgeTouch(); | 67 | void testScreenEdgeTouch(); | ||
68 | void testFullScreenEffect_data(); | ||||
69 | void testFullScreenEffect(); | ||||
68 | private: | 70 | private: | ||
69 | ScriptedEffect *loadEffect(const QString &name); | 71 | ScriptedEffect *loadEffect(const QString &name); | ||
70 | }; | 72 | }; | ||
71 | 73 | | |||
72 | class ScriptedEffectWithDebugSpy : public KWin::ScriptedEffect | 74 | class ScriptedEffectWithDebugSpy : public KWin::ScriptedEffect | ||
73 | { | 75 | { | ||
74 | Q_OBJECT | 76 | Q_OBJECT | ||
75 | public: | 77 | public: | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | |||||
157 | { | 159 | { | ||
158 | Test::destroyWaylandConnection(); | 160 | Test::destroyWaylandConnection(); | ||
159 | auto *e = static_cast<EffectsHandlerImpl*>(effects); | 161 | auto *e = static_cast<EffectsHandlerImpl*>(effects); | ||
160 | while (!e->loadedEffects().isEmpty()) { | 162 | while (!e->loadedEffects().isEmpty()) { | ||
161 | const QString effect = e->loadedEffects().first(); | 163 | const QString effect = e->loadedEffects().first(); | ||
162 | e->unloadEffect(effect); | 164 | e->unloadEffect(effect); | ||
163 | QVERIFY(!e->isEffectLoaded(effect)); | 165 | QVERIFY(!e->isEffectLoaded(effect)); | ||
164 | } | 166 | } | ||
167 | KWin::VirtualDesktopManager::self()->setCurrent(1); | ||||
165 | } | 168 | } | ||
166 | 169 | | |||
167 | void ScriptedEffectsTest::testEffectsHandler() | 170 | void ScriptedEffectsTest::testEffectsHandler() | ||
168 | { | 171 | { | ||
169 | // this triggers and tests some of the signals in EffectHandler, which is exposed to JS as context property "effects" | 172 | // this triggers and tests some of the signals in EffectHandler, which is exposed to JS as context property "effects" | ||
170 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | 173 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | ||
171 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | 174 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | ||
172 | auto waitFor = [&effectOutputSpy, this](const QString &expected) { | 175 | auto waitFor = [&effectOutputSpy](const QString &expected) { | ||
173 | QVERIFY(effectOutputSpy.count() == 1 || effectOutputSpy.wait()); | 176 | QVERIFY(effectOutputSpy.count() == 1 || effectOutputSpy.wait()); | ||
174 | QCOMPARE(effectOutputSpy.last().first(), expected); | 177 | QCOMPARE(effectOutputSpy.last().first(), expected); | ||
175 | effectOutputSpy.clear(); | 178 | effectOutputSpy.clear(); | ||
176 | }; | 179 | }; | ||
177 | QVERIFY(effect->load("effectsHandler")); | 180 | QVERIFY(effect->load("effectsHandler")); | ||
178 | 181 | | |||
179 | // trigger windowAdded signal | 182 | // trigger windowAdded signal | ||
180 | 183 | | |||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Line(s) | 335 | { | |||
333 | // this test checks registerTouchScreenEdge functions | 336 | // this test checks registerTouchScreenEdge functions | ||
334 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | 337 | auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | ||
335 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | 338 | QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); | ||
336 | QVERIFY(effect->load("screenEdgeTouchTest")); | 339 | QVERIFY(effect->load("screenEdgeTouchTest")); | ||
337 | effect->actions()[0]->trigger(); | 340 | effect->actions()[0]->trigger(); | ||
338 | QCOMPARE(effectOutputSpy.count(), 1); | 341 | QCOMPARE(effectOutputSpy.count(), 1); | ||
339 | } | 342 | } | ||
340 | 343 | | |||
344 | void ScriptedEffectsTest::testFullScreenEffect_data() | ||||
345 | { | ||||
346 | QTest::addColumn<QString>("file"); | ||||
347 | | ||||
348 | QTest::newRow("single") << "fullScreenEffectTest"; | ||||
349 | QTest::newRow("multi") << "fullScreenEffectTestMulti"; | ||||
350 | } | ||||
351 | | ||||
352 | void ScriptedEffectsTest::testFullScreenEffect() | ||||
353 | { | ||||
354 | QFETCH(QString, file); | ||||
355 | | ||||
356 | auto *effectMain = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean | ||||
zzag: please delte extra space | |||||
357 | QSignalSpy effectOutputSpy(effectMain, &ScriptedEffectWithDebugSpy::testOutput); | ||||
358 | QVERIFY(effectMain->load(file)); | ||||
359 | | ||||
360 | //load any random effect from another test to confirm fullscreen effect state is correctly | ||||
361 | //shown as being someone else | ||||
362 | auto effectOther = new ScriptedEffectWithDebugSpy(); | ||||
zzag: extra space | |||||
363 | QVERIFY(effectOther->load("screenEdgeTouchTest")); | ||||
364 | | ||||
365 | using namespace KWayland::Client; | ||||
366 | auto *surface = Test::createSurface(Test::waylandCompositor()); | ||||
367 | QVERIFY(surface); | ||||
368 | auto *shellSurface = Test::createXdgShellV6Surface(surface, surface); | ||||
369 | QVERIFY(shellSurface); | ||||
370 | shellSurface->setTitle("Window 1"); | ||||
371 | auto *c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); | ||||
372 | QVERIFY(c); | ||||
373 | QCOMPARE(workspace()->activeClient(), c); | ||||
374 | | ||||
375 | QCOMPARE(effectMain->fullScreenEffectState(), ScriptedEffect::InactiveFullScreenEffect); | ||||
376 | | ||||
377 | //trigger animation | ||||
378 | KWin::VirtualDesktopManager::self()->setCurrent(2); | ||||
379 | | ||||
380 | QCOMPARE(effectMain->fullScreenEffectState(), ScriptedEffect::OwnedFullScreenEffect); | ||||
381 | QCOMPARE(effects->activeFullScreenEffect(), effectMain); | ||||
382 | QCOMPARE(effectOther->fullScreenEffectState(), ScriptedEffect::ActiveFullScreenEffect); | ||||
383 | | ||||
384 | //after 500ms trigger another full screen animation | ||||
385 | QTest::qWait(500); | ||||
386 | KWin::VirtualDesktopManager::self()->setCurrent(1); | ||||
387 | QCOMPARE(effects->activeFullScreenEffect(), effectMain); | ||||
388 | | ||||
389 | //after 1000ms (+a safety margin for time based tests) we should still be the active full screen effect | ||||
390 | //despite first animation expiring | ||||
391 | QTest::qWait(500+100); | ||||
392 | QCOMPARE(effects->activeFullScreenEffect(), effectMain); | ||||
393 | | ||||
394 | //after 1500ms (+a safetey margin) we should have no full screen effect | ||||
zzag: extra space before `(` | |||||
395 | QTest::qWait(500+100); | ||||
396 | QCOMPARE(effects->activeFullScreenEffect(), nullptr); | ||||
397 | } | ||||
398 | | ||||
399 | | ||||
341 | WAYLANDTEST_MAIN(ScriptedEffectsTest) | 400 | WAYLANDTEST_MAIN(ScriptedEffectsTest) | ||
342 | #include "scripted_effects_test.moc" | 401 | #include "scripted_effects_test.moc" |
please delte extra space