Chromium Code Reviews| Index: Source/core/compositing/DisplayListCompositingBuilderTest.cpp |
| diff --git a/Source/core/compositing/DisplayListCompositingBuilderTest.cpp b/Source/core/compositing/DisplayListCompositingBuilderTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..16b93f8354698a99519f75053f777a235e8b72d3 |
| --- /dev/null |
| +++ b/Source/core/compositing/DisplayListCompositingBuilderTest.cpp |
| @@ -0,0 +1,96 @@ |
| +// 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. |
| + |
| +#include "config.h" |
| + |
| +#include "core/layout/LayoutTestHelper.h" |
| +#include "core/layout/LayoutView.h" |
| +#include "core/paint/DeprecatedPaintLayer.h" |
| +#include "platform/graphics/GraphicsLayer.h" |
| +#include "platform/transforms/TransformTestHelper.h" |
| +#include "platform/transforms/TransformationMatrix.h" |
| +#include <gtest/gtest.h> |
| + |
| +namespace blink { |
| + |
| +class DisplayItemListCompositingBuilderTest : public RenderingTest { |
|
chrishtr
2015/08/13 21:33:16
Make two test class: this one, and one which direc
pdr.
2015/08/14 00:10:29
Done
|
| +public: |
| + DisplayItemListCompositingBuilderTest() |
| + : m_layoutView(nullptr) |
| + , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { } |
| + |
| +protected: |
| + LayoutView& layoutView() { return *m_layoutView; } |
| + GraphicsLayer* graphicsLayer() { return layoutView().layer()->graphicsLayerBacking(); } |
| + |
| + void setBodyInnerHTMLWithoutUpdatingLifecycle(const String& htmlContent) |
| + { |
| + document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION); |
| + } |
| + |
| +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; |
| +}; |
| + |
| +TEST_F(DisplayItemListCompositingBuilderTest, TransformTreeBuildingNoTransforms) |
| +{ |
| + setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div>A</div>"); |
|
chrishtr
2015/08/13 21:33:16
Document (in RenderingTest.cpp) that setBodyInnerH
pdr.
2015/08/14 00:10:29
Added some comments in LayoutTestHelper.h
|
| + auto tree = graphicsLayer()->transformTree(); |
| + |
| + // There should only be a root transform node. |
| + ASSERT_EQ(1u, tree->nodeCount()); |
| + EXPECT_TRUE(tree->nodeAt(0).isRoot()); |
| + EXPECT_TRUE(tree->nodeAt(0).matrix.isIdentity()); |
| +} |
| + |
| +TEST_F(DisplayItemListCompositingBuilderTest, TransformTreeBuildingMultipleTransforms) |
| +{ |
| + setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"transform: translate3d(2px,3px,4px);\">X</div>"); |
| + auto tree = graphicsLayer()->transformTree(); |
| + |
| + ASSERT_EQ(2u, tree->nodeCount()); |
| + EXPECT_TRUE(tree->nodeAt(0).isRoot()); |
| + EXPECT_FALSE(tree->nodeAt(1).isRoot()); |
| + |
| + TransformationMatrix matrix; |
| + matrix.translate3d(2, 3, 4); |
| + EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); |
| + |
| + // Add a nested 3d transform. |
| + setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"transform: translate3d(2px,3px,4px);\"><div style=\"transform: translate3d(5px,6px,7px);\">X</div></div>"); |
| + tree = graphicsLayer()->transformTree(); |
| + |
| + ASSERT_EQ(3u, tree->nodeCount()); |
| + EXPECT_TRUE(tree->nodeAt(0).isRoot()); |
| + EXPECT_FALSE(tree->nodeAt(1).isRoot()); |
| + EXPECT_FALSE(tree->nodeAt(2).isRoot()); |
| + |
| + matrix.makeIdentity(); |
| + matrix.translate3d(2, 3, 4); |
| + EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); |
| + |
| + matrix.makeIdentity(); |
| + matrix.translate3d(5, 6, 7); |
| + EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(2).matrix); |
| +} |
| + |
| +} // namespace blink |