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

Side by Side Diff: Source/core/paint/DisplayItemListPaintTest.h

Issue 1312493007: Fix table cell background caching issue about interest rect (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/BlockPainter.cpp ('k') | Source/core/paint/DisplayItemListPaintTest.cpp » ('j') | 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 2015 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 #ifndef DisplayItemListPaintTest_h
6 #define DisplayItemListPaintTest_h
7
8 #include "core/frame/FrameView.h"
9 #include "core/layout/LayoutTestHelper.h"
10 #include "core/layout/LayoutView.h"
11 #include "core/paint/DeprecatedPaintLayer.h"
12 #include "platform/graphics/GraphicsLayer.h"
13 #include <gtest/gtest.h>
14
15 namespace blink {
16
17 class DisplayItemListPaintTest : public RenderingTest {
18 public:
19 DisplayItemListPaintTest()
20 : m_layoutView(nullptr)
21 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn abled()) { }
22
23 protected:
24 LayoutView& layoutView() { return *m_layoutView; }
25 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph icsLayerBacking()->displayItemList(); }
26 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi st().m_newDisplayItems; }
27
28 private:
29 void SetUp() override
30 {
31 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
32
33 RenderingTest::SetUp();
34 enableCompositing();
35
36 m_layoutView = document().view()->layoutView();
37 ASSERT_TRUE(m_layoutView);
38 }
39
40 void TearDown() override
41 {
42 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE nabled);
43 }
44
45 LayoutView* m_layoutView;
46 bool m_originalSlimmingPaintEnabled;
47 };
48
49 // 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.
51 class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest {
52 public:
53 DisplayItemListPaintTestForSlimmingPaintV2()
54 : m_layoutView(nullptr)
55 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { }
56
57 protected:
58 LayoutView& layoutView() { return *m_layoutView; }
59 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph icsLayerBacking()->displayItemList(); }
60 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi st().m_newDisplayItems; }
61
62 // Expose some document lifecycle steps for checking new display items befor e commiting.
63 void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean()
64 {
65 document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToComp ositingCleanPlusScrolling);
66 document().view()->invalidateTreeIfNeededRecursive();
67 document().view()->paintForSlimmingPaintV2();
68 }
69 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming PaintV2(); }
70
71 private:
72 void SetUp() override
73 {
74 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled());
75 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
76
77 RenderingTest::SetUp();
78 enableCompositing();
79
80 m_layoutView = document().view()->layoutView();
81 ASSERT_TRUE(m_layoutView);
82 }
83
84 void TearDown() override
85 {
86 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled);
87 }
88
89 LayoutView* m_layoutView;
90 bool m_originalSlimmingPaintV2Enabled;
91 };
92
93 class TestDisplayItem final : public DisplayItem {
94 public:
95 TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : Display Item(client, type, sizeof(*this)) { }
96
97 void replay(GraphicsContext&) final { ASSERT_NOT_REACHED(); }
98 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO T_REACHED(); }
99 };
100
101 #ifndef NDEBUG
102 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \
103 String trace = String::format("%d: ", (int)i) + "Expected: " + (expected).as DebugString() + " Actual: " + (actual).asDebugString(); \
104 SCOPED_TRACE(trace.utf8().data());
105 #else
106 #define TRACE_DISPLAY_ITEMS(i, expected, actual)
107 #endif
108
109 #define EXPECT_DISPLAY_LIST_BASE(actual, expectedSize, ...) \
110 do { \
111 EXPECT_EQ((size_t)expectedSize, actual.size()); \
112 if (expectedSize != actual.size()) \
113 break; \
114 const TestDisplayItem expected[] = { __VA_ARGS__ }; \
115 for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedS ize); index++) { \
116 TRACE_DISPLAY_ITEMS(index, expected[index], actual[index]); \
117 EXPECT_EQ(expected[index].client(), actual[index].client()); \
118 EXPECT_EQ(expected[index].type(), actual[index].type()); \
119 } \
120 } while (false);
121
122 #ifndef NDEBUG
123 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFi ll, ...) \
124 EXPECT_DISPLAY_LIST_BASE( \
125 actual, expectedSizeWithoutFill + 1, \
126 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking( ), DisplayItem::DebugRedFill), \
127 __VA_ARGS__)
128 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(actual, expectedSizeWi thoutFill, ...) \
129 EXPECT_DISPLAY_LIST_BASE( \
130 actual, expectedSizeWithoutFill + 1, \
131 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking( ), DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::DebugRedFill)), \
132 __VA_ARGS__)
133 #else
134 #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
136 #endif
137
138 } // namespace blink
139
140 #endif // DisplayItemListPaintTest_h
OLDNEW
« no previous file with comments | « Source/core/paint/BlockPainter.cpp ('k') | Source/core/paint/DisplayItemListPaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698