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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 EXPECT_EQ(4.0f, m_webView->maximumPageScaleFactor()); | 539 EXPECT_EQ(4.0f, m_webView->maximumPageScaleFactor()); |
540 } | 540 } |
541 | 541 |
542 #if ENABLE(GESTURE_EVENTS) | 542 #if ENABLE(GESTURE_EVENTS) |
543 void setScaleAndScrollAndLayout(WebKit::WebView* webView, WebPoint scroll, float
scale) | 543 void setScaleAndScrollAndLayout(WebKit::WebView* webView, WebPoint scroll, float
scale) |
544 { | 544 { |
545 webView->setPageScaleFactor(scale, WebPoint(scroll.x, scroll.y)); | 545 webView->setPageScaleFactor(scale, WebPoint(scroll.x, scroll.y)); |
546 webView->layout(); | 546 webView->layout(); |
547 } | 547 } |
548 | 548 |
549 TEST_F(WebFrameTest, DivAutoZoomParamsTestCompositorScaling) | 549 TEST_F(WebFrameTest, DivAutoZoomParamsTest) |
550 { | 550 { |
551 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); | 551 registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); |
552 | 552 |
553 const float deviceScaleFactor = 2.0f; | 553 const float deviceScaleFactor = 2.0f; |
554 int viewportWidth = 640 / deviceScaleFactor; | 554 int viewportWidth = 640 / deviceScaleFactor; |
555 int viewportHeight = 1280 / deviceScaleFactor; | 555 int viewportHeight = 1280 / deviceScaleFactor; |
556 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo
r_auto_zoom_into_div_test.html"); // | 556 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo
r_auto_zoom_into_div_test.html"); // |
557 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); | 557 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); |
558 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); | 558 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); |
559 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 559 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 600 |
601 // Test for Non-doubletap scaling | 601 // Test for Non-doubletap scaling |
602 // Test zooming into div. | 602 // Test zooming into div. |
603 webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebV
iewImpl::FindInPage, scale, scroll, isAnchor); | 603 webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebV
iewImpl::FindInPage, scale, scroll, isAnchor); |
604 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 604 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
605 } | 605 } |
606 | 606 |
607 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) | 607 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) |
608 { | 608 { |
609 webViewImpl->animateZoomAroundPoint(point, WebViewImpl::DoubleTap); | 609 webViewImpl->animateZoomAroundPoint(point, WebViewImpl::DoubleTap); |
610 webViewImpl->mainFrameImpl()->frameView()->layout(); | 610 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); |
| 611 WebCore::IntSize scrollDelta = webViewImpl->fakeDoubleTapTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
| 612 float scaleDelta = webViewImpl->fakeDoubleTapPageScaleFactorForTesting() / w
ebViewImpl->pageScaleFactor(); |
| 613 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); |
611 scale = webViewImpl->pageScaleFactor(); | 614 scale = webViewImpl->pageScaleFactor(); |
612 } | 615 } |
613 | 616 |
614 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTestCompositorScaling) | 617 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) |
615 { | 618 { |
616 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 619 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
617 | 620 |
618 const float deviceScaleFactor = 2.0f; | 621 const float deviceScaleFactor = 2.0f; |
619 int viewportWidth = 640 / deviceScaleFactor; | 622 int viewportWidth = 640 / deviceScaleFactor; |
620 int viewportHeight = 1280 / deviceScaleFactor; | 623 int viewportHeight = 1280 / deviceScaleFactor; |
621 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 624 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
622 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple
_divs_for_auto_zoom_test.html"); | 625 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple
_divs_for_auto_zoom_test.html"); |
623 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); | 626 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); |
624 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); | 627 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); |
625 m_webView->enableFixedLayoutMode(true); | 628 m_webView->enableFixedLayoutMode(true); |
626 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 629 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
627 m_webView->setPageScaleFactorLimits(0.5f, 4); | 630 m_webView->setPageScaleFactorLimits(0.5f, 4); |
628 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 631 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
629 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); | 632 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); |
630 m_webView->layout(); | 633 m_webView->layout(); |
631 | 634 |
632 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 635 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
633 webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true); | 636 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); |
634 | 637 |
635 WebRect topDiv(200, 100, 200, 150); | 638 WebRect topDiv(200, 100, 200, 150); |
636 WebRect bottomDiv(200, 300, 200, 150); | 639 WebRect bottomDiv(200, 300, 200, 150); |
637 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); | 640 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); |
638 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); | 641 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); |
639 float scale; | 642 float scale; |
640 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 643 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
641 | 644 |
642 // Test double tap on two different divs | 645 // Test double tap on two different divs |
643 // After first zoom, we should go back to minimum page scale with a second d
ouble tap. | 646 // After first zoom, we should go back to minimum page scale with a second d
ouble tap. |
644 simulateDoubleTap(webViewImpl, topPoint, scale); | 647 simulateDoubleTap(webViewImpl, topPoint, scale); |
645 EXPECT_FLOAT_EQ(1, scale); | 648 EXPECT_FLOAT_EQ(1, scale); |
646 simulateDoubleTap(webViewImpl, bottomPoint, scale); | 649 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
647 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 650 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
648 | 651 |
649 // If the user pinch zooms after double tap, a second double tap should zoom
back to the div. | 652 // If the user pinch zooms after double tap, a second double tap should zoom
back to the div. |
650 simulateDoubleTap(webViewImpl, topPoint, scale); | 653 simulateDoubleTap(webViewImpl, topPoint, scale); |
651 EXPECT_FLOAT_EQ(1, scale); | 654 EXPECT_FLOAT_EQ(1, scale); |
652 webViewImpl->applyScrollAndScale(WebSize(), 0.6f); | 655 webViewImpl->applyScrollAndScale(WebSize(), 0.6f); |
653 simulateDoubleTap(webViewImpl, bottomPoint, scale); | 656 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
654 EXPECT_FLOAT_EQ(1, scale); | 657 EXPECT_FLOAT_EQ(1, scale); |
| 658 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
| 659 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 660 |
| 661 // If we didn't yet get an auto-zoom update and a second double-tap arrives,
should go back to minimum scale. |
| 662 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); |
| 663 webViewImpl->animateZoomAroundPoint(topPoint, WebViewImpl::DoubleTap); |
| 664 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); |
| 665 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
| 666 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
655 } | 667 } |
656 | 668 |
657 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTestCompositorScaling) | 669 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) |
658 { | 670 { |
659 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 671 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
660 | 672 |
661 int viewportWidth = 320; | 673 int viewportWidth = 320; |
662 int viewportHeight = 480; | 674 int viewportHeight = 480; |
663 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 675 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
664 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo
unds_check_for_auto_zoom_test.html"); | 676 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo
unds_check_for_auto_zoom_test.html"); |
665 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); | 677 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); |
666 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); | 678 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); |
667 m_webView->enableFixedLayoutMode(true); | 679 m_webView->enableFixedLayoutMode(true); |
668 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 680 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
669 m_webView->setDeviceScaleFactor(1.5f); | 681 m_webView->setDeviceScaleFactor(1.5f); |
670 m_webView->layout(); | 682 m_webView->layout(); |
671 | 683 |
672 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 684 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
673 webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true); | 685 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); |
674 | 686 |
675 WebRect div(200, 100, 200, 150); | 687 WebRect div(200, 100, 200, 150); |
676 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 688 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
677 float scale; | 689 float scale; |
678 | 690 |
679 // Test double tap scale bounds. | 691 // Test double tap scale bounds. |
680 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 | 692 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 |
681 m_webView->setPageScaleFactorLimits(0.5f, 4); | 693 m_webView->setPageScaleFactorLimits(0.5f, 4); |
682 m_webView->layout(); | 694 m_webView->layout(); |
683 float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor
() * doubleTapZoomAlreadyLegibleRatio; | 695 float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor
() * doubleTapZoomAlreadyLegibleRatio; |
(...skipping 28 matching lines...) Expand all Loading... |
712 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 724 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
713 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 725 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
714 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 726 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
715 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 727 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
716 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 728 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
717 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 729 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
718 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 730 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
719 } | 731 } |
720 | 732 |
721 #if ENABLE(TEXT_AUTOSIZING) | 733 #if ENABLE(TEXT_AUTOSIZING) |
722 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTestCompositorScaling) | 734 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) |
723 { | 735 { |
724 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 736 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
725 | 737 |
726 int viewportWidth = 320; | 738 int viewportWidth = 320; |
727 int viewportHeight = 480; | 739 int viewportHeight = 480; |
728 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 740 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
729 float textAutosizingFontScaleFactor = 1.13f; | 741 float textAutosizingFontScaleFactor = 1.13f; |
730 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo
unds_check_for_auto_zoom_test.html"); | 742 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo
unds_check_for_auto_zoom_test.html"); |
731 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); | 743 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); |
732 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); | 744 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); |
733 m_webView->enableFixedLayoutMode(true); | 745 m_webView->enableFixedLayoutMode(true); |
734 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 746 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
735 m_webView->layout(); | 747 m_webView->layout(); |
736 | 748 |
737 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 749 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
738 webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true); | 750 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); |
739 webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosi
zingFontScaleFactor); | 751 webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosi
zingFontScaleFactor); |
740 | 752 |
741 WebRect div(200, 100, 200, 150); | 753 WebRect div(200, 100, 200, 150); |
742 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 754 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
743 float scale; | 755 float scale; |
744 | 756 |
745 // Test double tap scale bounds. | 757 // Test double tap scale bounds. |
746 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < textAutosizingF
ontScaleFactor | 758 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < textAutosizingF
ontScaleFactor |
747 float legibleScale = textAutosizingFontScaleFactor; | 759 float legibleScale = textAutosizingFontScaleFactor; |
748 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 760 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); | 825 m_webView->settings()->setApplyDeviceScaleFactorInCompositor(true); |
814 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); | 826 m_webView->settings()->setApplyPageScaleFactorInCompositor(true); |
815 m_webView->enableFixedLayoutMode(true); | 827 m_webView->enableFixedLayoutMode(true); |
816 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 828 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
817 m_webView->setPageScaleFactorLimits(1, 4); | 829 m_webView->setPageScaleFactorLimits(1, 4); |
818 m_webView->layout(); | 830 m_webView->layout(); |
819 m_webView->setDeviceScaleFactor(1.5f); | 831 m_webView->setDeviceScaleFactor(1.5f); |
820 m_webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true); | 832 m_webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true); |
821 | 833 |
822 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 834 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
823 webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true); | 835 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); |
824 | 836 |
825 WebRect editBoxWithText(200, 200, 250, 20); | 837 WebRect editBoxWithText(200, 200, 250, 20); |
826 WebRect editBoxWithNoText(200, 250, 250, 20); | 838 WebRect editBoxWithNoText(200, 250, 250, 20); |
827 | 839 |
828 // Test scrolling the focused node | 840 // Test scrolling the focused node |
829 // The edit box is shorter and narrower than the viewport when legible. | 841 // The edit box is shorter and narrower than the viewport when legible. |
830 m_webView->advanceFocus(false); | 842 m_webView->advanceFocus(false); |
831 // Set the caret to the end of the input box. | 843 // Set the caret to the end of the input box. |
832 m_webView->mainFrame()->document().getElementById("EditBoxWithText").to<WebI
nputElement>().setSelectionRange(1000, 1000); | 844 m_webView->mainFrame()->document().getElementById("EditBoxWithText").to<WebI
nputElement>().setSelectionRange(1000, 1000); |
833 setScaleAndScrollAndLayout(m_webView, WebPoint(0, 0), 1); | 845 setScaleAndScrollAndLayout(m_webView, WebPoint(0, 0), 1); |
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 TEST_F(WebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSelection) | 2239 TEST_F(WebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSelection) |
2228 { | 2240 { |
2229 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); | 2241 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); |
2230 WebFrame* frame = m_webView->mainFrame(); | 2242 WebFrame* frame = m_webView->mainFrame(); |
2231 | 2243 |
2232 // This test passes if this doesn't crash. | 2244 // This test passes if this doesn't crash. |
2233 frame->moveCaretSelectionTowardsWindowPoint(WebPoint(0, 0)); | 2245 frame->moveCaretSelectionTowardsWindowPoint(WebPoint(0, 0)); |
2234 } | 2246 } |
2235 | 2247 |
2236 } // namespace | 2248 } // namespace |
OLD | NEW |