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 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 m_webView->layout(); | 1175 m_webView->layout(); |
1176 | 1176 |
1177 WebRect wideDiv(200, 100, 400, 150); | 1177 WebRect wideDiv(200, 100, 400, 150); |
1178 WebRect tallDiv(200, 300, 400, 800); | 1178 WebRect tallDiv(200, 300, 400, 800); |
1179 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); | 1179 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, touchPointPadding
, touchPointPadding); |
1180 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); | 1180 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, touchPointPadding
, touchPointPadding); |
1181 WebRect wideBlockBounds; | 1181 WebRect wideBlockBounds; |
1182 WebRect tallBlockBounds; | 1182 WebRect tallBlockBounds; |
1183 float scale; | 1183 float scale; |
1184 WebPoint scroll; | 1184 WebPoint scroll; |
1185 bool doubleTapShouldZoomOut; | |
1186 | 1185 |
1187 // Test double-tap zooming into wide div. | 1186 // Test double-tap zooming into wide div. |
1188 wideBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointWide, fals
e); | 1187 wideBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointWide, fals
e); |
1189 webViewImpl()->computeScaleAndScrollForBlockRect(wideBlockBounds, touchPoint
Padding, scale, scroll, doubleTapShouldZoomOut); | 1188 webViewImpl()->computeScaleAndScrollForBlockRect(wideBlockBounds, touchPoint
Padding, scale, scroll); |
1190 // The div should horizontally fill the screen (modulo margins), and | 1189 // The div should horizontally fill the screen (modulo margins), and |
1191 // vertically centered (modulo integer rounding). | 1190 // vertically centered (modulo integer rounding). |
1192 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 1191 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
1193 EXPECT_NEAR(wideDiv.x, scroll.x, 20); | 1192 EXPECT_NEAR(wideDiv.x, scroll.x, 20); |
1194 EXPECT_EQ(0, scroll.y); | 1193 EXPECT_EQ(0, scroll.y); |
1195 EXPECT_FALSE(doubleTapShouldZoomOut); | |
1196 | 1194 |
1197 setScaleAndScrollAndLayout(webViewImpl(), scroll, scale); | 1195 setScaleAndScrollAndLayout(webViewImpl(), scroll, scale); |
1198 | 1196 |
1199 // Test zoom out back to minimum scale. | 1197 // Test zoom out back to minimum scale. |
1200 wideBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointWide, fals
e); | 1198 wideBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointWide, fals
e); |
1201 webViewImpl()->computeScaleAndScrollForBlockRect(wideBlockBounds, touchPoint
Padding, scale, scroll, doubleTapShouldZoomOut); | 1199 webViewImpl()->computeScaleAndScrollForBlockRect(wideBlockBounds, touchPoint
Padding, scale, scroll); |
1202 EXPECT_TRUE(doubleTapShouldZoomOut); | |
1203 | 1200 |
1204 scale = webViewImpl()->minimumPageScaleFactor(); | 1201 scale = webViewImpl()->minimumPageScaleFactor(); |
1205 setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), scale); | 1202 setScaleAndScrollAndLayout(webViewImpl(), WebPoint(0, 0), scale); |
1206 | 1203 |
1207 // Test double-tap zooming into tall div. | 1204 // Test double-tap zooming into tall div. |
1208 tallBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointTall, fals
e); | 1205 tallBlockBounds = webViewImpl()->computeBlockBounds(doubleTapPointTall, fals
e); |
1209 webViewImpl()->computeScaleAndScrollForBlockRect(tallBlockBounds, touchPoint
Padding, scale, scroll, doubleTapShouldZoomOut); | 1206 webViewImpl()->computeScaleAndScrollForBlockRect(tallBlockBounds, touchPoint
Padding, scale, scroll); |
1210 // The div should start at the top left of the viewport. | 1207 // The div should start at the top left of the viewport. |
1211 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); | 1208 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); |
1212 EXPECT_NEAR(tallDiv.x, scroll.x, 20); | 1209 EXPECT_NEAR(tallDiv.x, scroll.x, 20); |
1213 EXPECT_NEAR(tallDiv.y, scroll.y, 20); | 1210 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
1214 EXPECT_FALSE(doubleTapShouldZoomOut); | |
1215 | 1211 |
1216 // Test for Non-doubletap scaling | 1212 // Test for Non-doubletap scaling |
1217 // Test zooming into div. | 1213 // Test zooming into div. |
1218 webViewImpl()->computeScaleAndScrollForBlockRect(webViewImpl()->computeBlock
Bounds(WebRect(250, 250, 10, 10), true), 0, scale, scroll, doubleTapShouldZoomOu
t); | 1214 webViewImpl()->computeScaleAndScrollForBlockRect(webViewImpl()->computeBlock
Bounds(WebRect(250, 250, 10, 10), true), 0, scale, scroll); |
1219 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 1215 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
1220 } | 1216 } |
1221 | 1217 |
1222 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 1218 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
1223 { | 1219 { |
1224 WebCore::IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPosi
tionForTesting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | 1220 WebCore::IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPosi
tionForTesting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
1225 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | 1221 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
1226 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); | 1222 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); |
1227 scale = webViewImpl->pageScaleFactor(); | 1223 scale = webViewImpl->pageScaleFactor(); |
1228 } | 1224 } |
(...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3593 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); | 3589 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); |
3594 runPendingTasks(); | 3590 runPendingTasks(); |
3595 | 3591 |
3596 EXPECT_EQ(client.startLoadingCount(), 2); | 3592 EXPECT_EQ(client.startLoadingCount(), 2); |
3597 EXPECT_EQ(client.stopLoadingCount(), 2); | 3593 EXPECT_EQ(client.stopLoadingCount(), 2); |
3598 m_webView->close(); | 3594 m_webView->close(); |
3599 m_webView = 0; | 3595 m_webView = 0; |
3600 } | 3596 } |
3601 | 3597 |
3602 } // namespace | 3598 } // namespace |
OLD | NEW |