| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/frame/FrameView.h" | 5 #include "core/frame/FrameView.h" |
| 6 #include "core/layout/LayoutView.h" | 6 #include "core/layout/LayoutView.h" |
| 7 #include "core/paint/PaintLayerScrollableArea.h" | 7 #include "core/paint/PaintLayerScrollableArea.h" |
| 8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 9 #include "platform/testing/TestingPlatformSupport.h" | 9 #include "platform/testing/TestingPlatformSupport.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // layout otherwise. Ensure the change of scrollbar causes a layout to | 98 // layout otherwise. Ensure the change of scrollbar causes a layout to |
| 99 // recalculate the page width with the vertical scrollbar added. | 99 // recalculate the page width with the vertical scrollbar added. |
| 100 MainFrame().ExecuteScript(WebScriptSource( | 100 MainFrame().ExecuteScript(WebScriptSource( |
| 101 "document.getElementById('box').className = 'box transformed';")); | 101 "document.getElementById('box').className = 'box transformed';")); |
| 102 Compositor().BeginFrame(); | 102 Compositor().BeginFrame(); |
| 103 | 103 |
| 104 ASSERT_TRUE(layout_viewport->VerticalScrollbar()); | 104 ASSERT_TRUE(layout_viewport->VerticalScrollbar()); |
| 105 ASSERT_FALSE(layout_viewport->HorizontalScrollbar()); | 105 ASSERT_FALSE(layout_viewport->HorizontalScrollbar()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 TEST_F(ScrollbarsTest, TransparentBackgroundUsesDarkOverlayColorTheme) { |
| 109 // The bug reproduces only with RLS off. When RLS ships we can keep the test |
| 110 // but remove this setting. |
| 111 ScopedRootLayerScrollingForTest turn_off_root_layer_scrolling(false); |
| 112 |
| 113 // This test is specifically checking the behavior when overlay scrollbars |
| 114 // are enabled. |
| 115 DCHECK(ScrollbarTheme::GetTheme().UsesOverlayScrollbars()); |
| 116 |
| 117 WebView().Resize(WebSize(800, 600)); |
| 118 WebView().SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 119 SimRequest request("https://example.com/test.html", "text/html"); |
| 120 LoadURL("https://example.com/test.html"); |
| 121 request.Complete( |
| 122 "<!DOCTYPE html>" |
| 123 "<style>" |
| 124 " body{" |
| 125 " height: 300%;" |
| 126 " }" |
| 127 "</style>"); |
| 128 Compositor().BeginFrame(); |
| 129 |
| 130 ScrollableArea* layout_viewport = |
| 131 GetDocument().View()->LayoutViewportScrollableArea(); |
| 132 |
| 133 EXPECT_EQ(kScrollbarOverlayColorThemeDark, |
| 134 layout_viewport->GetScrollbarOverlayColorTheme()); |
| 135 } |
| 136 |
| 108 typedef bool TestParamOverlayScrollbar; | 137 typedef bool TestParamOverlayScrollbar; |
| 109 class ScrollbarAppearanceTest | 138 class ScrollbarAppearanceTest |
| 110 : public SimTest, | 139 : public SimTest, |
| 111 public ::testing::WithParamInterface<TestParamOverlayScrollbar> { | 140 public ::testing::WithParamInterface<TestParamOverlayScrollbar> { |
| 112 public: | 141 public: |
| 113 // Use real scrollbars to ensure we're testing the real ScrollbarThemes. | 142 // Use real scrollbars to ensure we're testing the real ScrollbarThemes. |
| 114 ScrollbarAppearanceTest() : mock_scrollbars_(false, GetParam()) {} | 143 ScrollbarAppearanceTest() : mock_scrollbars_(false, GetParam()) {} |
| 115 | 144 |
| 116 private: | 145 private: |
| 117 FrameTestHelpers::UseMockScrollbarSettings mock_scrollbars_; | 146 FrameTestHelpers::UseMockScrollbarSettings mock_scrollbars_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 EXPECT_EQ(StubWebThemeEngine::kMinimumHorizontalLength, | 200 EXPECT_EQ(StubWebThemeEngine::kMinimumHorizontalLength, |
| 172 theme.ThumbLength(*scrollable_area->HorizontalScrollbar())); | 201 theme.ThumbLength(*scrollable_area->HorizontalScrollbar())); |
| 173 EXPECT_EQ(StubWebThemeEngine::kMinimumVerticalLength, | 202 EXPECT_EQ(StubWebThemeEngine::kMinimumVerticalLength, |
| 174 theme.ThumbLength(*scrollable_area->VerticalScrollbar())); | 203 theme.ThumbLength(*scrollable_area->VerticalScrollbar())); |
| 175 } | 204 } |
| 176 #endif | 205 #endif |
| 177 | 206 |
| 178 } // namespace | 207 } // namespace |
| 179 | 208 |
| 180 } // namespace blink | 209 } // namespace blink |
| OLD | NEW |