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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); | 161 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); |
162 document->ensureStyleResolver().viewportStyleResolver()->resolve(); | 162 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
163 } | 163 } |
164 | 164 |
165 static void configueCompositingWebView(WebSettings* settings) | 165 static void configueCompositingWebView(WebSettings* settings) |
166 { | 166 { |
167 settings->setAcceleratedCompositingEnabled(true); | 167 settings->setAcceleratedCompositingEnabled(true); |
168 settings->setPreferCompositingToLCDTextEnabled(true); | 168 settings->setPreferCompositingToLCDTextEnabled(true); |
169 } | 169 } |
170 | 170 |
| 171 static void configurePinchVirtualViewport(WebSettings* settings) |
| 172 { |
| 173 settings->setPinchVirtualViewportEnabled(true); |
| 174 settings->setViewportMetaEnabled(true); |
| 175 settings->setViewportEnabled(true); |
| 176 settings->setMainFrameResizesAreOrientationChanges(true); |
| 177 settings->setShrinksViewportContentToFit(true); |
| 178 } |
| 179 |
171 static void configureLoadsImagesAutomatically(WebSettings* settings) | 180 static void configureLoadsImagesAutomatically(WebSettings* settings) |
172 { | 181 { |
173 settings->setLoadsImagesAutomatically(true); | 182 settings->setLoadsImagesAutomatically(true); |
174 } | 183 } |
175 | 184 |
176 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) | 185 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) |
177 { | 186 { |
178 webViewHelper->initializeAndLoad(url, true); | 187 webViewHelper->initializeAndLoad(url, true); |
179 webViewHelper->webView()->settings()->setDefaultFontSize(12); | 188 webViewHelper->webView()->settings()->setDefaultFontSize(12); |
180 webViewHelper->webView()->resize(WebSize(640, 480)); | 189 webViewHelper->webView()->resize(WebSize(640, 480)); |
(...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2307 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
2299 } | 2308 } |
2300 | 2309 |
2301 void setScaleAndScrollAndLayout(WebView* webView, WebPoint scroll, float scale) | 2310 void setScaleAndScrollAndLayout(WebView* webView, WebPoint scroll, float scale) |
2302 { | 2311 { |
2303 webView->setPageScaleFactor(scale); | 2312 webView->setPageScaleFactor(scale); |
2304 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); | 2313 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); |
2305 webView->layout(); | 2314 webView->layout(); |
2306 } | 2315 } |
2307 | 2316 |
2308 TEST_F(WebFrameTest, DivAutoZoomParamsTest) | 2317 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
| 2318 { |
| 2319 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
| 2320 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
| 2321 webViewImpl->applyViewportDeltas(scrollDelta, scaleDelta, 0); |
| 2322 scale = webViewImpl->pageScaleFactor(); |
| 2323 } |
| 2324 |
| 2325 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) |
| 2326 { |
| 2327 if (webViewImpl->zoomToMultipleTargetsRect(rect)) |
| 2328 simulatePageScale(webViewImpl, scale); |
| 2329 } |
| 2330 |
| 2331 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) |
| 2332 { |
| 2333 webViewImpl->animateDoubleTapZoom(point); |
| 2334 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); |
| 2335 simulatePageScale(webViewImpl, scale); |
| 2336 } |
| 2337 |
| 2338 // ======= |
| 2339 |
| 2340 TEST_F(WebFrameTest, DivAutoZoomParamsTest_VirtualViewport) |
2309 { | 2341 { |
2310 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); | 2342 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
2311 | 2343 |
2312 const float deviceScaleFactor = 2.0f; | 2344 const float deviceScaleFactor = 2.0f; |
2313 int viewportWidth = 640 / deviceScaleFactor; | 2345 int viewportWidth = 640 / deviceScaleFactor; |
2314 int viewportHeight = 1280 / deviceScaleFactor; | 2346 int viewportHeight = 1280 / deviceScaleFactor; |
2315 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2347 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2316 FrameTestHelpers::WebViewHelper webViewHelper; | 2348 FrameTestHelpers::WebViewHelper webViewHelper; |
2317 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html"); | 2349 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html", false, 0, 0, configurePinchVirtualViewport); |
2318 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2350 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2319 webViewHelper.webView()->setPageScaleFactorLimits(0.01f, 4); | 2351 webViewHelper.webView()->setPageScaleFactorLimits(0.01f, 4); |
2320 webViewHelper.webView()->setPageScaleFactor(0.5f); | 2352 webViewHelper.webView()->setPageScaleFactor(0.5f); |
2321 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2353 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2322 webViewHelper.webView()->layout(); | 2354 webViewHelper.webView()->layout(); |
2323 | 2355 |
2324 WebRect wideDiv(200, 100, 400, 150); | 2356 WebRect wideDiv(200, 100, 400, 150); |
2325 WebRect tallDiv(200, 300, 400, 800); | 2357 WebRect tallDiv(200, 300, 400, 800); |
2326 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); | 2358 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); |
2327 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); | 2359 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); |
(...skipping 29 matching lines...) Expand all Loading... |
2357 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); | 2389 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); |
2358 EXPECT_NEAR(tallDiv.x, scroll.x, 20); | 2390 EXPECT_NEAR(tallDiv.x, scroll.x, 20); |
2359 EXPECT_NEAR(tallDiv.y, scroll.y, 20); | 2391 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
2360 | 2392 |
2361 // Test for Non-doubletap scaling | 2393 // Test for Non-doubletap scaling |
2362 // Test zooming into div. | 2394 // Test zooming into div. |
2363 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); | 2395 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); |
2364 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 2396 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
2365 } | 2397 } |
2366 | 2398 |
2367 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 2399 TEST_F(WebFrameTest, DivAutoZoomWideDivTest_VirtualViewport) |
2368 { | |
2369 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | |
2370 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | |
2371 webViewImpl->applyViewportDeltas(scrollDelta, scaleDelta, 0); | |
2372 scale = webViewImpl->pageScaleFactor(); | |
2373 } | |
2374 | |
2375 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) | |
2376 { | |
2377 if (webViewImpl->zoomToMultipleTargetsRect(rect)) | |
2378 simulatePageScale(webViewImpl, scale); | |
2379 } | |
2380 | |
2381 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) | |
2382 { | |
2383 webViewImpl->animateDoubleTapZoom(point); | |
2384 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); | |
2385 simulatePageScale(webViewImpl, scale); | |
2386 } | |
2387 | |
2388 TEST_F(WebFrameTest, DivAutoZoomWideDivTest) | |
2389 { | 2400 { |
2390 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); | 2401 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); |
2391 | 2402 |
| 2403 const float deviceScaleFactor = 2.0f; |
| 2404 int viewportWidth = 640 / deviceScaleFactor; |
| 2405 int viewportHeight = 1280 / deviceScaleFactor; |
| 2406 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2407 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2408 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html", false, 0, 0, configurePinchVirtualViewport); |
| 2409 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2410 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
| 2411 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2412 webViewHelper.webView()->setPageScaleFactor(1.0f); |
| 2413 webViewHelper.webView()->layout(); |
| 2414 |
| 2415 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2416 |
| 2417 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2418 |
| 2419 WebRect div(0, 100, viewportWidth, 150); |
| 2420 WebPoint point(div.x + 50, div.y + 50); |
| 2421 float scale; |
| 2422 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2423 |
| 2424 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
| 2425 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2426 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
| 2427 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2428 } |
| 2429 |
| 2430 TEST_F(WebFrameTest, DivAutoZoomVeryTallTest_VirtualViewport) |
| 2431 { |
| 2432 // When a block is taller than the viewport and a zoom targets a lower part |
| 2433 // of it, then we should keep the target point onscreen instead of snapping |
| 2434 // back up the top of the block. |
| 2435 registerMockedHttpURLLoad("very_tall_div.html"); |
| 2436 |
| 2437 const float deviceScaleFactor = 2.0f; |
| 2438 int viewportWidth = 640 / deviceScaleFactor; |
| 2439 int viewportHeight = 1280 / deviceScaleFactor; |
| 2440 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2441 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, 0, 0
, configurePinchVirtualViewport); |
| 2442 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2443 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
| 2444 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2445 webViewHelper.webView()->setPageScaleFactor(1.0f); |
| 2446 webViewHelper.webView()->layout(); |
| 2447 |
| 2448 WebRect div(200, 300, 400, 5000); |
| 2449 WebPoint point(div.x + 50, div.y + 3000); |
| 2450 float scale; |
| 2451 WebPoint scroll; |
| 2452 |
| 2453 WebRect blockBounds = webViewHelper.webViewImpl()->computeBlockBounds(WebRec
t(point.x, point.y, 0, 0), true); |
| 2454 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockB
ounds, 0, 1.0f, scale, scroll); |
| 2455 EXPECT_EQ(scale, 1.0f); |
| 2456 EXPECT_EQ(scroll.y, 2660); |
| 2457 } |
| 2458 |
| 2459 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest_VirtualViewport) |
| 2460 { |
| 2461 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
| 2462 |
| 2463 const float deviceScaleFactor = 2.0f; |
| 2464 int viewportWidth = 640 / deviceScaleFactor; |
| 2465 int viewportHeight = 1280 / deviceScaleFactor; |
| 2466 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2467 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2468 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html", false, 0, 0, configurePinchVirtualViewport); |
| 2469 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2470 webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); |
| 2471 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2472 webViewHelper.webView()->setPageScaleFactor(0.5f); |
| 2473 webViewHelper.webView()->layout(); |
| 2474 |
| 2475 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2476 |
| 2477 WebRect topDiv(200, 100, 200, 150); |
| 2478 WebRect bottomDiv(200, 300, 200, 150); |
| 2479 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); |
| 2480 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); |
| 2481 float scale; |
| 2482 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2483 |
| 2484 // Test double tap on two different divs |
| 2485 // After first zoom, we should go back to minimum page scale with a second d
ouble tap. |
| 2486 simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); |
| 2487 EXPECT_FLOAT_EQ(1, scale); |
| 2488 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2489 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2490 |
| 2491 // If the user pinch zooms after double tap, a second double tap should zoom
back to the div. |
| 2492 simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); |
| 2493 EXPECT_FLOAT_EQ(1, scale); |
| 2494 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 0.6f, 0); |
| 2495 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2496 EXPECT_FLOAT_EQ(1, scale); |
| 2497 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2498 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2499 |
| 2500 // If we didn't yet get an auto-zoom update and a second double-tap arrives,
should go back to minimum scale. |
| 2501 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2502 webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); |
| 2503 EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTes
ting()); |
| 2504 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2505 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2506 } |
| 2507 |
| 2508 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest_VirtualViewport) |
| 2509 { |
| 2510 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
| 2511 |
| 2512 int viewportWidth = 320; |
| 2513 int viewportHeight = 480; |
| 2514 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2515 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2516 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html", false, 0, 0, configurePinchVirtualViewport); |
| 2517 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2518 webViewHelper.webView()->setDeviceScaleFactor(1.5f); |
| 2519 webViewHelper.webView()->layout(); |
| 2520 |
| 2521 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2522 |
| 2523 WebRect div(200, 100, 200, 150); |
| 2524 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
| 2525 float scale; |
| 2526 |
| 2527 // Test double tap scale bounds. |
| 2528 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 |
| 2529 webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); |
| 2530 webViewHelper.webView()->layout(); |
| 2531 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2532 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2533 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2534 EXPECT_FLOAT_EQ(1, scale); |
| 2535 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2536 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2537 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2538 EXPECT_FLOAT_EQ(1, scale); |
| 2539 |
| 2540 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2541 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2542 // 1 < minimumPageScale < doubleTapZoomAlreadyLegibleScale |
| 2543 webViewHelper.webView()->setPageScaleFactorLimits(1.1f, 4); |
| 2544 webViewHelper.webView()->layout(); |
| 2545 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2546 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2547 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2548 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2549 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2550 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2551 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2552 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2553 |
| 2554 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2555 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2556 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale |
| 2557 webViewHelper.webView()->setPageScaleFactorLimits(0.95f, 4); |
| 2558 webViewHelper.webView()->layout(); |
| 2559 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2560 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2561 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2562 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2563 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2564 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2565 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2566 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2567 } |
| 2568 |
| 2569 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest_VirtualViewport) |
| 2570 { |
| 2571 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
| 2572 |
| 2573 int viewportWidth = 320; |
| 2574 int viewportHeight = 480; |
| 2575 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2576 float accessibilityFontScaleFactor = 1.13f; |
| 2577 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2578 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html", false, 0, 0, configurePinchVirtualViewport); |
| 2579 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2580 webViewHelper.webView()->layout(); |
| 2581 |
| 2582 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2583 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(tru
e); |
| 2584 webViewHelper.webViewImpl()->page()->settings().setAccessibilityFontScaleFac
tor(accessibilityFontScaleFactor); |
| 2585 |
| 2586 WebRect div(200, 100, 200, 150); |
| 2587 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
| 2588 float scale; |
| 2589 |
| 2590 // Test double tap scale bounds. |
| 2591 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < accessibilityFo
ntScaleFactor |
| 2592 float legibleScale = accessibilityFontScaleFactor; |
| 2593 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2594 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2595 webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); |
| 2596 webViewHelper.webView()->layout(); |
| 2597 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2598 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2599 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2600 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2601 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2602 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2603 |
| 2604 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2605 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2606 // 1 < accessibilityFontScaleFactor < minimumPageScale < doubleTapZoomAlread
yLegibleScale |
| 2607 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
| 2608 webViewHelper.webView()->layout(); |
| 2609 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2610 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2611 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2612 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2613 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2614 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2615 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2616 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2617 |
| 2618 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2619 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2620 // minimumPageScale < 1 < accessibilityFontScaleFactor < doubleTapZoomAlread
yLegibleScale |
| 2621 webViewHelper.webView()->setPageScaleFactorLimits(0.95f, 4); |
| 2622 webViewHelper.webView()->layout(); |
| 2623 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2624 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2625 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2626 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2627 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2628 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2629 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2630 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2631 |
| 2632 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2633 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2634 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < accessibilityFo
ntScaleFactor |
| 2635 webViewHelper.webView()->setPageScaleFactorLimits(0.9f, 4); |
| 2636 webViewHelper.webView()->layout(); |
| 2637 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2638 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2639 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2640 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2641 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2642 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2643 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2644 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2645 } |
| 2646 |
| 2647 // FIXME(bokan): The following tests marked with _OldPinch test AutoZoom |
| 2648 // without the pinch virtual viewport mode enabled. As this becomes the default |
| 2649 // and the old path is deprecated, these tests can be removed; they've been |
| 2650 // cloned above to use the new virtual viewport path. |
| 2651 |
| 2652 TEST_F(WebFrameTest, DivAutoZoomParamsTest_OldPinch) |
| 2653 { |
| 2654 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
| 2655 |
| 2656 const float deviceScaleFactor = 2.0f; |
| 2657 int viewportWidth = 640 / deviceScaleFactor; |
| 2658 int viewportHeight = 1280 / deviceScaleFactor; |
| 2659 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2660 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2661 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html"); |
| 2662 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2663 webViewHelper.webView()->setPageScaleFactorLimits(0.01f, 4); |
| 2664 webViewHelper.webView()->setPageScaleFactor(0.5f); |
| 2665 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2666 webViewHelper.webView()->layout(); |
| 2667 |
| 2668 WebRect wideDiv(200, 100, 400, 150); |
| 2669 WebRect tallDiv(200, 300, 400, 800); |
| 2670 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); |
| 2671 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); |
| 2672 WebRect wideBlockBounds; |
| 2673 WebRect tallBlockBounds; |
| 2674 float scale; |
| 2675 WebPoint scroll; |
| 2676 |
| 2677 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2678 |
| 2679 // Test double-tap zooming into wide div. |
| 2680 wideBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapP
ointWide, false); |
| 2681 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub
leTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, dou
bleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2682 // The div should horizontally fill the screen (modulo margins), and |
| 2683 // vertically centered (modulo integer rounding). |
| 2684 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
| 2685 EXPECT_NEAR(wideDiv.x, scroll.x, 20); |
| 2686 EXPECT_EQ(0, scroll.y); |
| 2687 |
| 2688 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); |
| 2689 |
| 2690 // Test zoom out back to minimum scale. |
| 2691 wideBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapP
ointWide, false); |
| 2692 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub
leTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, dou
bleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2693 |
| 2694 scale = webViewHelper.webViewImpl()->minimumPageScaleFactor(); |
| 2695 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), scal
e); |
| 2696 |
| 2697 // Test double-tap zooming into tall div. |
| 2698 tallBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapP
ointTall, false); |
| 2699 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub
leTapPointTall.x, doubleTapPointTall.y), tallBlockBounds, touchPointPadding, dou
bleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2700 // The div should start at the top left of the viewport. |
| 2701 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); |
| 2702 EXPECT_NEAR(tallDiv.x, scroll.x, 20); |
| 2703 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
| 2704 |
| 2705 // Test for Non-doubletap scaling |
| 2706 // Test zooming into div. |
| 2707 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2708 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
| 2709 } |
| 2710 |
| 2711 TEST_F(WebFrameTest, DivAutoZoomWideDivTest_OldPinch) |
| 2712 { |
| 2713 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); |
| 2714 |
2392 const float deviceScaleFactor = 2.0f; | 2715 const float deviceScaleFactor = 2.0f; |
2393 int viewportWidth = 640 / deviceScaleFactor; | 2716 int viewportWidth = 640 / deviceScaleFactor; |
2394 int viewportHeight = 1280 / deviceScaleFactor; | 2717 int viewportHeight = 1280 / deviceScaleFactor; |
2395 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2718 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2396 FrameTestHelpers::WebViewHelper webViewHelper; | 2719 FrameTestHelpers::WebViewHelper webViewHelper; |
2397 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html"); | 2720 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html"); |
2398 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2721 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2399 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); | 2722 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
2400 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2723 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2401 webViewHelper.webView()->setPageScaleFactor(1.0f); | 2724 webViewHelper.webView()->setPageScaleFactor(1.0f); |
2402 webViewHelper.webView()->layout(); | 2725 webViewHelper.webView()->layout(); |
2403 | 2726 |
2404 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 2727 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
2405 | 2728 |
2406 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; | 2729 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
2407 | 2730 |
2408 WebRect div(0, 100, viewportWidth, 150); | 2731 WebRect div(0, 100, viewportWidth, 150); |
2409 WebPoint point(div.x + 50, div.y + 50); | 2732 WebPoint point(div.x + 50, div.y + 50); |
2410 float scale; | 2733 float scale; |
2411 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); | 2734 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
2412 | 2735 |
2413 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); | 2736 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
2414 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 2737 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
2415 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); | 2738 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
2416 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2739 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2417 } | 2740 } |
2418 | 2741 |
2419 TEST_F(WebFrameTest, DivAutoZoomVeryTallTest) | 2742 TEST_F(WebFrameTest, DivAutoZoomVeryTallTest_OldPinch) |
2420 { | 2743 { |
2421 // When a block is taller than the viewport and a zoom targets a lower part | 2744 // When a block is taller than the viewport and a zoom targets a lower part |
2422 // of it, then we should keep the target point onscreen instead of snapping | 2745 // of it, then we should keep the target point onscreen instead of snapping |
2423 // back up the top of the block. | 2746 // back up the top of the block. |
2424 registerMockedHttpURLLoad("very_tall_div.html"); | 2747 registerMockedHttpURLLoad("very_tall_div.html"); |
2425 | 2748 |
2426 const float deviceScaleFactor = 2.0f; | 2749 const float deviceScaleFactor = 2.0f; |
2427 int viewportWidth = 640 / deviceScaleFactor; | 2750 int viewportWidth = 640 / deviceScaleFactor; |
2428 int viewportHeight = 1280 / deviceScaleFactor; | 2751 int viewportHeight = 1280 / deviceScaleFactor; |
2429 FrameTestHelpers::WebViewHelper webViewHelper; | 2752 FrameTestHelpers::WebViewHelper webViewHelper; |
2430 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, 0, 0
, enableViewportSettings); | 2753 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, 0, 0
, enableViewportSettings); |
2431 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2754 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2432 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); | 2755 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
2433 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2756 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2434 webViewHelper.webView()->setPageScaleFactor(1.0f); | 2757 webViewHelper.webView()->setPageScaleFactor(1.0f); |
2435 webViewHelper.webView()->layout(); | 2758 webViewHelper.webView()->layout(); |
2436 | 2759 |
2437 WebRect div(200, 300, 400, 5000); | 2760 WebRect div(200, 300, 400, 5000); |
2438 WebPoint point(div.x + 50, div.y + 3000); | 2761 WebPoint point(div.x + 50, div.y + 3000); |
2439 float scale; | 2762 float scale; |
2440 WebPoint scroll; | 2763 WebPoint scroll; |
2441 | 2764 |
2442 WebRect blockBounds = webViewHelper.webViewImpl()->computeBlockBounds(WebRec
t(point.x, point.y, 0, 0), true); | 2765 WebRect blockBounds = webViewHelper.webViewImpl()->computeBlockBounds(WebRec
t(point.x, point.y, 0, 0), true); |
2443 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockB
ounds, 0, 1.0f, scale, scroll); | 2766 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockB
ounds, 0, 1.0f, scale, scroll); |
2444 EXPECT_EQ(scale, 1.0f); | 2767 EXPECT_EQ(scale, 1.0f); |
2445 EXPECT_EQ(scroll.y, 2660); | 2768 EXPECT_EQ(scroll.y, 2660); |
2446 } | 2769 } |
2447 | 2770 |
2448 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) | 2771 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest_OldPinch) |
2449 { | 2772 { |
2450 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 2773 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
2451 | 2774 |
2452 const float deviceScaleFactor = 2.0f; | 2775 const float deviceScaleFactor = 2.0f; |
2453 int viewportWidth = 640 / deviceScaleFactor; | 2776 int viewportWidth = 640 / deviceScaleFactor; |
2454 int viewportHeight = 1280 / deviceScaleFactor; | 2777 int viewportHeight = 1280 / deviceScaleFactor; |
2455 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2778 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2456 FrameTestHelpers::WebViewHelper webViewHelper; | 2779 FrameTestHelpers::WebViewHelper webViewHelper; |
2457 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); | 2780 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); |
2458 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2781 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
(...skipping 28 matching lines...) Expand all Loading... |
2487 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2810 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2488 | 2811 |
2489 // If we didn't yet get an auto-zoom update and a second double-tap arrives,
should go back to minimum scale. | 2812 // If we didn't yet get an auto-zoom update and a second double-tap arrives,
should go back to minimum scale. |
2490 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); | 2813 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
2491 webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); | 2814 webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); |
2492 EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTes
ting()); | 2815 EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTes
ting()); |
2493 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); | 2816 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
2494 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2817 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2495 } | 2818 } |
2496 | 2819 |
2497 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) | 2820 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest_OldPinch) |
2498 { | 2821 { |
2499 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 2822 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
2500 | 2823 |
2501 int viewportWidth = 320; | 2824 int viewportWidth = 320; |
2502 int viewportHeight = 480; | 2825 int viewportHeight = 480; |
2503 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2826 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2504 FrameTestHelpers::WebViewHelper webViewHelper; | 2827 FrameTestHelpers::WebViewHelper webViewHelper; |
2505 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); | 2828 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); |
2506 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2829 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2507 webViewHelper.webView()->setDeviceScaleFactor(1.5f); | 2830 webViewHelper.webView()->setDeviceScaleFactor(1.5f); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2548 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; | 2871 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
2549 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); | 2872 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
2550 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2873 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2551 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 2874 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
2552 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2875 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2553 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2876 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2554 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2877 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2555 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 2878 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
2556 } | 2879 } |
2557 | 2880 |
2558 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) | 2881 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest_OldPinch) |
2559 { | 2882 { |
2560 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 2883 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
2561 | 2884 |
2562 int viewportWidth = 320; | 2885 int viewportWidth = 320; |
2563 int viewportHeight = 480; | 2886 int viewportHeight = 480; |
2564 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2887 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2565 float accessibilityFontScaleFactor = 1.13f; | 2888 float accessibilityFontScaleFactor = 1.13f; |
2566 FrameTestHelpers::WebViewHelper webViewHelper; | 2889 FrameTestHelpers::WebViewHelper webViewHelper; |
2567 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); | 2890 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); |
2568 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2891 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; | 2949 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
2627 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); | 2950 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
2628 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2951 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2629 EXPECT_FLOAT_EQ(legibleScale, scale); | 2952 EXPECT_FLOAT_EQ(legibleScale, scale); |
2630 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2953 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2631 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2954 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2632 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2955 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2633 EXPECT_FLOAT_EQ(legibleScale, scale); | 2956 EXPECT_FLOAT_EQ(legibleScale, scale); |
2634 } | 2957 } |
2635 | 2958 |
| 2959 // ================= End Old-Style Pinch tests to be removed =================== |
| 2960 |
2636 TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) | 2961 TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) |
2637 { | 2962 { |
2638 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 2963 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
2639 | 2964 |
2640 const float deviceScaleFactor = 2.0f; | 2965 const float deviceScaleFactor = 2.0f; |
2641 int viewportWidth = 640 / deviceScaleFactor; | 2966 int viewportWidth = 640 / deviceScaleFactor; |
2642 int viewportHeight = 1280 / deviceScaleFactor; | 2967 int viewportHeight = 1280 / deviceScaleFactor; |
2643 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2968 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2644 FrameTestHelpers::WebViewHelper webViewHelper; | 2969 FrameTestHelpers::WebViewHelper webViewHelper; |
2645 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); | 2970 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); |
(...skipping 3622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6268 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6593 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6269 | 6594 |
6270 // Neither should a page reload. | 6595 // Neither should a page reload. |
6271 localFrame->reload(); | 6596 localFrame->reload(); |
6272 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6597 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6273 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6598 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6274 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6599 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6275 } | 6600 } |
6276 | 6601 |
6277 } // namespace | 6602 } // namespace |
OLD | NEW |