Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp

Issue 2734483002: Reland Change minimum length of Aura overlay scrollbars. (Closed)
Patch Set: Fix breakage on Android Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.h ('k') | ui/native_theme/native_theme_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a97e23189a1e5c67ac13a5393abe715013f503f2 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,76 @@ 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());
+
+#if !OS(MACOSX)
+// 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.
+TEST_P(ScrollbarAppearanceTest, ThemeEngineDefinesMinimumThumbLength) {
+ 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()));
+}
+#endif
+
} // namespace
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.h ('k') | ui/native_theme/native_theme_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698