Chromium Code Reviews| 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..54a6ffb2e2d6de7e07532e063fda8a4bad24450d |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositorTest.cpp |
| @@ -0,0 +1,68 @@ |
| +// 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" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| +class PaintLayerCompositorTest : public RenderingTest { |
| + public: |
| + PaintLayerCompositorTest() |
| + : RenderingTest(SingleChildLocalFrameClient::Create()) {} |
| + |
| + private: |
| + void SetUp() { |
| + RenderingTest::SetUp(); |
| + EnableCompositing(); |
| + } |
| +}; |
| +} |
| + |
| +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(); |
| + ASSERT_EQ(DocumentLifecycle::kCompositingInputsClean, |
| + GetDocument().Lifecycle().GetState()); |
|
flackr
2017/04/11 20:46:28
Also check that the compositing inputs are clean o
smcgruer
2017/04/12 15:33:04
Done.
|
| + |
| + 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(); |
| + ASSERT_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()); |
| +} |
| +} |