| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 "core/paint/PaintPropertyTreePrinter.h" |
| 6 |
| 7 #include "core/layout/LayoutTestHelper.h" |
| 8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 9 #include "testing/gmock/include/gmock/gmock-matchers.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 #ifndef NDEBUG |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 typedef bool TestParamRootLayerScrolling; |
| 17 class PaintPropertyTreePrinterTest |
| 18 : public ::testing::WithParamInterface<TestParamRootLayerScrolling> |
| 19 , private ScopedSlimmingPaintV2ForTest |
| 20 , private ScopedRootLayerScrollingForTest |
| 21 , public RenderingTest { |
| 22 public: |
| 23 PaintPropertyTreePrinterTest() |
| 24 : ScopedSlimmingPaintV2ForTest(true) |
| 25 , ScopedRootLayerScrollingForTest(GetParam()) |
| 26 , RenderingTest(SingleChildFrameLoaderClient::create()) { } |
| 27 |
| 28 private: |
| 29 void SetUp() override |
| 30 { |
| 31 Settings::setMockScrollbarsEnabled(true); |
| 32 |
| 33 RenderingTest::SetUp(); |
| 34 enableCompositing(); |
| 35 } |
| 36 |
| 37 void TearDown() override |
| 38 { |
| 39 RenderingTest::TearDown(); |
| 40 |
| 41 Settings::setMockScrollbarsEnabled(false); |
| 42 } |
| 43 }; |
| 44 |
| 45 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreePrinterTest, ::testing::Bool()); |
| 46 |
| 47 TEST_P(PaintPropertyTreePrinterTest, SimpleTransformTree) |
| 48 { |
| 49 setBodyInnerHTML("hello world"); |
| 50 String transformTreeAsString = transformPropertyTreeAsString(*document().vie
w()); |
| 51 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 52 EXPECT_THAT(transformTreeAsString.ascii().data(), |
| 53 testing::MatchesRegex("PaintOffsetTranslation \\(LayoutView #documen
t\\) .*" |
| 54 " ScrollTranslation \\(LayoutView #document\\) \\w+ .*")); |
| 55 } else { |
| 56 EXPECT_THAT(transformTreeAsString.ascii().data(), |
| 57 testing::MatchesRegex("root .*" |
| 58 " PreTranslation \\(FrameView\\) .*" |
| 59 " ScrollTranslation \\(FrameView\\) .*")); |
| 60 } |
| 61 } |
| 62 |
| 63 TEST_P(PaintPropertyTreePrinterTest, SimpleClipTree) |
| 64 { |
| 65 setBodyInnerHTML("hello world"); |
| 66 String clipTreeAsString = clipPropertyTreeAsString(*document().view()); |
| 67 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 68 EXPECT_THAT(clipTreeAsString.ascii().data(), |
| 69 testing::MatchesRegex("root \\w+ .*" |
| 70 " OverflowClip \\(LayoutView #document\\) .*")); |
| 71 } else { |
| 72 EXPECT_THAT(clipTreeAsString.ascii().data(), |
| 73 testing::MatchesRegex("root .*" |
| 74 " ContentClip \\(FrameView\\) .*")); |
| 75 } |
| 76 } |
| 77 |
| 78 TEST_P(PaintPropertyTreePrinterTest, SimpleEffectTree) |
| 79 { |
| 80 setBodyInnerHTML("<div style='opacity: 0.9;'>hello world</div>"); |
| 81 String effectTreeAsString = effectPropertyTreeAsString(*document().view()); |
| 82 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 83 EXPECT_THAT(effectTreeAsString.ascii().data(), |
| 84 testing::MatchesRegex("Effect \\(LayoutView #document\\) .*" |
| 85 " Effect \\(LayoutBlockFlow DIV\\) .*")); |
| 86 } else { |
| 87 EXPECT_THAT(effectTreeAsString.ascii().data(), |
| 88 testing::MatchesRegex("root .*" |
| 89 " Effect \\(LayoutBlockFlow DIV\\) .*")); |
| 90 } |
| 91 } |
| 92 |
| 93 TEST_P(PaintPropertyTreePrinterTest, SimpleScrollTree) |
| 94 { |
| 95 setBodyInnerHTML("<div style='height: 4000px;'>hello world</div>"); |
| 96 String scrollTreeAsString = scrollPropertyTreeAsString(*document().view()); |
| 97 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 98 EXPECT_THAT(scrollTreeAsString.ascii().data(), |
| 99 testing::MatchesRegex("Scroll \\(LayoutView #document\\) .*")); |
| 100 } else { |
| 101 EXPECT_THAT(scrollTreeAsString.ascii().data(), |
| 102 testing::MatchesRegex("root .*" |
| 103 " Scroll \\(FrameView\\) .*")); |
| 104 } |
| 105 } |
| 106 |
| 107 } // namespace blink |
| 108 |
| 109 #endif |
| OLD | NEW |