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

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

Issue 1774943003: blink: Rename platform/ methods to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-platform: rebase-yayyyyyyyy Created 4 years, 9 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) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 // Scrolling up after previous scroll downs should cause top controls to be 201 // Scrolling up after previous scroll downs should cause top controls to be
202 // shown only after all previously scrolled down amount is compensated. 202 // shown only after all previously scrolled down amount is compensated.
203 TEST_F(TopControlsTest, MAYBE(ScrollDownThenUp)) 203 TEST_F(TopControlsTest, MAYBE(ScrollDownThenUp))
204 { 204 {
205 WebViewImpl* webView = initialize(); 205 WebViewImpl* webView = initialize();
206 // initialize top controls to be shown and position page at 100px. 206 // initialize top controls to be shown and position page at 100px.
207 webView->setTopControlsHeight(50.f, true); 207 webView->setTopControlsHeight(50.f, true);
208 webView->topControls().setShownRatio(1); 208 webView->topControls().setShownRatio(1);
209 frame()->view()->scrollableArea()->setScrollPosition(IntPoint(0, 100), Progr ammaticScroll); 209 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), Pr ogrammaticScroll);
210 210
211 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); 211 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin));
212 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 212 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
213 213
214 // Scroll down to completely hide top controls. Excess deltaY (100px) should be consumed by the page. 214 // Scroll down to completely hide top controls. Excess deltaY (100px) should be consumed by the page.
215 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, -150.f)); 215 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, -150.f));
216 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 216 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
217 EXPECT_POINT_EQ(IntPoint(0, 200), frame()->view()->scrollPosition()); 217 EXPECT_POINT_EQ(IntPoint(0, 200), frame()->view()->scrollPosition());
218 218
219 // Scroll up and ensure the top controls does not move until we recover 100p x previously scrolled. 219 // Scroll up and ensure the top controls does not move until we recover 100p x previously scrolled.
(...skipping 17 matching lines...) Expand all
237 } 237 }
238 238
239 // Scrolling down should always cause visible top controls to start hiding even 239 // Scrolling down should always cause visible top controls to start hiding even
240 // if we have been scrolling up previously. 240 // if we have been scrolling up previously.
241 TEST_F(TopControlsTest, MAYBE(ScrollUpThenDown)) 241 TEST_F(TopControlsTest, MAYBE(ScrollUpThenDown))
242 { 242 {
243 WebViewImpl* webView = initialize(); 243 WebViewImpl* webView = initialize();
244 // initialize top controls to be hidden and position page at 100px. 244 // initialize top controls to be hidden and position page at 100px.
245 webView->setTopControlsHeight(50.f, false); 245 webView->setTopControlsHeight(50.f, false);
246 webView->topControls().setShownRatio(0); 246 webView->topControls().setShownRatio(0);
247 frame()->view()->scrollableArea()->setScrollPosition(IntPoint(0, 100), Progr ammaticScroll); 247 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), Pr ogrammaticScroll);
248 248
249 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); 249 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin));
250 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 250 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
251 251
252 // Scroll up to completely show top controls. Excess deltaY (50px) should be consumed by the page. 252 // Scroll up to completely show top controls. Excess deltaY (50px) should be consumed by the page.
253 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, 100.f)); 253 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, 100.f));
254 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 254 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
255 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); 255 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition());
256 256
257 // Scroll down and ensure only top controls is scrolled 257 // Scroll down and ensure only top controls is scrolled
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Initialize top controls to be shown. 295 // Initialize top controls to be shown.
296 webView->setTopControlsHeight(50.f, true); 296 webView->setTopControlsHeight(50.f, true);
297 webView->topControls().setShownRatio(1); 297 webView->topControls().setShownRatio(1);
298 298
299 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); 299 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin));
300 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 300 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
301 301
302 // Top controls should be scrolled partially and page should not scroll. 302 // Top controls should be scrolled partially and page should not scroll.
303 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, -20.f)); 303 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, -20.f));
304 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); 304 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset());
305 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->scrollableArea()->scrollPos itionDouble()); 305 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->getScrollableArea()->scroll PositionDouble());
306 306
307 // Top controls should consume 30px and become hidden. Excess scroll should be consumed by the page at 2x scale. 307 // Top controls should consume 30px and become hidden. Excess scroll should be consumed by the page at 2x scale.
308 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, -70.f)); 308 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, -70.f));
309 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 309 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
310 EXPECT_POINT_EQ(IntPoint(0, 20), frame()->view()->scrollableArea()->scrollPo sitionDouble()); 310 EXPECT_POINT_EQ(IntPoint(0, 20), frame()->view()->getScrollableArea()->scrol lPositionDouble());
311 311
312 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); 312 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd));
313 313
314 // Change page scale and test. 314 // Change page scale and test.
315 webView->setPageScaleFactor(0.5); 315 webView->setPageScaleFactor(0.5);
316 316
317 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); 317 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin));
318 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 318 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
319 EXPECT_POINT_EQ(IntPoint(0, 20), frame()->view()->scrollableArea()->scrollPo sitionDouble()); 319 EXPECT_POINT_EQ(IntPoint(0, 20), frame()->view()->getScrollableArea()->scrol lPositionDouble());
320 320
321 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, 50.f)); 321 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, 50.f));
322 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 322 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
323 EXPECT_POINT_EQ(IntPoint(0, 20), frame()->view()->scrollableArea()->scrollPo sitionDouble()); 323 EXPECT_POINT_EQ(IntPoint(0, 20), frame()->view()->getScrollableArea()->scrol lPositionDouble());
324 324
325 // At 0.5x scale scrolling 10px should take us to the top of the page. 325 // At 0.5x scale scrolling 10px should take us to the top of the page.
326 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, 10.f)); 326 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, 0, 10.f));
327 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 327 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
328 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->scrollableArea()->scrollPos itionDouble()); 328 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->getScrollableArea()->scroll PositionDouble());
329 } 329 }
330 330
331 // Some scroll deltas result in a shownRatio that can't be realized in a 331 // Some scroll deltas result in a shownRatio that can't be realized in a
332 // floating-point number. Make sure that if the top controls aren't fully 332 // floating-point number. Make sure that if the top controls aren't fully
333 // scrolled, scrollBy doesn't return any excess delta. i.e. There should be no 333 // scrolled, scrollBy doesn't return any excess delta. i.e. There should be no
334 // slippage between the content and top controls. 334 // slippage between the content and top controls.
335 TEST_F(TopControlsTest, MAYBE(FloatingPointSlippage)) 335 TEST_F(TopControlsTest, MAYBE(FloatingPointSlippage))
336 { 336 {
337 WebViewImpl* webView = initialize(); 337 WebViewImpl* webView = initialize();
338 webViewImpl()->setDefaultPageScaleLimits(0.25f, 5); 338 webViewImpl()->setDefaultPageScaleLimits(0.25f, 5);
(...skipping 12 matching lines...) Expand all
351 FloatSize remainingDelta = webView->topControls().scrollBy(FloatSize(0, 10)) ; 351 FloatSize remainingDelta = webView->topControls().scrollBy(FloatSize(0, 10)) ;
352 EXPECT_EQ(0, remainingDelta.height()); 352 EXPECT_EQ(0, remainingDelta.height());
353 } 353 }
354 354
355 // Scrollable subregions should scroll before top controls 355 // Scrollable subregions should scroll before top controls
356 TEST_F(TopControlsTest, MAYBE(ScrollableSubregionScrollFirst)) 356 TEST_F(TopControlsTest, MAYBE(ScrollableSubregionScrollFirst))
357 { 357 {
358 WebViewImpl* webView = initialize("overflow-scrolling.html"); 358 WebViewImpl* webView = initialize("overflow-scrolling.html");
359 webView->setTopControlsHeight(50.f, true); 359 webView->setTopControlsHeight(50.f, true);
360 webView->topControls().setShownRatio(1); 360 webView->topControls().setShownRatio(1);
361 frame()->view()->scrollableArea()->setScrollPosition(IntPoint(0, 50), Progra mmaticScroll); 361 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 50), Pro grammaticScroll);
362 362
363 // Test scroll down 363 // Test scroll down
364 // Scroll down should scroll the overflow div first but top controls and mai n frame should not scroll. 364 // Scroll down should scroll the overflow div first but top controls and mai n frame should not scroll.
365 verticalScroll(-800.f); 365 verticalScroll(-800.f);
366 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 366 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
367 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); 367 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition());
368 368
369 // Continued scroll down should start hiding top controls but main frame sho uld not scroll. 369 // Continued scroll down should start hiding top controls but main frame sho uld not scroll.
370 verticalScroll(-40.f); 370 verticalScroll(-40.f);
371 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); 371 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset());
(...skipping 21 matching lines...) Expand all
393 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); 393 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition());
394 } 394 }
395 395
396 396
397 // Scrollable iframes should scroll before top controls 397 // Scrollable iframes should scroll before top controls
398 TEST_F(TopControlsTest, MAYBE(ScrollableIframeScrollFirst)) 398 TEST_F(TopControlsTest, MAYBE(ScrollableIframeScrollFirst))
399 { 399 {
400 WebViewImpl* webView = initialize("iframe-scrolling.html"); 400 WebViewImpl* webView = initialize("iframe-scrolling.html");
401 webView->setTopControlsHeight(50.f, true); 401 webView->setTopControlsHeight(50.f, true);
402 webView->topControls().setShownRatio(1); 402 webView->topControls().setShownRatio(1);
403 frame()->view()->scrollableArea()->setScrollPosition(IntPoint(0, 50), Progra mmaticScroll); 403 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 50), Pro grammaticScroll);
404 404
405 // Test scroll down 405 // Test scroll down
406 // Scroll down should scroll the iframe first but top controls and main fram e should not scroll. 406 // Scroll down should scroll the iframe first but top controls and main fram e should not scroll.
407 verticalScroll(-800.f); 407 verticalScroll(-800.f);
408 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 408 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
409 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); 409 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition());
410 410
411 // Continued scroll down should start hiding top controls but main frame sho uld not scroll. 411 // Continued scroll down should start hiding top controls but main frame sho uld not scroll.
412 verticalScroll(-40.f); 412 verticalScroll(-40.f);
413 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); 413 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 webView->setTopControlsHeight(30.f, false); 456 webView->setTopControlsHeight(30.f, false);
457 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); 457 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset());
458 } 458 }
459 459
460 // Zero delta should not have any effect on top controls. 460 // Zero delta should not have any effect on top controls.
461 TEST_F(TopControlsTest, MAYBE(ZeroHeightMeansNoEffect)) 461 TEST_F(TopControlsTest, MAYBE(ZeroHeightMeansNoEffect))
462 { 462 {
463 WebViewImpl* webView = initialize(); 463 WebViewImpl* webView = initialize();
464 webView->setTopControlsHeight(0, false); 464 webView->setTopControlsHeight(0, false);
465 webView->topControls().setShownRatio(0); 465 webView->topControls().setShownRatio(0);
466 frame()->view()->scrollableArea()->setScrollPosition(IntPoint(0, 100), Progr ammaticScroll); 466 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), Pr ogrammaticScroll);
467 467
468 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 468 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
469 469
470 verticalScroll(20.f); 470 verticalScroll(20.f);
471 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 471 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
472 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); 472 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition());
473 473
474 verticalScroll(-30.f); 474 verticalScroll(-30.f);
475 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 475 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
476 EXPECT_POINT_EQ(IntPoint(0, 110), frame()->view()->scrollPosition()); 476 EXPECT_POINT_EQ(IntPoint(0, 110), frame()->view()->scrollPosition());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // Top controls should not move because neither frameview nor visual viewpor t 510 // Top controls should not move because neither frameview nor visual viewpor t
511 // are scrollable 511 // are scrollable
512 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); 512 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset());
513 } 513 }
514 514
515 // Top controls should honor its constraints 515 // Top controls should honor its constraints
516 TEST_F(TopControlsTest, MAYBE(StateConstraints)) 516 TEST_F(TopControlsTest, MAYBE(StateConstraints))
517 { 517 {
518 WebViewImpl* webView = initialize(); 518 WebViewImpl* webView = initialize();
519 webView->setTopControlsHeight(50.f, false); 519 webView->setTopControlsHeight(50.f, false);
520 frame()->view()->scrollableArea()->setScrollPosition(IntPoint(0, 100), Progr ammaticScroll); 520 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), Pr ogrammaticScroll);
521 521
522 // Setting permitted state should not change content offset 522 // Setting permitted state should not change content offset
523 webView->updateTopControlsState(WebTopControlsShown, WebTopControlsShown, fa lse); 523 webView->updateTopControlsState(WebTopControlsShown, WebTopControlsShown, fa lse);
524 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); 524 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset());
525 525
526 // Showing is permitted 526 // Showing is permitted
527 webView->topControls().setShownRatio(1); 527 webView->topControls().setShownRatio(1);
528 EXPECT_FLOAT_EQ(50, webView->topControls().contentOffset()); 528 EXPECT_FLOAT_EQ(50, webView->topControls().contentOffset());
529 529
530 // Only shown state is permitted so controls cannot hide 530 // Only shown state is permitted so controls cannot hide
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 // that's 1600px wide so the minimum scale is 0.25 to encompass that. 725 // that's 1600px wide so the minimum scale is 0.25 to encompass that.
726 ASSERT_EQ(0.25f, webView->minimumPageScaleFactor()); 726 ASSERT_EQ(0.25f, webView->minimumPageScaleFactor());
727 727
728 // The viewport will match the layout width at scale=0.5 so the height used 728 // The viewport will match the layout width at scale=0.5 so the height used
729 // for vh should be (300 / 0.5) for the layout height + (100 / 0.5) for top 729 // for vh should be (300 / 0.5) for the layout height + (100 / 0.5) for top
730 // controls = 800. 730 // controls = 800.
731 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height()); 731 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height());
732 } 732 }
733 733
734 } // namespace blink 734 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698