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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 m_webView->layout(); | 413 m_webView->layout(); |
414 EXPECT_EQ(1, m_webView->pageScaleFactor()); | 414 EXPECT_EQ(1, m_webView->pageScaleFactor()); |
415 | 415 |
416 // Force the layout to happen before leaving the test. | 416 // Force the layout to happen before leaving the test. |
417 m_webView->mainFrame()->contentAsText(1024).utf8(); | 417 m_webView->mainFrame()->contentAsText(1024).utf8(); |
418 } | 418 } |
419 | 419 |
420 TEST_F(WebFrameTest, FixedLayoutInitializeAtMinimumScale) | 420 TEST_F(WebFrameTest, FixedLayoutInitializeAtMinimumScale) |
421 { | 421 { |
422 WebCore::Settings::setMockScrollbarsEnabled(true); | 422 WebCore::Settings::setMockScrollbarsEnabled(true); |
423 WebCore::Settings::setUsesOverlayScrollbars(true); | 423 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
424 | 424 |
425 registerMockedHttpURLLoad("fixed_layout.html"); | 425 registerMockedHttpURLLoad("fixed_layout.html"); |
426 | 426 |
427 FixedLayoutTestWebViewClient client; | 427 FixedLayoutTestWebViewClient client; |
428 client.m_screenInfo.deviceScaleFactor = 1; | 428 client.m_screenInfo.deviceScaleFactor = 1; |
429 int viewportWidth = 640; | 429 int viewportWidth = 640; |
430 int viewportHeight = 480; | 430 int viewportHeight = 480; |
431 | 431 |
432 // Make sure we initialize to minimum scale, even if the window size | 432 // Make sure we initialize to minimum scale, even if the window size |
433 // only becomes available after the load begins. | 433 // only becomes available after the load begins. |
(...skipping 19 matching lines...) Expand all Loading... |
453 EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); | 453 EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); |
454 | 454 |
455 // Make sure we don't reset to initial scale if the viewport size changes. | 455 // Make sure we don't reset to initial scale if the viewport size changes. |
456 m_webView->resize(WebSize(viewportWidth, viewportHeight + 100)); | 456 m_webView->resize(WebSize(viewportWidth, viewportHeight + 100)); |
457 EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); | 457 EXPECT_EQ(userPinchPageScaleFactor, m_webView->pageScaleFactor()); |
458 } | 458 } |
459 | 459 |
460 TEST_F(WebFrameTest, WideDocumentInitializeAtMinimumScale) | 460 TEST_F(WebFrameTest, WideDocumentInitializeAtMinimumScale) |
461 { | 461 { |
462 WebCore::Settings::setMockScrollbarsEnabled(true); | 462 WebCore::Settings::setMockScrollbarsEnabled(true); |
463 WebCore::Settings::setUsesOverlayScrollbars(true); | 463 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
464 | 464 |
465 registerMockedHttpURLLoad("wide_document.html"); | 465 registerMockedHttpURLLoad("wide_document.html"); |
466 | 466 |
467 FixedLayoutTestWebViewClient client; | 467 FixedLayoutTestWebViewClient client; |
468 client.m_screenInfo.deviceScaleFactor = 1; | 468 client.m_screenInfo.deviceScaleFactor = 1; |
469 int viewportWidth = 640; | 469 int viewportWidth = 640; |
470 int viewportHeight = 480; | 470 int viewportHeight = 480; |
471 | 471 |
472 // Make sure we initialize to minimum scale, even if the window size | 472 // Make sure we initialize to minimum scale, even if the window size |
473 // only becomes available after the load begins. | 473 // only becomes available after the load begins. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 m_webView->settings()->setLoadWithOverviewMode(false); | 656 m_webView->settings()->setLoadWithOverviewMode(false); |
657 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 657 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
658 | 658 |
659 // The page must be displayed at 200% zoom, as specified in its viewport met
a tag. | 659 // The page must be displayed at 200% zoom, as specified in its viewport met
a tag. |
660 EXPECT_EQ(2.0f, m_webView->pageScaleFactor()); | 660 EXPECT_EQ(2.0f, m_webView->pageScaleFactor()); |
661 } | 661 } |
662 | 662 |
663 TEST_F(WebFrameTest, setInitialPageScaleFactorPermanently) | 663 TEST_F(WebFrameTest, setInitialPageScaleFactorPermanently) |
664 { | 664 { |
665 WebCore::Settings::setMockScrollbarsEnabled(true); | 665 WebCore::Settings::setMockScrollbarsEnabled(true); |
666 WebCore::Settings::setUsesOverlayScrollbars(true); | 666 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
667 | 667 |
668 registerMockedHttpURLLoad("fixed_layout.html"); | 668 registerMockedHttpURLLoad("fixed_layout.html"); |
669 | 669 |
670 FixedLayoutTestWebViewClient client; | 670 FixedLayoutTestWebViewClient client; |
671 client.m_screenInfo.deviceScaleFactor = 1; | 671 client.m_screenInfo.deviceScaleFactor = 1; |
672 float enforcedPageScaleFactor = 2.0f; | 672 float enforcedPageScaleFactor = 2.0f; |
673 | 673 |
674 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 674 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); |
675 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 675 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
676 m_webView->settings()->setLoadWithOverviewMode(false); | 676 m_webView->settings()->setLoadWithOverviewMode(false); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 | 816 |
817 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); | 817 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); |
818 webViewImpl()->setPageScaleFactor(3, WebPoint()); | 818 webViewImpl()->setPageScaleFactor(3, WebPoint()); |
819 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); | 819 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); |
820 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); | 820 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); |
821 } | 821 } |
822 | 822 |
823 TEST_F(WebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) | 823 TEST_F(WebFrameTest, setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) |
824 { | 824 { |
825 WebCore::Settings::setMockScrollbarsEnabled(true); | 825 WebCore::Settings::setMockScrollbarsEnabled(true); |
826 WebCore::Settings::setUsesOverlayScrollbars(true); | 826 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
827 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); | 827 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); |
828 | 828 |
829 registerMockedHttpURLLoad("fixed_layout.html"); | 829 registerMockedHttpURLLoad("fixed_layout.html"); |
830 | 830 |
831 FixedLayoutTestWebViewClient client; | 831 FixedLayoutTestWebViewClient client; |
832 client.m_screenInfo.deviceScaleFactor = 1; | 832 client.m_screenInfo.deviceScaleFactor = 1; |
833 int viewportWidth = 640; | 833 int viewportWidth = 640; |
834 int viewportHeight = 480; | 834 int viewportHeight = 480; |
835 | 835 |
836 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); | 836 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout
.html", true, 0, &client); |
837 m_webView->enableFixedLayoutMode(true); | 837 m_webView->enableFixedLayoutMode(true); |
838 m_webView->settings()->setViewportEnabled(true); | 838 m_webView->settings()->setViewportEnabled(true); |
839 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 839 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
840 m_webView->layout(); | 840 m_webView->layout(); |
841 | 841 |
842 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); | 842 int prevLayoutCount = webViewImpl()->mainFrameImpl()->frameView()->layoutCou
nt(); |
843 webViewImpl()->setPageScaleFactor(30, WebPoint()); | 843 webViewImpl()->setPageScaleFactor(30, WebPoint()); |
844 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); | 844 EXPECT_FALSE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout()); |
845 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); | 845 EXPECT_EQ(prevLayoutCount, webViewImpl()->mainFrameImpl()->frameView()->layo
utCount()); |
846 | 846 |
847 WebCore::Settings::setMockScrollbarsEnabled(false); | 847 WebCore::Settings::setMockScrollbarsEnabled(false); |
848 WebCore::Settings::setUsesOverlayScrollbars(false); | 848 WebCore::Settings::setMockScrollbarsUseOverlay(false); |
849 } | 849 } |
850 | 850 |
851 TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView) | 851 TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView) |
852 { | 852 { |
853 registerMockedHttpURLLoad("fixed_layout.html"); | 853 registerMockedHttpURLLoad("fixed_layout.html"); |
854 | 854 |
855 float pageScaleFactor = 3; | 855 float pageScaleFactor = 3; |
856 m_webView = FrameTestHelpers::createWebViewAndLoad("about:html", true, 0, 0)
; | 856 m_webView = FrameTestHelpers::createWebViewAndLoad("about:html", true, 0, 0)
; |
857 m_webView->setPageScaleFactor(pageScaleFactor, WebPoint()); | 857 m_webView->setPageScaleFactor(pageScaleFactor, WebPoint()); |
858 | 858 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 | 936 |
937 m_webView->setPageScaleFactor(2, WebPoint()); | 937 m_webView->setPageScaleFactor(2, WebPoint()); |
938 | 938 |
939 EXPECT_EQ(980, webViewImpl()->page()->mainFrame()->contentRenderer()->unscal
edDocumentRect().width()); | 939 EXPECT_EQ(980, webViewImpl()->page()->mainFrame()->contentRenderer()->unscal
edDocumentRect().width()); |
940 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); | 940 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w
idth()); |
941 } | 941 } |
942 | 942 |
943 TEST_F(WebFrameTest, targetDensityDpiHigh) | 943 TEST_F(WebFrameTest, targetDensityDpiHigh) |
944 { | 944 { |
945 WebCore::Settings::setMockScrollbarsEnabled(true); | 945 WebCore::Settings::setMockScrollbarsEnabled(true); |
946 WebCore::Settings::setUsesOverlayScrollbars(true); | 946 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
947 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); | 947 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); |
948 | 948 |
949 FixedLayoutTestWebViewClient client; | 949 FixedLayoutTestWebViewClient client; |
950 // high-dpi = 240 | 950 // high-dpi = 240 |
951 float targetDpi = 240.0f; | 951 float targetDpi = 240.0f; |
952 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 952 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
953 int viewportWidth = 640; | 953 int viewportWidth = 640; |
954 int viewportHeight = 480; | 954 int viewportHeight = 480; |
955 | 955 |
956 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { | 956 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { |
(...skipping 15 matching lines...) Expand all Loading... |
972 EXPECT_NEAR(1.0f / densityDpiScaleRatio, m_webView->pageScaleFactor(), 0
.01f); | 972 EXPECT_NEAR(1.0f / densityDpiScaleRatio, m_webView->pageScaleFactor(), 0
.01f); |
973 | 973 |
974 m_webView->close(); | 974 m_webView->close(); |
975 m_webView = 0; | 975 m_webView = 0; |
976 } | 976 } |
977 } | 977 } |
978 | 978 |
979 TEST_F(WebFrameTest, targetDensityDpiDevice) | 979 TEST_F(WebFrameTest, targetDensityDpiDevice) |
980 { | 980 { |
981 WebCore::Settings::setMockScrollbarsEnabled(true); | 981 WebCore::Settings::setMockScrollbarsEnabled(true); |
982 WebCore::Settings::setUsesOverlayScrollbars(true); | 982 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
983 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html"); | 983 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html"); |
984 | 984 |
985 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 985 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
986 | 986 |
987 FixedLayoutTestWebViewClient client; | 987 FixedLayoutTestWebViewClient client; |
988 int viewportWidth = 640; | 988 int viewportWidth = 640; |
989 int viewportHeight = 480; | 989 int viewportHeight = 480; |
990 | 990 |
991 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { | 991 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { |
992 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; | 992 client.m_screenInfo.deviceScaleFactor = deviceScaleFactors[i]; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 | 1184 |
1185 m_webView->setPageScaleFactor(10, WebPoint()); | 1185 m_webView->setPageScaleFactor(10, WebPoint()); |
1186 | 1186 |
1187 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); | 1187 EXPECT_EQ(view->scrollSize(WebCore::HorizontalScrollbar), view->contentsSize
().width() - view->visibleContentRect().width()); |
1188 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); | 1188 EXPECT_EQ(view->scrollSize(WebCore::VerticalScrollbar), view->contentsSize()
.height() - view->visibleContentRect().height()); |
1189 } | 1189 } |
1190 | 1190 |
1191 TEST_F(WebFrameTest, CanOverrideScaleLimits) | 1191 TEST_F(WebFrameTest, CanOverrideScaleLimits) |
1192 { | 1192 { |
1193 WebCore::Settings::setMockScrollbarsEnabled(true); | 1193 WebCore::Settings::setMockScrollbarsEnabled(true); |
1194 WebCore::Settings::setUsesOverlayScrollbars(true); | 1194 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
1195 | 1195 |
1196 registerMockedHttpURLLoad("no_scale_for_you.html"); | 1196 registerMockedHttpURLLoad("no_scale_for_you.html"); |
1197 | 1197 |
1198 FixedLayoutTestWebViewClient client; | 1198 FixedLayoutTestWebViewClient client; |
1199 client.m_screenInfo.deviceScaleFactor = 1; | 1199 client.m_screenInfo.deviceScaleFactor = 1; |
1200 int viewportWidth = 640; | 1200 int viewportWidth = 640; |
1201 int viewportHeight = 480; | 1201 int viewportHeight = 480; |
1202 | 1202 |
1203 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_scale_for
_you.html", true, 0, &client); | 1203 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_scale_for
_you.html", true, 0, &client); |
1204 m_webView->enableFixedLayoutMode(true); | 1204 m_webView->enableFixedLayoutMode(true); |
(...skipping 12 matching lines...) Expand all Loading... |
1217 m_webView->setIgnoreViewportTagScaleLimits(false); | 1217 m_webView->setIgnoreViewportTagScaleLimits(false); |
1218 m_webView->layout(); | 1218 m_webView->layout(); |
1219 | 1219 |
1220 EXPECT_EQ(2.0f, m_webView->minimumPageScaleFactor()); | 1220 EXPECT_EQ(2.0f, m_webView->minimumPageScaleFactor()); |
1221 EXPECT_EQ(2.0f, m_webView->maximumPageScaleFactor()); | 1221 EXPECT_EQ(2.0f, m_webView->maximumPageScaleFactor()); |
1222 } | 1222 } |
1223 | 1223 |
1224 TEST_F(WebFrameTest, updateOverlayScrollbarLayers) | 1224 TEST_F(WebFrameTest, updateOverlayScrollbarLayers) |
1225 { | 1225 { |
1226 WebCore::Settings::setMockScrollbarsEnabled(true); | 1226 WebCore::Settings::setMockScrollbarsEnabled(true); |
1227 WebCore::Settings::setUsesOverlayScrollbars(true); | 1227 WebCore::Settings::setMockScrollbarsUseOverlay(true); |
1228 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); | 1228 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); |
1229 | 1229 |
1230 registerMockedHttpURLLoad("large-div.html"); | 1230 registerMockedHttpURLLoad("large-div.html"); |
1231 | 1231 |
1232 int viewWidth = 500; | 1232 int viewWidth = 500; |
1233 int viewHeight = 500; | 1233 int viewHeight = 500; |
1234 | 1234 |
1235 createCompositingWebView(); | 1235 createCompositingWebView(); |
1236 m_webView->resize(WebSize(viewWidth, viewHeight)); | 1236 m_webView->resize(WebSize(viewWidth, viewHeight)); |
1237 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "large-div.h
tml"); | 1237 FrameTestHelpers::loadFrame(m_webView->mainFrame(), m_baseURL + "large-div.h
tml"); |
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3793 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); | 3793 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); |
3794 runPendingTasks(); | 3794 runPendingTasks(); |
3795 | 3795 |
3796 EXPECT_EQ(client.startLoadingCount(), 2); | 3796 EXPECT_EQ(client.startLoadingCount(), 2); |
3797 EXPECT_EQ(client.stopLoadingCount(), 2); | 3797 EXPECT_EQ(client.stopLoadingCount(), 2); |
3798 m_webView->close(); | 3798 m_webView->close(); |
3799 m_webView = 0; | 3799 m_webView = 0; |
3800 } | 3800 } |
3801 | 3801 |
3802 } // namespace | 3802 } // namespace |
OLD | NEW |