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

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

Issue 2467693002: Implement overlay scrollbar fade out for non-composited scrollers. (Closed)
Patch Set: sigh....git cl format Created 4 years, 1 month 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
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 2c1b85b20f51d313b5aa95ee4414c0f06d68cbc3..637306d061388c1c9d8a29824d64487e89cfa9e6 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -86,6 +86,7 @@
#include "platform/geometry/FloatRect.h"
#include "platform/network/ResourceError.h"
#include "platform/scroll/ScrollbarTheme.h"
+#include "platform/scroll/ScrollbarThemeOverlayMock.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/URLTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
@@ -10429,26 +10430,118 @@ TEST_F(WebFrameTest, HidingScrollbarsOnScrollableAreaDisablesScrollbars) {
ASSERT_TRUE(frameView->verticalScrollbar());
EXPECT_FALSE(frameView->scrollbarsHidden());
- EXPECT_TRUE(frameView->horizontalScrollbar()->enabled());
- EXPECT_TRUE(frameView->verticalScrollbar()->enabled());
+ EXPECT_TRUE(
+ frameView->horizontalScrollbar()->shouldParticipateInHitTesting());
+ EXPECT_TRUE(frameView->verticalScrollbar()->shouldParticipateInHitTesting());
EXPECT_FALSE(scrollerArea->scrollbarsHidden());
- EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled());
- EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled());
+ EXPECT_TRUE(
+ scrollerArea->horizontalScrollbar()->shouldParticipateInHitTesting());
+ EXPECT_TRUE(
+ scrollerArea->verticalScrollbar()->shouldParticipateInHitTesting());
frameView->setScrollbarsHidden(true);
- EXPECT_FALSE(frameView->horizontalScrollbar()->enabled());
- EXPECT_FALSE(frameView->verticalScrollbar()->enabled());
+ EXPECT_FALSE(
+ frameView->horizontalScrollbar()->shouldParticipateInHitTesting());
+ EXPECT_FALSE(frameView->verticalScrollbar()->shouldParticipateInHitTesting());
frameView->setScrollbarsHidden(false);
- EXPECT_TRUE(frameView->horizontalScrollbar()->enabled());
- EXPECT_TRUE(frameView->verticalScrollbar()->enabled());
+ EXPECT_TRUE(
+ frameView->horizontalScrollbar()->shouldParticipateInHitTesting());
+ EXPECT_TRUE(frameView->verticalScrollbar()->shouldParticipateInHitTesting());
scrollerArea->setScrollbarsHidden(true);
- EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled());
- EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled());
+ EXPECT_FALSE(
+ scrollerArea->horizontalScrollbar()->shouldParticipateInHitTesting());
+ EXPECT_FALSE(
+ scrollerArea->verticalScrollbar()->shouldParticipateInHitTesting());
scrollerArea->setScrollbarsHidden(false);
- EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled());
- EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled());
+ EXPECT_TRUE(
+ scrollerArea->horizontalScrollbar()->shouldParticipateInHitTesting());
+ EXPECT_TRUE(
+ scrollerArea->verticalScrollbar()->shouldParticipateInHitTesting());
+}
+
+static void disableCompositing(WebSettings* settings) {
+ settings->setAcceleratedCompositingEnabled(false);
+ settings->setPreferCompositingToLCDTextEnabled(false);
+}
+
+// Make sure overlay scrollbars on non-composited scrollers fade out and set
+// the hidden bit as needed.
+TEST_F(WebFrameTest, TestNonCompositedOverlayScrollbarsFade) {
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ WebViewImpl* webViewImpl = webViewHelper.initialize(
+ true, nullptr, nullptr, nullptr, &disableCompositing);
+
+ constexpr double kMockOverlayFadeOutDelayMs = 5.0;
+
+ ScrollbarTheme& theme = ScrollbarTheme::theme();
+ // This test relies on mock overlay scrollbars.
+ ASSERT_TRUE(theme.isMockTheme());
+ ASSERT_TRUE(theme.usesOverlayScrollbars());
+ ScrollbarThemeOverlayMock& mockOverlayTheme =
+ (ScrollbarThemeOverlayMock&)theme;
+ mockOverlayTheme.setOverlayScrollbarFadeOutDelay(kMockOverlayFadeOutDelayMs /
+ 1000.0);
+
+ webViewImpl->resizeWithBrowserControls(WebSize(640, 480), 0, false);
+
+ WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
+ FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
+ "<!DOCTYPE html>"
+ "<style>"
+ " #space {"
+ " width: 1000px;"
+ " height: 1000px;"
+ " }"
+ " #container {"
+ " width: 200px;"
+ " height: 200px;"
+ " overflow: scroll;"
+ " }"
+ " div { height:1000px; width: 200px; }"
+ "</style>"
+ "<div id='container'>"
+ " <div id='space'></div>"
+ "</div>",
+ baseURL);
+ webViewImpl->updateAllLifecyclePhases();
+
+ WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
+ Document* document =
+ toLocalFrame(webViewImpl->page()->mainFrame())->document();
+ Element* container = document->getElementById("container");
+ ScrollableArea* scrollableArea =
+ toLayoutBox(container->layoutObject())->getScrollableArea();
+
+ EXPECT_FALSE(scrollableArea->scrollbarsHidden());
+ testing::runDelayedTasks(kMockOverlayFadeOutDelayMs);
+ EXPECT_TRUE(scrollableArea->scrollbarsHidden());
+
+ scrollableArea->setScrollOffset(ScrollOffset(10, 10), ProgrammaticScroll,
+ ScrollBehaviorInstant);
+
+ EXPECT_FALSE(scrollableArea->scrollbarsHidden());
+ testing::runDelayedTasks(kMockOverlayFadeOutDelayMs);
+ EXPECT_TRUE(scrollableArea->scrollbarsHidden());
+
+ frame->executeScript(WebScriptSource(
+ "document.getElementById('space').style.height = '500px';"));
+ frame->view()->updateAllLifecyclePhases();
+
+ EXPECT_FALSE(scrollableArea->scrollbarsHidden());
+ testing::runDelayedTasks(kMockOverlayFadeOutDelayMs);
+ EXPECT_TRUE(scrollableArea->scrollbarsHidden());
+
+ frame->executeScript(WebScriptSource(
+ "document.getElementById('container').style.height = '300px';"));
+ frame->view()->updateAllLifecyclePhases();
+
+ EXPECT_FALSE(scrollableArea->scrollbarsHidden());
+ testing::runDelayedTasks(kMockOverlayFadeOutDelayMs);
+ EXPECT_TRUE(scrollableArea->scrollbarsHidden());
+
+ mockOverlayTheme.setOverlayScrollbarFadeOutDelay(0.0);
}
TEST_F(WebFrameTest, UniqueNames) {

Powered by Google App Engine
This is Rietveld 408576698