Commit 8a92d917 authored by Yue Li's avatar Yue Li Committed by Commit Bot

Fix setPlay logic for lottie

SetPlay does not work if the animation is not loaded. Update it to set
the autoplay attribite if the animation is not loaded yet.

Bug: None
Test: Manual Test
Change-Id: I8132d11b5fd9ae77002f79cab7f0e12ef4e91c91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879855Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Yue Li <updowndota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709996}
parent 055a5ec1
...@@ -129,6 +129,24 @@ cr.define('cr_lottie_test', function() { ...@@ -129,6 +129,24 @@ cr.define('cr_lottie_test', function() {
await waitForPlayingEventAgain; await waitForPlayingEventAgain;
}); });
test('TestPlayBeforeInit', async () => {
assertTrue(crLottieElement.autoplay);
crLottieElement.setPlay(false);
assertFalse(crLottieElement.autoplay);
crLottieElement.setPlay(true);
assertTrue(crLottieElement.autoplay);
const waitForInitializeEvent =
test_util.eventToPromise('cr-lottie-initialized', crLottieElement);
await waitForInitializeEvent;
const waitForPlayingEvent =
test_util.eventToPromise('cr-lottie-playing', crLottieElement);
await waitForPlayingEvent;
});
test('TestRenderFrame', async () => { test('TestRenderFrame', async () => {
// Offscreen canvas has a race issue when used in this test framework. To // Offscreen canvas has a race issue when used in this test framework. To
// ensure that we capture a frame from the animation and not an empty frame, // ensure that we capture a frame from the animation and not an empty frame,
......
...@@ -80,6 +80,8 @@ Polymer({ ...@@ -80,6 +80,8 @@ Polymer({
setPlay: function(shouldPlay) { setPlay: function(shouldPlay) {
if (this.isAnimationLoaded_) { if (this.isAnimationLoaded_) {
this.worker_.postMessage({control: {play: shouldPlay}}); this.worker_.postMessage({control: {play: shouldPlay}});
} else {
this.autoplay = shouldPlay;
} }
}, },
......
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