Commit c8711793 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[Animation Worklet] Clean up animator registration logic for wpt test...

[Animation Worklet] Clean up animator registration logic for wpt test worklet-animation-with-fill-mode.https.html

Similar to [1], we should register the animator only once in the setup.

[1] https://cs.chromium.org/chromium/src/third_party/blink/web_tests/external/wpt/animation-worklet/scroll-timeline-writing-modes.https.html

Bug: 923881
Change-Id: I0f6761b7753aacdf3ebe6d8ed63fe4e0ea183e25
Reviewed-on: https://chromium-review.googlesource.com/c/1448519Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628460}
parent f2e58c31
...@@ -14,83 +14,146 @@ ...@@ -14,83 +14,146 @@
} }
</style> </style>
<div id="target" class='target'></div>
<script> <script>
function CreateTest(target, effect, verify, test_name) { setup(setupAndRegisterTests, {explicit_done: true});
promise_test(async function() {
await registerConstantLocalTimeAnimator(2000); function setupAndRegisterTests() {
const animation = new WorkletAnimation('constant_time', effect); registerConstantLocalTimeAnimator(2000).then(() => {
animation.play(); promise_test(
effect_with_fill_mode_forwards,
await waitForAsyncAnimationFrames(1); "Effect with fill mode forwards in after phase produces output that is equivalent to effect's end value.");
// waitTwoAnimationFrames guarantees a compositor frame that could update
// the opacity value in the worklet. Meanwhile, getComputedStyle needs an promise_test(
// extra frame to fetch the updated value. effect_without_fill_mode_forwards,
await waitForNextFrame(); 'Effect without fill mode forwards in after phase (local time beyond end) should deactivate the animation.');
verify();
animation.cancel(); promise_test(
}, test_name); effect_without_fill_forwards_at_end,
'Effect without fill mode in after phase (local time at end) should deactivate the animation.');
promise_test(
effect_with_fill_backwards,
"Effect with fill mode backwards in before phase produces output that is equivalent to effect's start value.");
promise_test(
effect_without_fill_backwards,
'Effect without fill mode backwards in before phase (local time before start) should deactivate the animation.');
promise_test(
effect_without_fill_backwards_at_start,
'Effect with local time at start point is in active phase.');
done();
});
} }
</script>
<div id="target1" class='target'></div> async function effect_with_fill_mode_forwards(t) {
<div id="target2" class='target'></div> const effect_with_fill_forwards = new KeyframeEffect(
<div id="target3" class='target'></div> target,
<div id="target4" class='target'></div> { opacity: [0.5, 0] },
<div id="target5" class='target'></div> { duration: 1000, fill: 'forwards' });
<div id="target6" class='target'></div> const animation = new WorkletAnimation(
'constant_time',
effect_with_fill_forwards);
animation.play();
<script> await waitForAsyncAnimationFrames(1);
const effect_with_fill_forwards = new KeyframeEffect( await waitForNextFrame();
target1,
{ opacity: [0.5, 0] }, assert_equals(getComputedStyle(target).opacity, '0');
{ duration: 1000, fill: 'forwards' });
CreateTest(target1, animation.cancel();
effect_with_fill_forwards, }
function() { assert_equals(getComputedStyle(target1).opacity, '0'); },
"Effect with fill mode forwards in after phase produces output that is equivalent to effect's end value."); async function effect_without_fill_mode_forwards(t) {
const effect_without_fill_forwards = new KeyframeEffect(
const effect_without_fill_forwards = new KeyframeEffect( target,
target2, { opacity: [0.5, 0] },
{ opacity: [0.5, 0] }, { duration: 1000 });
{ duration: 1000 }); const animation = new WorkletAnimation(
CreateTest(target2, 'constant_time',
effect_without_fill_forwards, effect_without_fill_forwards);
function() { assert_equals(getComputedStyle(target2).opacity, '1'); }, animation.play();
'Effect without fill mode forwards in after phase (local time beyond end) should deactivate the animation.');
await waitForAsyncAnimationFrames(1);
const effect_without_fill_forwards_at_end = new KeyframeEffect( await waitForNextFrame();
target3,
{ opacity: [0.5, 0] }, assert_equals(getComputedStyle(target).opacity, '1');
{ duration: 2000 });
CreateTest(target3, animation.cancel();
effect_without_fill_forwards_at_end, }
function() { assert_equals(getComputedStyle(target3).opacity, '1'); },
'Effect without fill mode in after phase (local time at end) should deactivate the animation.'); async function effect_without_fill_forwards_at_end(t) {
const effect_without_fill_forwards_at_end = new KeyframeEffect(
const effect_with_fill_backwards = new KeyframeEffect( target,
target4, { opacity: [0.5, 0] },
{ opacity: [0.5, 0] }, { duration: 2000 });
{ duration: 1000, delay: 2001, fill: 'backwards' }); const animation = new WorkletAnimation(
CreateTest(target4, 'constant_time',
effect_with_fill_backwards, effect_without_fill_forwards_at_end);
function() { assert_equals(getComputedStyle(target4).opacity, '0.5'); }, animation.play();
"Effect with fill mode backwards in before phase produces output that is equivalent to effect's start value.");
await waitForAsyncAnimationFrames(1);
const effect_without_fill_backwards = new KeyframeEffect( await waitForNextFrame();
target5,
{ opacity: [0.5, 0] }, assert_equals(getComputedStyle(target).opacity, '1');
{ duration: 1000, delay: 2001 });
CreateTest(target5, animation.cancel();
effect_without_fill_backwards, }
function() { assert_equals(getComputedStyle(target5).opacity, '1'); },
'Effect without fill mode backwards in before phase (local time before start) should deactivate the animation.'); async function effect_with_fill_backwards(t) {
const effect_with_fill_backwards = new KeyframeEffect(
const effect_without_fill_backwards_at_start = new KeyframeEffect( target,
target6, { opacity: [0.5, 0] },
{ opacity: [0.5, 0] }, { duration: 1000, delay: 2001, fill: 'backwards' });
{ duration: 1000, delay: 2000 }); const animation = new WorkletAnimation(
CreateTest(target6, 'constant_time',
effect_without_fill_backwards_at_start, effect_with_fill_backwards);
function() { assert_equals(getComputedStyle(target6).opacity, '0.5'); }, animation.play();
'Effect with local time at start point is in active phase.');
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '0.5');
animation.cancel();
}
async function effect_without_fill_backwards(t) {
const effect_without_fill_backwards = new KeyframeEffect(
target,
{ opacity: [0.5, 0] },
{ duration: 1000, delay: 2001 });
const animation = new WorkletAnimation(
'constant_time',
effect_without_fill_backwards);
animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '1');
animation.cancel();
}
async function effect_without_fill_backwards_at_start(t) {
const effect_without_fill_backwards_at_start = new KeyframeEffect(
target,
{ opacity: [0.5, 0] },
{ duration: 1000, delay: 2000 });
const animation = new WorkletAnimation(
'constant_time',
effect_without_fill_backwards_at_start);
animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '0.5');
animation.cancel();
}
</script> </script>
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