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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); | 182 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); |
183 document->ensureStyleResolver().viewportStyleResolver()->resolve(); | 183 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
184 } | 184 } |
185 | 185 |
186 static void configueCompositingWebView(WebSettings* settings) | 186 static void configueCompositingWebView(WebSettings* settings) |
187 { | 187 { |
188 settings->setAcceleratedCompositingEnabled(true); | 188 settings->setAcceleratedCompositingEnabled(true); |
189 settings->setPreferCompositingToLCDTextEnabled(true); | 189 settings->setPreferCompositingToLCDTextEnabled(true); |
190 } | 190 } |
191 | 191 |
| 192 static void configurePinchVirtualViewport(WebSettings* settings) |
| 193 { |
| 194 settings->setPinchVirtualViewportEnabled(true); |
| 195 settings->setViewportMetaEnabled(true); |
| 196 settings->setViewportEnabled(true); |
| 197 settings->setMainFrameResizesAreOrientationChanges(true); |
| 198 settings->setShrinksViewportContentToFit(true); |
| 199 } |
| 200 |
192 static void configureLoadsImagesAutomatically(WebSettings* settings) | 201 static void configureLoadsImagesAutomatically(WebSettings* settings) |
193 { | 202 { |
194 settings->setLoadsImagesAutomatically(true); | 203 settings->setLoadsImagesAutomatically(true); |
195 } | 204 } |
196 | 205 |
197 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) | 206 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers
::WebViewHelper* webViewHelper) |
198 { | 207 { |
199 webViewHelper->initializeAndLoad(url, true); | 208 webViewHelper->initializeAndLoad(url, true); |
200 webViewHelper->webView()->settings()->setDefaultFontSize(12); | 209 webViewHelper->webView()->settings()->setDefaultFontSize(12); |
201 webViewHelper->webView()->resize(WebSize(640, 480)); | 210 webViewHelper->webView()->resize(WebSize(640, 480)); |
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); | 2152 EXPECT_FALSE(view->renderView()->compositor()->layerForVerticalScrollbar()); |
2144 } | 2153 } |
2145 | 2154 |
2146 void setScaleAndScrollAndLayout(WebView* webView, WebPoint scroll, float scale) | 2155 void setScaleAndScrollAndLayout(WebView* webView, WebPoint scroll, float scale) |
2147 { | 2156 { |
2148 webView->setPageScaleFactor(scale); | 2157 webView->setPageScaleFactor(scale); |
2149 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); | 2158 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); |
2150 webView->layout(); | 2159 webView->layout(); |
2151 } | 2160 } |
2152 | 2161 |
2153 TEST_F(WebFrameTest, DivAutoZoomParamsTest) | 2162 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
| 2163 { |
| 2164 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
| 2165 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
| 2166 webViewImpl->applyViewportDeltas(scrollDelta, scaleDelta, 0); |
| 2167 scale = webViewImpl->pageScaleFactor(); |
| 2168 } |
| 2169 |
| 2170 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) |
| 2171 { |
| 2172 if (webViewImpl->zoomToMultipleTargetsRect(rect)) |
| 2173 simulatePageScale(webViewImpl, scale); |
| 2174 } |
| 2175 |
| 2176 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) |
| 2177 { |
| 2178 webViewImpl->animateDoubleTapZoom(point); |
| 2179 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); |
| 2180 simulatePageScale(webViewImpl, scale); |
| 2181 } |
| 2182 |
| 2183 // ======= |
| 2184 |
| 2185 TEST_F(WebFrameTest, DivAutoZoomParamsTest_VirtualViewport) |
2154 { | 2186 { |
2155 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); | 2187 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
2156 | 2188 |
2157 const float deviceScaleFactor = 2.0f; | 2189 const float deviceScaleFactor = 2.0f; |
2158 int viewportWidth = 640 / deviceScaleFactor; | 2190 int viewportWidth = 640 / deviceScaleFactor; |
2159 int viewportHeight = 1280 / deviceScaleFactor; | 2191 int viewportHeight = 1280 / deviceScaleFactor; |
2160 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2192 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2161 FrameTestHelpers::WebViewHelper webViewHelper; | 2193 FrameTestHelpers::WebViewHelper webViewHelper; |
2162 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html"); | 2194 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html", false, 0, 0, configurePinchVirtualViewport); |
2163 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2195 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2164 webViewHelper.webView()->setPageScaleFactorLimits(0.01f, 4); | 2196 webViewHelper.webView()->setPageScaleFactorLimits(0.01f, 4); |
2165 webViewHelper.webView()->setPageScaleFactor(0.5f); | 2197 webViewHelper.webView()->setPageScaleFactor(0.5f); |
2166 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2198 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2167 webViewHelper.webView()->layout(); | 2199 webViewHelper.webView()->layout(); |
2168 | 2200 |
2169 WebRect wideDiv(200, 100, 400, 150); | 2201 WebRect wideDiv(200, 100, 400, 150); |
2170 WebRect tallDiv(200, 300, 400, 800); | 2202 WebRect tallDiv(200, 300, 400, 800); |
2171 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); | 2203 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); |
2172 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); | 2204 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); |
(...skipping 29 matching lines...) Expand all Loading... |
2202 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); | 2234 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); |
2203 EXPECT_NEAR(tallDiv.x, scroll.x, 20); | 2235 EXPECT_NEAR(tallDiv.x, scroll.x, 20); |
2204 EXPECT_NEAR(tallDiv.y, scroll.y, 20); | 2236 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
2205 | 2237 |
2206 // Test for Non-doubletap scaling | 2238 // Test for Non-doubletap scaling |
2207 // Test zooming into div. | 2239 // Test zooming into div. |
2208 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); | 2240 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); |
2209 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 2241 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
2210 } | 2242 } |
2211 | 2243 |
2212 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 2244 TEST_F(WebFrameTest, DivAutoZoomWideDivTest_VirtualViewport) |
2213 { | |
2214 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | |
2215 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | |
2216 webViewImpl->applyViewportDeltas(scrollDelta, scaleDelta, 0); | |
2217 scale = webViewImpl->pageScaleFactor(); | |
2218 } | |
2219 | |
2220 void simulateMultiTargetZoom(WebViewImpl* webViewImpl, const WebRect& rect, floa
t& scale) | |
2221 { | |
2222 if (webViewImpl->zoomToMultipleTargetsRect(rect)) | |
2223 simulatePageScale(webViewImpl, scale); | |
2224 } | |
2225 | |
2226 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) | |
2227 { | |
2228 webViewImpl->animateDoubleTapZoom(point); | |
2229 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); | |
2230 simulatePageScale(webViewImpl, scale); | |
2231 } | |
2232 | |
2233 TEST_F(WebFrameTest, DivAutoZoomWideDivTest) | |
2234 { | 2245 { |
2235 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); | 2246 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); |
2236 | 2247 |
| 2248 const float deviceScaleFactor = 2.0f; |
| 2249 int viewportWidth = 640 / deviceScaleFactor; |
| 2250 int viewportHeight = 1280 / deviceScaleFactor; |
| 2251 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2252 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2253 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html", false, 0, 0, configurePinchVirtualViewport); |
| 2254 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2255 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
| 2256 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2257 webViewHelper.webView()->setPageScaleFactor(1.0f); |
| 2258 webViewHelper.webView()->layout(); |
| 2259 |
| 2260 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2261 |
| 2262 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2263 |
| 2264 WebRect div(0, 100, viewportWidth, 150); |
| 2265 WebPoint point(div.x + 50, div.y + 50); |
| 2266 float scale; |
| 2267 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2268 |
| 2269 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
| 2270 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2271 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
| 2272 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2273 } |
| 2274 |
| 2275 TEST_F(WebFrameTest, DivAutoZoomVeryTallTest_VirtualViewport) |
| 2276 { |
| 2277 // When a block is taller than the viewport and a zoom targets a lower part |
| 2278 // of it, then we should keep the target point onscreen instead of snapping |
| 2279 // back up the top of the block. |
| 2280 registerMockedHttpURLLoad("very_tall_div.html"); |
| 2281 |
| 2282 const float deviceScaleFactor = 2.0f; |
| 2283 int viewportWidth = 640 / deviceScaleFactor; |
| 2284 int viewportHeight = 1280 / deviceScaleFactor; |
| 2285 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2286 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, 0, 0
, configurePinchVirtualViewport); |
| 2287 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2288 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
| 2289 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2290 webViewHelper.webView()->setPageScaleFactor(1.0f); |
| 2291 webViewHelper.webView()->layout(); |
| 2292 |
| 2293 WebRect div(200, 300, 400, 5000); |
| 2294 WebPoint point(div.x + 50, div.y + 3000); |
| 2295 float scale; |
| 2296 WebPoint scroll; |
| 2297 |
| 2298 WebRect blockBounds = webViewHelper.webViewImpl()->computeBlockBounds(WebRec
t(point.x, point.y, 0, 0), true); |
| 2299 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockB
ounds, 0, 1.0f, scale, scroll); |
| 2300 EXPECT_EQ(scale, 1.0f); |
| 2301 EXPECT_EQ(scroll.y, 2660); |
| 2302 } |
| 2303 |
| 2304 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest_VirtualViewport) |
| 2305 { |
| 2306 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
| 2307 |
| 2308 const float deviceScaleFactor = 2.0f; |
| 2309 int viewportWidth = 640 / deviceScaleFactor; |
| 2310 int viewportHeight = 1280 / deviceScaleFactor; |
| 2311 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2312 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2313 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html", false, 0, 0, configurePinchVirtualViewport); |
| 2314 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2315 webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); |
| 2316 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2317 webViewHelper.webView()->setPageScaleFactor(0.5f); |
| 2318 webViewHelper.webView()->layout(); |
| 2319 |
| 2320 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2321 |
| 2322 WebRect topDiv(200, 100, 200, 150); |
| 2323 WebRect bottomDiv(200, 300, 200, 150); |
| 2324 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); |
| 2325 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); |
| 2326 float scale; |
| 2327 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2328 |
| 2329 // Test double tap on two different divs |
| 2330 // After first zoom, we should go back to minimum page scale with a second d
ouble tap. |
| 2331 simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); |
| 2332 EXPECT_FLOAT_EQ(1, scale); |
| 2333 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2334 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2335 |
| 2336 // If the user pinch zooms after double tap, a second double tap should zoom
back to the div. |
| 2337 simulateDoubleTap(webViewHelper.webViewImpl(), topPoint, scale); |
| 2338 EXPECT_FLOAT_EQ(1, scale); |
| 2339 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 0.6f, 0); |
| 2340 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2341 EXPECT_FLOAT_EQ(1, scale); |
| 2342 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2343 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2344 |
| 2345 // If we didn't yet get an auto-zoom update and a second double-tap arrives,
should go back to minimum scale. |
| 2346 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2347 webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); |
| 2348 EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTes
ting()); |
| 2349 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
| 2350 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2351 } |
| 2352 |
| 2353 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest_VirtualViewport) |
| 2354 { |
| 2355 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
| 2356 |
| 2357 int viewportWidth = 320; |
| 2358 int viewportHeight = 480; |
| 2359 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2360 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2361 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html", false, 0, 0, configurePinchVirtualViewport); |
| 2362 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2363 webViewHelper.webView()->setDeviceScaleFactor(1.5f); |
| 2364 webViewHelper.webView()->layout(); |
| 2365 |
| 2366 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2367 |
| 2368 WebRect div(200, 100, 200, 150); |
| 2369 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
| 2370 float scale; |
| 2371 |
| 2372 // Test double tap scale bounds. |
| 2373 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 |
| 2374 webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); |
| 2375 webViewHelper.webView()->layout(); |
| 2376 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2377 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2378 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2379 EXPECT_FLOAT_EQ(1, scale); |
| 2380 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2381 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2382 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2383 EXPECT_FLOAT_EQ(1, scale); |
| 2384 |
| 2385 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2386 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2387 // 1 < minimumPageScale < doubleTapZoomAlreadyLegibleScale |
| 2388 webViewHelper.webView()->setPageScaleFactorLimits(1.1f, 4); |
| 2389 webViewHelper.webView()->layout(); |
| 2390 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2391 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2392 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2393 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2394 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2395 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2396 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2397 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2398 |
| 2399 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2400 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2401 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale |
| 2402 webViewHelper.webView()->setPageScaleFactorLimits(0.95f, 4); |
| 2403 webViewHelper.webView()->layout(); |
| 2404 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2405 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2406 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2407 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2408 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2409 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2410 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2411 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2412 } |
| 2413 |
| 2414 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest_VirtualViewport) |
| 2415 { |
| 2416 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
| 2417 |
| 2418 int viewportWidth = 320; |
| 2419 int viewportHeight = 480; |
| 2420 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2421 float accessibilityFontScaleFactor = 1.13f; |
| 2422 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2423 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html", false, 0, 0, configurePinchVirtualViewport); |
| 2424 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2425 webViewHelper.webView()->layout(); |
| 2426 |
| 2427 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2428 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(tru
e); |
| 2429 webViewHelper.webViewImpl()->page()->settings().setAccessibilityFontScaleFac
tor(accessibilityFontScaleFactor); |
| 2430 |
| 2431 WebRect div(200, 100, 200, 150); |
| 2432 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
| 2433 float scale; |
| 2434 |
| 2435 // Test double tap scale bounds. |
| 2436 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < accessibilityFo
ntScaleFactor |
| 2437 float legibleScale = accessibilityFontScaleFactor; |
| 2438 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2439 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2440 webViewHelper.webView()->setPageScaleFactorLimits(0.5f, 4); |
| 2441 webViewHelper.webView()->layout(); |
| 2442 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2443 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2444 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2445 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2446 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2447 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2448 |
| 2449 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2450 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2451 // 1 < accessibilityFontScaleFactor < minimumPageScale < doubleTapZoomAlread
yLegibleScale |
| 2452 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
| 2453 webViewHelper.webView()->layout(); |
| 2454 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2455 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2456 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2457 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2458 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2459 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2460 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2461 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2462 |
| 2463 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2464 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2465 // minimumPageScale < 1 < accessibilityFontScaleFactor < doubleTapZoomAlread
yLegibleScale |
| 2466 webViewHelper.webView()->setPageScaleFactorLimits(0.95f, 4); |
| 2467 webViewHelper.webView()->layout(); |
| 2468 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2469 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2470 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2471 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2472 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2473 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2474 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2475 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 2476 |
| 2477 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 2478 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
| 2479 // minimumPageScale < 1 < doubleTapZoomAlreadyLegibleScale < accessibilityFo
ntScaleFactor |
| 2480 webViewHelper.webView()->setPageScaleFactorLimits(0.9f, 4); |
| 2481 webViewHelper.webView()->layout(); |
| 2482 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2483 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
| 2484 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2485 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2486 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2487 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
| 2488 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
| 2489 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 2490 } |
| 2491 |
| 2492 // FIXME(bokan): The following tests marked with _OldPinch test AutoZoom |
| 2493 // without the pinch virtual viewport mode enabled. As this becomes the default |
| 2494 // and the old path is deprecated, these tests can be removed; they've been |
| 2495 // cloned above to use the new virtual viewport path. |
| 2496 |
| 2497 TEST_F(WebFrameTest, DivAutoZoomParamsTest_OldPinch) |
| 2498 { |
| 2499 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
| 2500 |
| 2501 const float deviceScaleFactor = 2.0f; |
| 2502 int viewportWidth = 640 / deviceScaleFactor; |
| 2503 int viewportHeight = 1280 / deviceScaleFactor; |
| 2504 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 2505 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2506 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_di
v_test.html"); |
| 2507 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
| 2508 webViewHelper.webView()->setPageScaleFactorLimits(0.01f, 4); |
| 2509 webViewHelper.webView()->setPageScaleFactor(0.5f); |
| 2510 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2511 webViewHelper.webView()->layout(); |
| 2512 |
| 2513 WebRect wideDiv(200, 100, 400, 150); |
| 2514 WebRect tallDiv(200, 300, 400, 800); |
| 2515 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); |
| 2516 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); |
| 2517 WebRect wideBlockBounds; |
| 2518 WebRect tallBlockBounds; |
| 2519 float scale; |
| 2520 WebPoint scroll; |
| 2521 |
| 2522 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| 2523 |
| 2524 // Test double-tap zooming into wide div. |
| 2525 wideBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapP
ointWide, false); |
| 2526 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub
leTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, dou
bleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2527 // The div should horizontally fill the screen (modulo margins), and |
| 2528 // vertically centered (modulo integer rounding). |
| 2529 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
| 2530 EXPECT_NEAR(wideDiv.x, scroll.x, 20); |
| 2531 EXPECT_EQ(0, scroll.y); |
| 2532 |
| 2533 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); |
| 2534 |
| 2535 // Test zoom out back to minimum scale. |
| 2536 wideBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapP
ointWide, false); |
| 2537 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub
leTapPointWide.x, doubleTapPointWide.y), wideBlockBounds, touchPointPadding, dou
bleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2538 |
| 2539 scale = webViewHelper.webViewImpl()->minimumPageScaleFactor(); |
| 2540 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), scal
e); |
| 2541 |
| 2542 // Test double-tap zooming into tall div. |
| 2543 tallBlockBounds = webViewHelper.webViewImpl()->computeBlockBounds(doubleTapP
ointTall, false); |
| 2544 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(doub
leTapPointTall.x, doubleTapPointTall.y), tallBlockBounds, touchPointPadding, dou
bleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2545 // The div should start at the top left of the viewport. |
| 2546 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); |
| 2547 EXPECT_NEAR(tallDiv.x, scroll.x, 20); |
| 2548 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
| 2549 |
| 2550 // Test for Non-doubletap scaling |
| 2551 // Test zooming into div. |
| 2552 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(WebPoint(250,
250), webViewHelper.webViewImpl()->computeBlockBounds(WebRect(250, 250, 10, 10)
, true), 0, doubleTapZoomAlreadyLegibleScale, scale, scroll); |
| 2553 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
| 2554 } |
| 2555 |
| 2556 TEST_F(WebFrameTest, DivAutoZoomWideDivTest_OldPinch) |
| 2557 { |
| 2558 registerMockedHttpURLLoad("get_wide_div_for_auto_zoom_test.html"); |
| 2559 |
2237 const float deviceScaleFactor = 2.0f; | 2560 const float deviceScaleFactor = 2.0f; |
2238 int viewportWidth = 640 / deviceScaleFactor; | 2561 int viewportWidth = 640 / deviceScaleFactor; |
2239 int viewportHeight = 1280 / deviceScaleFactor; | 2562 int viewportHeight = 1280 / deviceScaleFactor; |
2240 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2563 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2241 FrameTestHelpers::WebViewHelper webViewHelper; | 2564 FrameTestHelpers::WebViewHelper webViewHelper; |
2242 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html"); | 2565 webViewHelper.initializeAndLoad(m_baseURL + "get_wide_div_for_auto_zoom_test
.html"); |
2243 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2566 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2244 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); | 2567 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
2245 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2568 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2246 webViewHelper.webView()->setPageScaleFactor(1.0f); | 2569 webViewHelper.webView()->setPageScaleFactor(1.0f); |
2247 webViewHelper.webView()->layout(); | 2570 webViewHelper.webView()->layout(); |
2248 | 2571 |
2249 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 2572 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
2250 | 2573 |
2251 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; | 2574 float doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimu
mPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
2252 | 2575 |
2253 WebRect div(0, 100, viewportWidth, 150); | 2576 WebRect div(0, 100, viewportWidth, 150); |
2254 WebPoint point(div.x + 50, div.y + 50); | 2577 WebPoint point(div.x + 50, div.y + 50); |
2255 float scale; | 2578 float scale; |
2256 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); | 2579 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
2257 | 2580 |
2258 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); | 2581 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
2259 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 2582 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
2260 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); | 2583 simulateDoubleTap(webViewHelper.webViewImpl(), point, scale); |
2261 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2584 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2262 } | 2585 } |
2263 | 2586 |
2264 TEST_F(WebFrameTest, DivAutoZoomVeryTallTest) | 2587 TEST_F(WebFrameTest, DivAutoZoomVeryTallTest_OldPinch) |
2265 { | 2588 { |
2266 // When a block is taller than the viewport and a zoom targets a lower part | 2589 // When a block is taller than the viewport and a zoom targets a lower part |
2267 // of it, then we should keep the target point onscreen instead of snapping | 2590 // of it, then we should keep the target point onscreen instead of snapping |
2268 // back up the top of the block. | 2591 // back up the top of the block. |
2269 registerMockedHttpURLLoad("very_tall_div.html"); | 2592 registerMockedHttpURLLoad("very_tall_div.html"); |
2270 | 2593 |
2271 const float deviceScaleFactor = 2.0f; | 2594 const float deviceScaleFactor = 2.0f; |
2272 int viewportWidth = 640 / deviceScaleFactor; | 2595 int viewportWidth = 640 / deviceScaleFactor; |
2273 int viewportHeight = 1280 / deviceScaleFactor; | 2596 int viewportHeight = 1280 / deviceScaleFactor; |
2274 FrameTestHelpers::WebViewHelper webViewHelper; | 2597 FrameTestHelpers::WebViewHelper webViewHelper; |
2275 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, 0, 0
, enableViewportSettings); | 2598 webViewHelper.initializeAndLoad(m_baseURL + "very_tall_div.html", true, 0, 0
, enableViewportSettings); |
2276 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2599 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2277 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); | 2600 webViewHelper.webView()->setPageScaleFactorLimits(1.0f, 4); |
2278 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); | 2601 webViewHelper.webView()->setDeviceScaleFactor(deviceScaleFactor); |
2279 webViewHelper.webView()->setPageScaleFactor(1.0f); | 2602 webViewHelper.webView()->setPageScaleFactor(1.0f); |
2280 webViewHelper.webView()->layout(); | 2603 webViewHelper.webView()->layout(); |
2281 | 2604 |
2282 WebRect div(200, 300, 400, 5000); | 2605 WebRect div(200, 300, 400, 5000); |
2283 WebPoint point(div.x + 50, div.y + 3000); | 2606 WebPoint point(div.x + 50, div.y + 3000); |
2284 float scale; | 2607 float scale; |
2285 WebPoint scroll; | 2608 WebPoint scroll; |
2286 | 2609 |
2287 WebRect blockBounds = webViewHelper.webViewImpl()->computeBlockBounds(WebRec
t(point.x, point.y, 0, 0), true); | 2610 WebRect blockBounds = webViewHelper.webViewImpl()->computeBlockBounds(WebRec
t(point.x, point.y, 0, 0), true); |
2288 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockB
ounds, 0, 1.0f, scale, scroll); | 2611 webViewHelper.webViewImpl()->computeScaleAndScrollForBlockRect(point, blockB
ounds, 0, 1.0f, scale, scroll); |
2289 EXPECT_EQ(scale, 1.0f); | 2612 EXPECT_EQ(scale, 1.0f); |
2290 EXPECT_EQ(scroll.y, 2660); | 2613 EXPECT_EQ(scroll.y, 2660); |
2291 } | 2614 } |
2292 | 2615 |
2293 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) | 2616 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest_OldPinch) |
2294 { | 2617 { |
2295 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 2618 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
2296 | 2619 |
2297 const float deviceScaleFactor = 2.0f; | 2620 const float deviceScaleFactor = 2.0f; |
2298 int viewportWidth = 640 / deviceScaleFactor; | 2621 int viewportWidth = 640 / deviceScaleFactor; |
2299 int viewportHeight = 1280 / deviceScaleFactor; | 2622 int viewportHeight = 1280 / deviceScaleFactor; |
2300 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2623 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2301 FrameTestHelpers::WebViewHelper webViewHelper; | 2624 FrameTestHelpers::WebViewHelper webViewHelper; |
2302 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); | 2625 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); |
2303 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2626 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
(...skipping 28 matching lines...) Expand all Loading... |
2332 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2655 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2333 | 2656 |
2334 // If we didn't yet get an auto-zoom update and a second double-tap arrives,
should go back to minimum scale. | 2657 // If we didn't yet get an auto-zoom update and a second double-tap arrives,
should go back to minimum scale. |
2335 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); | 2658 webViewHelper.webViewImpl()->applyViewportDeltas(WebSize(), 1.1f, 0); |
2336 webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); | 2659 webViewHelper.webViewImpl()->animateDoubleTapZoom(topPoint); |
2337 EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTes
ting()); | 2660 EXPECT_TRUE(webViewHelper.webViewImpl()->fakeDoubleTapAnimationPendingForTes
ting()); |
2338 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); | 2661 simulateDoubleTap(webViewHelper.webViewImpl(), bottomPoint, scale); |
2339 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2662 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2340 } | 2663 } |
2341 | 2664 |
2342 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) | 2665 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest_OldPinch) |
2343 { | 2666 { |
2344 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 2667 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
2345 | 2668 |
2346 int viewportWidth = 320; | 2669 int viewportWidth = 320; |
2347 int viewportHeight = 480; | 2670 int viewportHeight = 480; |
2348 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2671 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2349 FrameTestHelpers::WebViewHelper webViewHelper; | 2672 FrameTestHelpers::WebViewHelper webViewHelper; |
2350 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); | 2673 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); |
2351 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2674 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
2352 webViewHelper.webView()->setDeviceScaleFactor(1.5f); | 2675 webViewHelper.webView()->setDeviceScaleFactor(1.5f); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2393 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; | 2716 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
2394 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); | 2717 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
2395 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2718 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2396 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 2719 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
2397 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2720 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2398 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2721 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2399 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2722 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2400 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 2723 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
2401 } | 2724 } |
2402 | 2725 |
2403 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) | 2726 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest_OldPinch) |
2404 { | 2727 { |
2405 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 2728 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
2406 | 2729 |
2407 int viewportWidth = 320; | 2730 int viewportWidth = 320; |
2408 int viewportHeight = 480; | 2731 int viewportHeight = 480; |
2409 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2732 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2410 float accessibilityFontScaleFactor = 1.13f; | 2733 float accessibilityFontScaleFactor = 1.13f; |
2411 FrameTestHelpers::WebViewHelper webViewHelper; | 2734 FrameTestHelpers::WebViewHelper webViewHelper; |
2412 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); | 2735 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_bounds_check_for_auto
_zoom_test.html"); |
2413 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2736 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; | 2794 doubleTapZoomAlreadyLegibleScale = webViewHelper.webViewImpl()->minimumPageS
caleFactor() * doubleTapZoomAlreadyLegibleRatio; |
2472 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); | 2795 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), (web
ViewHelper.webViewImpl()->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyL
egibleRatio) / 2); |
2473 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2796 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2474 EXPECT_FLOAT_EQ(legibleScale, scale); | 2797 EXPECT_FLOAT_EQ(legibleScale, scale); |
2475 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2798 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2476 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); | 2799 EXPECT_FLOAT_EQ(webViewHelper.webViewImpl()->minimumPageScaleFactor(), scale
); |
2477 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); | 2800 simulateDoubleTap(webViewHelper.webViewImpl(), doubleTapPoint, scale); |
2478 EXPECT_FLOAT_EQ(legibleScale, scale); | 2801 EXPECT_FLOAT_EQ(legibleScale, scale); |
2479 } | 2802 } |
2480 | 2803 |
| 2804 // ================= End Old-Style Pinch tests to be removed =================== |
| 2805 |
2481 TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) | 2806 TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) |
2482 { | 2807 { |
2483 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 2808 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
2484 | 2809 |
2485 const float deviceScaleFactor = 2.0f; | 2810 const float deviceScaleFactor = 2.0f; |
2486 int viewportWidth = 640 / deviceScaleFactor; | 2811 int viewportWidth = 640 / deviceScaleFactor; |
2487 int viewportHeight = 1280 / deviceScaleFactor; | 2812 int viewportHeight = 1280 / deviceScaleFactor; |
2488 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 2813 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
2489 FrameTestHelpers::WebViewHelper webViewHelper; | 2814 FrameTestHelpers::WebViewHelper webViewHelper; |
2490 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); | 2815 webViewHelper.initializeAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom
_test.html"); |
(...skipping 3813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6304 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6629 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6305 | 6630 |
6306 // Neither should a page reload. | 6631 // Neither should a page reload. |
6307 localFrame->reload(); | 6632 localFrame->reload(); |
6308 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6633 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6309 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6634 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6310 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6635 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6311 } | 6636 } |
6312 | 6637 |
6313 } // namespace | 6638 } // namespace |
OLD | NEW |