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

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

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: Update the test Created 3 years, 6 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/dom/ClientRect.h" 6 #include "core/dom/ClientRect.h"
7 #include "core/exported/WebRemoteFrameImpl.h" 7 #include "core/exported/WebRemoteFrameImpl.h"
8 #include "core/frame/BrowserControls.h" 8 #include "core/frame/BrowserControls.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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 document->documentElement()->ReplaceWith(nodes, non_throw); 214 document->documentElement()->ReplaceWith(nodes, non_throw);
215 215
216 MainFrameView()->UpdateAllLifecyclePhases(); 216 MainFrameView()->UpdateAllLifecyclePhases();
217 217
218 EXPECT_EQ(MainFrame()->GetDocument(), 218 EXPECT_EQ(MainFrame()->GetDocument(),
219 EffectiveRootScroller(MainFrame()->GetDocument())); 219 EffectiveRootScroller(MainFrame()->GetDocument()));
220 } 220 }
221 221
222 class OverscrollTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 222 class OverscrollTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
223 public: 223 public:
224 MOCK_METHOD4(DidOverscroll, 224 MOCK_METHOD5(DidOverscroll,
225 void(const WebFloatSize&, 225 void(const WebFloatSize&,
226 const WebFloatSize&, 226 const WebFloatSize&,
227 const WebFloatPoint&, 227 const WebFloatPoint&,
228 const WebFloatSize&)); 228 const WebFloatSize&,
229 const WebScrollBoundaryBehavior&));
229 }; 230 };
230 231
231 // Tests that setting an element as the root scroller causes it to control url 232 // Tests that setting an element as the root scroller causes it to control url
232 // bar hiding and overscroll. 233 // bar hiding and overscroll.
233 TEST_F(RootScrollerTest, TestSetRootScroller) { 234 TEST_F(RootScrollerTest, TestSetRootScroller) {
234 OverscrollTestWebViewClient client; 235 OverscrollTestWebViewClient client;
235 Initialize("root-scroller.html", &client); 236 Initialize("root-scroller.html", &client);
236 237
237 Element* container = MainFrame()->GetDocument()->getElementById("container"); 238 Element* container = MainFrame()->GetDocument()->getElementById("container");
238 MainFrame()->GetDocument()->setRootScroller(container); 239 MainFrame()->GetDocument()->setRootScroller(container);
(...skipping 21 matching lines...) Expand all
260 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent( 261 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent(
261 WebInputEvent::kGestureScrollUpdate, 0, -100)); 262 WebInputEvent::kGestureScrollUpdate, 0, -100));
262 EXPECT_FLOAT_EQ(100, container->scrollTop()); 263 EXPECT_FLOAT_EQ(100, container->scrollTop());
263 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 264 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
264 } 265 }
265 266
266 { 267 {
267 // Scroll 50 pixels past the end. Ensure we report the 50 pixels as 268 // Scroll 50 pixels past the end. Ensure we report the 50 pixels as
268 // overscroll. 269 // overscroll.
269 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 270 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
270 WebFloatPoint(100, 100), WebFloatSize())); 271 WebFloatPoint(100, 100), WebFloatSize(),
272 WebScrollBoundaryBehavior()));
271 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent( 273 GetWebView()->HandleInputEvent(GenerateTouchGestureEvent(
272 WebInputEvent::kGestureScrollUpdate, 0, -500)); 274 WebInputEvent::kGestureScrollUpdate, 0, -500));
273 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop()); 275 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop());
274 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 276 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
275 Mock::VerifyAndClearExpectations(&client); 277 Mock::VerifyAndClearExpectations(&client);
276 } 278 }
277 279
278 { 280 {
279 // Continue the gesture overscroll. 281 // Continue the gesture overscroll.
280 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 20), WebFloatSize(0, 70), 282 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 20), WebFloatSize(0, 70),
281 WebFloatPoint(100, 100), WebFloatSize())); 283 WebFloatPoint(100, 100), WebFloatSize(),
284 WebScrollBoundaryBehavior()));
282 GetWebView()->HandleInputEvent( 285 GetWebView()->HandleInputEvent(
283 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -20)); 286 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -20));
284 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop()); 287 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop());
285 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 288 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
286 Mock::VerifyAndClearExpectations(&client); 289 Mock::VerifyAndClearExpectations(&client);
287 } 290 }
288 291
289 GetWebView()->HandleInputEvent( 292 GetWebView()->HandleInputEvent(
290 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd)); 293 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd));
291 294
292 { 295 {
293 // Make sure a new gesture scroll still won't scroll the frameview and 296 // Make sure a new gesture scroll still won't scroll the frameview and
294 // overscrolls. 297 // overscrolls.
295 GetWebView()->HandleInputEvent( 298 GetWebView()->HandleInputEvent(
296 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollBegin)); 299 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollBegin));
297 300
298 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 30), WebFloatSize(0, 30), 301 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 30), WebFloatSize(0, 30),
299 WebFloatPoint(100, 100), WebFloatSize())); 302 WebFloatPoint(100, 100), WebFloatSize(),
303 WebScrollBoundaryBehavior()));
300 GetWebView()->HandleInputEvent( 304 GetWebView()->HandleInputEvent(
301 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -30)); 305 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, -30));
302 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop()); 306 EXPECT_FLOAT_EQ(maximum_scroll, container->scrollTop());
303 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height()); 307 EXPECT_FLOAT_EQ(0, MainFrameView()->GetScrollOffset().Height());
304 Mock::VerifyAndClearExpectations(&client); 308 Mock::VerifyAndClearExpectations(&client);
305 309
306 GetWebView()->HandleInputEvent( 310 GetWebView()->HandleInputEvent(
307 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd)); 311 GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd));
308 } 312 }
309 313
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // Ensure the target and container weren't put into the same layer. 1217 // Ensure the target and container weren't put into the same layer.
1214 ASSERT_NE(ToLayoutBox(target->GetLayoutObject())->EnclosingLayer(), 1218 ASSERT_NE(ToLayoutBox(target->GetLayoutObject())->EnclosingLayer(),
1215 ToLayoutBox(container->GetLayoutObject())->Layer()); 1219 ToLayoutBox(container->GetLayoutObject())->Layer());
1216 1220
1217 CheckHitTestAtBottomOfScreen(); 1221 CheckHitTestAtBottomOfScreen();
1218 } 1222 }
1219 1223
1220 } // namespace 1224 } // namespace
1221 1225
1222 } // namespace blink 1226 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698