| 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 9866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9877 WebGestureEvent event(type, WebInputEvent::kNoModifiers, | 9877 WebGestureEvent event(type, WebInputEvent::kNoModifiers, |
| 9878 WebInputEvent::kTimeStampForTesting); | 9878 WebInputEvent::kTimeStampForTesting); |
| 9879 // TODO(wjmaclean): Make sure that touchpad device is only ever used for | 9879 // TODO(wjmaclean): Make sure that touchpad device is only ever used for |
| 9880 // gesture scrolling event types. | 9880 // gesture scrolling event types. |
| 9881 event.source_device = GetParam(); | 9881 event.source_device = GetParam(); |
| 9882 event.x = 100; | 9882 event.x = 100; |
| 9883 event.y = 100; | 9883 event.y = 100; |
| 9884 if (type == WebInputEvent::kGestureScrollUpdate) { | 9884 if (type == WebInputEvent::kGestureScrollUpdate) { |
| 9885 event.data.scroll_update.delta_x = delta_x; | 9885 event.data.scroll_update.delta_x = delta_x; |
| 9886 event.data.scroll_update.delta_y = delta_y; | 9886 event.data.scroll_update.delta_y = delta_y; |
| 9887 } else if (type == WebInputEvent::kGestureScrollBegin) { |
| 9888 event.data.scroll_begin.delta_x_hint = delta_x; |
| 9889 event.data.scroll_begin.delta_y_hint = delta_y; |
| 9887 } | 9890 } |
| 9888 return WebCoalescedInputEvent(event); | 9891 return WebCoalescedInputEvent(event); |
| 9889 } | 9892 } |
| 9890 | 9893 |
| 9891 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper) { | 9894 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper, |
| 9892 web_view_helper->WebView()->HandleInputEvent( | 9895 float delta_x_hint, |
| 9893 GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 9896 float delta_y_hint) { |
| 9897 web_view_helper->WebView()->HandleInputEvent(GenerateEvent( |
| 9898 WebInputEvent::kGestureScrollBegin, delta_x_hint, delta_y_hint)); |
| 9894 } | 9899 } |
| 9895 | 9900 |
| 9896 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper, | 9901 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper, |
| 9897 float delta_x, | 9902 float delta_x, |
| 9898 float delta_y) { | 9903 float delta_y) { |
| 9899 web_view_helper->WebView()->HandleInputEvent( | 9904 web_view_helper->WebView()->HandleInputEvent( |
| 9900 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y)); | 9905 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y)); |
| 9901 } | 9906 } |
| 9902 | 9907 |
| 9903 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) { | 9908 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9916 OverscrollWebViewClient client; | 9921 OverscrollWebViewClient client; |
| 9917 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 9922 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
| 9918 FrameTestHelpers::WebViewHelper web_view_helper; | 9923 FrameTestHelpers::WebViewHelper web_view_helper; |
| 9919 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 9924 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
| 9920 nullptr, &client, nullptr, | 9925 nullptr, &client, nullptr, |
| 9921 ConfigureAndroid); | 9926 ConfigureAndroid); |
| 9922 web_view_helper.Resize(WebSize(200, 200)); | 9927 web_view_helper.Resize(WebSize(200, 200)); |
| 9923 | 9928 |
| 9924 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple | 9929 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple |
| 9925 // scrollUpdate. | 9930 // scrollUpdate. |
| 9926 ScrollBegin(&web_view_helper); | 9931 ScrollBegin(&web_view_helper, -300, -316); |
| 9927 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), | 9932 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), |
| 9928 WebFloatPoint(100, 100), WebFloatSize())); | 9933 WebFloatPoint(100, 100), WebFloatSize())); |
| 9929 ScrollUpdate(&web_view_helper, -308, -316); | 9934 ScrollUpdate(&web_view_helper, -308, -316); |
| 9930 Mock::VerifyAndClearExpectations(&client); | 9935 Mock::VerifyAndClearExpectations(&client); |
| 9931 | 9936 |
| 9932 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), | 9937 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), |
| 9933 WebFloatPoint(100, 100), WebFloatSize())); | 9938 WebFloatPoint(100, 100), WebFloatSize())); |
| 9934 ScrollUpdate(&web_view_helper, 0, -13); | 9939 ScrollUpdate(&web_view_helper, 0, -13); |
| 9935 Mock::VerifyAndClearExpectations(&client); | 9940 Mock::VerifyAndClearExpectations(&client); |
| 9936 | 9941 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 9964 TEST_P(WebFrameOverscrollTest, | 9969 TEST_P(WebFrameOverscrollTest, |
| 9965 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { | 9970 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { |
| 9966 OverscrollWebViewClient client; | 9971 OverscrollWebViewClient client; |
| 9967 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 9972 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
| 9968 FrameTestHelpers::WebViewHelper web_view_helper; | 9973 FrameTestHelpers::WebViewHelper web_view_helper; |
| 9969 web_view_helper.InitializeAndLoad( | 9974 web_view_helper.InitializeAndLoad( |
| 9970 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 9975 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
| 9971 ConfigureAndroid); | 9976 ConfigureAndroid); |
| 9972 web_view_helper.Resize(WebSize(200, 200)); | 9977 web_view_helper.Resize(WebSize(200, 200)); |
| 9973 | 9978 |
| 9974 ScrollBegin(&web_view_helper); | 9979 ScrollBegin(&web_view_helper, 0, -316); |
| 9975 | 9980 |
| 9976 // Scroll the Div to the end. | 9981 // Scroll the Div to the end. |
| 9977 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 9982 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| 9978 ScrollUpdate(&web_view_helper, 0, -316); | 9983 ScrollUpdate(&web_view_helper, 0, -316); |
| 9979 Mock::VerifyAndClearExpectations(&client); | 9984 Mock::VerifyAndClearExpectations(&client); |
| 9980 | 9985 |
| 9981 ScrollEnd(&web_view_helper); | 9986 ScrollEnd(&web_view_helper); |
| 9982 ScrollBegin(&web_view_helper); | 9987 ScrollBegin(&web_view_helper, 0, -100); |
| 9983 | 9988 |
| 9984 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 9989 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
| 9985 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), | 9990 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), |
| 9986 WebFloatPoint(100, 100), WebFloatSize())); | 9991 WebFloatPoint(100, 100), WebFloatSize())); |
| 9987 ScrollUpdate(&web_view_helper, 0, -100); | 9992 ScrollUpdate(&web_view_helper, 0, -100); |
| 9988 ScrollUpdate(&web_view_helper, 0, -100); | 9993 ScrollUpdate(&web_view_helper, 0, -100); |
| 9989 Mock::VerifyAndClearExpectations(&client); | 9994 Mock::VerifyAndClearExpectations(&client); |
| 9990 | 9995 |
| 9991 // TODO(bokan): This has never worked but by the accident that this test was | 9996 // TODO(bokan): This has never worked but by the accident that this test was |
| 9992 // being run in a WebView without a size. This test should be fixed along with | 9997 // being run in a WebView without a size. This test should be fixed along with |
| (...skipping 18 matching lines...) Expand all Loading... |
| 10011 | 10016 |
| 10012 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { | 10017 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { |
| 10013 OverscrollWebViewClient client; | 10018 OverscrollWebViewClient client; |
| 10014 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 10019 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
| 10015 FrameTestHelpers::WebViewHelper web_view_helper; | 10020 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10016 web_view_helper.InitializeAndLoad( | 10021 web_view_helper.InitializeAndLoad( |
| 10017 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 10022 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
| 10018 ConfigureAndroid); | 10023 ConfigureAndroid); |
| 10019 web_view_helper.Resize(WebSize(200, 200)); | 10024 web_view_helper.Resize(WebSize(200, 200)); |
| 10020 | 10025 |
| 10021 ScrollBegin(&web_view_helper); | 10026 ScrollBegin(&web_view_helper, 0, -316); |
| 10022 | 10027 |
| 10023 // Scroll the Div to the end. | 10028 // Scroll the Div to the end. |
| 10024 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10029 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| 10025 ScrollUpdate(&web_view_helper, 0, -316); | 10030 ScrollUpdate(&web_view_helper, 0, -316); |
| 10026 Mock::VerifyAndClearExpectations(&client); | 10031 Mock::VerifyAndClearExpectations(&client); |
| 10027 | 10032 |
| 10028 ScrollEnd(&web_view_helper); | 10033 ScrollEnd(&web_view_helper); |
| 10029 ScrollBegin(&web_view_helper); | 10034 ScrollBegin(&web_view_helper, 0, -150); |
| 10030 | 10035 |
| 10031 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 10036 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
| 10032 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10037 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
| 10033 WebFloatPoint(100, 100), WebFloatSize())); | 10038 WebFloatPoint(100, 100), WebFloatSize())); |
| 10034 ScrollUpdate(&web_view_helper, 0, -150); | 10039 ScrollUpdate(&web_view_helper, 0, -150); |
| 10035 Mock::VerifyAndClearExpectations(&client); | 10040 Mock::VerifyAndClearExpectations(&client); |
| 10036 } | 10041 } |
| 10037 | 10042 |
| 10038 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { | 10043 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { |
| 10039 OverscrollWebViewClient client; | 10044 OverscrollWebViewClient client; |
| 10040 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); | 10045 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); |
| 10041 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); | 10046 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); |
| 10042 FrameTestHelpers::WebViewHelper web_view_helper; | 10047 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10043 web_view_helper.InitializeAndLoad( | 10048 web_view_helper.InitializeAndLoad( |
| 10044 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, | 10049 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, |
| 10045 nullptr, ConfigureAndroid); | 10050 nullptr, ConfigureAndroid); |
| 10046 web_view_helper.Resize(WebSize(200, 200)); | 10051 web_view_helper.Resize(WebSize(200, 200)); |
| 10047 | 10052 |
| 10048 ScrollBegin(&web_view_helper); | 10053 ScrollBegin(&web_view_helper, 0, -320); |
| 10049 // Scroll the IFrame to the end. | 10054 // Scroll the IFrame to the end. |
| 10050 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10055 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| 10051 | 10056 |
| 10052 // This scroll will fully scroll the iframe but will be consumed before being | 10057 // This scroll will fully scroll the iframe but will be consumed before being |
| 10053 // counted as overscroll. | 10058 // counted as overscroll. |
| 10054 ScrollUpdate(&web_view_helper, 0, -320); | 10059 ScrollUpdate(&web_view_helper, 0, -320); |
| 10055 | 10060 |
| 10056 // This scroll will again target the iframe but wont bubble further up. Make | 10061 // This scroll will again target the iframe but wont bubble further up. Make |
| 10057 // sure that the unused scroll isn't handled as overscroll. | 10062 // sure that the unused scroll isn't handled as overscroll. |
| 10058 ScrollUpdate(&web_view_helper, 0, -50); | 10063 ScrollUpdate(&web_view_helper, 0, -50); |
| 10059 Mock::VerifyAndClearExpectations(&client); | 10064 Mock::VerifyAndClearExpectations(&client); |
| 10060 | 10065 |
| 10061 ScrollEnd(&web_view_helper); | 10066 ScrollEnd(&web_view_helper); |
| 10062 ScrollBegin(&web_view_helper); | 10067 ScrollBegin(&web_view_helper, 0, -150); |
| 10063 | 10068 |
| 10064 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. | 10069 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. |
| 10065 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10070 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
| 10066 WebFloatPoint(100, 100), WebFloatSize())); | 10071 WebFloatPoint(100, 100), WebFloatSize())); |
| 10067 ScrollUpdate(&web_view_helper, 0, -150); | 10072 ScrollUpdate(&web_view_helper, 0, -150); |
| 10068 Mock::VerifyAndClearExpectations(&client); | 10073 Mock::VerifyAndClearExpectations(&client); |
| 10069 | 10074 |
| 10070 ScrollEnd(&web_view_helper); | 10075 ScrollEnd(&web_view_helper); |
| 10071 } | 10076 } |
| 10072 | 10077 |
| 10073 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { | 10078 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { |
| 10074 OverscrollWebViewClient client; | 10079 OverscrollWebViewClient client; |
| 10075 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10080 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
| 10076 FrameTestHelpers::WebViewHelper web_view_helper; | 10081 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10077 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( | 10082 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( |
| 10078 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, | 10083 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, |
| 10079 ConfigureAndroid); | 10084 ConfigureAndroid); |
| 10080 web_view_helper.Resize(WebSize(200, 200)); | 10085 web_view_helper.Resize(WebSize(200, 200)); |
| 10081 web_view_impl->SetPageScaleFactor(3.0); | 10086 web_view_impl->SetPageScaleFactor(3.0); |
| 10082 | 10087 |
| 10083 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. | 10088 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. |
| 10084 // The point is (99, 99) because we clamp in the division by 3 to 33 so when | 10089 // The point is (99, 99) because we clamp in the division by 3 to 33 so when |
| 10085 // we go back to viewport coordinates it becomes (99, 99). | 10090 // we go back to viewport coordinates it becomes (99, 99). |
| 10086 ScrollBegin(&web_view_helper); | 10091 ScrollBegin(&web_view_helper, 0, 30); |
| 10087 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), | 10092 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), |
| 10088 WebFloatPoint(99, 99), WebFloatSize())); | 10093 WebFloatPoint(99, 99), WebFloatSize())); |
| 10089 ScrollUpdate(&web_view_helper, 0, 30); | 10094 ScrollUpdate(&web_view_helper, 0, 30); |
| 10090 Mock::VerifyAndClearExpectations(&client); | 10095 Mock::VerifyAndClearExpectations(&client); |
| 10091 | 10096 |
| 10092 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), | 10097 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), |
| 10093 WebFloatPoint(99, 99), WebFloatSize())); | 10098 WebFloatPoint(99, 99), WebFloatSize())); |
| 10094 ScrollUpdate(&web_view_helper, 0, 30); | 10099 ScrollUpdate(&web_view_helper, 0, 30); |
| 10095 Mock::VerifyAndClearExpectations(&client); | 10100 Mock::VerifyAndClearExpectations(&client); |
| 10096 | 10101 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 10114 | 10119 |
| 10115 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { | 10120 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { |
| 10116 OverscrollWebViewClient client; | 10121 OverscrollWebViewClient client; |
| 10117 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10122 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
| 10118 FrameTestHelpers::WebViewHelper web_view_helper; | 10123 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10119 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 10124 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
| 10120 nullptr, &client, nullptr, | 10125 nullptr, &client, nullptr, |
| 10121 ConfigureAndroid); | 10126 ConfigureAndroid); |
| 10122 web_view_helper.Resize(WebSize(200, 200)); | 10127 web_view_helper.Resize(WebSize(200, 200)); |
| 10123 | 10128 |
| 10124 ScrollBegin(&web_view_helper); | 10129 ScrollBegin(&web_view_helper, 10, 10); |
| 10125 EXPECT_CALL(client, | 10130 EXPECT_CALL(client, |
| 10126 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), | 10131 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), |
| 10127 WebFloatPoint(100, 100), WebFloatSize())); | 10132 WebFloatPoint(100, 100), WebFloatSize())); |
| 10128 ScrollUpdate(&web_view_helper, 10, 10); | 10133 ScrollUpdate(&web_view_helper, 10, 10); |
| 10129 Mock::VerifyAndClearExpectations(&client); | 10134 Mock::VerifyAndClearExpectations(&client); |
| 10130 | 10135 |
| 10131 EXPECT_CALL(client, | 10136 EXPECT_CALL(client, |
| 10132 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), | 10137 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), |
| 10133 WebFloatPoint(100, 100), WebFloatSize())); | 10138 WebFloatPoint(100, 100), WebFloatSize())); |
| 10134 ScrollUpdate(&web_view_helper, 0, 0.10); | 10139 ScrollUpdate(&web_view_helper, 0, 0.10); |
| (...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12010 if (obj->IsText()) { | 12015 if (obj->IsText()) { |
| 12011 LayoutText* layout_text = ToLayoutText(obj); | 12016 LayoutText* layout_text = ToLayoutText(obj); |
| 12012 text = layout_text->GetText(); | 12017 text = layout_text->GetText(); |
| 12013 break; | 12018 break; |
| 12014 } | 12019 } |
| 12015 } | 12020 } |
| 12016 EXPECT_EQ("foo alt", text.Utf8()); | 12021 EXPECT_EQ("foo alt", text.Utf8()); |
| 12017 } | 12022 } |
| 12018 | 12023 |
| 12019 } // namespace blink | 12024 } // namespace blink |
| OLD | NEW |