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

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

Issue 911083002: Carry out a resize even if no layout has been performed. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Minor changes in unit test Created 5 years, 10 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 | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/button.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 10f7ab0730c4990b04f9c1d84b56298d99e64d4f..cc5fada099ea00aafbd38cb5d6a5b419b2ca2db7 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -1317,7 +1317,7 @@ TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithWrapContentsMode)
EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width());
EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width());
- EXPECT_EQ(0.0, compositor->containerLayer()->size().height());
+ EXPECT_EQ(viewportHeight, compositor->containerLayer()->size().height());
LocalFrame* frame = webViewHelper.webViewImpl()->mainFrameImpl()->frame();
PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport();
@@ -1360,6 +1360,49 @@ TEST_F(WebFrameTest, SetForceZeroLayoutHeight)
EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
}
+TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged)
+{
+ // this unit test is an attempt to target a real world case where an app could
+ // 1. call resize(width, 0) and setForceZeroLayoutHeight(true)
+ // 2. load content (hoping that the viewport height would increase
+ // as more content is added)
+ // 3. fail to register touch events aimed at the loaded content
+ // because the layout is only updated if either width or height is changed
+ UseMockScrollbarSettings mockScrollbarSettings;
+ registerMockedHttpURLLoad("button.html");
+
+ FixedLayoutTestWebViewClient client;
+ client.m_screenInfo.deviceScaleFactor = 1;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+
+ FrameTestHelpers::WebViewHelper webViewHelper;
+
+ webViewHelper.initializeAndLoad(m_baseURL + "button.html", true, 0, &client, configurePinchVirtualViewport);
+ // set view height to zero so that if the height of the view is not
+ // successfully updated during later resizes touch events will fail
+ // (as in not hit content included in the view)
+ webViewHelper.webView()->resize(WebSize(viewportWidth, 0));
+ webViewHelper.webView()->layout();
+
+ webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
+ webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
+
+ IntPoint hitPoint = IntPoint(30, 30); // button size is 100x100
+
+ WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame());
+ Document* document = frame->frame()->document();
+ Element* element = document->getElementById("tap_button");
+
+ ASSERT_NE(nullptr, element);
+ EXPECT_EQ(String("oldValue"), element->innerText());
+
+ PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, false, false, false, false, 0.0, 0.0, 0.0, 0.0, false);
+ webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handleGestureEvent(gestureEvent);
+ // when pressed, the button changes its own text to "updatedValue"
+ EXPECT_EQ(String("updatedValue"), element->innerText());
+}
+
TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations)
{
UseMockScrollbarSettings mockScrollbarSettings;
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/button.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698