| Index: Source/core/paint/DisplayItemListPaintTest.h
|
| diff --git a/Source/core/paint/DisplayItemListPaintTest.h b/Source/core/paint/DisplayItemListPaintTest.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fe86e90a1774d07848089f1465443bdd55b9003f
|
| --- /dev/null
|
| +++ b/Source/core/paint/DisplayItemListPaintTest.h
|
| @@ -0,0 +1,140 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef DisplayItemListPaintTest_h
|
| +#define DisplayItemListPaintTest_h
|
| +
|
| +#include "core/frame/FrameView.h"
|
| +#include "core/layout/LayoutTestHelper.h"
|
| +#include "core/layout/LayoutView.h"
|
| +#include "core/paint/DeprecatedPaintLayer.h"
|
| +#include "platform/graphics/GraphicsLayer.h"
|
| +#include <gtest/gtest.h>
|
| +
|
| +namespace blink {
|
| +
|
| +class DisplayItemListPaintTest : public RenderingTest {
|
| +public:
|
| + DisplayItemListPaintTest()
|
| + : m_layoutView(nullptr)
|
| + , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEnabled()) { }
|
| +
|
| +protected:
|
| + LayoutView& layoutView() { return *m_layoutView; }
|
| + DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graphicsLayerBacking()->displayItemList(); }
|
| + const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemList().m_newDisplayItems; }
|
| +
|
| +private:
|
| + void SetUp() override
|
| + {
|
| + RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
|
| +
|
| + RenderingTest::SetUp();
|
| + enableCompositing();
|
| +
|
| + m_layoutView = document().view()->layoutView();
|
| + ASSERT_TRUE(m_layoutView);
|
| + }
|
| +
|
| + void TearDown() override
|
| + {
|
| + RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintEnabled);
|
| + }
|
| +
|
| + LayoutView* m_layoutView;
|
| + bool m_originalSlimmingPaintEnabled;
|
| +};
|
| +
|
| +// Slimming paint v2 has subtly different behavior on some paint tests. This
|
| +// class is used to test only v2 behavior while maintaining v1 test coverage.
|
| +class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest {
|
| +public:
|
| + DisplayItemListPaintTestForSlimmingPaintV2()
|
| + : m_layoutView(nullptr)
|
| + , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { }
|
| +
|
| +protected:
|
| + LayoutView& layoutView() { return *m_layoutView; }
|
| + DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graphicsLayerBacking()->displayItemList(); }
|
| + const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemList().m_newDisplayItems; }
|
| +
|
| + // Expose some document lifecycle steps for checking new display items before commiting.
|
| + void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean()
|
| + {
|
| + document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToCompositingCleanPlusScrolling);
|
| + document().view()->invalidateTreeIfNeededRecursive();
|
| + document().view()->paintForSlimmingPaintV2();
|
| + }
|
| + void compositeForSlimmingPaintV2() { document().view()->compositeForSlimmingPaintV2(); }
|
| +
|
| +private:
|
| + void SetUp() override
|
| + {
|
| + ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled());
|
| + RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
|
| +
|
| + RenderingTest::SetUp();
|
| + enableCompositing();
|
| +
|
| + m_layoutView = document().view()->layoutView();
|
| + ASSERT_TRUE(m_layoutView);
|
| + }
|
| +
|
| + void TearDown() override
|
| + {
|
| + RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPaintV2Enabled);
|
| + }
|
| +
|
| + LayoutView* m_layoutView;
|
| + bool m_originalSlimmingPaintV2Enabled;
|
| +};
|
| +
|
| +class TestDisplayItem final : public DisplayItem {
|
| +public:
|
| + TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : DisplayItem(client, type, sizeof(*this)) { }
|
| +
|
| + void replay(GraphicsContext&) final { ASSERT_NOT_REACHED(); }
|
| + void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NOT_REACHED(); }
|
| +};
|
| +
|
| +#ifndef NDEBUG
|
| +#define TRACE_DISPLAY_ITEMS(i, expected, actual) \
|
| + String trace = String::format("%d: ", (int)i) + "Expected: " + (expected).asDebugString() + " Actual: " + (actual).asDebugString(); \
|
| + SCOPED_TRACE(trace.utf8().data());
|
| +#else
|
| +#define TRACE_DISPLAY_ITEMS(i, expected, actual)
|
| +#endif
|
| +
|
| +#define EXPECT_DISPLAY_LIST_BASE(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);
|
| +
|
| +#ifndef NDEBUG
|
| +#define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFill, ...) \
|
| + EXPECT_DISPLAY_LIST_BASE( \
|
| + actual, expectedSizeWithoutFill + 1, \
|
| + TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking(), DisplayItem::DebugRedFill), \
|
| + __VA_ARGS__)
|
| +#define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFill, ...) \
|
| + EXPECT_DISPLAY_LIST_BASE( \
|
| + actual, expectedSizeWithoutFill + 1, \
|
| + TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking(), DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::DebugRedFill)), \
|
| + __VA_ARGS__)
|
| +#else
|
| +#define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE
|
| +#define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE
|
| +#endif
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // DisplayItemListPaintTest_h
|
|
|