Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp b/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp |
| index eee9d25621738eb0c628ed40bede8ff32fd0bc23..506287a61fbffa0d44f0dcd1c8501b9a8aac96ba 100644 |
| --- a/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp |
| @@ -2,10 +2,13 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "core/frame/FrameView.h" |
| #include "core/layout/LayoutView.h" |
| #include "core/paint/PaintLayerScrollableArea.h" |
| #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| +#include "platform/testing/TestingPlatformSupport.h" |
| #include "platform/testing/UnitTestHelpers.h" |
| +#include "public/platform/WebThemeEngine.h" |
| #include "public/web/WebScriptSource.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "web/WebLocalFrameImpl.h" |
| @@ -42,6 +45,78 @@ TEST_F(ScrollbarsTest, DocumentStyleRecalcPreservesScrollbars) { |
| ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar()); |
| } |
| +typedef bool TestParamOverlayScrollbar; |
| +class ScrollbarAppearanceTest |
| + : public SimTest, |
| + public ::testing::WithParamInterface<TestParamOverlayScrollbar> { |
| + public: |
| + // Use real scrollbars to ensure we're testing the real ScrollbarThemes. |
| + ScrollbarAppearanceTest() : m_mockScrollbars(false, GetParam()) {} |
| + |
| + private: |
| + FrameTestHelpers::UseMockScrollbarSettings m_mockScrollbars; |
| +}; |
| + |
| +class StubWebThemeEngine : public WebThemeEngine { |
| + public: |
| + WebSize getSize(Part part) override { |
| + switch (part) { |
| + case PartScrollbarHorizontalThumb: |
| + return blink::WebSize(kMinimumHorizontalLength, 15); |
| + case PartScrollbarVerticalThumb: |
| + return blink::WebSize(15, kMinimumVerticalLength); |
| + default: |
| + return WebSize(); |
| + } |
| + } |
| + static constexpr int kMinimumHorizontalLength = 51; |
| + static constexpr int kMinimumVerticalLength = 52; |
| +}; |
| + |
| +constexpr int StubWebThemeEngine::kMinimumHorizontalLength; |
| +constexpr int StubWebThemeEngine::kMinimumVerticalLength; |
| + |
| +class ScrollbarTestingPlatformSupport : public TestingPlatformSupport { |
| + public: |
| + WebThemeEngine* themeEngine() override { return &m_stubThemeEngine; } |
| + |
| + private: |
| + StubWebThemeEngine m_stubThemeEngine; |
| +}; |
| + |
| +// Test both overlay and non-overlay scrollbars. |
| +INSTANTIATE_TEST_CASE_P(All, ScrollbarAppearanceTest, ::testing::Bool()); |
| + |
| +// Ensure that the minimum length for a scrollbar thumb comes from the |
| +// WebThemeEngine. Note, Mac scrollbars differ from all other platforms so this |
| +// test doesn't apply there. https://crbug.com/682209. |
| +#if OS(MACOSX) |
| +TEST_P(ScrollbarAppearanceTest, DISABLED_ThemeEngineDefinesMinimumThumbLength) { |
|
Evan Stade
2017/03/28 00:11:36
nit: use MAYBE_TestName pattern? Or just wrap enti
bokan
2017/03/28 13:58:37
I'd tried the MAYBE() macro but it looks like TEST
Evan Stade
2017/03/28 15:33:30
#if OS(MACOSX)
#define MAYBE_TestName DISABLED_Tes
|
| +#else |
| +TEST_P(ScrollbarAppearanceTest, ThemeEngineDefinesMinimumThumbLength) { |
| +#endif |
| + ScopedTestingPlatformSupport<ScrollbarTestingPlatformSupport> platform; |
| + |
| + v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| + webView().resize(WebSize(800, 600)); |
| + SimRequest request("https://example.com/test.html", "text/html"); |
| + loadURL("https://example.com/test.html"); |
| + request.complete( |
| + "<style> body { width: 1000000px; height: 1000000px; } </style>"); |
| + ScrollableArea* scrollableArea = |
| + document().view()->layoutViewportScrollableArea(); |
| + |
| + compositor().beginFrame(); |
| + ASSERT_TRUE(scrollableArea->verticalScrollbar()); |
| + ASSERT_TRUE(scrollableArea->horizontalScrollbar()); |
| + |
| + ScrollbarTheme& theme = scrollableArea->verticalScrollbar()->theme(); |
| + EXPECT_EQ(StubWebThemeEngine::kMinimumHorizontalLength, |
| + theme.thumbLength(*scrollableArea->horizontalScrollbar())); |
| + EXPECT_EQ(StubWebThemeEngine::kMinimumVerticalLength, |
| + theme.thumbLength(*scrollableArea->verticalScrollbar())); |
| +} |
| + |
| } // namespace |
| } // namespace blink |