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

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

Issue 382543003: Add a force-layout-height-to-zero layout mode to WebViewImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: make it a setting Created 6 years, 5 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
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 8bdd4513fa124eaef83320487080146863deb82d..9e2e0ff81cbff4568c8a518e5a163a37ea5279e8 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -1371,6 +1371,40 @@ TEST_F(WebFrameTest, WideViewportInitialScaleDoesNotExpandFixedLayoutWidth)
EXPECT_EQ(0.5f, webViewHelper.webView()->pageScaleFactor());
}
+TEST_F(WebFrameTest, SetForceZeroLayoutHeight)
+{
+ UseMockScrollbarSettings mockScrollbarSettings;
+ registerMockedHttpURLLoad("200-by-300.html");
+
+ FixedLayoutTestWebViewClient client;
+ client.m_screenInfo.deviceScaleFactor = 1;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+
+ FrameTestHelpers::WebViewHelper webViewHelper;
+
+ webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, 0, &client, enableViewportSettings);
+ webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
+ webViewHelper.webView()->layout();
+
+ EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
+ webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
+ EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needsLayout());
+
+ EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
+
+ webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight * 2));
+ EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needsLayout());
+ EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
+
+ webViewHelper.webView()->resize(WebSize(viewportWidth * 2, viewportHeight));
+ webViewHelper.webView()->layout();
+ EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
+
+ webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false);
+ EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
+}
+
TEST_F(WebFrameTest, WideViewportAndWideContentWithInitialScale)
{
UseMockScrollbarSettings mockScrollbarSettings;

Powered by Google App Engine
This is Rietveld 408576698