OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef DisplayItemListPaintTest_h | 5 #ifndef DisplayItemListPaintTest_h |
6 #define DisplayItemListPaintTest_h | 6 #define DisplayItemListPaintTest_h |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
11 #include "core/paint/DeprecatedPaintLayer.h" | 11 #include "core/paint/DeprecatedPaintLayer.h" |
12 #include "platform/graphics/GraphicsLayer.h" | 12 #include "platform/graphics/GraphicsLayer.h" |
13 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class DisplayItemListPaintTest : public RenderingTest { | 17 class DisplayItemListPaintTest : public RenderingTest { |
18 public: | 18 public: |
19 DisplayItemListPaintTest() | 19 DisplayItemListPaintTest() |
20 : m_layoutView(nullptr) | 20 : m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } |
21 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } | |
22 | 21 |
23 protected: | 22 protected: |
24 LayoutView& layoutView() { return *m_layoutView; } | 23 LayoutView& layoutView() { return *document().layoutView(); } |
25 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } | 24 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } |
26 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi
st().m_newDisplayItems; } | |
27 | 25 |
28 private: | 26 private: |
29 void SetUp() override | 27 void SetUp() override |
30 { | 28 { |
31 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 29 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); |
32 | 30 |
33 RenderingTest::SetUp(); | 31 RenderingTest::SetUp(); |
34 enableCompositing(); | 32 enableCompositing(); |
35 | |
36 m_layoutView = document().view()->layoutView(); | |
37 ASSERT_TRUE(m_layoutView); | |
38 } | 33 } |
39 | 34 |
40 void TearDown() override | 35 void TearDown() override |
41 { | 36 { |
42 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE
nabled); | 37 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE
nabled); |
43 } | 38 } |
44 | 39 |
45 LayoutView* m_layoutView; | |
46 bool m_originalSlimmingPaintEnabled; | 40 bool m_originalSlimmingPaintEnabled; |
47 }; | 41 }; |
48 | 42 |
49 // Slimming paint v2 has subtly different behavior on some paint tests. This | 43 // Slimming paint v2 has subtly different behavior on some paint tests. This |
50 // class is used to test only v2 behavior while maintaining v1 test coverage. | 44 // class is used to test only v2 behavior while maintaining v1 test coverage. |
51 class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest { | 45 class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest { |
52 public: | 46 public: |
53 DisplayItemListPaintTestForSlimmingPaintV2() | 47 DisplayItemListPaintTestForSlimmingPaintV2() |
54 : m_layoutView(nullptr) | 48 : m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
55 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } | |
56 | 49 |
57 protected: | 50 protected: |
58 LayoutView& layoutView() { return *m_layoutView; } | 51 LayoutView& layoutView() { return *document().layoutView(); } |
59 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } | 52 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } |
60 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi
st().m_newDisplayItems; } | |
61 | 53 |
62 // Expose some document lifecycle steps for checking new display items befor
e commiting. | 54 // Expose some document lifecycle steps for checking new display items befor
e commiting. |
63 void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean() | 55 void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean() |
64 { | 56 { |
65 document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToComp
ositingCleanPlusScrolling); | 57 document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToComp
ositingCleanPlusScrolling); |
66 document().view()->invalidateTreeIfNeededRecursive(); | 58 document().view()->invalidateTreeIfNeededRecursive(); |
67 document().view()->paintForSlimmingPaintV2(); | 59 document().view()->paintForSlimmingPaintV2(); |
68 } | 60 } |
69 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming
PaintV2(); } | 61 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming
PaintV2(); } |
70 | 62 |
71 private: | 63 private: |
72 void SetUp() override | 64 void SetUp() override |
73 { | 65 { |
74 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 66 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
75 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 67 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
76 | 68 |
77 RenderingTest::SetUp(); | 69 RenderingTest::SetUp(); |
78 enableCompositing(); | 70 enableCompositing(); |
79 | |
80 m_layoutView = document().view()->layoutView(); | |
81 ASSERT_TRUE(m_layoutView); | |
82 } | 71 } |
83 | 72 |
84 void TearDown() override | 73 void TearDown() override |
85 { | 74 { |
86 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | 75 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
87 } | 76 } |
88 | 77 |
89 LayoutView* m_layoutView; | |
90 bool m_originalSlimmingPaintV2Enabled; | 78 bool m_originalSlimmingPaintV2Enabled; |
91 }; | 79 }; |
92 | 80 |
93 class TestDisplayItem final : public DisplayItem { | 81 class TestDisplayItem final : public DisplayItem { |
94 public: | 82 public: |
95 TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : Display
Item(client, type, sizeof(*this)) { } | 83 TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : Display
Item(client, type, sizeof(*this)) { } |
96 | 84 |
97 void replay(GraphicsContext&) final { ASSERT_NOT_REACHED(); } | 85 void replay(GraphicsContext&) final { ASSERT_NOT_REACHED(); } |
98 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO
T_REACHED(); } | 86 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO
T_REACHED(); } |
99 }; | 87 }; |
(...skipping 16 matching lines...) Expand all Loading... |
116 TRACE_DISPLAY_ITEMS(index, expected[index], actual[index]); \ | 104 TRACE_DISPLAY_ITEMS(index, expected[index], actual[index]); \ |
117 EXPECT_EQ(expected[index].client(), actual[index].client()); \ | 105 EXPECT_EQ(expected[index].client(), actual[index].client()); \ |
118 EXPECT_EQ(expected[index].type(), actual[index].type()); \ | 106 EXPECT_EQ(expected[index].type(), actual[index].type()); \ |
119 } \ | 107 } \ |
120 } while (false); | 108 } while (false); |
121 | 109 |
122 #ifndef NDEBUG | 110 #ifndef NDEBUG |
123 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFi
ll, ...) \ | 111 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFi
ll, ...) \ |
124 EXPECT_DISPLAY_LIST_BASE( \ | 112 EXPECT_DISPLAY_LIST_BASE( \ |
125 actual, expectedSizeWithoutFill + 1, \ | 113 actual, expectedSizeWithoutFill + 1, \ |
126 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking(
), DisplayItem::DebugRedFill), \ | 114 TestDisplayItem(*layoutView().layer()->graphicsLayerBacking(), DisplayIt
em::DebugRedFill), \ |
127 __VA_ARGS__) | 115 __VA_ARGS__) |
128 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(actual, expectedSizeWi
thoutFill, ...) \ | 116 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(actual, expectedSizeWi
thoutFill, ...) \ |
129 EXPECT_DISPLAY_LIST_BASE( \ | 117 EXPECT_DISPLAY_LIST_BASE( \ |
130 actual, expectedSizeWithoutFill + 1, \ | 118 actual, expectedSizeWithoutFill + 1, \ |
131 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking(
), DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::DebugRedFill)), \ | 119 TestDisplayItem(*layoutView().layer()->graphicsLayerBacking(), DisplayIt
em::drawingTypeToCachedDrawingType(DisplayItem::DebugRedFill)), \ |
132 __VA_ARGS__) | 120 __VA_ARGS__) |
133 #else | 121 #else |
134 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE | 122 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE |
135 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BA
SE | 123 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BA
SE |
136 #endif | 124 #endif |
137 | 125 |
138 } // namespace blink | 126 } // namespace blink |
139 | 127 |
140 #endif // DisplayItemListPaintTest_h | 128 #endif // DisplayItemListPaintTest_h |
OLD | NEW |