Commit 84af9252 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[animation worklet] Update unit tests to not rely on worklet console log

This patch is similar to crrev.com/c/1289430. Previously the test was
relying on worklet console log which might be racy on main. Using
computed style is better and more compatible.

Bug: 887659
Change-Id: I7fd64fcfb4a135d13e02574602111299d672139f
Reviewed-on: https://chromium-review.googlesource.com/c/1301563Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603089}
parent 70e151d1
...@@ -5408,7 +5408,6 @@ crbug.com/886566 http/tests/csspaint/invalidation-border-image.html [ Pass Timeo ...@@ -5408,7 +5408,6 @@ crbug.com/886566 http/tests/csspaint/invalidation-border-image.html [ Pass Timeo
crbug.com/886566 http/tests/csspaint/invalidation-content-image.html [ Pass Timeout ] crbug.com/886566 http/tests/csspaint/invalidation-content-image.html [ Pass Timeout ]
# Enable AnimationWorklet tests for mainthread # Enable AnimationWorklet tests for mainthread
crbug.com/887659 animations/animationworklet/worklet-animation-currentTime.html [ Failure ]
crbug.com/887659 animations/animationworklet/worklet-animation-local-time-after-duration.html [ Failure ] crbug.com/887659 animations/animationworklet/worklet-animation-local-time-after-duration.html [ Failure ]
# Sheriff 2018-09-25 # Sheriff 2018-09-25
......
CONSOLE MESSAGE: line 6: first currentTime is 0
CONSOLE MESSAGE: line 9: second currentTime > first currentTime is true
<!DOCTYPE html> <!DOCTYPE html>
<title>Test that opacity changes when animation starts</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style> <style>
#target { #target {
width: 100px; width: 100px;
...@@ -10,37 +14,27 @@ ...@@ -10,37 +14,27 @@
<script id="simple_animate" type="text/worklet"> <script id="simple_animate" type="text/worklet">
registerAnimator("test_animator", class { registerAnimator("test_animator", class {
animate(currentTime, effect) { animate(currentTime, effect) {
if (this.firstCurrentTime == undefined) { effect.localTime = currentTime;
this.firstCurrentTime = currentTime;
console.log(`first currentTime is ${this.firstCurrentTime}`);
} else if (this.secondCurrentTime == undefined) {
this.secondCurrentTime = currentTime;
console.log(`second currentTime > first currentTime is ${this.secondCurrentTime > this.firstCurrentTime}`)
}
} }
}); });
</script> </script>
<div id="target"></div> <div id="target"></div>
<script src="resources/animation-worklet-tests.js"></script> <script src="resources/animation-worklet-tests.js"></script>
<script> <script>
if (window.testRunner) { async_test(t => {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
runInAnimationWorklet( runInAnimationWorklet(
document.getElementById('simple_animate').textContent document.getElementById('simple_animate').textContent
).then(_ => { ).then(_ => {
const effect = new KeyframeEffect(document.getElementById("target"), [{ opacity: 0 }], { duration: 1000 }); const effect = new KeyframeEffect(target, [{ opacity: 0 }], { duration: 1000 });
const animation = new WorkletAnimation('test_animator', effect); const animation = new WorkletAnimation('test_animator', effect);
const first_opacity = getComputedStyle(target).opacity;
assert_equals(first_opacity, '1');
animation.play(); animation.play();
if (window.testRunner) { waitTwoAnimationFrames(t.step_func_done(() => {
waitTwoAnimationFrames( _ => { const second_opacity = getComputedStyle(target).opacity;
waitTwoAnimationFrames( _ => { assert_true(second_opacity < first_opacity);
testRunner.notifyDone(); }));
});
});
}
}); });
}, 'Opacity should change as the animation starts.');
</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