Chromium Code Reviews| 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 9858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9869 EXPECT_TRUE( | 9869 EXPECT_TRUE( |
| 9870 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); | 9870 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); |
| 9871 } | 9871 } |
| 9872 EXPECT_FALSE(page->Suspended()); | 9872 EXPECT_FALSE(page->Suspended()); |
| 9873 EXPECT_FALSE( | 9873 EXPECT_FALSE( |
| 9874 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); | 9874 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); |
| 9875 } | 9875 } |
| 9876 | 9876 |
| 9877 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { | 9877 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 9878 public: | 9878 public: |
| 9879 MOCK_METHOD4(DidOverscroll, | 9879 MOCK_METHOD5(DidOverscroll, |
| 9880 void(const WebFloatSize&, | 9880 void(const WebFloatSize&, |
| 9881 const WebFloatSize&, | 9881 const WebFloatSize&, |
| 9882 const WebFloatPoint&, | 9882 const WebFloatPoint&, |
| 9883 const WebFloatSize&)); | 9883 const WebFloatSize&, |
| 9884 const WebScrollBoundaryBehavior&)); | |
| 9884 }; | 9885 }; |
| 9885 | 9886 |
| 9886 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; | 9887 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; |
| 9887 class WebFrameOverscrollTest | 9888 class WebFrameOverscrollTest |
| 9888 : public WebFrameTest, | 9889 : public WebFrameTest, |
| 9889 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>, | 9890 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>, |
| 9890 private ScopedRootLayerScrollingForTest { | 9891 private ScopedRootLayerScrollingForTest { |
| 9891 public: | 9892 public: |
| 9892 WebFrameOverscrollTest() | 9893 WebFrameOverscrollTest() |
| 9893 : ScopedRootLayerScrollingForTest(GetParam().first) {} | 9894 : ScopedRootLayerScrollingForTest(GetParam().first) {} |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9950 FrameTestHelpers::WebViewHelper web_view_helper; | 9951 FrameTestHelpers::WebViewHelper web_view_helper; |
| 9951 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 9952 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
| 9952 nullptr, &client, nullptr, | 9953 nullptr, &client, nullptr, |
| 9953 ConfigureAndroid); | 9954 ConfigureAndroid); |
| 9954 web_view_helper.Resize(WebSize(200, 200)); | 9955 web_view_helper.Resize(WebSize(200, 200)); |
| 9955 | 9956 |
| 9956 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple | 9957 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple |
| 9957 // scrollUpdate. | 9958 // scrollUpdate. |
| 9958 ScrollBegin(&web_view_helper, -300, -316); | 9959 ScrollBegin(&web_view_helper, -300, -316); |
| 9959 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), | 9960 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), |
| 9960 WebFloatPoint(100, 100), WebFloatSize())); | 9961 WebFloatPoint(100, 100), WebFloatSize(), |
| 9962 WebScrollBoundaryBehavior())); | |
| 9961 ScrollUpdate(&web_view_helper, -308, -316); | 9963 ScrollUpdate(&web_view_helper, -308, -316); |
| 9962 Mock::VerifyAndClearExpectations(&client); | 9964 Mock::VerifyAndClearExpectations(&client); |
| 9963 | 9965 |
| 9964 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), | 9966 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), |
| 9965 WebFloatPoint(100, 100), WebFloatSize())); | 9967 WebFloatPoint(100, 100), WebFloatSize(), |
| 9968 WebScrollBoundaryBehavior())); | |
| 9966 ScrollUpdate(&web_view_helper, 0, -13); | 9969 ScrollUpdate(&web_view_helper, 0, -13); |
| 9967 Mock::VerifyAndClearExpectations(&client); | 9970 Mock::VerifyAndClearExpectations(&client); |
| 9968 | 9971 |
| 9969 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), | 9972 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), |
| 9970 WebFloatPoint(100, 100), WebFloatSize())); | 9973 WebFloatPoint(100, 100), WebFloatSize(), |
| 9974 WebScrollBoundaryBehavior())); | |
| 9971 ScrollUpdate(&web_view_helper, -20, -13); | 9975 ScrollUpdate(&web_view_helper, -20, -13); |
| 9972 Mock::VerifyAndClearExpectations(&client); | 9976 Mock::VerifyAndClearExpectations(&client); |
| 9973 | 9977 |
| 9974 // Overscroll is not reported. | 9978 // Overscroll is not reported. |
| 9975 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 9979 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 9976 ScrollUpdate(&web_view_helper, 0, 1); | 9980 ScrollUpdate(&web_view_helper, 0, 1); |
| 9977 Mock::VerifyAndClearExpectations(&client); | 9981 Mock::VerifyAndClearExpectations(&client); |
| 9978 | 9982 |
| 9979 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 9983 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 9980 ScrollUpdate(&web_view_helper, 1, 0); | 9984 ScrollUpdate(&web_view_helper, 1, 0); |
| 9981 Mock::VerifyAndClearExpectations(&client); | 9985 Mock::VerifyAndClearExpectations(&client); |
| 9982 | 9986 |
| 9983 // Overscroll is reported. | 9987 // Overscroll is reported. |
| 9984 EXPECT_CALL(client, | 9988 EXPECT_CALL(client, |
| 9985 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), | 9989 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), |
| 9986 WebFloatPoint(100, 100), WebFloatSize())); | 9990 WebFloatPoint(100, 100), WebFloatSize(), |
| 9991 WebScrollBoundaryBehavior())); | |
| 9987 ScrollUpdate(&web_view_helper, 0, 1000); | 9992 ScrollUpdate(&web_view_helper, 0, 1000); |
| 9988 Mock::VerifyAndClearExpectations(&client); | 9993 Mock::VerifyAndClearExpectations(&client); |
| 9989 | 9994 |
| 9990 // Overscroll is not reported. | 9995 // Overscroll is not reported. |
| 9991 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 9996 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 9992 ScrollEnd(&web_view_helper); | 9997 ScrollEnd(&web_view_helper); |
| 9993 Mock::VerifyAndClearExpectations(&client); | 9998 Mock::VerifyAndClearExpectations(&client); |
| 9994 } | 9999 } |
| 9995 | 10000 |
| 9996 TEST_P(WebFrameOverscrollTest, | 10001 TEST_P(WebFrameOverscrollTest, |
| 9997 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { | 10002 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { |
| 9998 OverscrollWebViewClient client; | 10003 OverscrollWebViewClient client; |
| 9999 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 10004 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
| 10000 FrameTestHelpers::WebViewHelper web_view_helper; | 10005 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10001 web_view_helper.InitializeAndLoad( | 10006 web_view_helper.InitializeAndLoad( |
| 10002 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 10007 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
| 10003 ConfigureAndroid); | 10008 ConfigureAndroid); |
| 10004 web_view_helper.Resize(WebSize(200, 200)); | 10009 web_view_helper.Resize(WebSize(200, 200)); |
| 10005 | 10010 |
| 10006 ScrollBegin(&web_view_helper, 0, -316); | 10011 ScrollBegin(&web_view_helper, 0, -316); |
| 10007 | 10012 |
| 10008 // Scroll the Div to the end. | 10013 // Scroll the Div to the end. |
| 10009 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10014 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10010 ScrollUpdate(&web_view_helper, 0, -316); | 10015 ScrollUpdate(&web_view_helper, 0, -316); |
| 10011 Mock::VerifyAndClearExpectations(&client); | 10016 Mock::VerifyAndClearExpectations(&client); |
| 10012 | 10017 |
| 10013 ScrollEnd(&web_view_helper); | 10018 ScrollEnd(&web_view_helper); |
| 10014 ScrollBegin(&web_view_helper, 0, -100); | 10019 ScrollBegin(&web_view_helper, 0, -100); |
| 10015 | 10020 |
| 10016 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 10021 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
| 10017 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), | 10022 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), |
| 10018 WebFloatPoint(100, 100), WebFloatSize())); | 10023 WebFloatPoint(100, 100), WebFloatSize(), |
| 10024 WebScrollBoundaryBehavior())); | |
| 10019 ScrollUpdate(&web_view_helper, 0, -100); | 10025 ScrollUpdate(&web_view_helper, 0, -100); |
| 10020 ScrollUpdate(&web_view_helper, 0, -100); | 10026 ScrollUpdate(&web_view_helper, 0, -100); |
| 10021 Mock::VerifyAndClearExpectations(&client); | 10027 Mock::VerifyAndClearExpectations(&client); |
| 10022 | 10028 |
| 10023 // TODO(bokan): This has never worked but by the accident that this test was | 10029 // TODO(bokan): This has never worked but by the accident that this test was |
| 10024 // being run in a WebView without a size. This test should be fixed along with | 10030 // being run in a WebView without a size. This test should be fixed along with |
| 10025 // the bug, crbug.com/589320. | 10031 // the bug, crbug.com/589320. |
| 10026 // Page scrolls vertically, but over-scrolls horizontally. | 10032 // Page scrolls vertically, but over-scrolls horizontally. |
| 10027 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, | 10033 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, |
| 10028 // 0), WebFloatPoint(100, 100), WebFloatSize())); | 10034 // 0), WebFloatPoint(100, 100), WebFloatSize(), WebScrollBoundaryBehavior())); |
| 10029 // ScrollUpdate(&webViewHelper, 100, 50); | 10035 // ScrollUpdate(&webViewHelper, 100, 50); |
| 10030 // Mock::VerifyAndClearExpectations(&client); | 10036 // Mock::VerifyAndClearExpectations(&client); |
| 10031 | 10037 |
| 10032 // Scrolling up, Overscroll is not reported. | 10038 // Scrolling up, Overscroll is not reported. |
| 10033 // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | 10039 // EXPECT_CALL(client, didOverscroll(_, _, _, _, _)).Times(0); |
| 10034 // ScrollUpdate(&webViewHelper, 0, -50); | 10040 // ScrollUpdate(&webViewHelper, 0, -50); |
| 10035 // Mock::VerifyAndClearExpectations(&client); | 10041 // Mock::VerifyAndClearExpectations(&client); |
| 10036 | 10042 |
| 10037 // Page scrolls horizontally, but over-scrolls vertically. | 10043 // Page scrolls horizontally, but over-scrolls vertically. |
| 10038 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, | 10044 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, |
| 10039 // 100), WebFloatPoint(100, 100), WebFloatSize())); | 10045 // 100), WebFloatPoint(100, 100), WebFloatSize(), |
| 10046 // WebScrollBoundaryBehavior())); | |
| 10040 // ScrollUpdate(&webViewHelper, -100, -100); | 10047 // ScrollUpdate(&webViewHelper, -100, -100); |
| 10041 // Mock::VerifyAndClearExpectations(&client); | 10048 // Mock::VerifyAndClearExpectations(&client); |
| 10042 } | 10049 } |
| 10043 | 10050 |
| 10044 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { | 10051 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { |
| 10045 OverscrollWebViewClient client; | 10052 OverscrollWebViewClient client; |
| 10046 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 10053 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
| 10047 FrameTestHelpers::WebViewHelper web_view_helper; | 10054 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10048 web_view_helper.InitializeAndLoad( | 10055 web_view_helper.InitializeAndLoad( |
| 10049 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 10056 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
| 10050 ConfigureAndroid); | 10057 ConfigureAndroid); |
| 10051 web_view_helper.Resize(WebSize(200, 200)); | 10058 web_view_helper.Resize(WebSize(200, 200)); |
| 10052 | 10059 |
| 10053 ScrollBegin(&web_view_helper, 0, -316); | 10060 ScrollBegin(&web_view_helper, 0, -316); |
| 10054 | 10061 |
| 10055 // Scroll the Div to the end. | 10062 // Scroll the Div to the end. |
| 10056 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10063 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10057 ScrollUpdate(&web_view_helper, 0, -316); | 10064 ScrollUpdate(&web_view_helper, 0, -316); |
| 10058 Mock::VerifyAndClearExpectations(&client); | 10065 Mock::VerifyAndClearExpectations(&client); |
| 10059 | 10066 |
| 10060 ScrollEnd(&web_view_helper); | 10067 ScrollEnd(&web_view_helper); |
| 10061 ScrollBegin(&web_view_helper, 0, -150); | 10068 ScrollBegin(&web_view_helper, 0, -150); |
| 10062 | 10069 |
| 10063 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 10070 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
| 10064 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10071 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
| 10065 WebFloatPoint(100, 100), WebFloatSize())); | 10072 WebFloatPoint(100, 100), WebFloatSize(), |
| 10073 WebScrollBoundaryBehavior())); | |
| 10066 ScrollUpdate(&web_view_helper, 0, -150); | 10074 ScrollUpdate(&web_view_helper, 0, -150); |
| 10067 Mock::VerifyAndClearExpectations(&client); | 10075 Mock::VerifyAndClearExpectations(&client); |
| 10068 } | 10076 } |
| 10069 | 10077 |
| 10070 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { | 10078 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { |
| 10071 OverscrollWebViewClient client; | 10079 OverscrollWebViewClient client; |
| 10072 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); | 10080 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); |
| 10073 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); | 10081 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); |
| 10074 FrameTestHelpers::WebViewHelper web_view_helper; | 10082 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10075 web_view_helper.InitializeAndLoad( | 10083 web_view_helper.InitializeAndLoad( |
| 10076 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, | 10084 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, |
| 10077 nullptr, ConfigureAndroid); | 10085 nullptr, ConfigureAndroid); |
| 10078 web_view_helper.Resize(WebSize(200, 200)); | 10086 web_view_helper.Resize(WebSize(200, 200)); |
| 10079 | 10087 |
| 10080 ScrollBegin(&web_view_helper, 0, -320); | 10088 ScrollBegin(&web_view_helper, 0, -320); |
| 10081 // Scroll the IFrame to the end. | 10089 // Scroll the IFrame to the end. |
| 10082 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10090 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10083 | 10091 |
| 10084 // This scroll will fully scroll the iframe but will be consumed before being | 10092 // This scroll will fully scroll the iframe but will be consumed before being |
| 10085 // counted as overscroll. | 10093 // counted as overscroll. |
| 10086 ScrollUpdate(&web_view_helper, 0, -320); | 10094 ScrollUpdate(&web_view_helper, 0, -320); |
| 10087 | 10095 |
| 10088 // This scroll will again target the iframe but wont bubble further up. Make | 10096 // This scroll will again target the iframe but wont bubble further up. Make |
| 10089 // sure that the unused scroll isn't handled as overscroll. | 10097 // sure that the unused scroll isn't handled as overscroll. |
| 10090 ScrollUpdate(&web_view_helper, 0, -50); | 10098 ScrollUpdate(&web_view_helper, 0, -50); |
| 10091 Mock::VerifyAndClearExpectations(&client); | 10099 Mock::VerifyAndClearExpectations(&client); |
| 10092 | 10100 |
| 10093 ScrollEnd(&web_view_helper); | 10101 ScrollEnd(&web_view_helper); |
| 10094 ScrollBegin(&web_view_helper, 0, -150); | 10102 ScrollBegin(&web_view_helper, 0, -150); |
| 10095 | 10103 |
| 10096 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. | 10104 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. |
| 10097 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10105 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
| 10098 WebFloatPoint(100, 100), WebFloatSize())); | 10106 WebFloatPoint(100, 100), WebFloatSize(), |
| 10107 WebScrollBoundaryBehavior())); | |
| 10099 ScrollUpdate(&web_view_helper, 0, -150); | 10108 ScrollUpdate(&web_view_helper, 0, -150); |
| 10100 Mock::VerifyAndClearExpectations(&client); | 10109 Mock::VerifyAndClearExpectations(&client); |
| 10101 | 10110 |
| 10102 ScrollEnd(&web_view_helper); | 10111 ScrollEnd(&web_view_helper); |
| 10103 } | 10112 } |
| 10104 | 10113 |
| 10105 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { | 10114 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { |
| 10106 OverscrollWebViewClient client; | 10115 OverscrollWebViewClient client; |
| 10107 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10116 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
| 10108 FrameTestHelpers::WebViewHelper web_view_helper; | 10117 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10109 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( | 10118 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( |
| 10110 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, | 10119 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, |
| 10111 ConfigureAndroid); | 10120 ConfigureAndroid); |
| 10112 web_view_helper.Resize(WebSize(200, 200)); | 10121 web_view_helper.Resize(WebSize(200, 200)); |
| 10113 web_view_impl->SetPageScaleFactor(3.0); | 10122 web_view_impl->SetPageScaleFactor(3.0); |
| 10114 | 10123 |
| 10115 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. | 10124 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. |
| 10116 // The point is (99, 99) because we clamp in the division by 3 to 33 so when | 10125 // The point is (99, 99) because we clamp in the division by 3 to 33 so when |
| 10117 // we go back to viewport coordinates it becomes (99, 99). | 10126 // we go back to viewport coordinates it becomes (99, 99). |
| 10118 ScrollBegin(&web_view_helper, 0, 30); | 10127 ScrollBegin(&web_view_helper, 0, 30); |
| 10119 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), | 10128 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), |
| 10120 WebFloatPoint(99, 99), WebFloatSize())); | 10129 WebFloatPoint(99, 99), WebFloatSize(), |
| 10130 WebScrollBoundaryBehavior())); | |
| 10121 ScrollUpdate(&web_view_helper, 0, 30); | 10131 ScrollUpdate(&web_view_helper, 0, 30); |
| 10122 Mock::VerifyAndClearExpectations(&client); | 10132 Mock::VerifyAndClearExpectations(&client); |
| 10123 | 10133 |
| 10124 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), | 10134 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), |
| 10125 WebFloatPoint(99, 99), WebFloatSize())); | 10135 WebFloatPoint(99, 99), WebFloatSize(), |
| 10136 WebScrollBoundaryBehavior())); | |
| 10126 ScrollUpdate(&web_view_helper, 0, 30); | 10137 ScrollUpdate(&web_view_helper, 0, 30); |
| 10127 Mock::VerifyAndClearExpectations(&client); | 10138 Mock::VerifyAndClearExpectations(&client); |
| 10128 | 10139 |
| 10129 EXPECT_CALL(client, | 10140 EXPECT_CALL(client, |
| 10130 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), | 10141 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), |
| 10131 WebFloatPoint(99, 99), WebFloatSize())); | 10142 WebFloatPoint(99, 99), WebFloatSize(), |
| 10143 WebScrollBoundaryBehavior())); | |
| 10132 ScrollUpdate(&web_view_helper, 30, 30); | 10144 ScrollUpdate(&web_view_helper, 30, 30); |
| 10133 Mock::VerifyAndClearExpectations(&client); | 10145 Mock::VerifyAndClearExpectations(&client); |
| 10134 | 10146 |
| 10135 EXPECT_CALL(client, | 10147 EXPECT_CALL(client, |
| 10136 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), | 10148 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), |
| 10137 WebFloatPoint(99, 99), WebFloatSize())); | 10149 WebFloatPoint(99, 99), WebFloatSize(), |
| 10150 WebScrollBoundaryBehavior())); | |
| 10138 ScrollUpdate(&web_view_helper, 30, 0); | 10151 ScrollUpdate(&web_view_helper, 30, 0); |
| 10139 Mock::VerifyAndClearExpectations(&client); | 10152 Mock::VerifyAndClearExpectations(&client); |
| 10140 | 10153 |
| 10141 // Overscroll is not reported. | 10154 // Overscroll is not reported. |
| 10142 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10155 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10143 ScrollEnd(&web_view_helper); | 10156 ScrollEnd(&web_view_helper); |
| 10144 Mock::VerifyAndClearExpectations(&client); | 10157 Mock::VerifyAndClearExpectations(&client); |
| 10145 } | 10158 } |
| 10146 | 10159 |
| 10147 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { | 10160 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { |
| 10148 OverscrollWebViewClient client; | 10161 OverscrollWebViewClient client; |
| 10149 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10162 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
| 10150 FrameTestHelpers::WebViewHelper web_view_helper; | 10163 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10151 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 10164 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
| 10152 nullptr, &client, nullptr, | 10165 nullptr, &client, nullptr, |
| 10153 ConfigureAndroid); | 10166 ConfigureAndroid); |
| 10154 web_view_helper.Resize(WebSize(200, 200)); | 10167 web_view_helper.Resize(WebSize(200, 200)); |
| 10155 | 10168 |
| 10156 ScrollBegin(&web_view_helper, 10, 10); | 10169 ScrollBegin(&web_view_helper, 10, 10); |
| 10157 EXPECT_CALL(client, | 10170 EXPECT_CALL(client, |
| 10158 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), | 10171 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), |
| 10159 WebFloatPoint(100, 100), WebFloatSize())); | 10172 WebFloatPoint(100, 100), WebFloatSize(), |
| 10173 WebScrollBoundaryBehavior())); | |
| 10160 ScrollUpdate(&web_view_helper, 10, 10); | 10174 ScrollUpdate(&web_view_helper, 10, 10); |
| 10161 Mock::VerifyAndClearExpectations(&client); | 10175 Mock::VerifyAndClearExpectations(&client); |
| 10162 | 10176 |
| 10163 EXPECT_CALL(client, | 10177 EXPECT_CALL(client, |
| 10164 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), | 10178 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), |
| 10165 WebFloatPoint(100, 100), WebFloatSize())); | 10179 WebFloatPoint(100, 100), WebFloatSize(), |
| 10180 WebScrollBoundaryBehavior())); | |
| 10166 ScrollUpdate(&web_view_helper, 0, 0.10); | 10181 ScrollUpdate(&web_view_helper, 0, 0.10); |
| 10167 Mock::VerifyAndClearExpectations(&client); | 10182 Mock::VerifyAndClearExpectations(&client); |
| 10168 | 10183 |
| 10169 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), | 10184 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), |
| 10170 WebFloatSize(-10.10, -10.10), | 10185 WebFloatSize(-10.10, -10.10), |
| 10171 WebFloatPoint(100, 100), WebFloatSize())); | 10186 WebFloatPoint(100, 100), WebFloatSize(), |
| 10187 WebScrollBoundaryBehavior())); | |
| 10172 ScrollUpdate(&web_view_helper, 0.10, 0); | 10188 ScrollUpdate(&web_view_helper, 0.10, 0); |
| 10173 Mock::VerifyAndClearExpectations(&client); | 10189 Mock::VerifyAndClearExpectations(&client); |
| 10174 | 10190 |
| 10175 // For residual values overscrollDelta should be reset and didOverscroll | 10191 // For residual values overscrollDelta should be reset and didOverscroll |
| 10176 // shouldn't be called. | 10192 // shouldn't be called. |
| 10177 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10193 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10178 ScrollUpdate(&web_view_helper, 0, 0.09); | 10194 ScrollUpdate(&web_view_helper, 0, 0.09); |
| 10179 Mock::VerifyAndClearExpectations(&client); | 10195 Mock::VerifyAndClearExpectations(&client); |
| 10180 | 10196 |
| 10181 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10197 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10182 ScrollUpdate(&web_view_helper, 0.09, 0.09); | 10198 ScrollUpdate(&web_view_helper, 0.09, 0.09); |
| 10183 Mock::VerifyAndClearExpectations(&client); | 10199 Mock::VerifyAndClearExpectations(&client); |
| 10184 | 10200 |
| 10185 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10201 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10186 ScrollUpdate(&web_view_helper, 0.09, 0); | 10202 ScrollUpdate(&web_view_helper, 0.09, 0); |
| 10187 Mock::VerifyAndClearExpectations(&client); | 10203 Mock::VerifyAndClearExpectations(&client); |
| 10188 | 10204 |
| 10189 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10205 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10190 ScrollUpdate(&web_view_helper, 0, -0.09); | 10206 ScrollUpdate(&web_view_helper, 0, -0.09); |
| 10191 Mock::VerifyAndClearExpectations(&client); | 10207 Mock::VerifyAndClearExpectations(&client); |
| 10192 | 10208 |
| 10193 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10209 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10194 ScrollUpdate(&web_view_helper, -0.09, -0.09); | 10210 ScrollUpdate(&web_view_helper, -0.09, -0.09); |
| 10195 Mock::VerifyAndClearExpectations(&client); | 10211 Mock::VerifyAndClearExpectations(&client); |
| 10196 | 10212 |
| 10197 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10213 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10198 ScrollUpdate(&web_view_helper, -0.09, 0); | 10214 ScrollUpdate(&web_view_helper, -0.09, 0); |
| 10199 Mock::VerifyAndClearExpectations(&client); | 10215 Mock::VerifyAndClearExpectations(&client); |
| 10200 | 10216 |
| 10201 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10217 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| 10202 ScrollEnd(&web_view_helper); | 10218 ScrollEnd(&web_view_helper); |
| 10203 Mock::VerifyAndClearExpectations(&client); | 10219 Mock::VerifyAndClearExpectations(&client); |
| 10204 } | 10220 } |
| 10205 | 10221 |
| 10222 TEST_P(WebFrameOverscrollTest, OnlyMainFrameScrollBoundaryBehaviorHasEffect) { | |
|
majidvp
2017/07/25 20:38:29
Please also add a test to ensure that updating mai
sunyunjia
2017/08/03 14:54:34
Done.
| |
| 10223 OverscrollWebViewClient client; | |
| 10224 RegisterMockedHttpURLLoad("single_iframe.html"); | |
| 10225 RegisterMockedHttpURLLoad("visible_iframe.html"); | |
| 10226 FrameTestHelpers::WebViewHelper web_view_helper; | |
| 10227 web_view_helper.InitializeAndLoad(base_url_ + "single_iframe.html", nullptr, | |
| 10228 &client, nullptr, ConfigureAndroid); | |
| 10229 web_view_helper.Resize(WebSize(200, 200)); | |
| 10230 | |
| 10231 WebLocalFrame* mainFrame = | |
| 10232 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame(); | |
| 10233 mainFrame->ExecuteScript( | |
| 10234 WebScriptSource(WebString("document.body.style=" | |
| 10235 "'height: 400px;" | |
| 10236 "width: 400px;" | |
| 10237 "scroll-boundary-behavior: auto;'"))); | |
|
majidvp
2017/07/25 20:38:29
If I understand it correctly, the height and width
sunyunjia
2017/08/03 14:54:34
Done.
| |
| 10238 WebLocalFrame* subframe = | |
| 10239 web_view_helper.WebView()->MainFrame()->FirstChild()->ToWebLocalFrame(); | |
| 10240 subframe->ExecuteScript( | |
| 10241 WebScriptSource(WebString("document.body.style=" | |
| 10242 "'scroll-boundary-behavior: none;" | |
| 10243 "height: 50px;" | |
| 10244 "width: 50px'"))); | |
| 10245 | |
| 10246 ScrollBegin(&web_view_helper, 100, 116); | |
| 10247 EXPECT_CALL( | |
| 10248 client, | |
| 10249 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100), | |
| 10250 WebFloatPoint(100, 100), WebFloatSize(), | |
| 10251 WebScrollBoundaryBehavior( | |
| 10252 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: | |
| 10253 kScrollBoundaryBehaviorTypeAuto))); | |
| 10254 ScrollUpdate(&web_view_helper, 100, 100); | |
| 10255 Mock::VerifyAndClearExpectations(&client); | |
| 10256 } | |
| 10257 | |
| 10206 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { | 10258 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { |
| 10207 RuntimeEnabledFeatures::SetOrientationEventEnabled(true); | 10259 RuntimeEnabledFeatures::SetOrientationEventEnabled(true); |
| 10208 RegisterMockedHttpURLLoad("orientation-frame-detach.html"); | 10260 RegisterMockedHttpURLLoad("orientation-frame-detach.html"); |
| 10209 FrameTestHelpers::WebViewHelper web_view_helper; | 10261 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10210 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( | 10262 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( |
| 10211 base_url_ + "orientation-frame-detach.html"); | 10263 base_url_ + "orientation-frame-detach.html"); |
| 10212 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent(); | 10264 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent(); |
| 10213 } | 10265 } |
| 10214 | 10266 |
| 10215 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) { | 10267 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) { |
| (...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12130 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation, | 12182 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation, |
| 12131 1); | 12183 1); |
| 12132 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an | 12184 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an |
| 12133 // illegal combination, which has been caught by DCHECK in | 12185 // illegal combination, which has been caught by DCHECK in |
| 12134 // UpdateForSameDocumentNavigation(). | 12186 // UpdateForSameDocumentNavigation(). |
| 12135 | 12187 |
| 12136 tester.ExpectTotalCount(histogramName, 3); | 12188 tester.ExpectTotalCount(histogramName, 3); |
| 12137 } | 12189 } |
| 12138 | 12190 |
| 12139 } // namespace blink | 12191 } // namespace blink |
| OLD | NEW |