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 9885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9896 WebGestureEvent event(type, WebInputEvent::kNoModifiers, | 9896 WebGestureEvent event(type, WebInputEvent::kNoModifiers, |
9897 WebInputEvent::kTimeStampForTesting); | 9897 WebInputEvent::kTimeStampForTesting); |
9898 // TODO(wjmaclean): Make sure that touchpad device is only ever used for | 9898 // TODO(wjmaclean): Make sure that touchpad device is only ever used for |
9899 // gesture scrolling event types. | 9899 // gesture scrolling event types. |
9900 event.source_device = GetParam(); | 9900 event.source_device = GetParam(); |
9901 event.x = 100; | 9901 event.x = 100; |
9902 event.y = 100; | 9902 event.y = 100; |
9903 if (type == WebInputEvent::kGestureScrollUpdate) { | 9903 if (type == WebInputEvent::kGestureScrollUpdate) { |
9904 event.data.scroll_update.delta_x = delta_x; | 9904 event.data.scroll_update.delta_x = delta_x; |
9905 event.data.scroll_update.delta_y = delta_y; | 9905 event.data.scroll_update.delta_y = delta_y; |
| 9906 } else if (type == WebInputEvent::kGestureScrollBegin) { |
| 9907 event.data.scroll_begin.delta_x_hint = delta_x; |
| 9908 event.data.scroll_begin.delta_y_hint = delta_y; |
9906 } | 9909 } |
9907 return WebCoalescedInputEvent(event); | 9910 return WebCoalescedInputEvent(event); |
9908 } | 9911 } |
9909 | 9912 |
9910 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper) { | 9913 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper, |
9911 web_view_helper->WebView()->HandleInputEvent( | 9914 float delta_x_hint, |
9912 GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 9915 float delta_y_hint) { |
| 9916 web_view_helper->WebView()->HandleInputEvent(GenerateEvent( |
| 9917 WebInputEvent::kGestureScrollBegin, delta_x_hint, delta_y_hint)); |
9913 } | 9918 } |
9914 | 9919 |
9915 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper, | 9920 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper, |
9916 float delta_x, | 9921 float delta_x, |
9917 float delta_y) { | 9922 float delta_y) { |
9918 web_view_helper->WebView()->HandleInputEvent( | 9923 web_view_helper->WebView()->HandleInputEvent( |
9919 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y)); | 9924 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y)); |
9920 } | 9925 } |
9921 | 9926 |
9922 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) { | 9927 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) { |
(...skipping 12 matching lines...) Expand all Loading... |
9935 OverscrollWebViewClient client; | 9940 OverscrollWebViewClient client; |
9936 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 9941 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
9937 FrameTestHelpers::WebViewHelper web_view_helper; | 9942 FrameTestHelpers::WebViewHelper web_view_helper; |
9938 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 9943 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
9939 nullptr, &client, nullptr, | 9944 nullptr, &client, nullptr, |
9940 ConfigureAndroid); | 9945 ConfigureAndroid); |
9941 web_view_helper.Resize(WebSize(200, 200)); | 9946 web_view_helper.Resize(WebSize(200, 200)); |
9942 | 9947 |
9943 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple | 9948 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple |
9944 // scrollUpdate. | 9949 // scrollUpdate. |
9945 ScrollBegin(&web_view_helper); | 9950 ScrollBegin(&web_view_helper, -300, -316); |
9946 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), | 9951 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), |
9947 WebFloatPoint(100, 100), WebFloatSize())); | 9952 WebFloatPoint(100, 100), WebFloatSize())); |
9948 ScrollUpdate(&web_view_helper, -308, -316); | 9953 ScrollUpdate(&web_view_helper, -308, -316); |
9949 Mock::VerifyAndClearExpectations(&client); | 9954 Mock::VerifyAndClearExpectations(&client); |
9950 | 9955 |
9951 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), | 9956 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), |
9952 WebFloatPoint(100, 100), WebFloatSize())); | 9957 WebFloatPoint(100, 100), WebFloatSize())); |
9953 ScrollUpdate(&web_view_helper, 0, -13); | 9958 ScrollUpdate(&web_view_helper, 0, -13); |
9954 Mock::VerifyAndClearExpectations(&client); | 9959 Mock::VerifyAndClearExpectations(&client); |
9955 | 9960 |
(...skipping 27 matching lines...) Expand all Loading... |
9983 TEST_P(WebFrameOverscrollTest, | 9988 TEST_P(WebFrameOverscrollTest, |
9984 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { | 9989 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { |
9985 OverscrollWebViewClient client; | 9990 OverscrollWebViewClient client; |
9986 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 9991 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
9987 FrameTestHelpers::WebViewHelper web_view_helper; | 9992 FrameTestHelpers::WebViewHelper web_view_helper; |
9988 web_view_helper.InitializeAndLoad( | 9993 web_view_helper.InitializeAndLoad( |
9989 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 9994 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
9990 ConfigureAndroid); | 9995 ConfigureAndroid); |
9991 web_view_helper.Resize(WebSize(200, 200)); | 9996 web_view_helper.Resize(WebSize(200, 200)); |
9992 | 9997 |
9993 ScrollBegin(&web_view_helper); | 9998 ScrollBegin(&web_view_helper, 0, -316); |
9994 | 9999 |
9995 // Scroll the Div to the end. | 10000 // Scroll the Div to the end. |
9996 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10001 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
9997 ScrollUpdate(&web_view_helper, 0, -316); | 10002 ScrollUpdate(&web_view_helper, 0, -316); |
9998 Mock::VerifyAndClearExpectations(&client); | 10003 Mock::VerifyAndClearExpectations(&client); |
9999 | 10004 |
10000 ScrollEnd(&web_view_helper); | 10005 ScrollEnd(&web_view_helper); |
10001 ScrollBegin(&web_view_helper); | 10006 ScrollBegin(&web_view_helper, 0, -100); |
10002 | 10007 |
10003 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 10008 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
10004 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), | 10009 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), |
10005 WebFloatPoint(100, 100), WebFloatSize())); | 10010 WebFloatPoint(100, 100), WebFloatSize())); |
10006 ScrollUpdate(&web_view_helper, 0, -100); | 10011 ScrollUpdate(&web_view_helper, 0, -100); |
10007 ScrollUpdate(&web_view_helper, 0, -100); | 10012 ScrollUpdate(&web_view_helper, 0, -100); |
10008 Mock::VerifyAndClearExpectations(&client); | 10013 Mock::VerifyAndClearExpectations(&client); |
10009 | 10014 |
10010 // TODO(bokan): This has never worked but by the accident that this test was | 10015 // TODO(bokan): This has never worked but by the accident that this test was |
10011 // being run in a WebView without a size. This test should be fixed along with | 10016 // being run in a WebView without a size. This test should be fixed along with |
(...skipping 18 matching lines...) Expand all Loading... |
10030 | 10035 |
10031 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { | 10036 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { |
10032 OverscrollWebViewClient client; | 10037 OverscrollWebViewClient client; |
10033 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 10038 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
10034 FrameTestHelpers::WebViewHelper web_view_helper; | 10039 FrameTestHelpers::WebViewHelper web_view_helper; |
10035 web_view_helper.InitializeAndLoad( | 10040 web_view_helper.InitializeAndLoad( |
10036 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 10041 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
10037 ConfigureAndroid); | 10042 ConfigureAndroid); |
10038 web_view_helper.Resize(WebSize(200, 200)); | 10043 web_view_helper.Resize(WebSize(200, 200)); |
10039 | 10044 |
10040 ScrollBegin(&web_view_helper); | 10045 ScrollBegin(&web_view_helper, 0, -316); |
10041 | 10046 |
10042 // Scroll the Div to the end. | 10047 // Scroll the Div to the end. |
10043 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10048 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
10044 ScrollUpdate(&web_view_helper, 0, -316); | 10049 ScrollUpdate(&web_view_helper, 0, -316); |
10045 Mock::VerifyAndClearExpectations(&client); | 10050 Mock::VerifyAndClearExpectations(&client); |
10046 | 10051 |
10047 ScrollEnd(&web_view_helper); | 10052 ScrollEnd(&web_view_helper); |
10048 ScrollBegin(&web_view_helper); | 10053 ScrollBegin(&web_view_helper, 0, -150); |
10049 | 10054 |
10050 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 10055 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
10051 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10056 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
10052 WebFloatPoint(100, 100), WebFloatSize())); | 10057 WebFloatPoint(100, 100), WebFloatSize())); |
10053 ScrollUpdate(&web_view_helper, 0, -150); | 10058 ScrollUpdate(&web_view_helper, 0, -150); |
10054 Mock::VerifyAndClearExpectations(&client); | 10059 Mock::VerifyAndClearExpectations(&client); |
10055 } | 10060 } |
10056 | 10061 |
10057 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { | 10062 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { |
10058 OverscrollWebViewClient client; | 10063 OverscrollWebViewClient client; |
10059 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); | 10064 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); |
10060 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); | 10065 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); |
10061 FrameTestHelpers::WebViewHelper web_view_helper; | 10066 FrameTestHelpers::WebViewHelper web_view_helper; |
10062 web_view_helper.InitializeAndLoad( | 10067 web_view_helper.InitializeAndLoad( |
10063 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, | 10068 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, |
10064 nullptr, ConfigureAndroid); | 10069 nullptr, ConfigureAndroid); |
10065 web_view_helper.Resize(WebSize(200, 200)); | 10070 web_view_helper.Resize(WebSize(200, 200)); |
10066 | 10071 |
10067 ScrollBegin(&web_view_helper); | 10072 ScrollBegin(&web_view_helper, 0, -320); |
10068 // Scroll the IFrame to the end. | 10073 // Scroll the IFrame to the end. |
10069 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10074 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
10070 | 10075 |
10071 // This scroll will fully scroll the iframe but will be consumed before being | 10076 // This scroll will fully scroll the iframe but will be consumed before being |
10072 // counted as overscroll. | 10077 // counted as overscroll. |
10073 ScrollUpdate(&web_view_helper, 0, -320); | 10078 ScrollUpdate(&web_view_helper, 0, -320); |
10074 | 10079 |
10075 // This scroll will again target the iframe but wont bubble further up. Make | 10080 // This scroll will again target the iframe but wont bubble further up. Make |
10076 // sure that the unused scroll isn't handled as overscroll. | 10081 // sure that the unused scroll isn't handled as overscroll. |
10077 ScrollUpdate(&web_view_helper, 0, -50); | 10082 ScrollUpdate(&web_view_helper, 0, -50); |
10078 Mock::VerifyAndClearExpectations(&client); | 10083 Mock::VerifyAndClearExpectations(&client); |
10079 | 10084 |
10080 ScrollEnd(&web_view_helper); | 10085 ScrollEnd(&web_view_helper); |
10081 ScrollBegin(&web_view_helper); | 10086 ScrollBegin(&web_view_helper, 0, -150); |
10082 | 10087 |
10083 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. | 10088 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. |
10084 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10089 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
10085 WebFloatPoint(100, 100), WebFloatSize())); | 10090 WebFloatPoint(100, 100), WebFloatSize())); |
10086 ScrollUpdate(&web_view_helper, 0, -150); | 10091 ScrollUpdate(&web_view_helper, 0, -150); |
10087 Mock::VerifyAndClearExpectations(&client); | 10092 Mock::VerifyAndClearExpectations(&client); |
10088 | 10093 |
10089 ScrollEnd(&web_view_helper); | 10094 ScrollEnd(&web_view_helper); |
10090 } | 10095 } |
10091 | 10096 |
10092 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { | 10097 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { |
10093 OverscrollWebViewClient client; | 10098 OverscrollWebViewClient client; |
10094 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10099 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
10095 FrameTestHelpers::WebViewHelper web_view_helper; | 10100 FrameTestHelpers::WebViewHelper web_view_helper; |
10096 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( | 10101 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( |
10097 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, | 10102 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, |
10098 ConfigureAndroid); | 10103 ConfigureAndroid); |
10099 web_view_helper.Resize(WebSize(200, 200)); | 10104 web_view_helper.Resize(WebSize(200, 200)); |
10100 web_view_impl->SetPageScaleFactor(3.0); | 10105 web_view_impl->SetPageScaleFactor(3.0); |
10101 | 10106 |
10102 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. | 10107 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. |
10103 // The point is (99, 99) because we clamp in the division by 3 to 33 so when | 10108 // The point is (99, 99) because we clamp in the division by 3 to 33 so when |
10104 // we go back to viewport coordinates it becomes (99, 99). | 10109 // we go back to viewport coordinates it becomes (99, 99). |
10105 ScrollBegin(&web_view_helper); | 10110 ScrollBegin(&web_view_helper, 0, 30); |
10106 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), | 10111 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), |
10107 WebFloatPoint(99, 99), WebFloatSize())); | 10112 WebFloatPoint(99, 99), WebFloatSize())); |
10108 ScrollUpdate(&web_view_helper, 0, 30); | 10113 ScrollUpdate(&web_view_helper, 0, 30); |
10109 Mock::VerifyAndClearExpectations(&client); | 10114 Mock::VerifyAndClearExpectations(&client); |
10110 | 10115 |
10111 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), | 10116 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), |
10112 WebFloatPoint(99, 99), WebFloatSize())); | 10117 WebFloatPoint(99, 99), WebFloatSize())); |
10113 ScrollUpdate(&web_view_helper, 0, 30); | 10118 ScrollUpdate(&web_view_helper, 0, 30); |
10114 Mock::VerifyAndClearExpectations(&client); | 10119 Mock::VerifyAndClearExpectations(&client); |
10115 | 10120 |
(...skipping 17 matching lines...) Expand all Loading... |
10133 | 10138 |
10134 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { | 10139 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { |
10135 OverscrollWebViewClient client; | 10140 OverscrollWebViewClient client; |
10136 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10141 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
10137 FrameTestHelpers::WebViewHelper web_view_helper; | 10142 FrameTestHelpers::WebViewHelper web_view_helper; |
10138 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 10143 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
10139 nullptr, &client, nullptr, | 10144 nullptr, &client, nullptr, |
10140 ConfigureAndroid); | 10145 ConfigureAndroid); |
10141 web_view_helper.Resize(WebSize(200, 200)); | 10146 web_view_helper.Resize(WebSize(200, 200)); |
10142 | 10147 |
10143 ScrollBegin(&web_view_helper); | 10148 ScrollBegin(&web_view_helper, 10, 10); |
10144 EXPECT_CALL(client, | 10149 EXPECT_CALL(client, |
10145 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), | 10150 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), |
10146 WebFloatPoint(100, 100), WebFloatSize())); | 10151 WebFloatPoint(100, 100), WebFloatSize())); |
10147 ScrollUpdate(&web_view_helper, 10, 10); | 10152 ScrollUpdate(&web_view_helper, 10, 10); |
10148 Mock::VerifyAndClearExpectations(&client); | 10153 Mock::VerifyAndClearExpectations(&client); |
10149 | 10154 |
10150 EXPECT_CALL(client, | 10155 EXPECT_CALL(client, |
10151 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), | 10156 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), |
10152 WebFloatPoint(100, 100), WebFloatSize())); | 10157 WebFloatPoint(100, 100), WebFloatSize())); |
10153 ScrollUpdate(&web_view_helper, 0, 0.10); | 10158 ScrollUpdate(&web_view_helper, 0, 0.10); |
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12029 if (obj->IsText()) { | 12034 if (obj->IsText()) { |
12030 LayoutText* layout_text = ToLayoutText(obj); | 12035 LayoutText* layout_text = ToLayoutText(obj); |
12031 text = layout_text->GetText(); | 12036 text = layout_text->GetText(); |
12032 break; | 12037 break; |
12033 } | 12038 } |
12034 } | 12039 } |
12035 EXPECT_EQ("foo alt", text.Utf8()); | 12040 EXPECT_EQ("foo alt", text.Utf8()); |
12036 } | 12041 } |
12037 | 12042 |
12038 } // namespace blink | 12043 } // namespace blink |
OLD | NEW |