Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/effects/scripted_effects_test.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | #include <KWayland/Client/compositor.h> | 44 | #include <KWayland/Client/compositor.h> | ||
45 | #include <KWayland/Client/connection_thread.h> | 45 | #include <KWayland/Client/connection_thread.h> | ||
46 | #include <KWayland/Client/registry.h> | 46 | #include <KWayland/Client/registry.h> | ||
47 | #include <KWayland/Client/slide.h> | 47 | #include <KWayland/Client/slide.h> | ||
48 | #include <KWayland/Client/surface.h> | 48 | #include <KWayland/Client/surface.h> | ||
49 | #include <KWayland/Client/xdgshell.h> | 49 | #include <KWayland/Client/xdgshell.h> | ||
50 | 50 | | |||
51 | using namespace KWin; | 51 | using namespace KWin; | ||
52 | using namespace std::chrono_literals; | ||||
53 | | ||||
52 | static const QString s_socketName = QStringLiteral("wayland_test_effects_scripts-0"); | 54 | static const QString s_socketName = QStringLiteral("wayland_test_effects_scripts-0"); | ||
53 | 55 | | |||
54 | class ScriptedEffectsTest : public QObject | 56 | class ScriptedEffectsTest : public QObject | ||
55 | { | 57 | { | ||
56 | Q_OBJECT | 58 | Q_OBJECT | ||
57 | private Q_SLOTS: | 59 | private Q_SLOTS: | ||
58 | void initTestCase(); | 60 | void initTestCase(); | ||
59 | void init(); | 61 | void init(); | ||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Line(s) | 271 | { | |||
284 | QVERIFY(surface); | 286 | QVERIFY(surface); | ||
285 | auto *shellSurface = Test::createXdgShellV6Surface(surface, surface); | 287 | auto *shellSurface = Test::createXdgShellV6Surface(surface, surface); | ||
286 | QVERIFY(shellSurface); | 288 | QVERIFY(shellSurface); | ||
287 | shellSurface->setTitle("Window 1"); | 289 | shellSurface->setTitle("Window 1"); | ||
288 | auto *c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); | 290 | auto *c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); | ||
289 | QVERIFY(c); | 291 | QVERIFY(c); | ||
290 | QCOMPARE(workspace()->activeClient(), c); | 292 | QCOMPARE(workspace()->activeClient(), c); | ||
291 | 293 | | |||
292 | // we are running the event loop during renderAndWaitForShown | | |||
293 | // some time will pass with the event loop running between the window being added and getting to here | | |||
294 | // anim.duration is an aboslute value, but retarget will update the duration based on time passed | | |||
295 | int timePassed = 0; | | |||
296 | | ||||
297 | { | 294 | { | ||
298 | const AnimationEffect::AniMap state = effect->state(); | 295 | const AnimationEffect::AniMap state = effect->state(); | ||
299 | QCOMPARE(state.count(), 1); | 296 | QCOMPARE(state.count(), 1); | ||
300 | QCOMPARE(state.firstKey(), c->effectWindow()); | 297 | QCOMPARE(state.firstKey(), c->effectWindow()); | ||
301 | const auto &animationsForWindow = state.first().first; | 298 | const auto &animationsForWindow = state.first().first; | ||
302 | QCOMPARE(animationsForWindow.count(), animationCount); | 299 | QCOMPARE(animationsForWindow.count(), animationCount); | ||
303 | QCOMPARE(animationsForWindow[0].duration, 100); | 300 | QCOMPARE(animationsForWindow[0].timeLine.duration(), 100ms); | ||
304 | QCOMPARE(animationsForWindow[0].to, FPx2(1.4)); | 301 | QCOMPARE(animationsForWindow[0].to, FPx2(1.4)); | ||
305 | QCOMPARE(animationsForWindow[0].attribute, AnimationEffect::Scale); | 302 | QCOMPARE(animationsForWindow[0].attribute, AnimationEffect::Scale); | ||
306 | QCOMPARE(animationsForWindow[0].curve.type(), QEasingCurve::OutQuad); | 303 | QCOMPARE(animationsForWindow[0].timeLine.easingCurve().type(), QEasingCurve::OutQuad); | ||
307 | QCOMPARE(animationsForWindow[0].keepAtTarget, false); | 304 | QCOMPARE(animationsForWindow[0].keepAtTarget, false); | ||
308 | timePassed = animationsForWindow[0].time; | 305 | | ||
309 | if (animationCount == 2) { | 306 | if (animationCount == 2) { | ||
310 | QCOMPARE(animationsForWindow[1].duration, 100); | 307 | QCOMPARE(animationsForWindow[1].timeLine.duration(), 100ms); | ||
311 | QCOMPARE(animationsForWindow[1].to, FPx2(0.0)); | 308 | QCOMPARE(animationsForWindow[1].to, FPx2(0.0)); | ||
312 | QCOMPARE(animationsForWindow[1].attribute, AnimationEffect::Opacity); | 309 | QCOMPARE(animationsForWindow[1].attribute, AnimationEffect::Opacity); | ||
313 | QCOMPARE(animationsForWindow[1].keepAtTarget, false); | 310 | QCOMPARE(animationsForWindow[1].keepAtTarget, false); | ||
314 | } | 311 | } | ||
315 | } | 312 | } | ||
316 | QCOMPARE(effectOutputSpy[0].first(), "true"); | 313 | QCOMPARE(effectOutputSpy[0].first(), "true"); | ||
317 | 314 | | |||
318 | // window state changes, scale should be retargetted | 315 | // window state changes, scale should be retargetted | ||
319 | 316 | | |||
320 | c->setMinimized(true); | 317 | c->setMinimized(true); | ||
321 | { | 318 | { | ||
322 | const AnimationEffect::AniMap state = effect->state(); | 319 | const AnimationEffect::AniMap state = effect->state(); | ||
323 | QCOMPARE(state.count(), 1); | 320 | QCOMPARE(state.count(), 1); | ||
324 | const auto &animationsForWindow = state.first().first; | 321 | const auto &animationsForWindow = state.first().first; | ||
325 | QCOMPARE(animationsForWindow.count(), animationCount); | 322 | QCOMPARE(animationsForWindow.count(), animationCount); | ||
326 | QCOMPARE(animationsForWindow[0].duration, 200 + timePassed); | 323 | QCOMPARE(animationsForWindow[0].timeLine.duration(), 200ms); | ||
327 | QCOMPARE(animationsForWindow[0].to, FPx2(1.5)); | 324 | QCOMPARE(animationsForWindow[0].to, FPx2(1.5)); | ||
328 | QCOMPARE(animationsForWindow[0].attribute, AnimationEffect::Scale); | 325 | QCOMPARE(animationsForWindow[0].attribute, AnimationEffect::Scale); | ||
329 | QCOMPARE(animationsForWindow[0].keepAtTarget, false); | 326 | QCOMPARE(animationsForWindow[0].keepAtTarget, false); | ||
330 | if (animationCount == 2) { | 327 | if (animationCount == 2) { | ||
331 | QCOMPARE(animationsForWindow[1].duration, 200 + timePassed); | 328 | QCOMPARE(animationsForWindow[1].timeLine.duration(), 200ms); | ||
332 | QCOMPARE(animationsForWindow[1].to, FPx2(1.5)); | 329 | QCOMPARE(animationsForWindow[1].to, FPx2(1.5)); | ||
333 | QCOMPARE(animationsForWindow[1].attribute, AnimationEffect::Opacity); | 330 | QCOMPARE(animationsForWindow[1].attribute, AnimationEffect::Opacity); | ||
334 | QCOMPARE(animationsForWindow[1].keepAtTarget, false); | 331 | QCOMPARE(animationsForWindow[1].keepAtTarget, false); | ||
335 | } | 332 | } | ||
336 | } | 333 | } | ||
337 | c->setMinimized(false); | 334 | c->setMinimized(false); | ||
338 | { | 335 | { | ||
339 | const AnimationEffect::AniMap state = effect->state(); | 336 | const AnimationEffect::AniMap state = effect->state(); | ||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |