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

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 test disable on Mac and implement getSize 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 // Ensure that the minimum length for a scrollbar thumb comes from the
91 // WebThemeEngine. Note, Mac scrollbars differ from all other platforms so this
92 // test doesn't apply there. https://crbug.com/682209.
93 #if OS(MACOSX)
94 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
95 #else
96 TEST_P(ScrollbarAppearanceTest, ThemeEngineDefinesMinimumThumbLength) {
97 #endif
98 ScopedTestingPlatformSupport<ScrollbarTestingPlatformSupport> platform;
99
100 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
101 webView().resize(WebSize(800, 600));
102 SimRequest request("https://example.com/test.html", "text/html");
103 loadURL("https://example.com/test.html");
104 request.complete(
105 "<style> body { width: 1000000px; height: 1000000px; } </style>");
106 ScrollableArea* scrollableArea =
107 document().view()->layoutViewportScrollableArea();
108
109 compositor().beginFrame();
110 ASSERT_TRUE(scrollableArea->verticalScrollbar());
111 ASSERT_TRUE(scrollableArea->horizontalScrollbar());
112
113 ScrollbarTheme& theme = scrollableArea->verticalScrollbar()->theme();
114 EXPECT_EQ(StubWebThemeEngine::kMinimumHorizontalLength,
115 theme.thumbLength(*scrollableArea->horizontalScrollbar()));
116 EXPECT_EQ(StubWebThemeEngine::kMinimumVerticalLength,
117 theme.thumbLength(*scrollableArea->verticalScrollbar()));
118 }
119
45 } // namespace 120 } // namespace
46 121
47 } // namespace blink 122 } // 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