OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/PaintPropertyTreePrinter.h" | 5 #include "core/paint/PaintPropertyTreePrinter.h" |
6 | 6 |
7 #include "core/layout/LayoutObject.h" | 7 #include "core/layout/LayoutObject.h" |
8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
10 #include "testing/gmock/include/gmock/gmock-matchers.h" | 10 #include "testing/gmock/include/gmock/gmock-matchers.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 }; | 42 }; |
43 | 43 |
44 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreePrinterTest, ::testing::Bool()); | 44 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreePrinterTest, ::testing::Bool()); |
45 | 45 |
46 TEST_P(PaintPropertyTreePrinterTest, SimpleTransformTree) { | 46 TEST_P(PaintPropertyTreePrinterTest, SimpleTransformTree) { |
47 SetBodyInnerHTML("hello world"); | 47 SetBodyInnerHTML("hello world"); |
48 String transform_tree_as_string = | 48 String transform_tree_as_string = |
49 transformPropertyTreeAsString(*GetDocument().View()); | 49 transformPropertyTreeAsString(*GetDocument().View()); |
50 EXPECT_THAT(transform_tree_as_string.Ascii().data(), | 50 EXPECT_THAT(transform_tree_as_string.Ascii().data(), |
51 testing::MatchesRegex("root .*" | 51 ::testing::MatchesRegex("root .*" |
52 " .*Translation \\(.*\\) .*")); | 52 " .*Translation \\(.*\\) .*")); |
53 } | 53 } |
54 | 54 |
55 TEST_P(PaintPropertyTreePrinterTest, SimpleClipTree) { | 55 TEST_P(PaintPropertyTreePrinterTest, SimpleClipTree) { |
56 SetBodyInnerHTML("hello world"); | 56 SetBodyInnerHTML("hello world"); |
57 String clip_tree_as_string = clipPropertyTreeAsString(*GetDocument().View()); | 57 String clip_tree_as_string = clipPropertyTreeAsString(*GetDocument().View()); |
58 EXPECT_THAT(clip_tree_as_string.Ascii().data(), | 58 EXPECT_THAT(clip_tree_as_string.Ascii().data(), |
59 testing::MatchesRegex("root .*" | 59 ::testing::MatchesRegex("root .*" |
60 " .*Clip \\(.*\\) .*")); | 60 " .*Clip \\(.*\\) .*")); |
61 } | 61 } |
62 | 62 |
63 TEST_P(PaintPropertyTreePrinterTest, SimpleEffectTree) { | 63 TEST_P(PaintPropertyTreePrinterTest, SimpleEffectTree) { |
64 SetBodyInnerHTML("<div style='opacity: 0.9;'>hello world</div>"); | 64 SetBodyInnerHTML("<div style='opacity: 0.9;'>hello world</div>"); |
65 String effect_tree_as_string = | 65 String effect_tree_as_string = |
66 effectPropertyTreeAsString(*GetDocument().View()); | 66 effectPropertyTreeAsString(*GetDocument().View()); |
67 EXPECT_THAT(effect_tree_as_string.Ascii().data(), | 67 EXPECT_THAT(effect_tree_as_string.Ascii().data(), |
68 testing::MatchesRegex("root .*" | 68 ::testing::MatchesRegex("root .*" |
69 " Effect \\(LayoutBlockFlow DIV\\) .*")); | 69 " Effect \\(LayoutBlockFlow DIV\\) .*")); |
70 } | 70 } |
71 | 71 |
72 TEST_P(PaintPropertyTreePrinterTest, SimpleScrollTree) { | 72 TEST_P(PaintPropertyTreePrinterTest, SimpleScrollTree) { |
73 SetBodyInnerHTML("<div style='height: 4000px;'>hello world</div>"); | 73 SetBodyInnerHTML("<div style='height: 4000px;'>hello world</div>"); |
74 String scroll_tree_as_string = | 74 String scroll_tree_as_string = |
75 scrollPropertyTreeAsString(*GetDocument().View()); | 75 scrollPropertyTreeAsString(*GetDocument().View()); |
76 EXPECT_THAT(scroll_tree_as_string.Ascii().data(), | 76 EXPECT_THAT(scroll_tree_as_string.Ascii().data(), |
77 testing::MatchesRegex("root .*" | 77 ::testing::MatchesRegex("root .*" |
78 " Scroll \\(.*\\) .*")); | 78 " Scroll \\(.*\\) .*")); |
79 } | 79 } |
80 | 80 |
81 TEST_P(PaintPropertyTreePrinterTest, SimpleTransformTreePath) { | 81 TEST_P(PaintPropertyTreePrinterTest, SimpleTransformTreePath) { |
82 SetBodyInnerHTML( | 82 SetBodyInnerHTML( |
83 "<div id='transform' style='transform: translate3d(10px, 10px, " | 83 "<div id='transform' style='transform: translate3d(10px, 10px, " |
84 "0px);'></div>"); | 84 "0px);'></div>"); |
85 LayoutObject* transformed_object = | 85 LayoutObject* transformed_object = |
86 GetDocument().getElementById("transform")->GetLayoutObject(); | 86 GetDocument().getElementById("transform")->GetLayoutObject(); |
87 const auto* transformed_object_properties = | 87 const auto* transformed_object_properties = |
88 transformed_object->PaintProperties(); | 88 transformed_object->PaintProperties(); |
89 String transform_path_as_string = | 89 String transform_path_as_string = |
90 transformed_object_properties->Transform()->ToTreeString(); | 90 transformed_object_properties->Transform()->ToTreeString(); |
91 EXPECT_THAT(transform_path_as_string.Ascii().data(), | 91 EXPECT_THAT(transform_path_as_string.Ascii().data(), |
92 testing::MatchesRegex("root .* transform.*" | 92 ::testing::MatchesRegex("root .* transform.*" |
93 " .* transform.*" | 93 " .* transform.*" |
94 " .* transform.*" | 94 " .* transform.*" |
95 " .* transform.*")); | 95 " .* transform.*")); |
96 } | 96 } |
97 | 97 |
98 TEST_P(PaintPropertyTreePrinterTest, SimpleClipTreePath) { | 98 TEST_P(PaintPropertyTreePrinterTest, SimpleClipTreePath) { |
99 SetBodyInnerHTML( | 99 SetBodyInnerHTML( |
100 "<div id='clip' style='position: absolute; clip: rect(10px, 80px, 70px, " | 100 "<div id='clip' style='position: absolute; clip: rect(10px, 80px, 70px, " |
101 "40px);'></div>"); | 101 "40px);'></div>"); |
102 LayoutObject* clipped_object = | 102 LayoutObject* clipped_object = |
103 GetDocument().getElementById("clip")->GetLayoutObject(); | 103 GetDocument().getElementById("clip")->GetLayoutObject(); |
104 const auto* clipped_object_properties = clipped_object->PaintProperties(); | 104 const auto* clipped_object_properties = clipped_object->PaintProperties(); |
105 String clip_path_as_string = | 105 String clip_path_as_string = |
106 clipped_object_properties->CssClip()->ToTreeString(); | 106 clipped_object_properties->CssClip()->ToTreeString(); |
107 EXPECT_THAT(clip_path_as_string.Ascii().data(), | 107 EXPECT_THAT(clip_path_as_string.Ascii().data(), |
108 testing::MatchesRegex("root .* rect.*" | 108 ::testing::MatchesRegex("root .* rect.*" |
109 " .* rect.*" | 109 " .* rect.*" |
110 " .* rect.*")); | 110 " .* rect.*")); |
111 } | 111 } |
112 | 112 |
113 TEST_P(PaintPropertyTreePrinterTest, SimpleEffectTreePath) { | 113 TEST_P(PaintPropertyTreePrinterTest, SimpleEffectTreePath) { |
114 SetBodyInnerHTML("<div id='effect' style='opacity: 0.9;'></div>"); | 114 SetBodyInnerHTML("<div id='effect' style='opacity: 0.9;'></div>"); |
115 LayoutObject* effect_object = | 115 LayoutObject* effect_object = |
116 GetDocument().getElementById("effect")->GetLayoutObject(); | 116 GetDocument().getElementById("effect")->GetLayoutObject(); |
117 const auto* effect_object_properties = effect_object->PaintProperties(); | 117 const auto* effect_object_properties = effect_object->PaintProperties(); |
118 String effect_path_as_string = | 118 String effect_path_as_string = |
119 effect_object_properties->Effect()->ToTreeString(); | 119 effect_object_properties->Effect()->ToTreeString(); |
120 EXPECT_THAT(effect_path_as_string.Ascii().data(), | 120 EXPECT_THAT(effect_path_as_string.Ascii().data(), |
121 testing::MatchesRegex("root .* opacity.*" | 121 ::testing::MatchesRegex("root .* opacity.*" |
122 " .* opacity.*")); | 122 " .* opacity.*")); |
123 } | 123 } |
124 | 124 |
125 TEST_P(PaintPropertyTreePrinterTest, SimpleScrollTreePath) { | 125 TEST_P(PaintPropertyTreePrinterTest, SimpleScrollTreePath) { |
126 SetBodyInnerHTML( | 126 SetBodyInnerHTML( |
127 "<div id='scroll' style='overflow: scroll; height: 100px;'>" | 127 "<div id='scroll' style='overflow: scroll; height: 100px;'>" |
128 " <div id='forceScroll' style='height: 4000px;'></div>" | 128 " <div id='forceScroll' style='height: 4000px;'></div>" |
129 "</div>"); | 129 "</div>"); |
130 LayoutObject* scroll_object = | 130 LayoutObject* scroll_object = |
131 GetDocument().getElementById("scroll")->GetLayoutObject(); | 131 GetDocument().getElementById("scroll")->GetLayoutObject(); |
132 const auto* scroll_object_properties = scroll_object->PaintProperties(); | 132 const auto* scroll_object_properties = scroll_object->PaintProperties(); |
133 String scroll_path_as_string = scroll_object_properties->ScrollTranslation() | 133 String scroll_path_as_string = scroll_object_properties->ScrollTranslation() |
134 ->ScrollNode() | 134 ->ScrollNode() |
135 ->ToTreeString(); | 135 ->ToTreeString(); |
136 EXPECT_THAT(scroll_path_as_string.Ascii().data(), | 136 EXPECT_THAT(scroll_path_as_string.Ascii().data(), |
137 testing::MatchesRegex("root .* parent.*" | 137 ::testing::MatchesRegex("root .* parent.*" |
138 " .* parent.*")); | 138 " .* parent.*")); |
139 } | 139 } |
140 | 140 |
141 } // namespace blink | 141 } // namespace blink |
142 | 142 |
143 #endif // if DCHECK_IS_ON() | 143 #endif // if DCHECK_IS_ON() |
OLD | NEW |