Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2907053004: GSB uses delta_hints to calculate scrolling chain. (Closed)
Patch Set: Merge branch 'master' into GSB_checks_delta_hints Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9856 matching lines...) Expand 10 before | Expand all | Expand 10 after
9867 WebGestureEvent event(type, WebInputEvent::kNoModifiers, 9867 WebGestureEvent event(type, WebInputEvent::kNoModifiers,
9868 WebInputEvent::kTimeStampForTesting); 9868 WebInputEvent::kTimeStampForTesting);
9869 // TODO(wjmaclean): Make sure that touchpad device is only ever used for 9869 // TODO(wjmaclean): Make sure that touchpad device is only ever used for
9870 // gesture scrolling event types. 9870 // gesture scrolling event types.
9871 event.source_device = GetParam(); 9871 event.source_device = GetParam();
9872 event.x = 100; 9872 event.x = 100;
9873 event.y = 100; 9873 event.y = 100;
9874 if (type == WebInputEvent::kGestureScrollUpdate) { 9874 if (type == WebInputEvent::kGestureScrollUpdate) {
9875 event.data.scroll_update.delta_x = delta_x; 9875 event.data.scroll_update.delta_x = delta_x;
9876 event.data.scroll_update.delta_y = delta_y; 9876 event.data.scroll_update.delta_y = delta_y;
9877 } else if (type == WebInputEvent::kGestureScrollBegin) {
9878 event.data.scroll_begin.delta_x_hint = delta_x;
9879 event.data.scroll_begin.delta_y_hint = delta_y;
9877 } 9880 }
9878 return WebCoalescedInputEvent(event); 9881 return WebCoalescedInputEvent(event);
9879 } 9882 }
9880 9883
9881 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper) { 9884 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper,
9882 web_view_helper->WebView()->HandleInputEvent( 9885 float delta_x_hint,
9883 GenerateEvent(WebInputEvent::kGestureScrollBegin)); 9886 float delta_y_hint) {
9887 web_view_helper->WebView()->HandleInputEvent(GenerateEvent(
9888 WebInputEvent::kGestureScrollBegin, delta_x_hint, delta_y_hint));
9884 } 9889 }
9885 9890
9886 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper, 9891 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper,
9887 float delta_x, 9892 float delta_x,
9888 float delta_y) { 9893 float delta_y) {
9889 web_view_helper->WebView()->HandleInputEvent( 9894 web_view_helper->WebView()->HandleInputEvent(
9890 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y)); 9895 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y));
9891 } 9896 }
9892 9897
9893 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) { 9898 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) {
(...skipping 12 matching lines...) Expand all
9906 OverscrollWebViewClient client; 9911 OverscrollWebViewClient client;
9907 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 9912 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
9908 FrameTestHelpers::WebViewHelper web_view_helper; 9913 FrameTestHelpers::WebViewHelper web_view_helper;
9909 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 9914 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
9910 nullptr, &client, nullptr, 9915 nullptr, &client, nullptr,
9911 ConfigureAndroid); 9916 ConfigureAndroid);
9912 web_view_helper.Resize(WebSize(200, 200)); 9917 web_view_helper.Resize(WebSize(200, 200));
9913 9918
9914 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple 9919 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple
9915 // scrollUpdate. 9920 // scrollUpdate.
9916 ScrollBegin(&web_view_helper); 9921 ScrollBegin(&web_view_helper, -300, -316);
9917 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), 9922 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16),
9918 WebFloatPoint(100, 100), WebFloatSize())); 9923 WebFloatPoint(100, 100), WebFloatSize()));
9919 ScrollUpdate(&web_view_helper, -308, -316); 9924 ScrollUpdate(&web_view_helper, -308, -316);
9920 Mock::VerifyAndClearExpectations(&client); 9925 Mock::VerifyAndClearExpectations(&client);
9921 9926
9922 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), 9927 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29),
9923 WebFloatPoint(100, 100), WebFloatSize())); 9928 WebFloatPoint(100, 100), WebFloatSize()));
9924 ScrollUpdate(&web_view_helper, 0, -13); 9929 ScrollUpdate(&web_view_helper, 0, -13);
9925 Mock::VerifyAndClearExpectations(&client); 9930 Mock::VerifyAndClearExpectations(&client);
9926 9931
(...skipping 27 matching lines...) Expand all
9954 TEST_P(WebFrameOverscrollTest, 9959 TEST_P(WebFrameOverscrollTest,
9955 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { 9960 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) {
9956 OverscrollWebViewClient client; 9961 OverscrollWebViewClient client;
9957 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 9962 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
9958 FrameTestHelpers::WebViewHelper web_view_helper; 9963 FrameTestHelpers::WebViewHelper web_view_helper;
9959 web_view_helper.InitializeAndLoad( 9964 web_view_helper.InitializeAndLoad(
9960 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 9965 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
9961 ConfigureAndroid); 9966 ConfigureAndroid);
9962 web_view_helper.Resize(WebSize(200, 200)); 9967 web_view_helper.Resize(WebSize(200, 200));
9963 9968
9964 ScrollBegin(&web_view_helper); 9969 ScrollBegin(&web_view_helper, 0, -316);
9965 9970
9966 // Scroll the Div to the end. 9971 // Scroll the Div to the end.
9967 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 9972 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0);
9968 ScrollUpdate(&web_view_helper, 0, -316); 9973 ScrollUpdate(&web_view_helper, 0, -316);
9969 Mock::VerifyAndClearExpectations(&client); 9974 Mock::VerifyAndClearExpectations(&client);
9970 9975
9971 ScrollEnd(&web_view_helper); 9976 ScrollEnd(&web_view_helper);
9972 ScrollBegin(&web_view_helper); 9977 ScrollBegin(&web_view_helper, 0, -100);
9973 9978
9974 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 9979 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
9975 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), 9980 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100),
9976 WebFloatPoint(100, 100), WebFloatSize())); 9981 WebFloatPoint(100, 100), WebFloatSize()));
9977 ScrollUpdate(&web_view_helper, 0, -100); 9982 ScrollUpdate(&web_view_helper, 0, -100);
9978 ScrollUpdate(&web_view_helper, 0, -100); 9983 ScrollUpdate(&web_view_helper, 0, -100);
9979 Mock::VerifyAndClearExpectations(&client); 9984 Mock::VerifyAndClearExpectations(&client);
9980 9985
9981 // TODO(bokan): This has never worked but by the accident that this test was 9986 // TODO(bokan): This has never worked but by the accident that this test was
9982 // being run in a WebView without a size. This test should be fixed along with 9987 // being run in a WebView without a size. This test should be fixed along with
(...skipping 18 matching lines...) Expand all
10001 10006
10002 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { 10007 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) {
10003 OverscrollWebViewClient client; 10008 OverscrollWebViewClient client;
10004 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10009 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10005 FrameTestHelpers::WebViewHelper web_view_helper; 10010 FrameTestHelpers::WebViewHelper web_view_helper;
10006 web_view_helper.InitializeAndLoad( 10011 web_view_helper.InitializeAndLoad(
10007 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 10012 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
10008 ConfigureAndroid); 10013 ConfigureAndroid);
10009 web_view_helper.Resize(WebSize(200, 200)); 10014 web_view_helper.Resize(WebSize(200, 200));
10010 10015
10011 ScrollBegin(&web_view_helper); 10016 ScrollBegin(&web_view_helper, 0, -316);
10012 10017
10013 // Scroll the Div to the end. 10018 // Scroll the Div to the end.
10014 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10019 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0);
10015 ScrollUpdate(&web_view_helper, 0, -316); 10020 ScrollUpdate(&web_view_helper, 0, -316);
10016 Mock::VerifyAndClearExpectations(&client); 10021 Mock::VerifyAndClearExpectations(&client);
10017 10022
10018 ScrollEnd(&web_view_helper); 10023 ScrollEnd(&web_view_helper);
10019 ScrollBegin(&web_view_helper); 10024 ScrollBegin(&web_view_helper, 0, -150);
10020 10025
10021 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10026 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10022 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10027 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10023 WebFloatPoint(100, 100), WebFloatSize())); 10028 WebFloatPoint(100, 100), WebFloatSize()));
10024 ScrollUpdate(&web_view_helper, 0, -150); 10029 ScrollUpdate(&web_view_helper, 0, -150);
10025 Mock::VerifyAndClearExpectations(&client); 10030 Mock::VerifyAndClearExpectations(&client);
10026 } 10031 }
10027 10032
10028 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { 10033 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) {
10029 OverscrollWebViewClient client; 10034 OverscrollWebViewClient client;
10030 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); 10035 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10031 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); 10036 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10032 FrameTestHelpers::WebViewHelper web_view_helper; 10037 FrameTestHelpers::WebViewHelper web_view_helper;
10033 web_view_helper.InitializeAndLoad( 10038 web_view_helper.InitializeAndLoad(
10034 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, 10039 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client,
10035 nullptr, ConfigureAndroid); 10040 nullptr, ConfigureAndroid);
10036 web_view_helper.Resize(WebSize(200, 200)); 10041 web_view_helper.Resize(WebSize(200, 200));
10037 10042
10038 ScrollBegin(&web_view_helper); 10043 ScrollBegin(&web_view_helper, 0, -320);
10039 // Scroll the IFrame to the end. 10044 // Scroll the IFrame to the end.
10040 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10045 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0);
10041 10046
10042 // This scroll will fully scroll the iframe but will be consumed before being 10047 // This scroll will fully scroll the iframe but will be consumed before being
10043 // counted as overscroll. 10048 // counted as overscroll.
10044 ScrollUpdate(&web_view_helper, 0, -320); 10049 ScrollUpdate(&web_view_helper, 0, -320);
10045 10050
10046 // This scroll will again target the iframe but wont bubble further up. Make 10051 // This scroll will again target the iframe but wont bubble further up. Make
10047 // sure that the unused scroll isn't handled as overscroll. 10052 // sure that the unused scroll isn't handled as overscroll.
10048 ScrollUpdate(&web_view_helper, 0, -50); 10053 ScrollUpdate(&web_view_helper, 0, -50);
10049 Mock::VerifyAndClearExpectations(&client); 10054 Mock::VerifyAndClearExpectations(&client);
10050 10055
10051 ScrollEnd(&web_view_helper); 10056 ScrollEnd(&web_view_helper);
10052 ScrollBegin(&web_view_helper); 10057 ScrollBegin(&web_view_helper, 0, -150);
10053 10058
10054 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. 10059 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled.
10055 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10060 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10056 WebFloatPoint(100, 100), WebFloatSize())); 10061 WebFloatPoint(100, 100), WebFloatSize()));
10057 ScrollUpdate(&web_view_helper, 0, -150); 10062 ScrollUpdate(&web_view_helper, 0, -150);
10058 Mock::VerifyAndClearExpectations(&client); 10063 Mock::VerifyAndClearExpectations(&client);
10059 10064
10060 ScrollEnd(&web_view_helper); 10065 ScrollEnd(&web_view_helper);
10061 } 10066 }
10062 10067
10063 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { 10068 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) {
10064 OverscrollWebViewClient client; 10069 OverscrollWebViewClient client;
10065 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10070 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10066 FrameTestHelpers::WebViewHelper web_view_helper; 10071 FrameTestHelpers::WebViewHelper web_view_helper;
10067 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( 10072 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad(
10068 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, 10073 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr,
10069 ConfigureAndroid); 10074 ConfigureAndroid);
10070 web_view_helper.Resize(WebSize(200, 200)); 10075 web_view_helper.Resize(WebSize(200, 200));
10071 web_view_impl->SetPageScaleFactor(3.0); 10076 web_view_impl->SetPageScaleFactor(3.0);
10072 10077
10073 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. 10078 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page.
10074 // The point is (99, 99) because we clamp in the division by 3 to 33 so when 10079 // The point is (99, 99) because we clamp in the division by 3 to 33 so when
10075 // we go back to viewport coordinates it becomes (99, 99). 10080 // we go back to viewport coordinates it becomes (99, 99).
10076 ScrollBegin(&web_view_helper); 10081 ScrollBegin(&web_view_helper, 0, 30);
10077 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), 10082 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30),
10078 WebFloatPoint(99, 99), WebFloatSize())); 10083 WebFloatPoint(99, 99), WebFloatSize()));
10079 ScrollUpdate(&web_view_helper, 0, 30); 10084 ScrollUpdate(&web_view_helper, 0, 30);
10080 Mock::VerifyAndClearExpectations(&client); 10085 Mock::VerifyAndClearExpectations(&client);
10081 10086
10082 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), 10087 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60),
10083 WebFloatPoint(99, 99), WebFloatSize())); 10088 WebFloatPoint(99, 99), WebFloatSize()));
10084 ScrollUpdate(&web_view_helper, 0, 30); 10089 ScrollUpdate(&web_view_helper, 0, 30);
10085 Mock::VerifyAndClearExpectations(&client); 10090 Mock::VerifyAndClearExpectations(&client);
10086 10091
(...skipping 17 matching lines...) Expand all
10104 10109
10105 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { 10110 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) {
10106 OverscrollWebViewClient client; 10111 OverscrollWebViewClient client;
10107 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10112 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10108 FrameTestHelpers::WebViewHelper web_view_helper; 10113 FrameTestHelpers::WebViewHelper web_view_helper;
10109 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10114 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10110 nullptr, &client, nullptr, 10115 nullptr, &client, nullptr,
10111 ConfigureAndroid); 10116 ConfigureAndroid);
10112 web_view_helper.Resize(WebSize(200, 200)); 10117 web_view_helper.Resize(WebSize(200, 200));
10113 10118
10114 ScrollBegin(&web_view_helper); 10119 ScrollBegin(&web_view_helper, 10, 10);
10115 EXPECT_CALL(client, 10120 EXPECT_CALL(client,
10116 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), 10121 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10),
10117 WebFloatPoint(100, 100), WebFloatSize())); 10122 WebFloatPoint(100, 100), WebFloatSize()));
10118 ScrollUpdate(&web_view_helper, 10, 10); 10123 ScrollUpdate(&web_view_helper, 10, 10);
10119 Mock::VerifyAndClearExpectations(&client); 10124 Mock::VerifyAndClearExpectations(&client);
10120 10125
10121 EXPECT_CALL(client, 10126 EXPECT_CALL(client,
10122 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), 10127 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10),
10123 WebFloatPoint(100, 100), WebFloatSize())); 10128 WebFloatPoint(100, 100), WebFloatSize()));
10124 ScrollUpdate(&web_view_helper, 0, 0.10); 10129 ScrollUpdate(&web_view_helper, 0, 0.10);
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after
12000 if (obj->IsText()) { 12005 if (obj->IsText()) {
12001 LayoutText* layout_text = ToLayoutText(obj); 12006 LayoutText* layout_text = ToLayoutText(obj);
12002 text = layout_text->GetText(); 12007 text = layout_text->GetText();
12003 break; 12008 break;
12004 } 12009 }
12005 } 12010 }
12006 EXPECT_EQ("foo alt", text.Utf8()); 12011 EXPECT_EQ("foo alt", text.Utf8());
12007 } 12012 }
12008 12013
12009 } // namespace blink 12014 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698