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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "core/paint/PaintLayer.h"
11
12 namespace blink {
13
14 namespace {
15 class PaintLayerCompositorTest : public RenderingTest {
16 public:
17 PaintLayerCompositorTest()
18 : RenderingTest(SingleChildLocalFrameClient::Create()) {}
19
20 private:
21 void SetUp() {
22 RenderingTest::SetUp();
23 EnableCompositing();
24 }
25 };
26 }
27
28 TEST_F(PaintLayerCompositorTest, AdvancingToCompositingInputsClean) {
29 SetBodyInnerHTML("<div id='box' style='position: relative'></div>");
30
31 PaintLayer* box_layer =
32 ToLayoutBox(GetLayoutObjectByElementId("box"))->Layer();
33 ASSERT_TRUE(box_layer);
34 EXPECT_FALSE(box_layer->NeedsCompositingInputsUpdate());
35
36 box_layer->SetNeedsCompositingInputsUpdate();
37
38 GetDocument().View()->UpdateLifecycleToCompositingInputsClean();
39 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
40 GetDocument().Lifecycle().GetState());
41 EXPECT_FALSE(box_layer->NeedsCompositingInputsUpdate());
42 }
43
44 TEST_F(PaintLayerCompositorTest,
45 CompositingInputsCleanDoesNotTriggerAnimations) {
46 SetBodyInnerHTML(
47 "<style>@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }"
48 ".animate { animation: fadeOut 2s; }</style>"
49 "<div id='box'></div>"
50 "<div id='otherBox'></div>");
51
52 Element* box = GetDocument().GetElementById("box");
53 Element* otherBox = GetDocument().GetElementById("otherBox");
54 ASSERT_TRUE(box);
55 ASSERT_TRUE(otherBox);
56
57 box->setAttribute("class", "animate", ASSERT_NO_EXCEPTION);
58
59 // Update the lifecycle to CompositingInputsClean. This should not start the
60 // animation lifecycle.
61 GetDocument().View()->UpdateLifecycleToCompositingInputsClean();
62 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
63 GetDocument().Lifecycle().GetState());
64
65 otherBox->setAttribute("class", "animate", ASSERT_NO_EXCEPTION);
66
67 // Now run the rest of the lifecycle. Because both 'box' and 'otherBox' were
68 // given animations separated only by a lifecycle update to
69 // CompositingInputsClean, they should both be started in the same lifecycle
70 // and as such grouped together.
71 GetDocument().View()->UpdateAllLifecyclePhases();
72 EXPECT_EQ(DocumentLifecycle::kPaintClean,
73 GetDocument().Lifecycle().GetState());
74
75 HeapVector<Member<Animation>> boxAnimations =
76 ElementAnimation::getAnimations(*box);
77 HeapVector<Member<Animation>> otherBoxAnimations =
78 ElementAnimation::getAnimations(*box);
79
80 EXPECT_EQ(1ul, boxAnimations.size());
81 EXPECT_EQ(1ul, otherBoxAnimations.size());
82 EXPECT_EQ(boxAnimations.front()->CompositorGroup(),
83 otherBoxAnimations.front()->CompositorGroup());
84 }
85 }
OLDNEW
« 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