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 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 | 2743 |
2744 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); | 2744 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); |
2745 | 2745 |
2746 // Move focus back to the first edit box. | 2746 // Move focus back to the first edit box. |
2747 webViewHelper.webView()->advanceFocus(true); | 2747 webViewHelper.webView()->advanceFocus(true); |
2748 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2748 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
2749 // The position should have stayed the same since this box was already on sc
reen with the right scale. | 2749 // The position should have stayed the same since this box was already on sc
reen with the right scale. |
2750 EXPECT_FALSE(needAnimation); | 2750 EXPECT_FALSE(needAnimation); |
2751 } | 2751 } |
2752 | 2752 |
| 2753 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) |
| 2754 { |
| 2755 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
| 2756 |
| 2757 const int viewportWidth = 450; |
| 2758 const int viewportHeight = 300; |
| 2759 const float minReadableCaretHeight = 18.0f; |
| 2760 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2761 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); |
| 2762 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2763 webViewHelper.webView()->setPageScaleFactorLimits(1, 4); |
| 2764 webViewHelper.webView()->layout(); |
| 2765 webViewHelper.webView()->setDeviceScaleFactor(1.5f); |
| 2766 webViewHelper.webView()->settings()->setAutoZoomFocusedNodeToLegibleScale(tr
ue); |
| 2767 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2768 |
| 2769 const WebRect editBoxWithText(200, 200, 250, 20); |
| 2770 |
| 2771 webViewHelper.webView()->advanceFocus(false); |
| 2772 // Set the caret to the begining of the input box. |
| 2773 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(0, 0); |
| 2774 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); |
| 2775 WebRect rect, caret; |
| 2776 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
| 2777 |
| 2778 // Set page scale twice larger then minimal readable scale |
| 2779 float newScale = minReadableCaretHeight / caret.height * 2.0; |
| 2780 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), newScale
); |
| 2781 |
| 2782 float scale; |
| 2783 IntPoint scroll; |
| 2784 bool needAnimation; |
| 2785 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2786 EXPECT_TRUE(needAnimation); |
| 2787 // Edit box and caret should be left alinged |
| 2788 int hScroll = editBoxWithText.x; |
| 2789 EXPECT_NEAR(hScroll, scroll.x(), 1); |
| 2790 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; |
| 2791 EXPECT_NEAR(vScroll, scroll.y(), 1); |
| 2792 // Page scale have to be unchanged |
| 2793 EXPECT_EQ(newScale, scale); |
| 2794 |
| 2795 // Set page scale and scroll such that edit box will be under the screen |
| 2796 newScale = 3.0; |
| 2797 hScroll = 200; |
| 2798 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(hScroll, 0), ne
wScale); |
| 2799 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2800 EXPECT_TRUE(needAnimation); |
| 2801 // Horizontal scroll have to be the same |
| 2802 EXPECT_NEAR(hScroll, scroll.x(), 1); |
| 2803 vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.heig
ht) / 2; |
| 2804 EXPECT_NEAR(vScroll, scroll.y(), 1); |
| 2805 // Page scale have to be unchanged |
| 2806 EXPECT_EQ(newScale, scale); |
| 2807 } |
| 2808 |
2753 class TestReloadDoesntRedirectWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { | 2809 class TestReloadDoesntRedirectWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { |
2754 public: | 2810 public: |
2755 virtual WebNavigationPolicy decidePolicyForNavigation(const NavigationPolicy
Info& info) OVERRIDE | 2811 virtual WebNavigationPolicy decidePolicyForNavigation(const NavigationPolicy
Info& info) OVERRIDE |
2756 { | 2812 { |
2757 EXPECT_FALSE(info.isRedirect); | 2813 EXPECT_FALSE(info.isRedirect); |
2758 return WebNavigationPolicyCurrentTab; | 2814 return WebNavigationPolicyCurrentTab; |
2759 } | 2815 } |
2760 }; | 2816 }; |
2761 | 2817 |
2762 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) | 2818 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) |
(...skipping 3419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6182 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6238 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6183 | 6239 |
6184 // Neither should a page reload. | 6240 // Neither should a page reload. |
6185 localFrame->reload(); | 6241 localFrame->reload(); |
6186 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6242 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6187 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6243 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6188 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6244 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6189 } | 6245 } |
6190 | 6246 |
6191 } // namespace | 6247 } // namespace |
OLD | NEW |