OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/layout/compositing/PaintLayerCompositor.h" | |
6 | |
7 #include "core/animation/Animation.h" | |
8 #include "core/animation/ElementAnimation.h" | |
9 #include "core/layout/LayoutTestHelper.h" | |
10 | |
11 namespace blink { | |
12 | |
13 namespace { | |
14 class PaintLayerCompositorTest : public RenderingTest { | |
15 public: | |
16 PaintLayerCompositorTest() | |
17 : RenderingTest(SingleChildLocalFrameClient::Create()) {} | |
18 | |
19 private: | |
20 void SetUp() { | |
21 RenderingTest::SetUp(); | |
22 EnableCompositing(); | |
23 } | |
24 }; | |
25 } | |
26 | |
27 TEST_F(PaintLayerCompositorTest, | |
28 CompositingInputsCleanDoesNotTriggerAnimations) { | |
29 SetBodyInnerHTML( | |
30 "<style>@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }" | |
31 ".animate { animation: fadeOut 2s; }</style>" | |
32 "<div id='box'></div>" | |
33 "<div id='otherBox'></div>"); | |
34 | |
35 Element* box = GetDocument().GetElementById("box"); | |
36 Element* otherBox = GetDocument().GetElementById("otherBox"); | |
37 ASSERT_TRUE(box); | |
38 ASSERT_TRUE(otherBox); | |
39 | |
40 box->setAttribute("class", "animate", ASSERT_NO_EXCEPTION); | |
41 | |
42 // Update the lifecycle to CompositingInputsClean. This should not start the | |
43 // animation lifecycle. | |
44 GetDocument().View()->UpdateLifecycleToCompositingInputsClean(); | |
45 ASSERT_EQ(DocumentLifecycle::kCompositingInputsClean, | |
46 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.
| |
47 | |
48 otherBox->setAttribute("class", "animate", ASSERT_NO_EXCEPTION); | |
49 | |
50 // Now run the rest of the lifecycle. Because both 'box' and 'otherBox' were | |
51 // given animations separated only by a lifecycle update to | |
52 // CompositingInputsClean, they should both be started in the same lifecycle | |
53 // and as such grouped together. | |
54 GetDocument().View()->UpdateAllLifecyclePhases(); | |
55 ASSERT_EQ(DocumentLifecycle::kPaintClean, | |
56 GetDocument().Lifecycle().GetState()); | |
57 | |
58 HeapVector<Member<Animation>> boxAnimations = | |
59 ElementAnimation::getAnimations(*box); | |
60 HeapVector<Member<Animation>> otherBoxAnimations = | |
61 ElementAnimation::getAnimations(*box); | |
62 | |
63 EXPECT_EQ(1ul, boxAnimations.size()); | |
64 EXPECT_EQ(1ul, otherBoxAnimations.size()); | |
65 EXPECT_EQ(boxAnimations.front()->CompositorGroup(), | |
66 otherBoxAnimations.front()->CompositorGroup()); | |
67 } | |
68 } | |
OLD | NEW |