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 PaintControllerPaintTest_h | 5 #ifndef PaintControllerPaintTest_h |
6 #define PaintControllerPaintTest_h | 6 #define PaintControllerPaintTest_h |
7 | 7 |
8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/layout/LayoutTestHelper.h" | 10 #include "core/layout/LayoutTestHelper.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 : DisplayItem(client, type, sizeof(*this)) {} | 111 : DisplayItem(client, type, sizeof(*this)) {} |
112 | 112 |
113 void replay(GraphicsContext&) const final { ASSERT_NOT_REACHED(); } | 113 void replay(GraphicsContext&) const final { ASSERT_NOT_REACHED(); } |
114 void appendToWebDisplayItemList(const IntRect&, | 114 void appendToWebDisplayItemList(const IntRect&, |
115 WebDisplayItemList*) const final { | 115 WebDisplayItemList*) const final { |
116 ASSERT_NOT_REACHED(); | 116 ASSERT_NOT_REACHED(); |
117 } | 117 } |
118 }; | 118 }; |
119 | 119 |
120 #ifndef NDEBUG | 120 #ifndef NDEBUG |
121 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \ | 121 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \ |
122 String trace = String::format("%d: ", (int)i) + "Expected: " + \ | 122 String trace = String::format("%d: ", (int)i) + \ |
123 (expected).asDebugString() + " Actual: " + \ | 123 "Expected: " + (expected).asDebugString() + \ |
124 (actual).asDebugString(); \ | 124 " Actual: " + (actual).asDebugString(); \ |
125 SCOPED_TRACE(trace.utf8().data()); | 125 SCOPED_TRACE(trace.utf8().data()); |
126 #else | 126 #else |
127 #define TRACE_DISPLAY_ITEMS(i, expected, actual) | 127 #define TRACE_DISPLAY_ITEMS(i, expected, actual) |
128 #endif | 128 #endif |
129 | 129 |
130 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) \ | 130 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) \ |
131 do { \ | 131 do { \ |
132 EXPECT_EQ((size_t)expectedSize, actual.size()); \ | 132 EXPECT_EQ((size_t)expectedSize, actual.size()); \ |
133 if (expectedSize != actual.size()) \ | 133 if (expectedSize != actual.size()) \ |
134 break; \ | 134 break; \ |
135 const TestDisplayItem expected[] = {__VA_ARGS__}; \ | 135 const TestDisplayItem expected[] = {__VA_ARGS__}; \ |
136 for (size_t index = 0; \ | 136 for (size_t index = 0; \ |
137 index < std::min<size_t>(actual.size(), expectedSize); index++) { \ | 137 index < std::min<size_t>(actual.size(), expectedSize); index++) { \ |
138 TRACE_DISPLAY_ITEMS(index, expected[index], actual[index]); \ | 138 TRACE_DISPLAY_ITEMS(index, expected[index], actual[index]); \ |
139 EXPECT_EQ(expected[index].client(), actual[index].client()); \ | 139 EXPECT_EQ(expected[index].client(), actual[index].client()); \ |
140 EXPECT_EQ(expected[index].getType(), actual[index].getType()); \ | 140 EXPECT_EQ(expected[index].getType(), actual[index].getType()); \ |
141 } \ | 141 } \ |
142 } while (false); | 142 } while (false); |
143 | 143 |
144 // Shorter names for frequently used display item types in tests. | 144 // Shorter names for frequently used display item types in tests. |
145 const DisplayItem::Type backgroundType = DisplayItem::kBoxDecorationBackground; | 145 const DisplayItem::Type backgroundType = DisplayItem::kBoxDecorationBackground; |
146 const DisplayItem::Type foregroundType = | 146 const DisplayItem::Type foregroundType = |
147 DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground); | 147 DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground); |
148 const DisplayItem::Type documentBackgroundType = | 148 const DisplayItem::Type documentBackgroundType = |
149 DisplayItem::kDocumentBackground; | 149 DisplayItem::kDocumentBackground; |
150 | 150 |
151 } // namespace blink | 151 } // namespace blink |
152 | 152 |
153 #endif // PaintControllerPaintTest_h | 153 #endif // PaintControllerPaintTest_h |
OLD | NEW |