Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #include "config.h" | |
| 6 | |
| 7 #include "core/layout/LayoutTestHelper.h" | |
| 8 #include "core/layout/LayoutView.h" | |
| 9 #include "core/paint/DeprecatedPaintLayer.h" | |
| 10 #include "platform/graphics/GraphicsLayer.h" | |
| 11 #include "platform/transforms/TransformTestHelper.h" | |
| 12 #include "platform/transforms/TransformationMatrix.h" | |
| 13 #include <gtest/gtest.h> | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 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
| |
| 18 public: | |
| 19 DisplayItemListCompositingBuilderTest() | |
| 20 : m_layoutView(nullptr) | |
| 21 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { } | |
| 22 | |
| 23 protected: | |
| 24 LayoutView& layoutView() { return *m_layoutView; } | |
| 25 GraphicsLayer* graphicsLayer() { return layoutView().layer()->graphicsLayerB acking(); } | |
| 26 | |
| 27 void setBodyInnerHTMLWithoutUpdatingLifecycle(const String& htmlContent) | |
| 28 { | |
| 29 document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION); | |
| 30 } | |
| 31 | |
| 32 private: | |
| 33 void SetUp() override | |
| 34 { | |
| 35 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); | |
| 36 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | |
| 37 | |
| 38 RenderingTest::SetUp(); | |
| 39 enableCompositing(); | |
| 40 | |
| 41 m_layoutView = document().view()->layoutView(); | |
| 42 ASSERT_TRUE(m_layoutView); | |
| 43 } | |
| 44 | |
| 45 void TearDown() override | |
| 46 { | |
| 47 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled); | |
| 48 } | |
| 49 | |
| 50 LayoutView* m_layoutView; | |
| 51 bool m_originalSlimmingPaintV2Enabled; | |
| 52 }; | |
| 53 | |
| 54 TEST_F(DisplayItemListCompositingBuilderTest, TransformTreeBuildingNoTransforms) | |
| 55 { | |
| 56 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
| |
| 57 auto tree = graphicsLayer()->transformTree(); | |
| 58 | |
| 59 // There should only be a root transform node. | |
| 60 ASSERT_EQ(1u, tree->nodeCount()); | |
| 61 EXPECT_TRUE(tree->nodeAt(0).isRoot()); | |
| 62 EXPECT_TRUE(tree->nodeAt(0).matrix.isIdentity()); | |
| 63 } | |
| 64 | |
| 65 TEST_F(DisplayItemListCompositingBuilderTest, TransformTreeBuildingMultipleTrans forms) | |
| 66 { | |
| 67 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"tra nsform: translate3d(2px,3px,4px);\">X</div>"); | |
| 68 auto tree = graphicsLayer()->transformTree(); | |
| 69 | |
| 70 ASSERT_EQ(2u, tree->nodeCount()); | |
| 71 EXPECT_TRUE(tree->nodeAt(0).isRoot()); | |
| 72 EXPECT_FALSE(tree->nodeAt(1).isRoot()); | |
| 73 | |
| 74 TransformationMatrix matrix; | |
| 75 matrix.translate3d(2, 3, 4); | |
| 76 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); | |
| 77 | |
| 78 // Add a nested 3d transform. | |
| 79 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"tra nsform: translate3d(2px,3px,4px);\"><div style=\"transform: translate3d(5px,6px, 7px);\">X</div></div>"); | |
| 80 tree = graphicsLayer()->transformTree(); | |
| 81 | |
| 82 ASSERT_EQ(3u, tree->nodeCount()); | |
| 83 EXPECT_TRUE(tree->nodeAt(0).isRoot()); | |
| 84 EXPECT_FALSE(tree->nodeAt(1).isRoot()); | |
| 85 EXPECT_FALSE(tree->nodeAt(2).isRoot()); | |
| 86 | |
| 87 matrix.makeIdentity(); | |
| 88 matrix.translate3d(2, 3, 4); | |
| 89 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); | |
| 90 | |
| 91 matrix.makeIdentity(); | |
| 92 matrix.translate3d(5, 6, 7); | |
| 93 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(2).matrix); | |
| 94 } | |
| 95 | |
| 96 } // namespace blink | |
| OLD | NEW |