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

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: Update ScrollManager to pass the test. Created 3 years, 4 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 10033 matching lines...) Expand 10 before | Expand all | Expand 10 after
10044 EXPECT_TRUE( 10044 EXPECT_TRUE(
10045 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); 10045 local_child->GetDocument()->Fetcher()->Context().DefersLoading());
10046 } 10046 }
10047 EXPECT_FALSE(page->Paused()); 10047 EXPECT_FALSE(page->Paused());
10048 EXPECT_FALSE( 10048 EXPECT_FALSE(
10049 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); 10049 local_child->GetDocument()->Fetcher()->Context().DefersLoading());
10050 } 10050 }
10051 10051
10052 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { 10052 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient {
10053 public: 10053 public:
10054 MOCK_METHOD4(DidOverscroll, 10054 MOCK_METHOD5(DidOverscroll,
10055 void(const WebFloatSize&, 10055 void(const WebFloatSize&,
10056 const WebFloatSize&, 10056 const WebFloatSize&,
10057 const WebFloatPoint&, 10057 const WebFloatPoint&,
10058 const WebFloatSize&)); 10058 const WebFloatSize&,
10059 const WebScrollBoundaryBehavior&));
10059 }; 10060 };
10060 10061
10061 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; 10062 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam;
10062 class WebFrameOverscrollTest 10063 class WebFrameOverscrollTest
10063 : public WebFrameTest, 10064 : public WebFrameTest,
10064 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>, 10065 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>,
10065 private ScopedRootLayerScrollingForTest { 10066 private ScopedRootLayerScrollingForTest {
10066 public: 10067 public:
10067 WebFrameOverscrollTest() 10068 WebFrameOverscrollTest()
10068 : ScopedRootLayerScrollingForTest(GetParam().first) {} 10069 : ScopedRootLayerScrollingForTest(GetParam().first) {}
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
10125 FrameTestHelpers::WebViewHelper web_view_helper; 10126 FrameTestHelpers::WebViewHelper web_view_helper;
10126 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10127 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10127 nullptr, &client, nullptr, 10128 nullptr, &client, nullptr,
10128 ConfigureAndroid); 10129 ConfigureAndroid);
10129 web_view_helper.Resize(WebSize(200, 200)); 10130 web_view_helper.Resize(WebSize(200, 200));
10130 10131
10131 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple 10132 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple
10132 // scrollUpdate. 10133 // scrollUpdate.
10133 ScrollBegin(&web_view_helper, -300, -316); 10134 ScrollBegin(&web_view_helper, -300, -316);
10134 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), 10135 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16),
10135 WebFloatPoint(100, 100), WebFloatSize())); 10136 WebFloatPoint(100, 100), WebFloatSize(),
10137 WebScrollBoundaryBehavior()));
10136 ScrollUpdate(&web_view_helper, -308, -316); 10138 ScrollUpdate(&web_view_helper, -308, -316);
10137 Mock::VerifyAndClearExpectations(&client); 10139 Mock::VerifyAndClearExpectations(&client);
10138 10140
10139 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), 10141 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29),
10140 WebFloatPoint(100, 100), WebFloatSize())); 10142 WebFloatPoint(100, 100), WebFloatSize(),
10143 WebScrollBoundaryBehavior()));
10141 ScrollUpdate(&web_view_helper, 0, -13); 10144 ScrollUpdate(&web_view_helper, 0, -13);
10142 Mock::VerifyAndClearExpectations(&client); 10145 Mock::VerifyAndClearExpectations(&client);
10143 10146
10144 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), 10147 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42),
10145 WebFloatPoint(100, 100), WebFloatSize())); 10148 WebFloatPoint(100, 100), WebFloatSize(),
10149 WebScrollBoundaryBehavior()));
10146 ScrollUpdate(&web_view_helper, -20, -13); 10150 ScrollUpdate(&web_view_helper, -20, -13);
10147 Mock::VerifyAndClearExpectations(&client); 10151 Mock::VerifyAndClearExpectations(&client);
10148 10152
10149 // Overscroll is not reported. 10153 // Overscroll is not reported.
10150 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10154 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10151 ScrollUpdate(&web_view_helper, 0, 1); 10155 ScrollUpdate(&web_view_helper, 0, 1);
10152 Mock::VerifyAndClearExpectations(&client); 10156 Mock::VerifyAndClearExpectations(&client);
10153 10157
10154 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10158 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10155 ScrollUpdate(&web_view_helper, 1, 0); 10159 ScrollUpdate(&web_view_helper, 1, 0);
10156 Mock::VerifyAndClearExpectations(&client); 10160 Mock::VerifyAndClearExpectations(&client);
10157 10161
10158 // Overscroll is reported. 10162 // Overscroll is reported.
10159 EXPECT_CALL(client, 10163 EXPECT_CALL(client,
10160 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), 10164 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701),
10161 WebFloatPoint(100, 100), WebFloatSize())); 10165 WebFloatPoint(100, 100), WebFloatSize(),
10166 WebScrollBoundaryBehavior()));
10162 ScrollUpdate(&web_view_helper, 0, 1000); 10167 ScrollUpdate(&web_view_helper, 0, 1000);
10163 Mock::VerifyAndClearExpectations(&client); 10168 Mock::VerifyAndClearExpectations(&client);
10164 10169
10165 // Overscroll is not reported. 10170 // Overscroll is not reported.
10166 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10171 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10167 ScrollEnd(&web_view_helper); 10172 ScrollEnd(&web_view_helper);
10168 Mock::VerifyAndClearExpectations(&client); 10173 Mock::VerifyAndClearExpectations(&client);
10169 } 10174 }
10170 10175
10171 TEST_P(WebFrameOverscrollTest, 10176 TEST_P(WebFrameOverscrollTest,
10172 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { 10177 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) {
10173 OverscrollWebViewClient client; 10178 OverscrollWebViewClient client;
10174 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10179 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10175 FrameTestHelpers::WebViewHelper web_view_helper; 10180 FrameTestHelpers::WebViewHelper web_view_helper;
10176 web_view_helper.InitializeAndLoad( 10181 web_view_helper.InitializeAndLoad(
10177 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 10182 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
10178 ConfigureAndroid); 10183 ConfigureAndroid);
10179 web_view_helper.Resize(WebSize(200, 200)); 10184 web_view_helper.Resize(WebSize(200, 200));
10180 10185
10181 ScrollBegin(&web_view_helper, 0, -316); 10186 ScrollBegin(&web_view_helper, 0, -316);
10182 10187
10183 // Scroll the Div to the end. 10188 // Scroll the Div to the end.
10184 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10189 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10185 ScrollUpdate(&web_view_helper, 0, -316); 10190 ScrollUpdate(&web_view_helper, 0, -316);
10186 Mock::VerifyAndClearExpectations(&client); 10191 Mock::VerifyAndClearExpectations(&client);
10187 10192
10188 ScrollEnd(&web_view_helper); 10193 ScrollEnd(&web_view_helper);
10189 ScrollBegin(&web_view_helper, 0, -100); 10194 ScrollBegin(&web_view_helper, 0, -100);
10190 10195
10191 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10196 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10192 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), 10197 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100),
10193 WebFloatPoint(100, 100), WebFloatSize())); 10198 WebFloatPoint(100, 100), WebFloatSize(),
10199 WebScrollBoundaryBehavior()));
10194 ScrollUpdate(&web_view_helper, 0, -100); 10200 ScrollUpdate(&web_view_helper, 0, -100);
10195 ScrollUpdate(&web_view_helper, 0, -100); 10201 ScrollUpdate(&web_view_helper, 0, -100);
10196 Mock::VerifyAndClearExpectations(&client); 10202 Mock::VerifyAndClearExpectations(&client);
10197 10203
10198 // TODO(bokan): This has never worked but by the accident that this test was 10204 // TODO(bokan): This has never worked but by the accident that this test was
10199 // being run in a WebView without a size. This test should be fixed along with 10205 // being run in a WebView without a size. This test should be fixed along with
10200 // the bug, crbug.com/589320. 10206 // the bug, crbug.com/589320.
10201 // Page scrolls vertically, but over-scrolls horizontally. 10207 // Page scrolls vertically, but over-scrolls horizontally.
10202 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, 10208 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100,
10203 // 0), WebFloatPoint(100, 100), WebFloatSize())); 10209 // 0), WebFloatPoint(100, 100), WebFloatSize(), WebScrollBoundaryBehavior()));
10204 // ScrollUpdate(&webViewHelper, 100, 50); 10210 // ScrollUpdate(&webViewHelper, 100, 50);
10205 // Mock::VerifyAndClearExpectations(&client); 10211 // Mock::VerifyAndClearExpectations(&client);
10206 10212
10207 // Scrolling up, Overscroll is not reported. 10213 // Scrolling up, Overscroll is not reported.
10208 // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); 10214 // EXPECT_CALL(client, didOverscroll(_, _, _, _, _)).Times(0);
10209 // ScrollUpdate(&webViewHelper, 0, -50); 10215 // ScrollUpdate(&webViewHelper, 0, -50);
10210 // Mock::VerifyAndClearExpectations(&client); 10216 // Mock::VerifyAndClearExpectations(&client);
10211 10217
10212 // Page scrolls horizontally, but over-scrolls vertically. 10218 // Page scrolls horizontally, but over-scrolls vertically.
10213 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 10219 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0,
10214 // 100), WebFloatPoint(100, 100), WebFloatSize())); 10220 // 100), WebFloatPoint(100, 100), WebFloatSize(),
10221 // WebScrollBoundaryBehavior()));
10215 // ScrollUpdate(&webViewHelper, -100, -100); 10222 // ScrollUpdate(&webViewHelper, -100, -100);
10216 // Mock::VerifyAndClearExpectations(&client); 10223 // Mock::VerifyAndClearExpectations(&client);
10217 } 10224 }
10218 10225
10219 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { 10226 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) {
10220 OverscrollWebViewClient client; 10227 OverscrollWebViewClient client;
10221 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10228 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10222 FrameTestHelpers::WebViewHelper web_view_helper; 10229 FrameTestHelpers::WebViewHelper web_view_helper;
10223 web_view_helper.InitializeAndLoad( 10230 web_view_helper.InitializeAndLoad(
10224 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 10231 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
10225 ConfigureAndroid); 10232 ConfigureAndroid);
10226 web_view_helper.Resize(WebSize(200, 200)); 10233 web_view_helper.Resize(WebSize(200, 200));
10227 10234
10228 ScrollBegin(&web_view_helper, 0, -316); 10235 ScrollBegin(&web_view_helper, 0, -316);
10229 10236
10230 // Scroll the Div to the end. 10237 // Scroll the Div to the end.
10231 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10238 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10232 ScrollUpdate(&web_view_helper, 0, -316); 10239 ScrollUpdate(&web_view_helper, 0, -316);
10233 Mock::VerifyAndClearExpectations(&client); 10240 Mock::VerifyAndClearExpectations(&client);
10234 10241
10235 ScrollEnd(&web_view_helper); 10242 ScrollEnd(&web_view_helper);
10236 ScrollBegin(&web_view_helper, 0, -150); 10243 ScrollBegin(&web_view_helper, 0, -150);
10237 10244
10238 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10245 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10239 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10246 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10240 WebFloatPoint(100, 100), WebFloatSize())); 10247 WebFloatPoint(100, 100), WebFloatSize(),
10248 WebScrollBoundaryBehavior()));
10241 ScrollUpdate(&web_view_helper, 0, -150); 10249 ScrollUpdate(&web_view_helper, 0, -150);
10242 Mock::VerifyAndClearExpectations(&client); 10250 Mock::VerifyAndClearExpectations(&client);
10243 } 10251 }
10244 10252
10245 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { 10253 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) {
10246 OverscrollWebViewClient client; 10254 OverscrollWebViewClient client;
10247 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); 10255 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10248 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); 10256 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10249 FrameTestHelpers::WebViewHelper web_view_helper; 10257 FrameTestHelpers::WebViewHelper web_view_helper;
10250 web_view_helper.InitializeAndLoad( 10258 web_view_helper.InitializeAndLoad(
10251 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, 10259 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client,
10252 nullptr, ConfigureAndroid); 10260 nullptr, ConfigureAndroid);
10253 web_view_helper.Resize(WebSize(200, 200)); 10261 web_view_helper.Resize(WebSize(200, 200));
10254 10262
10255 ScrollBegin(&web_view_helper, 0, -320); 10263 ScrollBegin(&web_view_helper, 0, -320);
10256 // Scroll the IFrame to the end. 10264 // Scroll the IFrame to the end.
10257 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10265 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10258 10266
10259 // This scroll will fully scroll the iframe but will be consumed before being 10267 // This scroll will fully scroll the iframe but will be consumed before being
10260 // counted as overscroll. 10268 // counted as overscroll.
10261 ScrollUpdate(&web_view_helper, 0, -320); 10269 ScrollUpdate(&web_view_helper, 0, -320);
10262 10270
10263 // This scroll will again target the iframe but wont bubble further up. Make 10271 // This scroll will again target the iframe but wont bubble further up. Make
10264 // sure that the unused scroll isn't handled as overscroll. 10272 // sure that the unused scroll isn't handled as overscroll.
10265 ScrollUpdate(&web_view_helper, 0, -50); 10273 ScrollUpdate(&web_view_helper, 0, -50);
10266 Mock::VerifyAndClearExpectations(&client); 10274 Mock::VerifyAndClearExpectations(&client);
10267 10275
10268 ScrollEnd(&web_view_helper); 10276 ScrollEnd(&web_view_helper);
10269 ScrollBegin(&web_view_helper, 0, -150); 10277 ScrollBegin(&web_view_helper, 0, -150);
10270 10278
10271 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. 10279 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled.
10272 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10280 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10273 WebFloatPoint(100, 100), WebFloatSize())); 10281 WebFloatPoint(100, 100), WebFloatSize(),
10282 WebScrollBoundaryBehavior()));
10274 ScrollUpdate(&web_view_helper, 0, -150); 10283 ScrollUpdate(&web_view_helper, 0, -150);
10275 Mock::VerifyAndClearExpectations(&client); 10284 Mock::VerifyAndClearExpectations(&client);
10276 10285
10277 ScrollEnd(&web_view_helper); 10286 ScrollEnd(&web_view_helper);
10278 } 10287 }
10279 10288
10280 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { 10289 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) {
10281 OverscrollWebViewClient client; 10290 OverscrollWebViewClient client;
10282 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10291 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10283 FrameTestHelpers::WebViewHelper web_view_helper; 10292 FrameTestHelpers::WebViewHelper web_view_helper;
10284 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( 10293 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad(
10285 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, 10294 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr,
10286 ConfigureAndroid); 10295 ConfigureAndroid);
10287 web_view_helper.Resize(WebSize(200, 200)); 10296 web_view_helper.Resize(WebSize(200, 200));
10288 web_view_impl->SetPageScaleFactor(3.0); 10297 web_view_impl->SetPageScaleFactor(3.0);
10289 10298
10290 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. 10299 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page.
10291 // The point is (99, 99) because we clamp in the division by 3 to 33 so when 10300 // The point is (99, 99) because we clamp in the division by 3 to 33 so when
10292 // we go back to viewport coordinates it becomes (99, 99). 10301 // we go back to viewport coordinates it becomes (99, 99).
10293 ScrollBegin(&web_view_helper, 0, 30); 10302 ScrollBegin(&web_view_helper, 0, 30);
10294 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), 10303 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30),
10295 WebFloatPoint(99, 99), WebFloatSize())); 10304 WebFloatPoint(99, 99), WebFloatSize(),
10305 WebScrollBoundaryBehavior()));
10296 ScrollUpdate(&web_view_helper, 0, 30); 10306 ScrollUpdate(&web_view_helper, 0, 30);
10297 Mock::VerifyAndClearExpectations(&client); 10307 Mock::VerifyAndClearExpectations(&client);
10298 10308
10299 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), 10309 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60),
10300 WebFloatPoint(99, 99), WebFloatSize())); 10310 WebFloatPoint(99, 99), WebFloatSize(),
10311 WebScrollBoundaryBehavior()));
10301 ScrollUpdate(&web_view_helper, 0, 30); 10312 ScrollUpdate(&web_view_helper, 0, 30);
10302 Mock::VerifyAndClearExpectations(&client); 10313 Mock::VerifyAndClearExpectations(&client);
10303 10314
10304 EXPECT_CALL(client, 10315 EXPECT_CALL(client,
10305 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), 10316 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90),
10306 WebFloatPoint(99, 99), WebFloatSize())); 10317 WebFloatPoint(99, 99), WebFloatSize(),
10318 WebScrollBoundaryBehavior()));
10307 ScrollUpdate(&web_view_helper, 30, 30); 10319 ScrollUpdate(&web_view_helper, 30, 30);
10308 Mock::VerifyAndClearExpectations(&client); 10320 Mock::VerifyAndClearExpectations(&client);
10309 10321
10310 EXPECT_CALL(client, 10322 EXPECT_CALL(client,
10311 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), 10323 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90),
10312 WebFloatPoint(99, 99), WebFloatSize())); 10324 WebFloatPoint(99, 99), WebFloatSize(),
10325 WebScrollBoundaryBehavior()));
10313 ScrollUpdate(&web_view_helper, 30, 0); 10326 ScrollUpdate(&web_view_helper, 30, 0);
10314 Mock::VerifyAndClearExpectations(&client); 10327 Mock::VerifyAndClearExpectations(&client);
10315 10328
10316 // Overscroll is not reported. 10329 // Overscroll is not reported.
10317 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10330 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10318 ScrollEnd(&web_view_helper); 10331 ScrollEnd(&web_view_helper);
10319 Mock::VerifyAndClearExpectations(&client); 10332 Mock::VerifyAndClearExpectations(&client);
10320 } 10333 }
10321 10334
10322 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { 10335 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) {
10323 OverscrollWebViewClient client; 10336 OverscrollWebViewClient client;
10324 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10337 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10325 FrameTestHelpers::WebViewHelper web_view_helper; 10338 FrameTestHelpers::WebViewHelper web_view_helper;
10326 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10339 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10327 nullptr, &client, nullptr, 10340 nullptr, &client, nullptr,
10328 ConfigureAndroid); 10341 ConfigureAndroid);
10329 web_view_helper.Resize(WebSize(200, 200)); 10342 web_view_helper.Resize(WebSize(200, 200));
10330 10343
10331 ScrollBegin(&web_view_helper, 10, 10); 10344 ScrollBegin(&web_view_helper, 10, 10);
10332 EXPECT_CALL(client, 10345 EXPECT_CALL(client,
10333 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), 10346 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10),
10334 WebFloatPoint(100, 100), WebFloatSize())); 10347 WebFloatPoint(100, 100), WebFloatSize(),
10348 WebScrollBoundaryBehavior()));
10335 ScrollUpdate(&web_view_helper, 10, 10); 10349 ScrollUpdate(&web_view_helper, 10, 10);
10336 Mock::VerifyAndClearExpectations(&client); 10350 Mock::VerifyAndClearExpectations(&client);
10337 10351
10338 EXPECT_CALL(client, 10352 EXPECT_CALL(client,
10339 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), 10353 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10),
10340 WebFloatPoint(100, 100), WebFloatSize())); 10354 WebFloatPoint(100, 100), WebFloatSize(),
10355 WebScrollBoundaryBehavior()));
10341 ScrollUpdate(&web_view_helper, 0, 0.10); 10356 ScrollUpdate(&web_view_helper, 0, 0.10);
10342 Mock::VerifyAndClearExpectations(&client); 10357 Mock::VerifyAndClearExpectations(&client);
10343 10358
10344 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), 10359 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0),
10345 WebFloatSize(-10.10, -10.10), 10360 WebFloatSize(-10.10, -10.10),
10346 WebFloatPoint(100, 100), WebFloatSize())); 10361 WebFloatPoint(100, 100), WebFloatSize(),
10362 WebScrollBoundaryBehavior()));
10347 ScrollUpdate(&web_view_helper, 0.10, 0); 10363 ScrollUpdate(&web_view_helper, 0.10, 0);
10348 Mock::VerifyAndClearExpectations(&client); 10364 Mock::VerifyAndClearExpectations(&client);
10349 10365
10350 // For residual values overscrollDelta should be reset and didOverscroll 10366 // For residual values overscrollDelta should be reset and didOverscroll
10351 // shouldn't be called. 10367 // shouldn't be called.
10352 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10368 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10353 ScrollUpdate(&web_view_helper, 0, 0.09); 10369 ScrollUpdate(&web_view_helper, 0, 0.09);
10354 Mock::VerifyAndClearExpectations(&client); 10370 Mock::VerifyAndClearExpectations(&client);
10355 10371
10356 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10372 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10357 ScrollUpdate(&web_view_helper, 0.09, 0.09); 10373 ScrollUpdate(&web_view_helper, 0.09, 0.09);
10358 Mock::VerifyAndClearExpectations(&client); 10374 Mock::VerifyAndClearExpectations(&client);
10359 10375
10360 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10376 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10361 ScrollUpdate(&web_view_helper, 0.09, 0); 10377 ScrollUpdate(&web_view_helper, 0.09, 0);
10362 Mock::VerifyAndClearExpectations(&client); 10378 Mock::VerifyAndClearExpectations(&client);
10363 10379
10364 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10380 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10365 ScrollUpdate(&web_view_helper, 0, -0.09); 10381 ScrollUpdate(&web_view_helper, 0, -0.09);
10366 Mock::VerifyAndClearExpectations(&client); 10382 Mock::VerifyAndClearExpectations(&client);
10367 10383
10368 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10384 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10369 ScrollUpdate(&web_view_helper, -0.09, -0.09); 10385 ScrollUpdate(&web_view_helper, -0.09, -0.09);
10370 Mock::VerifyAndClearExpectations(&client); 10386 Mock::VerifyAndClearExpectations(&client);
10371 10387
10372 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10388 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10373 ScrollUpdate(&web_view_helper, -0.09, 0); 10389 ScrollUpdate(&web_view_helper, -0.09, 0);
10374 Mock::VerifyAndClearExpectations(&client); 10390 Mock::VerifyAndClearExpectations(&client);
10375 10391
10376 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10392 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10377 ScrollEnd(&web_view_helper); 10393 ScrollEnd(&web_view_helper);
10378 Mock::VerifyAndClearExpectations(&client); 10394 Mock::VerifyAndClearExpectations(&client);
10379 } 10395 }
10380 10396
10397 TEST_P(WebFrameOverscrollTest, ScrollBoundaryBehaviorAffectsDidOverscroll) {
10398 OverscrollWebViewClient client;
10399 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10400 FrameTestHelpers::WebViewHelper web_view_helper;
10401 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10402 nullptr, &client, nullptr,
10403 ConfigureAndroid);
10404 web_view_helper.Resize(WebSize(200, 200));
10405
10406 WebLocalFrame* mainFrame =
10407 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame();
10408 mainFrame->ExecuteScript(
10409 WebScriptSource(WebString("document.body.style="
10410 "'scroll-boundary-behavior: auto;'")));
10411
10412 ScrollBegin(&web_view_helper, 100, 116);
10413 EXPECT_CALL(
10414 client,
10415 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100),
10416 WebFloatPoint(100, 100), WebFloatSize(),
10417 WebScrollBoundaryBehavior(
10418 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10419 kScrollBoundaryBehaviorTypeAuto)));
10420 ScrollUpdate(&web_view_helper, 100, 100);
10421 Mock::VerifyAndClearExpectations(&client);
10422
10423 mainFrame->ExecuteScript(
10424 WebScriptSource(WebString("document.body.style="
10425 "'scroll-boundary-behavior: contain;'")));
10426
10427 ScrollBegin(&web_view_helper, 100, 116);
10428 EXPECT_CALL(
10429 client,
10430 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200),
10431 WebFloatPoint(100, 100), WebFloatSize(),
10432 WebScrollBoundaryBehavior(
10433 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10434 kScrollBoundaryBehaviorTypeContain)));
10435 ScrollUpdate(&web_view_helper, 100, 100);
10436 Mock::VerifyAndClearExpectations(&client);
10437
10438 mainFrame->ExecuteScript(
10439 WebScriptSource(WebString("document.body.style="
10440 "'scroll-boundary-behavior: none;'")));
10441
10442 ScrollBegin(&web_view_helper, 100, 116);
10443 EXPECT_CALL(
10444 client,
10445 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-300, -300),
10446 WebFloatPoint(100, 100), WebFloatSize(),
10447 WebScrollBoundaryBehavior(
10448 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10449 kScrollBoundaryBehaviorTypeNone)));
10450 ScrollUpdate(&web_view_helper, 100, 100);
10451 Mock::VerifyAndClearExpectations(&client);
10452 }
10453
10454 TEST_P(WebFrameOverscrollTest, OnlyMainFrameScrollBoundaryBehaviorHasEffect) {
10455 OverscrollWebViewClient client;
10456 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10457 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10458 FrameTestHelpers::WebViewHelper web_view_helper;
10459 web_view_helper.InitializeAndLoad(
10460 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client,
10461 nullptr, ConfigureAndroid);
10462 web_view_helper.Resize(WebSize(200, 200));
10463
10464 WebLocalFrame* mainFrame =
10465 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame();
10466 mainFrame->ExecuteScript(
10467 WebScriptSource(WebString("document.body.style="
10468 "'scroll-boundary-behavior: auto;'")));
10469 WebLocalFrame* subframe =
10470 web_view_helper.WebView()->MainFrame()->FirstChild()->ToWebLocalFrame();
10471 subframe->ExecuteScript(
10472 WebScriptSource(WebString("document.body.style="
10473 "'scroll-boundary-behavior: none;'")));
10474
10475 ScrollBegin(&web_view_helper, 100, 116);
10476 EXPECT_CALL(
10477 client,
10478 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100),
10479 WebFloatPoint(100, 100), WebFloatSize(),
10480 WebScrollBoundaryBehavior(
10481 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10482 kScrollBoundaryBehaviorTypeAuto)));
10483 ScrollUpdate(&web_view_helper, 100, 100);
10484 Mock::VerifyAndClearExpectations(&client);
10485
10486 mainFrame->ExecuteScript(
10487 WebScriptSource(WebString("document.body.style="
10488 "'scroll-boundary-behavior: contain;'")));
10489
10490 EXPECT_CALL(
10491 client,
10492 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200),
10493 WebFloatPoint(100, 100), WebFloatSize(),
10494 WebScrollBoundaryBehavior(
10495 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10496 kScrollBoundaryBehaviorTypeContain)));
10497 ScrollUpdate(&web_view_helper, 100, 100);
10498 Mock::VerifyAndClearExpectations(&client);
10499 }
10500
10381 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { 10501 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) {
10382 RuntimeEnabledFeatures::SetOrientationEventEnabled(true); 10502 RuntimeEnabledFeatures::SetOrientationEventEnabled(true);
10383 RegisterMockedHttpURLLoad("orientation-frame-detach.html"); 10503 RegisterMockedHttpURLLoad("orientation-frame-detach.html");
10384 FrameTestHelpers::WebViewHelper web_view_helper; 10504 FrameTestHelpers::WebViewHelper web_view_helper;
10385 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( 10505 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad(
10386 base_url_ + "orientation-frame-detach.html"); 10506 base_url_ + "orientation-frame-detach.html");
10387 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent(); 10507 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent();
10388 } 10508 }
10389 10509
10390 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) { 10510 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) {
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
12330 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation, 12450 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation,
12331 1); 12451 1);
12332 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an 12452 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an
12333 // illegal combination, which has been caught by DCHECK in 12453 // illegal combination, which has been caught by DCHECK in
12334 // UpdateForSameDocumentNavigation(). 12454 // UpdateForSameDocumentNavigation().
12335 12455
12336 tester.ExpectTotalCount(histogramName, 3); 12456 tester.ExpectTotalCount(histogramName, 3);
12337 } 12457 }
12338 12458
12339 } // namespace blink 12459 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698