Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: third_party/WebKit/Source/core/animation/CompositorAnimationsSimTest.cpp

Issue 1727443002: Blink CompositorAnimations: Add more tests for integration with CC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebasing. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/animation/CompositorAnimationsSimTest.cpp
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsSimTest.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimationsSimTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dc89538b0d60487b46bebc5a2c372b1e3f14b18d
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsSimTest.cpp
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+
+#include "core/animation/AnimationTimeline.h"
+#include "core/animation/ElementAnimations.h"
+#include "web/tests/sim/SimCompositor.h"
+#include "web/tests/sim/SimDisplayItemList.h"
+#include "web/tests/sim/SimRequest.h"
+#include "web/tests/sim/SimTest.h"
+
+namespace blink {
+
+class CompositorAnimationsSimTest : public SimTest {
+public:
+};
+
+TEST_F(CompositorAnimationsSimTest, CancelCompositorAnimationIfAnimationDisposed)
+{
+ const String html = "<html><body>"
+ "<div id=element></div>"
+ "<script>"
+ "element.animate([{opacity: 0}, {opacity: 1}], {duration: 1});"
+ "requestAnimationFrame(() => {"
+ " requestAnimationFrame(() => {"
+ " element.animate([{opacity: 1}, {opacity: 0}], {duration: 1});"
+ " });"
+ "});"
+ "</script>"
+ "</body></html>";
+ SimRequest request("https://example.com/", "text/html");
+
+ loadURL("https://example.com/");
+ request.complete(html);
+
+ // 1st animation frame.
+ compositor().beginFrame();
+
+ Element* element = toHTMLElement(document().getElementById("element"));
+ EXPECT_TRUE(element);
+ EXPECT_TRUE(element->hasAnimations());
+
+ ElementAnimations* animations = element->elementAnimations();
+ EXPECT_EQ(1u, animations->animations().size());
+
+ for (const auto& entry : animations->animations()) {
+ Animation* animation = entry.key;
+ EXPECT_TRUE(animation->hasActiveAnimationsOnCompositor());
+ }
+
+ // Destroy compositor animation players.
+ document().timeline().dispose();
+
+ // 2nd animation frame.
+ // Cancel incompatible compositor animations. This shouldn't crash.
+ compositor().beginFrame();
+
+ EXPECT_EQ(2u, animations->animations().size());
+ for (const auto& entry : animations->animations()) {
+ Animation* animation = entry.key;
+ EXPECT_FALSE(animation->hasActiveAnimationsOnCompositor());
+ }
+}
+
+} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698