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

Side by Side Diff: third_party/WebKit/Source/core/exported/WebFrameTest.cpp

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: Rebase Created 3 years, 3 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 10003 matching lines...) Expand 10 before | Expand all | Expand 10 after
10014 EXPECT_TRUE( 10014 EXPECT_TRUE(
10015 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); 10015 local_child->GetDocument()->Fetcher()->Context().DefersLoading());
10016 } 10016 }
10017 EXPECT_FALSE(page->Paused()); 10017 EXPECT_FALSE(page->Paused());
10018 EXPECT_FALSE( 10018 EXPECT_FALSE(
10019 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); 10019 local_child->GetDocument()->Fetcher()->Context().DefersLoading());
10020 } 10020 }
10021 10021
10022 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { 10022 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient {
10023 public: 10023 public:
10024 MOCK_METHOD4(DidOverscroll, 10024 MOCK_METHOD5(DidOverscroll,
10025 void(const WebFloatSize&, 10025 void(const WebFloatSize&,
10026 const WebFloatSize&, 10026 const WebFloatSize&,
10027 const WebFloatPoint&, 10027 const WebFloatPoint&,
10028 const WebFloatSize&)); 10028 const WebFloatSize&,
10029 const WebScrollBoundaryBehavior&));
10029 }; 10030 };
10030 10031
10031 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; 10032 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam;
10032 class WebFrameOverscrollTest 10033 class WebFrameOverscrollTest
10033 : public WebFrameTest, 10034 : public WebFrameTest,
10034 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>, 10035 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>,
10035 private ScopedRootLayerScrollingForTest { 10036 private ScopedRootLayerScrollingForTest {
10036 public: 10037 public:
10037 WebFrameOverscrollTest() 10038 WebFrameOverscrollTest()
10038 : ScopedRootLayerScrollingForTest(GetParam().first) {} 10039 : ScopedRootLayerScrollingForTest(GetParam().first) {}
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
10095 FrameTestHelpers::WebViewHelper web_view_helper; 10096 FrameTestHelpers::WebViewHelper web_view_helper;
10096 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10097 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10097 nullptr, &client, nullptr, 10098 nullptr, &client, nullptr,
10098 ConfigureAndroid); 10099 ConfigureAndroid);
10099 web_view_helper.Resize(WebSize(200, 200)); 10100 web_view_helper.Resize(WebSize(200, 200));
10100 10101
10101 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple 10102 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple
10102 // scrollUpdate. 10103 // scrollUpdate.
10103 ScrollBegin(&web_view_helper, -300, -316); 10104 ScrollBegin(&web_view_helper, -300, -316);
10104 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), 10105 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16),
10105 WebFloatPoint(100, 100), WebFloatSize())); 10106 WebFloatPoint(100, 100), WebFloatSize(),
10107 WebScrollBoundaryBehavior()));
10106 ScrollUpdate(&web_view_helper, -308, -316); 10108 ScrollUpdate(&web_view_helper, -308, -316);
10107 Mock::VerifyAndClearExpectations(&client); 10109 Mock::VerifyAndClearExpectations(&client);
10108 10110
10109 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), 10111 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29),
10110 WebFloatPoint(100, 100), WebFloatSize())); 10112 WebFloatPoint(100, 100), WebFloatSize(),
10113 WebScrollBoundaryBehavior()));
10111 ScrollUpdate(&web_view_helper, 0, -13); 10114 ScrollUpdate(&web_view_helper, 0, -13);
10112 Mock::VerifyAndClearExpectations(&client); 10115 Mock::VerifyAndClearExpectations(&client);
10113 10116
10114 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), 10117 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42),
10115 WebFloatPoint(100, 100), WebFloatSize())); 10118 WebFloatPoint(100, 100), WebFloatSize(),
10119 WebScrollBoundaryBehavior()));
10116 ScrollUpdate(&web_view_helper, -20, -13); 10120 ScrollUpdate(&web_view_helper, -20, -13);
10117 Mock::VerifyAndClearExpectations(&client); 10121 Mock::VerifyAndClearExpectations(&client);
10118 10122
10119 // Overscroll is not reported. 10123 // Overscroll is not reported.
10120 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10124 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10121 ScrollUpdate(&web_view_helper, 0, 1); 10125 ScrollUpdate(&web_view_helper, 0, 1);
10122 Mock::VerifyAndClearExpectations(&client); 10126 Mock::VerifyAndClearExpectations(&client);
10123 10127
10124 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10128 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10125 ScrollUpdate(&web_view_helper, 1, 0); 10129 ScrollUpdate(&web_view_helper, 1, 0);
10126 Mock::VerifyAndClearExpectations(&client); 10130 Mock::VerifyAndClearExpectations(&client);
10127 10131
10128 // Overscroll is reported. 10132 // Overscroll is reported.
10129 EXPECT_CALL(client, 10133 EXPECT_CALL(client,
10130 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), 10134 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701),
10131 WebFloatPoint(100, 100), WebFloatSize())); 10135 WebFloatPoint(100, 100), WebFloatSize(),
10136 WebScrollBoundaryBehavior()));
10132 ScrollUpdate(&web_view_helper, 0, 1000); 10137 ScrollUpdate(&web_view_helper, 0, 1000);
10133 Mock::VerifyAndClearExpectations(&client); 10138 Mock::VerifyAndClearExpectations(&client);
10134 10139
10135 // Overscroll is not reported. 10140 // Overscroll is not reported.
10136 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10141 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10137 ScrollEnd(&web_view_helper); 10142 ScrollEnd(&web_view_helper);
10138 Mock::VerifyAndClearExpectations(&client); 10143 Mock::VerifyAndClearExpectations(&client);
10139 } 10144 }
10140 10145
10141 TEST_P(WebFrameOverscrollTest, 10146 TEST_P(WebFrameOverscrollTest,
10142 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { 10147 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) {
10143 OverscrollWebViewClient client; 10148 OverscrollWebViewClient client;
10144 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10149 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10145 FrameTestHelpers::WebViewHelper web_view_helper; 10150 FrameTestHelpers::WebViewHelper web_view_helper;
10146 web_view_helper.InitializeAndLoad( 10151 web_view_helper.InitializeAndLoad(
10147 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 10152 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
10148 ConfigureAndroid); 10153 ConfigureAndroid);
10149 web_view_helper.Resize(WebSize(200, 200)); 10154 web_view_helper.Resize(WebSize(200, 200));
10150 10155
10151 ScrollBegin(&web_view_helper, 0, -316); 10156 ScrollBegin(&web_view_helper, 0, -316);
10152 10157
10153 // Scroll the Div to the end. 10158 // Scroll the Div to the end.
10154 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10159 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10155 ScrollUpdate(&web_view_helper, 0, -316); 10160 ScrollUpdate(&web_view_helper, 0, -316);
10156 Mock::VerifyAndClearExpectations(&client); 10161 Mock::VerifyAndClearExpectations(&client);
10157 10162
10158 ScrollEnd(&web_view_helper); 10163 ScrollEnd(&web_view_helper);
10159 ScrollBegin(&web_view_helper, 0, -100); 10164 ScrollBegin(&web_view_helper, 0, -100);
10160 10165
10161 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10166 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10162 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), 10167 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100),
10163 WebFloatPoint(100, 100), WebFloatSize())); 10168 WebFloatPoint(100, 100), WebFloatSize(),
10169 WebScrollBoundaryBehavior()));
10164 ScrollUpdate(&web_view_helper, 0, -100); 10170 ScrollUpdate(&web_view_helper, 0, -100);
10165 ScrollUpdate(&web_view_helper, 0, -100); 10171 ScrollUpdate(&web_view_helper, 0, -100);
10166 Mock::VerifyAndClearExpectations(&client); 10172 Mock::VerifyAndClearExpectations(&client);
10167 10173
10168 // TODO(bokan): This has never worked but by the accident that this test was 10174 // TODO(bokan): This has never worked but by the accident that this test was
10169 // being run in a WebView without a size. This test should be fixed along with 10175 // being run in a WebView without a size. This test should be fixed along with
10170 // the bug, crbug.com/589320. 10176 // the bug, crbug.com/589320.
10171 // Page scrolls vertically, but over-scrolls horizontally. 10177 // Page scrolls vertically, but over-scrolls horizontally.
10172 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, 10178 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100,
10173 // 0), WebFloatPoint(100, 100), WebFloatSize())); 10179 // 0), WebFloatPoint(100, 100), WebFloatSize(), WebScrollBoundaryBehavior()));
10174 // ScrollUpdate(&webViewHelper, 100, 50); 10180 // ScrollUpdate(&webViewHelper, 100, 50);
10175 // Mock::VerifyAndClearExpectations(&client); 10181 // Mock::VerifyAndClearExpectations(&client);
10176 10182
10177 // Scrolling up, Overscroll is not reported. 10183 // Scrolling up, Overscroll is not reported.
10178 // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); 10184 // EXPECT_CALL(client, didOverscroll(_, _, _, _, _)).Times(0);
10179 // ScrollUpdate(&webViewHelper, 0, -50); 10185 // ScrollUpdate(&webViewHelper, 0, -50);
10180 // Mock::VerifyAndClearExpectations(&client); 10186 // Mock::VerifyAndClearExpectations(&client);
10181 10187
10182 // Page scrolls horizontally, but over-scrolls vertically. 10188 // Page scrolls horizontally, but over-scrolls vertically.
10183 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 10189 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0,
10184 // 100), WebFloatPoint(100, 100), WebFloatSize())); 10190 // 100), WebFloatPoint(100, 100), WebFloatSize(),
10191 // WebScrollBoundaryBehavior()));
10185 // ScrollUpdate(&webViewHelper, -100, -100); 10192 // ScrollUpdate(&webViewHelper, -100, -100);
10186 // Mock::VerifyAndClearExpectations(&client); 10193 // Mock::VerifyAndClearExpectations(&client);
10187 } 10194 }
10188 10195
10189 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { 10196 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) {
10190 OverscrollWebViewClient client; 10197 OverscrollWebViewClient client;
10191 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10198 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10192 FrameTestHelpers::WebViewHelper web_view_helper; 10199 FrameTestHelpers::WebViewHelper web_view_helper;
10193 web_view_helper.InitializeAndLoad( 10200 web_view_helper.InitializeAndLoad(
10194 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 10201 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
10195 ConfigureAndroid); 10202 ConfigureAndroid);
10196 web_view_helper.Resize(WebSize(200, 200)); 10203 web_view_helper.Resize(WebSize(200, 200));
10197 10204
10198 ScrollBegin(&web_view_helper, 0, -316); 10205 ScrollBegin(&web_view_helper, 0, -316);
10199 10206
10200 // Scroll the Div to the end. 10207 // Scroll the Div to the end.
10201 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10208 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10202 ScrollUpdate(&web_view_helper, 0, -316); 10209 ScrollUpdate(&web_view_helper, 0, -316);
10203 Mock::VerifyAndClearExpectations(&client); 10210 Mock::VerifyAndClearExpectations(&client);
10204 10211
10205 ScrollEnd(&web_view_helper); 10212 ScrollEnd(&web_view_helper);
10206 ScrollBegin(&web_view_helper, 0, -150); 10213 ScrollBegin(&web_view_helper, 0, -150);
10207 10214
10208 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10215 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10209 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10216 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10210 WebFloatPoint(100, 100), WebFloatSize())); 10217 WebFloatPoint(100, 100), WebFloatSize(),
10218 WebScrollBoundaryBehavior()));
10211 ScrollUpdate(&web_view_helper, 0, -150); 10219 ScrollUpdate(&web_view_helper, 0, -150);
10212 Mock::VerifyAndClearExpectations(&client); 10220 Mock::VerifyAndClearExpectations(&client);
10213 } 10221 }
10214 10222
10215 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { 10223 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) {
10216 OverscrollWebViewClient client; 10224 OverscrollWebViewClient client;
10217 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); 10225 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10218 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); 10226 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10219 FrameTestHelpers::WebViewHelper web_view_helper; 10227 FrameTestHelpers::WebViewHelper web_view_helper;
10220 web_view_helper.InitializeAndLoad( 10228 web_view_helper.InitializeAndLoad(
10221 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, 10229 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client,
10222 nullptr, ConfigureAndroid); 10230 nullptr, ConfigureAndroid);
10223 web_view_helper.Resize(WebSize(200, 200)); 10231 web_view_helper.Resize(WebSize(200, 200));
10224 10232
10225 ScrollBegin(&web_view_helper, 0, -320); 10233 ScrollBegin(&web_view_helper, 0, -320);
10226 // Scroll the IFrame to the end. 10234 // Scroll the IFrame to the end.
10227 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10235 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10228 10236
10229 // This scroll will fully scroll the iframe but will be consumed before being 10237 // This scroll will fully scroll the iframe but will be consumed before being
10230 // counted as overscroll. 10238 // counted as overscroll.
10231 ScrollUpdate(&web_view_helper, 0, -320); 10239 ScrollUpdate(&web_view_helper, 0, -320);
10232 10240
10233 // This scroll will again target the iframe but wont bubble further up. Make 10241 // This scroll will again target the iframe but wont bubble further up. Make
10234 // sure that the unused scroll isn't handled as overscroll. 10242 // sure that the unused scroll isn't handled as overscroll.
10235 ScrollUpdate(&web_view_helper, 0, -50); 10243 ScrollUpdate(&web_view_helper, 0, -50);
10236 Mock::VerifyAndClearExpectations(&client); 10244 Mock::VerifyAndClearExpectations(&client);
10237 10245
10238 ScrollEnd(&web_view_helper); 10246 ScrollEnd(&web_view_helper);
10239 ScrollBegin(&web_view_helper, 0, -150); 10247 ScrollBegin(&web_view_helper, 0, -150);
10240 10248
10241 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. 10249 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled.
10242 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10250 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10243 WebFloatPoint(100, 100), WebFloatSize())); 10251 WebFloatPoint(100, 100), WebFloatSize(),
10252 WebScrollBoundaryBehavior()));
10244 ScrollUpdate(&web_view_helper, 0, -150); 10253 ScrollUpdate(&web_view_helper, 0, -150);
10245 Mock::VerifyAndClearExpectations(&client); 10254 Mock::VerifyAndClearExpectations(&client);
10246 10255
10247 ScrollEnd(&web_view_helper); 10256 ScrollEnd(&web_view_helper);
10248 } 10257 }
10249 10258
10250 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { 10259 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) {
10251 OverscrollWebViewClient client; 10260 OverscrollWebViewClient client;
10252 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10261 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10253 FrameTestHelpers::WebViewHelper web_view_helper; 10262 FrameTestHelpers::WebViewHelper web_view_helper;
10254 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( 10263 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad(
10255 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, 10264 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr,
10256 ConfigureAndroid); 10265 ConfigureAndroid);
10257 web_view_helper.Resize(WebSize(200, 200)); 10266 web_view_helper.Resize(WebSize(200, 200));
10258 web_view_impl->SetPageScaleFactor(3.0); 10267 web_view_impl->SetPageScaleFactor(3.0);
10259 10268
10260 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. 10269 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page.
10261 // The point is (99, 99) because we clamp in the division by 3 to 33 so when 10270 // The point is (99, 99) because we clamp in the division by 3 to 33 so when
10262 // we go back to viewport coordinates it becomes (99, 99). 10271 // we go back to viewport coordinates it becomes (99, 99).
10263 ScrollBegin(&web_view_helper, 0, 30); 10272 ScrollBegin(&web_view_helper, 0, 30);
10264 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), 10273 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30),
10265 WebFloatPoint(99, 99), WebFloatSize())); 10274 WebFloatPoint(99, 99), WebFloatSize(),
10275 WebScrollBoundaryBehavior()));
10266 ScrollUpdate(&web_view_helper, 0, 30); 10276 ScrollUpdate(&web_view_helper, 0, 30);
10267 Mock::VerifyAndClearExpectations(&client); 10277 Mock::VerifyAndClearExpectations(&client);
10268 10278
10269 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), 10279 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60),
10270 WebFloatPoint(99, 99), WebFloatSize())); 10280 WebFloatPoint(99, 99), WebFloatSize(),
10281 WebScrollBoundaryBehavior()));
10271 ScrollUpdate(&web_view_helper, 0, 30); 10282 ScrollUpdate(&web_view_helper, 0, 30);
10272 Mock::VerifyAndClearExpectations(&client); 10283 Mock::VerifyAndClearExpectations(&client);
10273 10284
10274 EXPECT_CALL(client, 10285 EXPECT_CALL(client,
10275 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), 10286 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90),
10276 WebFloatPoint(99, 99), WebFloatSize())); 10287 WebFloatPoint(99, 99), WebFloatSize(),
10288 WebScrollBoundaryBehavior()));
10277 ScrollUpdate(&web_view_helper, 30, 30); 10289 ScrollUpdate(&web_view_helper, 30, 30);
10278 Mock::VerifyAndClearExpectations(&client); 10290 Mock::VerifyAndClearExpectations(&client);
10279 10291
10280 EXPECT_CALL(client, 10292 EXPECT_CALL(client,
10281 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), 10293 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90),
10282 WebFloatPoint(99, 99), WebFloatSize())); 10294 WebFloatPoint(99, 99), WebFloatSize(),
10295 WebScrollBoundaryBehavior()));
10283 ScrollUpdate(&web_view_helper, 30, 0); 10296 ScrollUpdate(&web_view_helper, 30, 0);
10284 Mock::VerifyAndClearExpectations(&client); 10297 Mock::VerifyAndClearExpectations(&client);
10285 10298
10286 // Overscroll is not reported. 10299 // Overscroll is not reported.
10287 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10300 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10288 ScrollEnd(&web_view_helper); 10301 ScrollEnd(&web_view_helper);
10289 Mock::VerifyAndClearExpectations(&client); 10302 Mock::VerifyAndClearExpectations(&client);
10290 } 10303 }
10291 10304
10292 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { 10305 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) {
10293 OverscrollWebViewClient client; 10306 OverscrollWebViewClient client;
10294 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10307 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10295 FrameTestHelpers::WebViewHelper web_view_helper; 10308 FrameTestHelpers::WebViewHelper web_view_helper;
10296 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10309 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10297 nullptr, &client, nullptr, 10310 nullptr, &client, nullptr,
10298 ConfigureAndroid); 10311 ConfigureAndroid);
10299 web_view_helper.Resize(WebSize(200, 200)); 10312 web_view_helper.Resize(WebSize(200, 200));
10300 10313
10301 ScrollBegin(&web_view_helper, 10, 10); 10314 ScrollBegin(&web_view_helper, 10, 10);
10302 EXPECT_CALL(client, 10315 EXPECT_CALL(client,
10303 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), 10316 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10),
10304 WebFloatPoint(100, 100), WebFloatSize())); 10317 WebFloatPoint(100, 100), WebFloatSize(),
10318 WebScrollBoundaryBehavior()));
10305 ScrollUpdate(&web_view_helper, 10, 10); 10319 ScrollUpdate(&web_view_helper, 10, 10);
10306 Mock::VerifyAndClearExpectations(&client); 10320 Mock::VerifyAndClearExpectations(&client);
10307 10321
10308 EXPECT_CALL(client, 10322 EXPECT_CALL(client,
10309 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), 10323 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10),
10310 WebFloatPoint(100, 100), WebFloatSize())); 10324 WebFloatPoint(100, 100), WebFloatSize(),
10325 WebScrollBoundaryBehavior()));
10311 ScrollUpdate(&web_view_helper, 0, 0.10); 10326 ScrollUpdate(&web_view_helper, 0, 0.10);
10312 Mock::VerifyAndClearExpectations(&client); 10327 Mock::VerifyAndClearExpectations(&client);
10313 10328
10314 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), 10329 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0),
10315 WebFloatSize(-10.10, -10.10), 10330 WebFloatSize(-10.10, -10.10),
10316 WebFloatPoint(100, 100), WebFloatSize())); 10331 WebFloatPoint(100, 100), WebFloatSize(),
10332 WebScrollBoundaryBehavior()));
10317 ScrollUpdate(&web_view_helper, 0.10, 0); 10333 ScrollUpdate(&web_view_helper, 0.10, 0);
10318 Mock::VerifyAndClearExpectations(&client); 10334 Mock::VerifyAndClearExpectations(&client);
10319 10335
10320 // For residual values overscrollDelta should be reset and didOverscroll 10336 // For residual values overscrollDelta should be reset and didOverscroll
10321 // shouldn't be called. 10337 // shouldn't be called.
10322 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10338 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10323 ScrollUpdate(&web_view_helper, 0, 0.09); 10339 ScrollUpdate(&web_view_helper, 0, 0.09);
10324 Mock::VerifyAndClearExpectations(&client); 10340 Mock::VerifyAndClearExpectations(&client);
10325 10341
10326 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10342 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10327 ScrollUpdate(&web_view_helper, 0.09, 0.09); 10343 ScrollUpdate(&web_view_helper, 0.09, 0.09);
10328 Mock::VerifyAndClearExpectations(&client); 10344 Mock::VerifyAndClearExpectations(&client);
10329 10345
10330 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10346 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10331 ScrollUpdate(&web_view_helper, 0.09, 0); 10347 ScrollUpdate(&web_view_helper, 0.09, 0);
10332 Mock::VerifyAndClearExpectations(&client); 10348 Mock::VerifyAndClearExpectations(&client);
10333 10349
10334 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10350 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10335 ScrollUpdate(&web_view_helper, 0, -0.09); 10351 ScrollUpdate(&web_view_helper, 0, -0.09);
10336 Mock::VerifyAndClearExpectations(&client); 10352 Mock::VerifyAndClearExpectations(&client);
10337 10353
10338 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10354 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10339 ScrollUpdate(&web_view_helper, -0.09, -0.09); 10355 ScrollUpdate(&web_view_helper, -0.09, -0.09);
10340 Mock::VerifyAndClearExpectations(&client); 10356 Mock::VerifyAndClearExpectations(&client);
10341 10357
10342 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10358 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10343 ScrollUpdate(&web_view_helper, -0.09, 0); 10359 ScrollUpdate(&web_view_helper, -0.09, 0);
10344 Mock::VerifyAndClearExpectations(&client); 10360 Mock::VerifyAndClearExpectations(&client);
10345 10361
10346 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10362 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10347 ScrollEnd(&web_view_helper); 10363 ScrollEnd(&web_view_helper);
10348 Mock::VerifyAndClearExpectations(&client); 10364 Mock::VerifyAndClearExpectations(&client);
10349 } 10365 }
10350 10366
10351 TEST_P(WebFrameOverscrollTest, 10367 TEST_P(WebFrameOverscrollTest, ScrollBoundaryBehaviorAffectsDidOverscroll) {
10352 ScrollBoundaryBehaviorOnBodyDoesNotPreventOverscroll) {
10353 OverscrollWebViewClient client; 10368 OverscrollWebViewClient client;
10354 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10369 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10355 FrameTestHelpers::WebViewHelper web_view_helper; 10370 FrameTestHelpers::WebViewHelper web_view_helper;
10356 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10371 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10357 nullptr, &client, nullptr, 10372 nullptr, &client, nullptr,
10358 ConfigureAndroid); 10373 ConfigureAndroid);
10359 web_view_helper.Resize(WebSize(200, 200)); 10374 web_view_helper.Resize(WebSize(200, 200));
10360 10375
10361 WebLocalFrame* mainFrame = 10376 WebLocalFrame* mainFrame =
10362 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame(); 10377 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame();
10363 mainFrame->ExecuteScript( 10378 mainFrame->ExecuteScript(
10364 WebScriptSource(WebString("document.body.style=" 10379 WebScriptSource(WebString("document.body.style="
10380 "'scroll-boundary-behavior: auto;'")));
10381
10382 ScrollBegin(&web_view_helper, 100, 116);
10383 EXPECT_CALL(
10384 client,
10385 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100),
10386 WebFloatPoint(100, 100), WebFloatSize(),
10387 WebScrollBoundaryBehavior(
10388 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10389 kScrollBoundaryBehaviorTypeAuto)));
10390 ScrollUpdate(&web_view_helper, 100, 100);
10391 Mock::VerifyAndClearExpectations(&client);
10392
10393 mainFrame->ExecuteScript(
10394 WebScriptSource(WebString("document.body.style="
10365 "'scroll-boundary-behavior: contain;'"))); 10395 "'scroll-boundary-behavior: contain;'")));
10366 10396
10367 ScrollBegin(&web_view_helper, 100, 100); 10397 ScrollBegin(&web_view_helper, 100, 116);
10368 EXPECT_CALL(client, 10398 EXPECT_CALL(
10369 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100), 10399 client,
10370 WebFloatPoint(100, 100), WebFloatSize())); 10400 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200),
10401 WebFloatPoint(100, 100), WebFloatSize(),
10402 WebScrollBoundaryBehavior(
10403 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10404 kScrollBoundaryBehaviorTypeContain)));
10405 ScrollUpdate(&web_view_helper, 100, 100);
10406 Mock::VerifyAndClearExpectations(&client);
10407
10408 mainFrame->ExecuteScript(
10409 WebScriptSource(WebString("document.body.style="
10410 "'scroll-boundary-behavior: none;'")));
10411
10412 ScrollBegin(&web_view_helper, 100, 116);
10413 EXPECT_CALL(
10414 client,
10415 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-300, -300),
10416 WebFloatPoint(100, 100), WebFloatSize(),
10417 WebScrollBoundaryBehavior(
10418 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10419 kScrollBoundaryBehaviorTypeNone)));
10371 ScrollUpdate(&web_view_helper, 100, 100); 10420 ScrollUpdate(&web_view_helper, 100, 100);
10372 Mock::VerifyAndClearExpectations(&client); 10421 Mock::VerifyAndClearExpectations(&client);
10373 } 10422 }
10423
10424 TEST_P(WebFrameOverscrollTest, OnlyMainFrameScrollBoundaryBehaviorHasEffect) {
10425 OverscrollWebViewClient client;
10426 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10427 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10428 FrameTestHelpers::WebViewHelper web_view_helper;
10429 web_view_helper.InitializeAndLoad(
10430 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client,
10431 nullptr, ConfigureAndroid);
10432 web_view_helper.Resize(WebSize(200, 200));
10433
10434 WebLocalFrame* mainFrame =
10435 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame();
10436 mainFrame->ExecuteScript(
10437 WebScriptSource(WebString("document.body.style="
10438 "'scroll-boundary-behavior: auto;'")));
10439 WebLocalFrame* subframe =
10440 web_view_helper.WebView()->MainFrame()->FirstChild()->ToWebLocalFrame();
10441 subframe->ExecuteScript(
10442 WebScriptSource(WebString("document.body.style="
10443 "'scroll-boundary-behavior: none;'")));
10444
10445 ScrollBegin(&web_view_helper, 100, 116);
10446 EXPECT_CALL(
10447 client,
10448 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100),
10449 WebFloatPoint(100, 100), WebFloatSize(),
10450 WebScrollBoundaryBehavior(
10451 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10452 kScrollBoundaryBehaviorTypeAuto)));
10453 ScrollUpdate(&web_view_helper, 100, 100);
10454 Mock::VerifyAndClearExpectations(&client);
10455
10456 mainFrame->ExecuteScript(
10457 WebScriptSource(WebString("document.body.style="
10458 "'scroll-boundary-behavior: contain;'")));
10459
10460 EXPECT_CALL(
10461 client,
10462 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200),
10463 WebFloatPoint(100, 100), WebFloatSize(),
10464 WebScrollBoundaryBehavior(
10465 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10466 kScrollBoundaryBehaviorTypeContain)));
10467 ScrollUpdate(&web_view_helper, 100, 100);
10468 Mock::VerifyAndClearExpectations(&client);
10469 }
10374 10470
10375 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { 10471 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) {
10376 RuntimeEnabledFeatures::SetOrientationEventEnabled(true); 10472 RuntimeEnabledFeatures::SetOrientationEventEnabled(true);
10377 RegisterMockedHttpURLLoad("orientation-frame-detach.html"); 10473 RegisterMockedHttpURLLoad("orientation-frame-detach.html");
10378 FrameTestHelpers::WebViewHelper web_view_helper; 10474 FrameTestHelpers::WebViewHelper web_view_helper;
10379 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( 10475 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad(
10380 base_url_ + "orientation-frame-detach.html"); 10476 base_url_ + "orientation-frame-detach.html");
10381 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent(); 10477 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent();
10382 } 10478 }
10383 10479
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
11877 EXPECT_EQ(ScrollHitTestLayerCount(), 1u); 11973 EXPECT_EQ(ScrollHitTestLayerCount(), 1u);
11878 ScrollHitTestLayerAt(0)->SetScrollOffsetFromImplSideForTesting( 11974 ScrollHitTestLayerAt(0)->SetScrollOffsetFromImplSideForTesting(
11879 gfx::ScrollOffset(0, 3)); 11975 gfx::ScrollOffset(0, 3));
11880 11976
11881 WebView()->UpdateAllLifecyclePhases(); 11977 WebView()->UpdateAllLifecyclePhases();
11882 EXPECT_EQ(ContentLayerCount(), 1u); 11978 EXPECT_EQ(ContentLayerCount(), 1u);
11883 EXPECT_EQ(ScrollHitTestLayerCount(), 0u); 11979 EXPECT_EQ(ScrollHitTestLayerCount(), 0u);
11884 } 11980 }
11885 11981
11886 } // namespace blink 11982 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/exported/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698