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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
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/layout/LayoutView.h" 6 #include "core/layout/LayoutView.h"
6 #include "core/paint/PaintLayerScrollableArea.h" 7 #include "core/paint/PaintLayerScrollableArea.h"
7 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
9 #include "platform/testing/TestingPlatformSupport.h"
8 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
11 #include "public/platform/WebThemeEngine.h"
9 #include "public/web/WebScriptSource.h" 12 #include "public/web/WebScriptSource.h"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 #include "web/WebLocalFrameImpl.h" 14 #include "web/WebLocalFrameImpl.h"
12 #include "web/tests/sim/SimDisplayItemList.h" 15 #include "web/tests/sim/SimDisplayItemList.h"
13 #include "web/tests/sim/SimRequest.h" 16 #include "web/tests/sim/SimRequest.h"
14 #include "web/tests/sim/SimTest.h" 17 #include "web/tests/sim/SimTest.h"
15 18
16 namespace blink { 19 namespace blink {
17 20
18 namespace { 21 namespace {
(...skipping 16 matching lines...) Expand all
35 38
36 // Forces recalc of LayoutView's computed style in Document::updateStyle, 39 // Forces recalc of LayoutView's computed style in Document::updateStyle,
37 // without invalidating layout. 40 // without invalidating layout.
38 mainFrame().executeScriptAndReturnValue(WebScriptSource( 41 mainFrame().executeScriptAndReturnValue(WebScriptSource(
39 "document.querySelector('style').sheet.insertRule('body {}', 1);")); 42 "document.querySelector('style').sheet.insertRule('body {}', 1);"));
40 43
41 compositor().beginFrame(); 44 compositor().beginFrame();
42 ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar()); 45 ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar());
43 } 46 }
44 47
48 typedef bool TestParamOverlayScrollbar;
49 class ScrollbarAppearanceTest
50 : public SimTest,
51 public ::testing::WithParamInterface<TestParamOverlayScrollbar> {
52 public:
53 // Use real scrollbars to ensure we're testing the real ScrollbarThemes.
54 ScrollbarAppearanceTest() : m_mockScrollbars(false, GetParam()) {}
55
56 private:
57 FrameTestHelpers::UseMockScrollbarSettings m_mockScrollbars;
58 };
59
60 class StubWebThemeEngine : public WebThemeEngine {
61 public:
62 WebSize getSize(Part part) override {
63 switch (part) {
64 case PartScrollbarHorizontalThumb:
65 return blink::WebSize(kMinimumHorizontalLength, 15);
66 case PartScrollbarVerticalThumb:
67 return blink::WebSize(15, kMinimumVerticalLength);
68 default:
69 return WebSize();
70 }
71 }
72 static constexpr int kMinimumHorizontalLength = 51;
73 static constexpr int kMinimumVerticalLength = 52;
74 };
75
76 constexpr int StubWebThemeEngine::kMinimumHorizontalLength;
77 constexpr int StubWebThemeEngine::kMinimumVerticalLength;
78
79 class ScrollbarTestingPlatformSupport : public TestingPlatformSupport {
80 public:
81 WebThemeEngine* themeEngine() override { return &m_stubThemeEngine; }
82
83 private:
84 StubWebThemeEngine m_stubThemeEngine;
85 };
86
87 // Test both overlay and non-overlay scrollbars.
88 INSTANTIATE_TEST_CASE_P(All, ScrollbarAppearanceTest, ::testing::Bool());
89
90 #if !OS(MACOSX)
91 // Ensure that the minimum length for a scrollbar thumb comes from the
92 // WebThemeEngine. Note, Mac scrollbars differ from all other platforms so this
93 // test doesn't apply there. https://crbug.com/682209.
94 TEST_P(ScrollbarAppearanceTest, ThemeEngineDefinesMinimumThumbLength) {
95 ScopedTestingPlatformSupport<ScrollbarTestingPlatformSupport> platform;
96
97 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
98 webView().resize(WebSize(800, 600));
99 SimRequest request("https://example.com/test.html", "text/html");
100 loadURL("https://example.com/test.html");
101 request.complete(
102 "<style> body { width: 1000000px; height: 1000000px; } </style>");
103 ScrollableArea* scrollableArea =
104 document().view()->layoutViewportScrollableArea();
105
106 compositor().beginFrame();
107 ASSERT_TRUE(scrollableArea->verticalScrollbar());
108 ASSERT_TRUE(scrollableArea->horizontalScrollbar());
109
110 ScrollbarTheme& theme = scrollableArea->verticalScrollbar()->theme();
111 EXPECT_EQ(StubWebThemeEngine::kMinimumHorizontalLength,
112 theme.thumbLength(*scrollableArea->horizontalScrollbar()));
113 EXPECT_EQ(StubWebThemeEngine::kMinimumVerticalLength,
114 theme.thumbLength(*scrollableArea->verticalScrollbar()));
115 }
116 #endif
117
45 } // namespace 118 } // namespace
46 119
47 } // namespace blink 120 } // namespace blink
OLDNEW
« 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