OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); | 1310 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); |
1311 | 1311 |
1312 // Two flags PinchVirtualViewportEnabled and ForceZeroLayoutHeight will caus
e the following | 1312 // Two flags PinchVirtualViewportEnabled and ForceZeroLayoutHeight will caus
e the following |
1313 // resize of viewport height to be ignored by the outer viewport (the contai
ner layer of | 1313 // resize of viewport height to be ignored by the outer viewport (the contai
ner layer of |
1314 // LayerCompositor). The height of the pinchViewport, however, is not affect
ed. | 1314 // LayerCompositor). The height of the pinchViewport, however, is not affect
ed. |
1315 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1315 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1316 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need
sLayout()); | 1316 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need
sLayout()); |
1317 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); | 1317 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); |
1318 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); | 1318 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); |
1319 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); | 1319 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); |
1320 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); | |
1321 | 1320 |
1322 LocalFrame* frame = webViewHelper.webViewImpl()->mainFrameImpl()->frame(); | 1321 LocalFrame* frame = webViewHelper.webViewImpl()->mainFrameImpl()->frame(); |
1323 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); | 1322 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); |
1324 EXPECT_EQ(viewportHeight, pinchViewport.containerLayer()->size().height()); | 1323 EXPECT_EQ(viewportHeight, pinchViewport.containerLayer()->size().height()); |
1325 EXPECT_TRUE(pinchViewport.containerLayer()->platformLayer()->masksToBounds()
); | 1324 EXPECT_TRUE(pinchViewport.containerLayer()->platformLayer()->masksToBounds()
); |
1326 EXPECT_FALSE(compositor->containerLayer()->platformLayer()->masksToBounds())
; | 1325 EXPECT_FALSE(compositor->containerLayer()->platformLayer()->masksToBounds())
; |
1327 } | 1326 } |
1328 | 1327 |
1329 TEST_F(WebFrameTest, SetForceZeroLayoutHeight) | 1328 TEST_F(WebFrameTest, SetForceZeroLayoutHeight) |
1330 { | 1329 { |
(...skipping 22 matching lines...) Expand all Loading... |
1353 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); | 1352 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); |
1354 | 1353 |
1355 webViewHelper.webView()->resize(WebSize(viewportWidth * 2, viewportHeight)); | 1354 webViewHelper.webView()->resize(WebSize(viewportWidth * 2, viewportHeight)); |
1356 webViewHelper.webView()->layout(); | 1355 webViewHelper.webView()->layout(); |
1357 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); | 1356 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); |
1358 | 1357 |
1359 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false); | 1358 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false); |
1360 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram
eView()->layoutSize().height()); | 1359 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram
eView()->layoutSize().height()); |
1361 } | 1360 } |
1362 | 1361 |
| 1362 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged
) |
| 1363 { |
| 1364 // this unit test is an attempt to target a real world case where an app cou
ld |
| 1365 // 1. call resize(width, 0) and setForceZeroLayoutHeight(true) |
| 1366 // 2. load content (hoping that the viewport height would increase |
| 1367 // as more content is added) |
| 1368 // 3. fail to register touch events aimed at the loaded content |
| 1369 // because the layout is only updated if either width or height is changed |
| 1370 UseMockScrollbarSettings mockScrollbarSettings; |
| 1371 registerMockedHttpURLLoad("button.html"); |
| 1372 |
| 1373 FixedLayoutTestWebViewClient client; |
| 1374 client.m_screenInfo.deviceScaleFactor = 1; |
| 1375 int viewportWidth = 640; |
| 1376 int viewportHeight = 480; |
| 1377 |
| 1378 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1379 |
| 1380 webViewHelper.initializeAndLoad(m_baseURL + "button.html", true, 0, &client,
configurePinchVirtualViewport); |
| 1381 // set view height to zero so that if the height of the view is not |
| 1382 // successfully updated during later resizes touch events will fail |
| 1383 // (as in not hit content included in the view) |
| 1384 webViewHelper.webView()->resize(WebSize(viewportWidth, 0)); |
| 1385 webViewHelper.webView()->layout(); |
| 1386 |
| 1387 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); |
| 1388 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); |
| 1389 |
| 1390 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1391 |
| 1392 IntPoint hitPoint = IntPoint(30, 30); // button size is 100x100 |
| 1393 |
| 1394 String id("tap_button"); |
| 1395 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele
ment>>(webViewHelper.webView()->mainFrame()->document().getElementById(id)); |
| 1396 EXPECT_NE(nullptr, element); |
| 1397 |
| 1398 if (element) { |
| 1399 EXPECT_EQ(String("oldValue"), element->innerText()); |
| 1400 |
| 1401 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPo
int, hitPoint, IntSize(0, 0), 0, false, false, false, false, 0.0, 0.0, 0.0, 0.0,
false); |
| 1402 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().ha
ndleGestureEvent(gestureEvent); |
| 1403 // when pressed, the button changes its own text to "updatedValue" |
| 1404 EXPECT_EQ(String("updatedValue"), element->innerText()); |
| 1405 } |
| 1406 } |
| 1407 |
1363 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations) | 1408 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations) |
1364 { | 1409 { |
1365 UseMockScrollbarSettings mockScrollbarSettings; | 1410 UseMockScrollbarSettings mockScrollbarSettings; |
1366 registerMockedHttpURLLoad("200-by-300.html"); | 1411 registerMockedHttpURLLoad("200-by-300.html"); |
1367 registerMockedHttpURLLoad("large-div.html"); | 1412 registerMockedHttpURLLoad("large-div.html"); |
1368 | 1413 |
1369 FixedLayoutTestWebViewClient client; | 1414 FixedLayoutTestWebViewClient client; |
1370 client.m_screenInfo.deviceScaleFactor = 1; | 1415 client.m_screenInfo.deviceScaleFactor = 1; |
1371 int viewportWidth = 640; | 1416 int viewportWidth = 640; |
1372 int viewportHeight = 480; | 1417 int viewportHeight = 480; |
(...skipping 5691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7064 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7109 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
7065 | 7110 |
7066 // Neither should a page reload. | 7111 // Neither should a page reload. |
7067 localFrame->reload(); | 7112 localFrame->reload(); |
7068 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 7113 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
7069 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 7114 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
7070 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7115 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
7071 } | 7116 } |
7072 | 7117 |
7073 } // namespace | 7118 } // namespace |
OLD | NEW |