OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 "platform/graphics/paint/PropertyTreeState.h" | |
6 | |
7 #include "platform/geometry/LayoutRect.h" | |
8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | |
9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | |
10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 | |
13 namespace blink { | |
14 | |
15 class PropertyTreeStateTest : public ::testing::Test { | |
16 public: | |
17 RefPtr<TransformPaintPropertyNode> rootTransformNode; | |
18 RefPtr<ClipPaintPropertyNode> rootClipNode; | |
19 RefPtr<EffectPaintPropertyNode> rootEffectNode; | |
20 | |
21 PropertyTreeState rootPropertyTreeState() | |
22 { | |
23 PropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), roo
tEffectNode.get()); | |
24 return state; | |
25 } | |
26 | |
27 private: | |
28 void SetUp() override | |
29 { | |
30 rootTransformNode = TransformPaintPropertyNode::create(nullptr, Transfor
mationMatrix(), FloatPoint3D()); | |
31 rootClipNode = ClipPaintPropertyNode::create(nullptr, rootTransformNode,
FloatRoundedRect(LayoutRect::infiniteIntRect())); | |
32 rootEffectNode = EffectPaintPropertyNode::create(nullptr, 1.0); | |
33 } | |
34 }; | |
35 | |
36 TEST_F(PropertyTreeStateTest, LeastCommonAncestor) | |
37 { | |
38 TransformationMatrix matrix; | |
39 RefPtr<TransformPaintPropertyNode> child1 = TransformPaintPropertyNode::crea
te(rootPropertyTreeState().transform, matrix, FloatPoint3D()); | |
40 RefPtr<TransformPaintPropertyNode> child2 = TransformPaintPropertyNode::crea
te(rootPropertyTreeState().transform, matrix, FloatPoint3D()); | |
41 | |
42 RefPtr<TransformPaintPropertyNode> childOfChild1 = TransformPaintPropertyNod
e::create(child1, matrix, FloatPoint3D()); | |
43 RefPtr<TransformPaintPropertyNode> childOfChild2 = TransformPaintPropertyNod
e::create(child2, matrix, FloatPoint3D()); | |
44 | |
45 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest
or<TransformPaintPropertyNode>(childOfChild1.get(), childOfChild2.get())); | |
46 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest
or<TransformPaintPropertyNode>(childOfChild1.get(), child2.get())); | |
47 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest
or<TransformPaintPropertyNode>(childOfChild1.get(), rootPropertyTreeState().tran
sform.get())); | |
48 EXPECT_EQ(child1, propertyTreeNearestCommonAncestor<TransformPaintPropertyNo
de>(childOfChild1.get(), child1.get())); | |
49 | |
50 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest
or<TransformPaintPropertyNode>(childOfChild2.get(), childOfChild1.get())); | |
51 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest
or<TransformPaintPropertyNode>(childOfChild2.get(), child1.get())); | |
52 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest
or<TransformPaintPropertyNode>(childOfChild2.get(), rootPropertyTreeState().tran
sform.get())); | |
53 EXPECT_EQ(child2, propertyTreeNearestCommonAncestor<TransformPaintPropertyNo
de>(childOfChild2.get(), child2.get())); | |
54 | |
55 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest
or<TransformPaintPropertyNode>(child1.get(), child2.get())); | |
56 } | |
57 | |
58 } // namespace blink | |
OLD | NEW |