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

Unified Diff: Source/core/paint/DisplayItemListPaintTest.cpp

Issue 1287093004: Slimming Paint phase 2 compositing algorithm plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Minor cleanup Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/DisplayItemListPaintTest.cpp
diff --git a/Source/core/paint/DisplayItemListPaintTest.cpp b/Source/core/paint/DisplayItemListPaintTest.cpp
index 4a9f008783518b5926bf2dc0426d9e7d778a8586..9fbce4d5f51f854692ab34e0985acb7ce3bf3871 100644
--- a/Source/core/paint/DisplayItemListPaintTest.cpp
+++ b/Source/core/paint/DisplayItemListPaintTest.cpp
@@ -85,35 +85,55 @@ public:
} \
} while (false);
+#ifndef NDEBUG
+#define EXPECT_DISPLAY_LIST_WITH_DEBUG_ONLY_RED_FILL(actual, expectedSizeWithoutFill, ...) \
+ do { \
+ EXPECT_EQ((size_t)expectedSizeWithoutFill + 1, actual.size()); \
+ if (expectedSizeWithoutFill + 1 != actual.size()) \
+ break; \
+ EXPECT_EQ(DisplayItem::DebugRedFill, actual[0].type()); \
+ const TestDisplayItem expected[] = { __VA_ARGS__ }; \
+ for (size_t index = 1; index < std::min<size_t>(actual.size(), expectedSizeWithoutFill + 1); index++) { \
+ TRACE_DISPLAY_ITEMS(index, expected[index - 1], actual[index]); \
+ EXPECT_EQ(expected[index - 1].client(), actual[index].client()); \
+ EXPECT_EQ(expected[index - 1].type(), actual[index].type()); \
+ } \
+ } while (false);
+#else
+#define EXPECT_DISPLAY_LIST_WITH_DEBUG_ONLY_RED_FILL(actual, expectedSize, ...) \
+ do { \
+ EXPECT_EQ((size_t)expectedSize, actual.size()); \
+ if (expectedSize != actual.size()) \
+ break; \
+ const TestDisplayItem expected[] = { __VA_ARGS__ }; \
+ for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize); index++) { \
+ TRACE_DISPLAY_ITEMS(index, expected[index], actual[index]); \
+ EXPECT_EQ(expected[index].client(), actual[index].client()); \
+ EXPECT_EQ(expected[index].type(), actual[index].type()); \
+ } \
+ } while (false);
+#endif
Xianzhu 2015/08/13 17:03:58 Would the following work? 75s/EXPECT_DISPLAY_LIST
pdr. 2015/08/13 20:55:00 Good idea, done.
+
TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret)
{
setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>XYZ</div>");
document().page()->focusController().setActive(true);
document().page()->focusController().setFocused(true);
LayoutView& layoutView = *document().layoutView();
- DeprecatedPaintLayer& rootLayer = *layoutView.layer();
Element& div = *toElement(document().body()->firstChild());
LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObject();
InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject())->firstTextBox();
- GraphicsContext context(&rootDisplayItemList());
- DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600), GlobalPaintNormalPhase, LayoutSize());
- DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
- rootDisplayItemList().commitNewDisplayItems();
+ document().view()->updateAllLifecyclePhases();
- EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2,
+ EXPECT_DISPLAY_LIST_WITH_DEBUG_ONLY_RED_FILL(rootDisplayItemList().displayItems(), 2,
TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)));
div.focus();
document().view()->updateAllLifecyclePhases();
- EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemClient()));
- EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divLayoutObject.displayItemClient()));
- EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox.displayItemClient()));
- DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
- rootDisplayItemList().commitNewDisplayItems();
- EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3,
+ EXPECT_DISPLAY_LIST_WITH_DEBUG_ONLY_RED_FILL(rootDisplayItemList().displayItems(), 3,
TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)),
TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New!
@@ -123,35 +143,25 @@ TEST_F(DisplayItemListPaintTest, InlineRelayout)
{
setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAAA BBBBBBBBBB</div>");
LayoutView& layoutView = *document().layoutView();
- DeprecatedPaintLayer& rootLayer = *layoutView.layer();
Element& div = *toElement(document().body()->firstChild());
LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layoutObject());
LayoutText& text = *toLayoutText(divBlock.firstChild());
InlineTextBox& firstTextBox = *text.firstTextBox();
- DisplayItemClient firstTextBoxDisplayItemClient = firstTextBox.displayItemClient();
- GraphicsContext context(&rootDisplayItemList());
- DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600), GlobalPaintNormalPhase, LayoutSize());
- DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
- rootDisplayItemList().commitNewDisplayItems();
+ document().view()->updateAllLifecyclePhases();
- EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2,
+ EXPECT_DISPLAY_LIST_WITH_DEBUG_ONLY_RED_FILL(rootDisplayItemList().displayItems(), 2,
TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)));
div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
document().view()->updateAllLifecyclePhases();
- EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemClient()));
- EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemClient()));
- EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayItemClient));
- DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
- rootDisplayItemList().commitNewDisplayItems();
LayoutText& newText = *toLayoutText(divBlock.firstChild());
InlineTextBox& newFirstTextBox = *newText.firstTextBox();
InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();
- EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 5,
+ EXPECT_DISPLAY_LIST_WITH_DEBUG_ONLY_RED_FILL(rootDisplayItemList().displayItems(), 5,
TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
TestDisplayItem(divBlock, DisplayItem::paintPhaseToBeginSubtreeType(PaintPhaseForeground)),
TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)),

Powered by Google App Engine
This is Rietveld 408576698