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

Unified Diff: third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositorTest.cpp

Issue 2795263002: Add a new document lifecycle; CompositingInputsClean (Closed)
Patch Set: Rebase Created 3 years, 8 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 | « third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositorTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositorTest.cpp b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositorTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b9c7489be135251925fdc5b72b32a3796a0b7979
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositorTest.cpp
@@ -0,0 +1,85 @@
+// Copyright 2017 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/layout/compositing/PaintLayerCompositor.h"
+
+#include "core/animation/Animation.h"
+#include "core/animation/ElementAnimation.h"
+#include "core/layout/LayoutTestHelper.h"
+#include "core/paint/PaintLayer.h"
+
+namespace blink {
+
+namespace {
+class PaintLayerCompositorTest : public RenderingTest {
+ public:
+ PaintLayerCompositorTest()
+ : RenderingTest(SingleChildLocalFrameClient::Create()) {}
+
+ private:
+ void SetUp() {
+ RenderingTest::SetUp();
+ EnableCompositing();
+ }
+};
+}
+
+TEST_F(PaintLayerCompositorTest, AdvancingToCompositingInputsClean) {
+ SetBodyInnerHTML("<div id='box' style='position: relative'></div>");
+
+ PaintLayer* box_layer =
+ ToLayoutBox(GetLayoutObjectByElementId("box"))->Layer();
+ ASSERT_TRUE(box_layer);
+ EXPECT_FALSE(box_layer->NeedsCompositingInputsUpdate());
+
+ box_layer->SetNeedsCompositingInputsUpdate();
+
+ GetDocument().View()->UpdateLifecycleToCompositingInputsClean();
+ EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
+ GetDocument().Lifecycle().GetState());
+ EXPECT_FALSE(box_layer->NeedsCompositingInputsUpdate());
+}
+
+TEST_F(PaintLayerCompositorTest,
+ CompositingInputsCleanDoesNotTriggerAnimations) {
+ SetBodyInnerHTML(
+ "<style>@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }"
+ ".animate { animation: fadeOut 2s; }</style>"
+ "<div id='box'></div>"
+ "<div id='otherBox'></div>");
+
+ Element* box = GetDocument().GetElementById("box");
+ Element* otherBox = GetDocument().GetElementById("otherBox");
+ ASSERT_TRUE(box);
+ ASSERT_TRUE(otherBox);
+
+ box->setAttribute("class", "animate", ASSERT_NO_EXCEPTION);
+
+ // Update the lifecycle to CompositingInputsClean. This should not start the
+ // animation lifecycle.
+ GetDocument().View()->UpdateLifecycleToCompositingInputsClean();
+ EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
+ GetDocument().Lifecycle().GetState());
+
+ otherBox->setAttribute("class", "animate", ASSERT_NO_EXCEPTION);
+
+ // Now run the rest of the lifecycle. Because both 'box' and 'otherBox' were
+ // given animations separated only by a lifecycle update to
+ // CompositingInputsClean, they should both be started in the same lifecycle
+ // and as such grouped together.
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ EXPECT_EQ(DocumentLifecycle::kPaintClean,
+ GetDocument().Lifecycle().GetState());
+
+ HeapVector<Member<Animation>> boxAnimations =
+ ElementAnimation::getAnimations(*box);
+ HeapVector<Member<Animation>> otherBoxAnimations =
+ ElementAnimation::getAnimations(*box);
+
+ EXPECT_EQ(1ul, boxAnimations.size());
+ EXPECT_EQ(1ul, otherBoxAnimations.size());
+ EXPECT_EQ(boxAnimations.front()->CompositorGroup(),
+ otherBoxAnimations.front()->CompositorGroup());
+}
+}
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698