OLD | NEW |
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); | 165 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); |
166 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 166 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
167 | 167 |
168 // Top controls should be scrolled partially and page should not scroll. | 168 // Top controls should be scrolled partially and page should not scroll. |
169 webView->handleInputEvent( | 169 webView->handleInputEvent( |
170 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -25.f)); | 170 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -25.f)); |
171 EXPECT_FLOAT_EQ(25.f, webView->topControls().contentOffset()); | 171 EXPECT_FLOAT_EQ(25.f, webView->topControls().contentOffset()); |
172 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->scrollPosition()); | 172 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->scrollPosition()); |
173 | 173 |
174 // Top controls should consume 25px and become hidden. Excess scroll should be
consumed by the page. | 174 // Top controls should consume 25px and become hidden. Excess scroll should be |
| 175 // consumed by the page. |
175 webView->handleInputEvent( | 176 webView->handleInputEvent( |
176 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -40.f)); | 177 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -40.f)); |
177 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 178 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
178 EXPECT_POINT_EQ(IntPoint(0, 15), frame()->view()->scrollPosition()); | 179 EXPECT_POINT_EQ(IntPoint(0, 15), frame()->view()->scrollPosition()); |
179 | 180 |
180 // Only page should consume scroll | 181 // Only page should consume scroll |
181 webView->handleInputEvent( | 182 webView->handleInputEvent( |
182 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -20.f)); | 183 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -20.f)); |
183 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 184 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
184 EXPECT_POINT_EQ(IntPoint(0, 35), frame()->view()->scrollPosition()); | 185 EXPECT_POINT_EQ(IntPoint(0, 35), frame()->view()->scrollPosition()); |
(...skipping 26 matching lines...) Expand all Loading... |
211 WebViewImpl* webView = initialize(); | 212 WebViewImpl* webView = initialize(); |
212 // initialize top controls to be shown and position page at 100px. | 213 // initialize top controls to be shown and position page at 100px. |
213 webView->resizeWithTopControls(webView->size(), 50.f, true); | 214 webView->resizeWithTopControls(webView->size(), 50.f, true); |
214 webView->topControls().setShownRatio(1); | 215 webView->topControls().setShownRatio(1); |
215 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), | 216 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), |
216 ProgrammaticScroll); | 217 ProgrammaticScroll); |
217 | 218 |
218 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); | 219 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); |
219 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 220 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
220 | 221 |
221 // Scroll down to completely hide top controls. Excess deltaY (100px) should b
e consumed by the page. | 222 // Scroll down to completely hide top controls. Excess deltaY (100px) should |
| 223 // be consumed by the page. |
222 webView->handleInputEvent( | 224 webView->handleInputEvent( |
223 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -150.f)); | 225 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -150.f)); |
224 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 226 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
225 EXPECT_POINT_EQ(IntPoint(0, 200), frame()->view()->scrollPosition()); | 227 EXPECT_POINT_EQ(IntPoint(0, 200), frame()->view()->scrollPosition()); |
226 | 228 |
227 // Scroll up and ensure the top controls does not move until we recover 100px
previously scrolled. | 229 // Scroll up and ensure the top controls does not move until we recover 100px |
| 230 // previously scrolled. |
228 webView->handleInputEvent( | 231 webView->handleInputEvent( |
229 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 40.f)); | 232 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 40.f)); |
230 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 233 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
231 EXPECT_POINT_EQ(IntPoint(0, 160), frame()->view()->scrollPosition()); | 234 EXPECT_POINT_EQ(IntPoint(0, 160), frame()->view()->scrollPosition()); |
232 | 235 |
233 webView->handleInputEvent( | 236 webView->handleInputEvent( |
234 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 60.f)); | 237 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 60.f)); |
235 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 238 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
236 EXPECT_POINT_EQ(IntPoint(0, 100), frame()->view()->scrollPosition()); | 239 EXPECT_POINT_EQ(IntPoint(0, 100), frame()->view()->scrollPosition()); |
237 | 240 |
238 // Now we have hit the threshold so further scroll up should be consumed by to
p controls. | 241 // Now we have hit the threshold so further scroll up should be consumed by |
| 242 // top controls. |
239 webView->handleInputEvent( | 243 webView->handleInputEvent( |
240 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 30.f)); | 244 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 30.f)); |
241 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); | 245 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); |
242 EXPECT_POINT_EQ(IntPoint(0, 100), frame()->view()->scrollPosition()); | 246 EXPECT_POINT_EQ(IntPoint(0, 100), frame()->view()->scrollPosition()); |
243 | 247 |
244 // Once top control is fully shown then page should consume any excess scroll. | 248 // Once top control is fully shown then page should consume any excess scroll. |
245 webView->handleInputEvent( | 249 webView->handleInputEvent( |
246 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 70.f)); | 250 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 70.f)); |
247 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 251 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
248 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 252 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
249 } | 253 } |
250 | 254 |
251 // Scrolling down should always cause visible top controls to start hiding even | 255 // Scrolling down should always cause visible top controls to start hiding even |
252 // if we have been scrolling up previously. | 256 // if we have been scrolling up previously. |
253 TEST_F(TopControlsTest, MAYBE(ScrollUpThenDown)) { | 257 TEST_F(TopControlsTest, MAYBE(ScrollUpThenDown)) { |
254 WebViewImpl* webView = initialize(); | 258 WebViewImpl* webView = initialize(); |
255 // initialize top controls to be hidden and position page at 100px. | 259 // initialize top controls to be hidden and position page at 100px. |
256 webView->resizeWithTopControls(webView->size(), 50.f, false); | 260 webView->resizeWithTopControls(webView->size(), 50.f, false); |
257 webView->topControls().setShownRatio(0); | 261 webView->topControls().setShownRatio(0); |
258 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), | 262 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), |
259 ProgrammaticScroll); | 263 ProgrammaticScroll); |
260 | 264 |
261 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); | 265 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); |
262 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 266 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
263 | 267 |
264 // Scroll up to completely show top controls. Excess deltaY (50px) should be c
onsumed by the page. | 268 // Scroll up to completely show top controls. Excess deltaY (50px) should be |
| 269 // consumed by the page. |
265 webView->handleInputEvent( | 270 webView->handleInputEvent( |
266 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 100.f)); | 271 generateEvent(WebInputEvent::GestureScrollUpdate, 0, 100.f)); |
267 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 272 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
268 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 273 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
269 | 274 |
270 // Scroll down and ensure only top controls is scrolled | 275 // Scroll down and ensure only top controls is scrolled |
271 webView->handleInputEvent( | 276 webView->handleInputEvent( |
272 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -40.f)); | 277 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -40.f)); |
273 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); | 278 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); |
274 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 279 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); | 319 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin)); |
315 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 320 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
316 | 321 |
317 // Top controls should be scrolled partially and page should not scroll. | 322 // Top controls should be scrolled partially and page should not scroll. |
318 webView->handleInputEvent( | 323 webView->handleInputEvent( |
319 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -20.f)); | 324 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -20.f)); |
320 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); | 325 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); |
321 EXPECT_POINT_EQ(IntPoint(0, 0), | 326 EXPECT_POINT_EQ(IntPoint(0, 0), |
322 frame()->view()->getScrollableArea()->scrollPositionDouble()); | 327 frame()->view()->getScrollableArea()->scrollPositionDouble()); |
323 | 328 |
324 // Top controls should consume 30px and become hidden. Excess scroll should be
consumed by the page at 2x scale. | 329 // Top controls should consume 30px and become hidden. Excess scroll should be |
| 330 // consumed by the page at 2x scale. |
325 webView->handleInputEvent( | 331 webView->handleInputEvent( |
326 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -70.f)); | 332 generateEvent(WebInputEvent::GestureScrollUpdate, 0, -70.f)); |
327 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 333 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
328 EXPECT_POINT_EQ(IntPoint(0, 20), | 334 EXPECT_POINT_EQ(IntPoint(0, 20), |
329 frame()->view()->getScrollableArea()->scrollPositionDouble()); | 335 frame()->view()->getScrollableArea()->scrollPositionDouble()); |
330 | 336 |
331 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); | 337 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); |
332 | 338 |
333 // Change page scale and test. | 339 // Change page scale and test. |
334 webView->setPageScaleFactor(0.5); | 340 webView->setPageScaleFactor(0.5); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 383 |
378 // Scrollable subregions should scroll before top controls | 384 // Scrollable subregions should scroll before top controls |
379 TEST_F(TopControlsTest, MAYBE(ScrollableSubregionScrollFirst)) { | 385 TEST_F(TopControlsTest, MAYBE(ScrollableSubregionScrollFirst)) { |
380 WebViewImpl* webView = initialize("overflow-scrolling.html"); | 386 WebViewImpl* webView = initialize("overflow-scrolling.html"); |
381 webView->resizeWithTopControls(webView->size(), 50.f, true); | 387 webView->resizeWithTopControls(webView->size(), 50.f, true); |
382 webView->topControls().setShownRatio(1); | 388 webView->topControls().setShownRatio(1); |
383 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 50), | 389 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 50), |
384 ProgrammaticScroll); | 390 ProgrammaticScroll); |
385 | 391 |
386 // Test scroll down | 392 // Test scroll down |
387 // Scroll down should scroll the overflow div first but top controls and main
frame should not scroll. | 393 // Scroll down should scroll the overflow div first but top controls and main |
| 394 // frame should not scroll. |
388 verticalScroll(-800.f); | 395 verticalScroll(-800.f); |
389 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 396 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
390 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 397 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
391 | 398 |
392 // Continued scroll down should start hiding top controls but main frame shoul
d not scroll. | 399 // Continued scroll down should start hiding top controls but main frame |
| 400 // should not scroll. |
393 verticalScroll(-40.f); | 401 verticalScroll(-40.f); |
394 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); | 402 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); |
395 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 403 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
396 | 404 |
397 // Continued scroll down should scroll down the main frame | 405 // Continued scroll down should scroll down the main frame |
398 verticalScroll(-40.f); | 406 verticalScroll(-40.f); |
399 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 407 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
400 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); | 408 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); |
401 | 409 |
402 // Test scroll up | 410 // Test scroll up |
403 // scroll up should scroll overflow div first | 411 // scroll up should scroll overflow div first |
404 verticalScroll(800.f); | 412 verticalScroll(800.f); |
405 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 413 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
406 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); | 414 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); |
407 | 415 |
408 // Continued scroll up should start showing top controls but main frame should
not scroll. | 416 // Continued scroll up should start showing top controls but main frame should |
| 417 // not scroll. |
409 verticalScroll(40.f); | 418 verticalScroll(40.f); |
410 EXPECT_FLOAT_EQ(40.f, webView->topControls().contentOffset()); | 419 EXPECT_FLOAT_EQ(40.f, webView->topControls().contentOffset()); |
411 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); | 420 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); |
412 | 421 |
413 // Continued scroll down up scroll up the main frame | 422 // Continued scroll down up scroll up the main frame |
414 verticalScroll(40.f); | 423 verticalScroll(40.f); |
415 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 424 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
416 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 425 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
417 } | 426 } |
418 | 427 |
419 // Scrollable iframes should scroll before top controls | 428 // Scrollable iframes should scroll before top controls |
420 TEST_F(TopControlsTest, MAYBE(ScrollableIframeScrollFirst)) { | 429 TEST_F(TopControlsTest, MAYBE(ScrollableIframeScrollFirst)) { |
421 WebViewImpl* webView = initialize("iframe-scrolling.html"); | 430 WebViewImpl* webView = initialize("iframe-scrolling.html"); |
422 webView->resizeWithTopControls(webView->size(), 50.f, true); | 431 webView->resizeWithTopControls(webView->size(), 50.f, true); |
423 webView->topControls().setShownRatio(1); | 432 webView->topControls().setShownRatio(1); |
424 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 50), | 433 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 50), |
425 ProgrammaticScroll); | 434 ProgrammaticScroll); |
426 | 435 |
427 // Test scroll down | 436 // Test scroll down |
428 // Scroll down should scroll the iframe first but top controls and main frame
should not scroll. | 437 // Scroll down should scroll the iframe first but top controls and main frame |
| 438 // should not scroll. |
429 verticalScroll(-800.f); | 439 verticalScroll(-800.f); |
430 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 440 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
431 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 441 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
432 | 442 |
433 // Continued scroll down should start hiding top controls but main frame shoul
d not scroll. | 443 // Continued scroll down should start hiding top controls but main frame |
| 444 // should not scroll. |
434 verticalScroll(-40.f); | 445 verticalScroll(-40.f); |
435 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); | 446 EXPECT_FLOAT_EQ(10.f, webView->topControls().contentOffset()); |
436 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 447 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
437 | 448 |
438 // Continued scroll down should scroll down the main frame | 449 // Continued scroll down should scroll down the main frame |
439 verticalScroll(-40.f); | 450 verticalScroll(-40.f); |
440 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 451 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
441 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); | 452 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); |
442 | 453 |
443 // Test scroll up | 454 // Test scroll up |
444 // scroll up should scroll iframe first | 455 // scroll up should scroll iframe first |
445 verticalScroll(800.f); | 456 verticalScroll(800.f); |
446 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 457 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
447 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); | 458 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); |
448 | 459 |
449 // Continued scroll up should start showing top controls but main frame should
not scroll. | 460 // Continued scroll up should start showing top controls but main frame should |
| 461 // not scroll. |
450 verticalScroll(40.f); | 462 verticalScroll(40.f); |
451 EXPECT_FLOAT_EQ(40.f, webView->topControls().contentOffset()); | 463 EXPECT_FLOAT_EQ(40.f, webView->topControls().contentOffset()); |
452 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); | 464 EXPECT_POINT_EQ(IntPoint(0, 80), frame()->view()->scrollPosition()); |
453 | 465 |
454 // Continued scroll down up scroll up the main frame | 466 // Continued scroll down up scroll up the main frame |
455 verticalScroll(40.f); | 467 verticalScroll(40.f); |
456 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); | 468 EXPECT_FLOAT_EQ(50.f, webView->topControls().contentOffset()); |
457 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); | 469 EXPECT_POINT_EQ(IntPoint(0, 50), frame()->view()->scrollPosition()); |
458 } | 470 } |
459 | 471 |
460 // Top controls visibility should remain consistent when height is changed. | 472 // Top controls visibility should remain consistent when height is changed. |
461 TEST_F(TopControlsTest, MAYBE(HeightChangeMaintainsVisibility)) { | 473 TEST_F(TopControlsTest, MAYBE(HeightChangeMaintainsVisibility)) { |
462 WebViewImpl* webView = initialize(); | 474 WebViewImpl* webView = initialize(); |
463 webView->resizeWithTopControls(webView->size(), 20.f, false); | 475 webView->resizeWithTopControls(webView->size(), 20.f, false); |
464 webView->topControls().setShownRatio(0); | 476 webView->topControls().setShownRatio(0); |
465 | 477 |
466 webView->resizeWithTopControls(webView->size(), 20.f, false); | 478 webView->resizeWithTopControls(webView->size(), 20.f, false); |
467 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 479 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
468 | 480 |
469 webView->resizeWithTopControls(webView->size(), 40.f, false); | 481 webView->resizeWithTopControls(webView->size(), 40.f, false); |
470 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); | 482 EXPECT_FLOAT_EQ(0.f, webView->topControls().contentOffset()); |
471 | 483 |
472 // Scroll up to show top controls. | 484 // Scroll up to show top controls. |
473 verticalScroll(40.f); | 485 verticalScroll(40.f); |
474 EXPECT_FLOAT_EQ(40.f, webView->topControls().contentOffset()); | 486 EXPECT_FLOAT_EQ(40.f, webView->topControls().contentOffset()); |
475 | 487 |
476 // Changing height of a fully shown top controls should correctly adjust conte
nt offset | 488 // Changing height of a fully shown top controls should correctly adjust |
| 489 // content offset |
477 webView->resizeWithTopControls(webView->size(), 30.f, false); | 490 webView->resizeWithTopControls(webView->size(), 30.f, false); |
478 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); | 491 EXPECT_FLOAT_EQ(30.f, webView->topControls().contentOffset()); |
479 } | 492 } |
480 | 493 |
481 // Zero delta should not have any effect on top controls. | 494 // Zero delta should not have any effect on top controls. |
482 TEST_F(TopControlsTest, MAYBE(ZeroHeightMeansNoEffect)) { | 495 TEST_F(TopControlsTest, MAYBE(ZeroHeightMeansNoEffect)) { |
483 WebViewImpl* webView = initialize(); | 496 WebViewImpl* webView = initialize(); |
484 webView->resizeWithTopControls(webView->size(), 0, false); | 497 webView->resizeWithTopControls(webView->size(), 0, false); |
485 webView->topControls().setShownRatio(0); | 498 webView->topControls().setShownRatio(0); |
486 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), | 499 frame()->view()->getScrollableArea()->setScrollPosition(IntPoint(0, 100), |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 view->setScrollPosition(view->scrollPosition(), ProgrammaticScroll); | 846 view->setScrollPosition(view->scrollPosition(), ProgrammaticScroll); |
834 | 847 |
835 ASSERT_EQ(80.f, webView->topControls().contentOffset()); | 848 ASSERT_EQ(80.f, webView->topControls().contentOffset()); |
836 EXPECT_EQ(expectedRootOffset, rootViewport->scrollPosition().y()); | 849 EXPECT_EQ(expectedRootOffset, rootViewport->scrollPosition().y()); |
837 | 850 |
838 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); | 851 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); |
839 } | 852 } |
840 } | 853 } |
841 | 854 |
842 } // namespace blink | 855 } // namespace blink |
OLD | NEW |