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

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/RootScrollerTest.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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/NodeOrString.h" 5 #include "bindings/core/v8/NodeOrString.h"
6 #include "core/exported/WebRemoteFrameImpl.h" 6 #include "core/exported/WebRemoteFrameImpl.h"
7 #include "core/frame/BrowserControls.h" 7 #include "core/frame/BrowserControls.h"
8 #include "core/frame/FrameTestHelpers.h" 8 #include "core/frame/FrameTestHelpers.h"
9 #include "core/frame/LocalFrameView.h" 9 #include "core/frame/LocalFrameView.h"
10 #include "core/frame/RootFrameViewport.h" 10 #include "core/frame/RootFrameViewport.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 document->documentElement()->ReplaceWith(nodes, non_throw); 223 document->documentElement()->ReplaceWith(nodes, non_throw);
224 224
225 MainFrameView()->UpdateAllLifecyclePhases(); 225 MainFrameView()->UpdateAllLifecyclePhases();
226 226
227 EXPECT_EQ(MainFrame()->GetDocument(), 227 EXPECT_EQ(MainFrame()->GetDocument(),
228 EffectiveRootScroller(MainFrame()->GetDocument())); 228 EffectiveRootScroller(MainFrame()->GetDocument()));
229 } 229 }
230 230
231 class OverscrollTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 231 class OverscrollTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
232 public: 232 public:
233 MOCK_METHOD4(DidOverscroll, 233 MOCK_METHOD5(DidOverscroll,
234 void(const WebFloatSize&, 234 void(const WebFloatSize&,
235 const WebFloatSize&, 235 const WebFloatSize&,
236 const WebFloatPoint&, 236 const WebFloatPoint&,
237 const WebFloatSize&)); 237 const WebFloatSize&,
238 const WebScrollBoundaryBehavior&));
238 }; 239 };
239 240
240 // Tests that setting an element as the root scroller causes it to control url 241 // Tests that setting an element as the root scroller causes it to control url
241 // bar hiding and overscroll. 242 // bar hiding and overscroll.
242 TEST_P(RootScrollerTest, TestSetRootScroller) { 243 TEST_P(RootScrollerTest, TestSetRootScroller) {
243 OverscrollTestWebViewClient client; 244 OverscrollTestWebViewClient client;
244 Initialize("root-scroller.html", &client); 245 Initialize("root-scroller.html", &client);
245 246
246 Element* container = MainFrame()->GetDocument()->getElementById("container"); 247 Element* container = MainFrame()->GetDocument()->getElementById("container");
247 MainFrame()->GetDocument()->setRootScroller(container); 248 MainFrame()->GetDocument()->setRootScroller(container);
(...skipping 21 matching lines...) Expand all
269 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent( 270 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent(
270 WebInputEvent::kGestureScrollUpdate, 0, -100)); 271 WebInputEvent::kGestureScrollUpdate, 0, -100));
271 EXPECT_FLOAT_EQ(100, container->scrollTop()); 272 EXPECT_FLOAT_EQ(100, container->scrollTop());
272 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 273 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
273 } 274 }
274 275
275 { 276 {
276 // Scroll 50 pixels past the end. Ensure we report the 50 pixels as 277 // Scroll 50 pixels past the end. Ensure we report the 50 pixels as
277 // overscroll. 278 // overscroll.
278 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 279 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
279 WebFloatPoint(100, 100), WebFloatSize())); 280 WebFloatPoint(100, 100), WebFloatSize(),
281 WebScrollBoundaryBehavior()));
280 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent( 282 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent(
281 WebInputEvent::kGestureScrollUpdate, 0, -500)); 283 WebInputEvent::kGestureScrollUpdate, 0, -500));
282 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop()); 284 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop());
283 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 285 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
284 Mock::VerifyAndClearExpectations(&client); 286 Mock::VerifyAndClearExpectations(&client);
285 } 287 }
286 288
287 { 289 {
288 // Continue the gesture overscroll. 290 // Continue the gesture overscroll.
289 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 20), WebFloatSize(0, 70), 291 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 20), WebFloatSize(0, 70),
290 WebFloatPoint(100, 100), WebFloatSize())); 292 WebFloatPoint(100, 100), WebFloatSize(),
293 WebScrollBoundaryBehavior()));
291 GetWebView()->HandleInputEvent( 294 GetWebView()->HandleInputEvent(
292 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -20)); 295 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -20));
293 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop()); 296 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop());
294 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 297 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
295 Mock::VerifyAndClearExpectations(&client); 298 Mock::VerifyAndClearExpectations(&client);
296 } 299 }
297 300
298 GetWebView()->HandleInputEvent( 301 GetWebView()->HandleInputEvent(
299 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd)); 302 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd));
300 303
301 { 304 {
302 // Make sure a new gesture scroll still won't scroll the frameview and 305 // Make sure a new gesture scroll still won't scroll the frameview and
303 // overscrolls. 306 // overscrolls.
304 GetWebView()->HandleInputEvent( 307 GetWebView()->HandleInputEvent(
305 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollBegin)); 308 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollBegin));
306 309
307 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 30), WebFloatSize(0, 30), 310 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 30), WebFloatSize(0, 30),
308 WebFloatPoint(100, 100), WebFloatSize())); 311 WebFloatPoint(100, 100), WebFloatSize(),
312 WebScrollBoundaryBehavior()));
309 GetWebView()->HandleInputEvent( 313 GetWebView()->HandleInputEvent(
310 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -30)); 314 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -30));
311 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop()); 315 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop());
312 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 316 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
313 Mock::VerifyAndClearExpectations(&client); 317 Mock::VerifyAndClearExpectations(&client);
314 318
315 GetWebView()->HandleInputEvent( 319 GetWebView()->HandleInputEvent(
316 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd)); 320 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd));
317 } 321 }
318 322
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 // Ensure the target and container weren't put into the same layer. 1347 // Ensure the target and container weren't put into the same layer.
1344 ASSERT_NE(ToLayoutBox(target->GetLayoutObject())->EnclosingLayer(), 1348 ASSERT_NE(ToLayoutBox(target->GetLayoutObject())->EnclosingLayer(),
1345 ToLayoutBox(container->GetLayoutObject())->Layer()); 1349 ToLayoutBox(container->GetLayoutObject())->Layer());
1346 1350
1347 CheckHitTestAtBottomOfScreen(); 1351 CheckHitTestAtBottomOfScreen();
1348 } 1352 }
1349 1353
1350 } // namespace 1354 } // namespace
1351 1355
1352 } // namespace blink 1356 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/scrolling/OverscrollController.cpp ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698