Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/input/scrollbar_animation_controller.h" | 5 #include "cc/input/scrollbar_animation_controller.h" |
| 6 | 6 |
| 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 8 #include "cc/test/fake_impl_task_runner_provider.h" | 8 #include "cc/test/fake_impl_task_runner_provider.h" |
| 9 #include "cc/test/fake_layer_tree_host_impl.h" | 9 #include "cc/test/fake_layer_tree_host_impl.h" |
| 10 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 scrollbar_controller_->DidScrollUpdate(); | 308 scrollbar_controller_->DidScrollUpdate(); |
| 309 scrollbar_controller_->DidScrollEnd(); | 309 scrollbar_controller_->DidScrollEnd(); |
| 310 | 310 |
| 311 // An fade out animation should have been enqueued. | 311 // An fade out animation should have been enqueued. |
| 312 EXPECT_EQ(kFadeDelay, client_.delay()); | 312 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 313 EXPECT_FALSE(client_.start_fade().is_null()); | 313 EXPECT_FALSE(client_.start_fade().is_null()); |
| 314 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 314 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 315 | 315 |
| 316 // Now move the mouse near the vertical scrollbar track. This should cancel | 316 // Now move the mouse near the vertical scrollbar track. This should cancel |
| 317 // the currently queued fading animation and stay scrollbar thin. | 317 // the currently queued fading animation and stay scrollbar thin. |
| 318 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0)); | 318 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0), false); |
| 319 ExpectScrollbarsOpacity(1); | 319 ExpectScrollbarsOpacity(1); |
| 320 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 320 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 321 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 321 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 322 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 322 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 323 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 323 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 324 EXPECT_TRUE(client_.start_fade().IsCancelled()); | 324 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 325 | 325 |
| 326 scrollbar_controller_->Animate(time); | 326 scrollbar_controller_->Animate(time); |
| 327 time += kThinningDuration; | 327 time += kThinningDuration; |
| 328 scrollbar_controller_->Animate(time); | 328 scrollbar_controller_->Animate(time); |
| 329 | 329 |
| 330 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 330 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 331 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 331 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 332 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 332 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 333 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 333 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 334 | 334 |
| 335 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0)); | 335 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0), false); |
| 336 scrollbar_controller_->Animate(time); | 336 scrollbar_controller_->Animate(time); |
| 337 time += kThinningDuration; | 337 time += kThinningDuration; |
| 338 scrollbar_controller_->Animate(time); | 338 scrollbar_controller_->Animate(time); |
| 339 | 339 |
| 340 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 340 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 341 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 341 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 342 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 342 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 343 | 343 |
| 344 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0)); | 344 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0), false); |
| 345 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 345 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 346 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 346 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 347 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 347 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 348 EXPECT_TRUE(client_.start_fade().IsCancelled()); | 348 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 349 | 349 |
| 350 scrollbar_controller_->Animate(time); | 350 scrollbar_controller_->Animate(time); |
| 351 time += kThinningDuration; | 351 time += kThinningDuration; |
| 352 scrollbar_controller_->Animate(time); | 352 scrollbar_controller_->Animate(time); |
| 353 | 353 |
| 354 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 354 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 368 scrollbar_controller_->DidScrollUpdate(); | 368 scrollbar_controller_->DidScrollUpdate(); |
| 369 scrollbar_controller_->DidScrollEnd(); | 369 scrollbar_controller_->DidScrollEnd(); |
| 370 | 370 |
| 371 // An fade out animation should have been enqueued. | 371 // An fade out animation should have been enqueued. |
| 372 EXPECT_EQ(kFadeDelay, client_.delay()); | 372 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 373 EXPECT_FALSE(client_.start_fade().is_null()); | 373 EXPECT_FALSE(client_.start_fade().is_null()); |
| 374 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 374 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 375 | 375 |
| 376 // Now move the mouse near the vertical scrollbar thumb. This should cancel | 376 // Now move the mouse near the vertical scrollbar thumb. This should cancel |
| 377 // the currently queued fading animation and start animating thickness. | 377 // the currently queued fading animation and start animating thickness. |
| 378 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0)); | 378 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0), false); |
| 379 ExpectScrollbarsOpacity(1); | 379 ExpectScrollbarsOpacity(1); |
| 380 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 380 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 381 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 381 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 382 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 382 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 383 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 383 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 384 EXPECT_TRUE(client_.start_fade().IsCancelled()); | 384 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 385 | 385 |
| 386 // Vertical scrollbar should become thick. | 386 // Vertical scrollbar should become thick. |
| 387 scrollbar_controller_->Animate(time); | 387 scrollbar_controller_->Animate(time); |
| 388 time += kThinningDuration; | 388 time += kThinningDuration; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 409 scrollbar_controller_->DidScrollUpdate(); | 409 scrollbar_controller_->DidScrollUpdate(); |
| 410 scrollbar_controller_->DidScrollEnd(); | 410 scrollbar_controller_->DidScrollEnd(); |
| 411 | 411 |
| 412 // An fade out animation should have been enqueued. | 412 // An fade out animation should have been enqueued. |
| 413 EXPECT_EQ(kFadeDelay, client_.delay()); | 413 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 414 EXPECT_FALSE(client_.start_fade().is_null()); | 414 EXPECT_FALSE(client_.start_fade().is_null()); |
| 415 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 415 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 416 | 416 |
| 417 // Now move the mouse over the vertical scrollbar thumb. This should cancel | 417 // Now move the mouse over the vertical scrollbar thumb. This should cancel |
| 418 // the currently queued fading animation and start animating thickness. | 418 // the currently queued fading animation and start animating thickness. |
| 419 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 419 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 420 ExpectScrollbarsOpacity(1); | 420 ExpectScrollbarsOpacity(1); |
| 421 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 421 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 422 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 422 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 423 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 423 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 424 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 424 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 425 EXPECT_TRUE(client_.start_fade().IsCancelled()); | 425 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 426 | 426 |
| 427 // Vertical scrollbar should become thick. | 427 // Vertical scrollbar should become thick. |
| 428 scrollbar_controller_->Animate(time); | 428 scrollbar_controller_->Animate(time); |
| 429 time += kThinningDuration; | 429 time += kThinningDuration; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 450 scrollbar_controller_->DidScrollBegin(); | 450 scrollbar_controller_->DidScrollBegin(); |
| 451 scrollbar_controller_->DidScrollUpdate(); | 451 scrollbar_controller_->DidScrollUpdate(); |
| 452 scrollbar_controller_->DidScrollEnd(); | 452 scrollbar_controller_->DidScrollEnd(); |
| 453 | 453 |
| 454 // An fade out animation should have been enqueued. | 454 // An fade out animation should have been enqueued. |
| 455 EXPECT_EQ(kFadeDelay, client_.delay()); | 455 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 456 EXPECT_FALSE(client_.start_fade().is_null()); | 456 EXPECT_FALSE(client_.start_fade().is_null()); |
| 457 | 457 |
| 458 // Now move the mouse over the vertical scrollbar thumb and capture it. It | 458 // Now move the mouse over the vertical scrollbar thumb and capture it. It |
| 459 // should become thick without need for an animation. | 459 // should become thick without need for an animation. |
| 460 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 460 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 461 scrollbar_controller_->DidMouseDown(); | 461 scrollbar_controller_->DidMouseDown(); |
| 462 ExpectScrollbarsOpacity(1); | 462 ExpectScrollbarsOpacity(1); |
| 463 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 463 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 464 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 464 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 465 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 465 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 466 | 466 |
| 467 // The fade out animation should have been cleared or cancelled. | 467 // The fade out animation should have been cleared or cancelled. |
| 468 EXPECT_TRUE(client_.start_fade().is_null() || | 468 EXPECT_TRUE(client_.start_fade().is_null() || |
| 469 client_.start_fade().IsCancelled()); | 469 client_.start_fade().IsCancelled()); |
| 470 } | 470 } |
| 471 | 471 |
| 472 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. | 472 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. |
| 473 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 473 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 474 DontFadeWhileCapturedThenAway) { | 474 DontFadeWhileCapturedThenAway) { |
| 475 base::TimeTicks time; | 475 base::TimeTicks time; |
| 476 time += base::TimeDelta::FromSeconds(1); | 476 time += base::TimeDelta::FromSeconds(1); |
| 477 | 477 |
| 478 scrollbar_controller_->DidScrollBegin(); | 478 scrollbar_controller_->DidScrollBegin(); |
| 479 scrollbar_controller_->DidScrollUpdate(); | 479 scrollbar_controller_->DidScrollUpdate(); |
| 480 scrollbar_controller_->DidScrollEnd(); | 480 scrollbar_controller_->DidScrollEnd(); |
| 481 | 481 |
| 482 // An fade out animation should have been enqueued. | 482 // An fade out animation should have been enqueued. |
| 483 EXPECT_EQ(kFadeDelay, client_.delay()); | 483 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 484 EXPECT_FALSE(client_.start_fade().is_null()); | 484 EXPECT_FALSE(client_.start_fade().is_null()); |
| 485 | 485 |
| 486 // Now move the mouse over the vertical scrollbar and capture it. It should | 486 // Now move the mouse over the vertical scrollbar and capture it. It should |
| 487 // become thick without need for an animation. | 487 // become thick without need for an animation. |
| 488 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 488 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 489 scrollbar_controller_->DidMouseDown(); | 489 scrollbar_controller_->DidMouseDown(); |
| 490 ExpectScrollbarsOpacity(1); | 490 ExpectScrollbarsOpacity(1); |
| 491 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 491 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 492 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 492 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 493 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 493 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 494 | 494 |
| 495 // The fade out animation should have been cleared or cancelled. | 495 // The fade out animation should have been cleared or cancelled. |
| 496 EXPECT_TRUE(client_.start_fade().is_null() || | 496 EXPECT_TRUE(client_.start_fade().is_null() || |
| 497 client_.start_fade().IsCancelled()); | 497 client_.start_fade().IsCancelled()); |
| 498 | 498 |
| 499 // Then move mouse away, The fade out animation should have been cleared or | 499 // Then move mouse away, The fade out animation should have been cleared or |
| 500 // cancelled. | 500 // cancelled. |
| 501 scrollbar_controller_->DidMouseMove( | 501 scrollbar_controller_->DidMouseMove( |
| 502 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0)); | 502 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0), false); |
| 503 | 503 |
| 504 EXPECT_TRUE(client_.start_fade().is_null() || | 504 EXPECT_TRUE(client_.start_fade().is_null() || |
| 505 client_.start_fade().IsCancelled()); | 505 client_.start_fade().IsCancelled()); |
| 506 } | 506 } |
| 507 | 507 |
| 508 // Make sure a scrollbar captured after a thickening animation doesn't try to | 508 // Make sure a scrollbar captured after a thickening animation doesn't try to |
| 509 // fade out. | 509 // fade out. |
| 510 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { | 510 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { |
| 511 base::TimeTicks time; | 511 base::TimeTicks time; |
| 512 time += base::TimeDelta::FromSeconds(1); | 512 time += base::TimeDelta::FromSeconds(1); |
| 513 | 513 |
| 514 scrollbar_controller_->DidScrollBegin(); | 514 scrollbar_controller_->DidScrollBegin(); |
| 515 scrollbar_controller_->DidScrollUpdate(); | 515 scrollbar_controller_->DidScrollUpdate(); |
| 516 scrollbar_controller_->DidScrollEnd(); | 516 scrollbar_controller_->DidScrollEnd(); |
| 517 | 517 |
| 518 // An fade out animation should have been enqueued. | 518 // An fade out animation should have been enqueued. |
| 519 EXPECT_EQ(kFadeDelay, client_.delay()); | 519 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 520 EXPECT_FALSE(client_.start_fade().is_null()); | 520 EXPECT_FALSE(client_.start_fade().is_null()); |
| 521 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 521 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 522 | 522 |
| 523 // Now move the mouse over the vertical scrollbar thumb and animate it until | 523 // Now move the mouse over the vertical scrollbar thumb and animate it until |
| 524 // it's thick. | 524 // it's thick. |
| 525 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 525 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 526 scrollbar_controller_->Animate(time); | 526 scrollbar_controller_->Animate(time); |
| 527 time += kThinningDuration; | 527 time += kThinningDuration; |
| 528 scrollbar_controller_->Animate(time); | 528 scrollbar_controller_->Animate(time); |
| 529 ExpectScrollbarsOpacity(1); | 529 ExpectScrollbarsOpacity(1); |
| 530 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 530 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 531 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 531 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 532 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 532 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 533 | 533 |
| 534 // Since the mouse is over the scrollbar, it should either clear or cancel the | 534 // Since the mouse is over the scrollbar, it should either clear or cancel the |
| 535 // queued fade. | 535 // queued fade. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 552 scrollbar_controller_->DidScrollBegin(); | 552 scrollbar_controller_->DidScrollBegin(); |
| 553 scrollbar_controller_->DidScrollUpdate(); | 553 scrollbar_controller_->DidScrollUpdate(); |
| 554 scrollbar_controller_->DidScrollEnd(); | 554 scrollbar_controller_->DidScrollEnd(); |
| 555 | 555 |
| 556 // An fade out animation should have been enqueued. | 556 // An fade out animation should have been enqueued. |
| 557 EXPECT_EQ(kFadeDelay, client_.delay()); | 557 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 558 EXPECT_FALSE(client_.start_fade().is_null()); | 558 EXPECT_FALSE(client_.start_fade().is_null()); |
| 559 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 559 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 560 | 560 |
| 561 // Now move the mouse over the vertical scrollbar thumb and capture it. | 561 // Now move the mouse over the vertical scrollbar thumb and capture it. |
| 562 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 562 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 563 scrollbar_controller_->DidMouseDown(); | 563 scrollbar_controller_->DidMouseDown(); |
| 564 ExpectScrollbarsOpacity(1); | 564 ExpectScrollbarsOpacity(1); |
| 565 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 565 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 566 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 566 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 567 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 567 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 568 | 568 |
| 569 // Since the mouse is still near the scrollbar, the queued fade should be | 569 // Since the mouse is still near the scrollbar, the queued fade should be |
| 570 // either null or cancelled. | 570 // either null or cancelled. |
| 571 EXPECT_TRUE(client_.start_fade().is_null() || | 571 EXPECT_TRUE(client_.start_fade().is_null() || |
| 572 client_.start_fade().IsCancelled()); | 572 client_.start_fade().IsCancelled()); |
| 573 | 573 |
| 574 // Now move the mouse away from the scrollbar and release it. | 574 // Now move the mouse away from the scrollbar and release it. |
| 575 scrollbar_controller_->DidMouseMove( | 575 scrollbar_controller_->DidMouseMove( |
| 576 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0)); | 576 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0), false); |
| 577 scrollbar_controller_->DidMouseUp(); | 577 scrollbar_controller_->DidMouseUp(); |
| 578 | 578 |
| 579 scrollbar_controller_->Animate(time); | 579 scrollbar_controller_->Animate(time); |
| 580 ExpectScrollbarsOpacity(1); | 580 ExpectScrollbarsOpacity(1); |
| 581 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 581 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 582 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 582 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 583 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 583 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 584 time += kThinningDuration; | 584 time += kThinningDuration; |
| 585 scrollbar_controller_->Animate(time); | 585 scrollbar_controller_->Animate(time); |
| 586 ExpectScrollbarsOpacity(1); | 586 ExpectScrollbarsOpacity(1); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 603 scrollbar_controller_->DidScrollBegin(); | 603 scrollbar_controller_->DidScrollBegin(); |
| 604 scrollbar_controller_->DidScrollUpdate(); | 604 scrollbar_controller_->DidScrollUpdate(); |
| 605 scrollbar_controller_->DidScrollEnd(); | 605 scrollbar_controller_->DidScrollEnd(); |
| 606 | 606 |
| 607 // An fade out animation should have been enqueued. | 607 // An fade out animation should have been enqueued. |
| 608 EXPECT_EQ(kFadeDelay, client_.delay()); | 608 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 609 EXPECT_FALSE(client_.start_fade().is_null()); | 609 EXPECT_FALSE(client_.start_fade().is_null()); |
| 610 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 610 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 611 | 611 |
| 612 // Now move the mouse over the vertical scrollbar thumb and capture it. | 612 // Now move the mouse over the vertical scrollbar thumb and capture it. |
| 613 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 613 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 614 scrollbar_controller_->DidMouseDown(); | 614 scrollbar_controller_->DidMouseDown(); |
| 615 ExpectScrollbarsOpacity(1); | 615 ExpectScrollbarsOpacity(1); |
| 616 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 616 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 617 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 617 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 618 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 618 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 619 | 619 |
| 620 // Since the mouse is over the scrollbar, the queued fade must be either | 620 // Since the mouse is over the scrollbar, the queued fade must be either |
| 621 // null or cancelled. | 621 // null or cancelled. |
| 622 EXPECT_TRUE(client_.start_fade().is_null() || | 622 EXPECT_TRUE(client_.start_fade().is_null() || |
| 623 client_.start_fade().IsCancelled()); | 623 client_.start_fade().IsCancelled()); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 651 scrollbar_controller_->Animate(time); | 651 scrollbar_controller_->Animate(time); |
| 652 ExpectScrollbarsOpacity(1); | 652 ExpectScrollbarsOpacity(1); |
| 653 | 653 |
| 654 // Proceed half way through the fade out animation. | 654 // Proceed half way through the fade out animation. |
| 655 time += kFadeDuration / 2; | 655 time += kFadeDuration / 2; |
| 656 scrollbar_controller_->Animate(time); | 656 scrollbar_controller_->Animate(time); |
| 657 ExpectScrollbarsOpacity(.5f); | 657 ExpectScrollbarsOpacity(.5f); |
| 658 | 658 |
| 659 // Now move the mouse near the vertical scrollbar thumb. It should reset | 659 // Now move the mouse near the vertical scrollbar thumb. It should reset |
| 660 // opacity to 1 instantly and start animating to thick. | 660 // opacity to 1 instantly and start animating to thick. |
| 661 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 661 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 662 ExpectScrollbarsOpacity(1); | 662 ExpectScrollbarsOpacity(1); |
| 663 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 663 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 664 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 664 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 665 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 665 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 666 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 666 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 667 | 667 |
| 668 scrollbar_controller_->Animate(time); | 668 scrollbar_controller_->Animate(time); |
| 669 time += kThinningDuration; | 669 time += kThinningDuration; |
| 670 scrollbar_controller_->Animate(time); | 670 scrollbar_controller_->Animate(time); |
| 671 ExpectScrollbarsOpacity(1); | 671 ExpectScrollbarsOpacity(1); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 690 scrollbar_controller_->Animate(time); | 690 scrollbar_controller_->Animate(time); |
| 691 ExpectScrollbarsOpacity(1); | 691 ExpectScrollbarsOpacity(1); |
| 692 | 692 |
| 693 // Fade the scrollbar out completely. | 693 // Fade the scrollbar out completely. |
| 694 time += kFadeDuration; | 694 time += kFadeDuration; |
| 695 scrollbar_controller_->Animate(time); | 695 scrollbar_controller_->Animate(time); |
| 696 ExpectScrollbarsOpacity(0); | 696 ExpectScrollbarsOpacity(0); |
| 697 | 697 |
| 698 // Move mouse over the vertical scrollbar thumb. It shouldn't thicken the | 698 // Move mouse over the vertical scrollbar thumb. It shouldn't thicken the |
| 699 // scrollbar since it's completely faded out. | 699 // scrollbar since it's completely faded out. |
| 700 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0)); | 700 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0), false); |
| 701 scrollbar_controller_->Animate(time); | 701 scrollbar_controller_->Animate(time); |
| 702 time += kThinningDuration; | 702 time += kThinningDuration; |
| 703 scrollbar_controller_->Animate(time); | 703 scrollbar_controller_->Animate(time); |
| 704 ExpectScrollbarsOpacity(0); | 704 ExpectScrollbarsOpacity(0); |
| 705 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 705 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 706 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 706 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 707 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 707 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 708 | 708 |
| 709 client_.start_fade().Reset(); | 709 client_.start_fade().Reset(); |
| 710 | 710 |
| 711 // Now try to capture the scrollbar. It shouldn't do anything since it's | 711 // Now try to capture the scrollbar. It shouldn't do anything since it's |
| 712 // completely faded out. | 712 // completely faded out. |
| 713 scrollbar_controller_->DidMouseDown(); | 713 scrollbar_controller_->DidMouseDown(); |
| 714 ExpectScrollbarsOpacity(0); | 714 ExpectScrollbarsOpacity(0); |
| 715 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 715 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 716 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 716 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 717 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 717 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 718 EXPECT_TRUE(client_.start_fade().is_null()); | 718 EXPECT_TRUE(client_.start_fade().is_null()); |
| 719 | 719 |
| 720 // Similarly, releasing the scrollbar should have no effect. | 720 // Similarly, releasing the scrollbar should have no effect but trigger a fade |
| 721 // in. | |
| 721 scrollbar_controller_->DidMouseUp(); | 722 scrollbar_controller_->DidMouseUp(); |
| 722 ExpectScrollbarsOpacity(0); | 723 ExpectScrollbarsOpacity(0); |
| 723 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 724 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 724 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 725 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 725 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 726 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 726 EXPECT_TRUE(client_.start_fade().is_null()); | 727 |
| 728 // An fade in animation should have been enqueued. | |
| 729 EXPECT_FALSE(client_.start_fade().is_null()); | |
| 730 EXPECT_FALSE(client_.start_fade().IsCancelled()); | |
| 731 EXPECT_EQ(kFadeDelay, client_.delay()); | |
| 732 | |
| 733 // Play the delay animation. | |
| 734 client_.start_fade().Run(); | |
| 735 EXPECT_TRUE(client_.start_fade().IsCancelled()); | |
| 736 | |
| 737 scrollbar_controller_->Animate(time); | |
| 738 time += kFadeDuration; | |
| 739 scrollbar_controller_->Animate(time); | |
| 740 | |
| 741 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | |
| 727 } | 742 } |
| 728 | 743 |
| 729 // Initiate a scroll when the pointer is already near the scrollbar. It should | 744 // Initiate a scroll when the pointer is already near the scrollbar. It should |
| 730 // appear thick and remain thick. | 745 // appear thick and remain thick. |
| 731 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) { | 746 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) { |
| 732 base::TimeTicks time; | 747 base::TimeTicks time; |
| 733 time += base::TimeDelta::FromSeconds(1); | 748 time += base::TimeDelta::FromSeconds(1); |
| 734 | 749 |
| 735 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0)); | 750 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0), false); |
| 736 scrollbar_controller_->Animate(time); | 751 scrollbar_controller_->Animate(time); |
| 737 time += kThinningDuration; | 752 time += kThinningDuration; |
| 738 | 753 |
| 739 // Since the scrollbar isn't visible yet (because we haven't scrolled), we | 754 // Since the scrollbar isn't visible yet (because we haven't scrolled), we |
| 740 // shouldn't have applied the thickening. | 755 // shouldn't have applied the thickening. |
| 741 scrollbar_controller_->Animate(time); | 756 scrollbar_controller_->Animate(time); |
| 742 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 757 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 743 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 758 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 744 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 759 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 745 | 760 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { | 894 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { |
| 880 base::TimeTicks time; | 895 base::TimeTicks time; |
| 881 time += base::TimeDelta::FromSeconds(1); | 896 time += base::TimeDelta::FromSeconds(1); |
| 882 | 897 |
| 883 // Scroll to make the scrollbars visible. | 898 // Scroll to make the scrollbars visible. |
| 884 scrollbar_controller_->DidScrollBegin(); | 899 scrollbar_controller_->DidScrollBegin(); |
| 885 scrollbar_controller_->DidScrollUpdate(); | 900 scrollbar_controller_->DidScrollUpdate(); |
| 886 scrollbar_controller_->DidScrollEnd(); | 901 scrollbar_controller_->DidScrollEnd(); |
| 887 | 902 |
| 888 // Near vertical scrollbar. | 903 // Near vertical scrollbar. |
| 889 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0)); | 904 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0), false); |
| 890 scrollbar_controller_->Animate(time); | 905 scrollbar_controller_->Animate(time); |
| 891 ExpectScrollbarsOpacity(1); | 906 ExpectScrollbarsOpacity(1); |
| 892 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 907 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 893 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 908 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 894 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 909 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 895 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 910 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 896 | 911 |
| 897 // Should animate to thickened. | 912 // Should animate to thickened. |
| 898 time += kThinningDuration; | 913 time += kThinningDuration; |
| 899 scrollbar_controller_->Animate(time); | 914 scrollbar_controller_->Animate(time); |
| 900 ExpectScrollbarsOpacity(1); | 915 ExpectScrollbarsOpacity(1); |
| 901 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 916 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 902 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 917 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 903 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 918 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 904 | 919 |
| 905 // Subsequent moves within the nearness threshold should not change anything. | 920 // Subsequent moves within the nearness threshold should not change anything. |
| 906 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-2, 0)); | 921 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-2, 0), false); |
| 907 scrollbar_controller_->Animate(time); | 922 scrollbar_controller_->Animate(time); |
| 908 time += base::TimeDelta::FromSeconds(10); | 923 time += base::TimeDelta::FromSeconds(10); |
| 909 scrollbar_controller_->Animate(time); | 924 scrollbar_controller_->Animate(time); |
| 910 ExpectScrollbarsOpacity(1); | 925 ExpectScrollbarsOpacity(1); |
| 911 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 926 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 912 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 927 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 913 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 928 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 914 | 929 |
| 915 // Now move away from bar. | 930 // Now move away from bar. |
| 916 scrollbar_controller_->DidMouseMove( | 931 scrollbar_controller_->DidMouseMove( |
| 917 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0)); | 932 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0), false); |
| 918 scrollbar_controller_->Animate(time); | 933 scrollbar_controller_->Animate(time); |
| 919 time += kThinningDuration; | 934 time += kThinningDuration; |
| 920 scrollbar_controller_->Animate(time); | 935 scrollbar_controller_->Animate(time); |
| 921 ExpectScrollbarsOpacity(1); | 936 ExpectScrollbarsOpacity(1); |
| 922 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 937 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 923 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 938 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 924 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 939 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 925 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 940 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 926 | 941 |
| 927 // Near horizontal scrollbar | 942 // Near horizontal scrollbar |
| 928 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -1)); | 943 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -1), |
| 944 false); | |
| 929 scrollbar_controller_->Animate(time); | 945 scrollbar_controller_->Animate(time); |
| 930 ExpectScrollbarsOpacity(1); | 946 ExpectScrollbarsOpacity(1); |
| 931 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 947 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 932 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 948 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 933 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 949 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 934 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 950 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 935 | 951 |
| 936 // Should animate to thickened. | 952 // Should animate to thickened. |
| 937 time += kThinningDuration; | 953 time += kThinningDuration; |
| 938 scrollbar_controller_->Animate(time); | 954 scrollbar_controller_->Animate(time); |
| 939 ExpectScrollbarsOpacity(1); | 955 ExpectScrollbarsOpacity(1); |
| 940 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 956 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 941 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 957 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 942 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); | 958 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 943 | 959 |
| 944 // Subsequent moves within the nearness threshold should not change anything. | 960 // Subsequent moves within the nearness threshold should not change anything. |
| 945 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -2)); | 961 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -2), |
| 962 false); | |
| 946 scrollbar_controller_->Animate(time); | 963 scrollbar_controller_->Animate(time); |
| 947 time += base::TimeDelta::FromSeconds(10); | 964 time += base::TimeDelta::FromSeconds(10); |
| 948 scrollbar_controller_->Animate(time); | 965 scrollbar_controller_->Animate(time); |
| 949 ExpectScrollbarsOpacity(1); | 966 ExpectScrollbarsOpacity(1); |
| 950 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 967 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 951 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 968 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 952 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); | 969 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 953 | 970 |
| 954 // Now move away from bar. | 971 // Now move away from bar. |
| 955 scrollbar_controller_->DidMouseMove( | 972 scrollbar_controller_->DidMouseMove( |
| 956 NearHorizontalScrollbarBegin(0, -kMouseMoveDistanceToTriggerExpand)); | 973 NearHorizontalScrollbarBegin(0, -kMouseMoveDistanceToTriggerExpand), |
| 974 false); | |
| 957 scrollbar_controller_->Animate(time); | 975 scrollbar_controller_->Animate(time); |
| 958 time += kThinningDuration; | 976 time += kThinningDuration; |
| 959 scrollbar_controller_->Animate(time); | 977 scrollbar_controller_->Animate(time); |
| 960 ExpectScrollbarsOpacity(1); | 978 ExpectScrollbarsOpacity(1); |
| 961 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 979 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 962 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 980 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 963 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 981 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 964 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 982 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 965 | 983 |
| 966 // An fade out animation should have been enqueued. | 984 // An fade out animation should have been enqueued. |
| 967 EXPECT_FALSE(client_.start_fade().is_null()); | 985 EXPECT_FALSE(client_.start_fade().is_null()); |
| 968 EXPECT_EQ(kFadeDelay, client_.delay()); | 986 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 969 } | 987 } |
| 970 | 988 |
| 971 // Move mouse near both scrollbars at the same time. | 989 // Move mouse near both scrollbars at the same time. |
| 972 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { | 990 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { |
| 973 base::TimeTicks time; | 991 base::TimeTicks time; |
| 974 time += base::TimeDelta::FromSeconds(1); | 992 time += base::TimeDelta::FromSeconds(1); |
| 975 | 993 |
| 976 // Scroll to make the scrollbars visible. | 994 // Scroll to make the scrollbars visible. |
| 977 scrollbar_controller_->DidScrollBegin(); | 995 scrollbar_controller_->DidScrollBegin(); |
| 978 scrollbar_controller_->DidScrollUpdate(); | 996 scrollbar_controller_->DidScrollUpdate(); |
| 979 scrollbar_controller_->DidScrollEnd(); | 997 scrollbar_controller_->DidScrollEnd(); |
| 980 | 998 |
| 981 // Move scrollbar thumb to the end of track. | 999 // Move scrollbar thumb to the end of track. |
| 982 v_scrollbar_layer_->SetCurrentPos(100); | 1000 v_scrollbar_layer_->SetCurrentPos(100); |
| 983 h_scrollbar_layer_->SetCurrentPos(100); | 1001 h_scrollbar_layer_->SetCurrentPos(100); |
| 984 | 1002 |
| 985 // Near both Scrollbar | 1003 // Near both Scrollbar |
| 986 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, -1)); | 1004 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, -1), false); |
| 987 scrollbar_controller_->Animate(time); | 1005 scrollbar_controller_->Animate(time); |
| 988 ExpectScrollbarsOpacity(1); | 1006 ExpectScrollbarsOpacity(1); |
| 989 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1007 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 990 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 1008 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 991 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1009 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 992 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 1010 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 993 | 1011 |
| 994 // Should animate to thickened. | 1012 // Should animate to thickened. |
| 995 time += kThinningDuration; | 1013 time += kThinningDuration; |
| 996 scrollbar_controller_->Animate(time); | 1014 scrollbar_controller_->Animate(time); |
| 997 ExpectScrollbarsOpacity(1); | 1015 ExpectScrollbarsOpacity(1); |
| 998 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 1016 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 999 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); | 1017 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1000 } | 1018 } |
| 1001 | 1019 |
| 1002 // Move mouse from one to the other scrollbar before animation is finished, then | 1020 // Move mouse from one to the other scrollbar before animation is finished, then |
| 1003 // away before animation finished. | 1021 // away before animation finished. |
| 1004 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1022 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1005 MouseNearOtherBeforeAnimationFinished) { | 1023 MouseNearOtherBeforeAnimationFinished) { |
| 1006 base::TimeTicks time; | 1024 base::TimeTicks time; |
| 1007 time += base::TimeDelta::FromSeconds(1); | 1025 time += base::TimeDelta::FromSeconds(1); |
| 1008 | 1026 |
| 1009 // Scroll to make the scrollbars visible. | 1027 // Scroll to make the scrollbars visible. |
| 1010 scrollbar_controller_->DidScrollBegin(); | 1028 scrollbar_controller_->DidScrollBegin(); |
| 1011 scrollbar_controller_->DidScrollUpdate(); | 1029 scrollbar_controller_->DidScrollUpdate(); |
| 1012 scrollbar_controller_->DidScrollEnd(); | 1030 scrollbar_controller_->DidScrollEnd(); |
| 1013 | 1031 |
| 1014 // Near vertical scrollbar. | 1032 // Near vertical scrollbar. |
| 1015 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0)); | 1033 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0), false); |
| 1016 scrollbar_controller_->Animate(time); | 1034 scrollbar_controller_->Animate(time); |
| 1017 ExpectScrollbarsOpacity(1); | 1035 ExpectScrollbarsOpacity(1); |
| 1018 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1036 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 1019 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 1037 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1020 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1038 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 1021 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 1039 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1022 | 1040 |
| 1023 // Vertical scrollbar animate to half thickened. | 1041 // Vertical scrollbar animate to half thickened. |
| 1024 time += kThinningDuration / 2; | 1042 time += kThinningDuration / 2; |
| 1025 scrollbar_controller_->Animate(time); | 1043 scrollbar_controller_->Animate(time); |
| 1026 ExpectScrollbarsOpacity(1); | 1044 ExpectScrollbarsOpacity(1); |
| 1027 EXPECT_FLOAT_EQ(kIdleThicknessScale + (1.0f - kIdleThicknessScale) / 2, | 1045 EXPECT_FLOAT_EQ(kIdleThicknessScale + (1.0f - kIdleThicknessScale) / 2, |
| 1028 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 1046 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1029 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1047 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 1030 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 1048 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1031 | 1049 |
| 1032 // Away vertical scrollbar and near horizontal scrollbar. | 1050 // Away vertical scrollbar and near horizontal scrollbar. |
| 1033 scrollbar_controller_->DidMouseMove(gfx::PointF(0, 0)); | 1051 scrollbar_controller_->DidMouseMove(gfx::PointF(0, 0), false); |
| 1034 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -1)); | 1052 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -1), |
| 1053 false); | |
| 1035 scrollbar_controller_->Animate(time); | 1054 scrollbar_controller_->Animate(time); |
| 1036 | 1055 |
| 1037 // Vertical scrollbar animate to thin. horizontal scrollbar animate to | 1056 // Vertical scrollbar animate to thin. horizontal scrollbar animate to |
| 1038 // thickened. | 1057 // thickened. |
| 1039 time += kThinningDuration; | 1058 time += kThinningDuration; |
| 1040 scrollbar_controller_->Animate(time); | 1059 scrollbar_controller_->Animate(time); |
| 1041 ExpectScrollbarsOpacity(1); | 1060 ExpectScrollbarsOpacity(1); |
| 1042 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1061 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 1043 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 1062 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1044 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); | 1063 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1045 | 1064 |
| 1046 // Away horizontal scrollbar. | 1065 // Away horizontal scrollbar. |
| 1047 scrollbar_controller_->DidMouseMove(gfx::PointF(0, 0)); | 1066 scrollbar_controller_->DidMouseMove(gfx::PointF(0, 0), false); |
| 1048 scrollbar_controller_->Animate(time); | 1067 scrollbar_controller_->Animate(time); |
| 1049 | 1068 |
| 1050 // Horizontal scrollbar animate to thin. | 1069 // Horizontal scrollbar animate to thin. |
| 1051 time += kThinningDuration; | 1070 time += kThinningDuration; |
| 1052 scrollbar_controller_->Animate(time); | 1071 scrollbar_controller_->Animate(time); |
| 1053 ExpectScrollbarsOpacity(1); | 1072 ExpectScrollbarsOpacity(1); |
| 1054 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1073 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 1055 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 1074 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1056 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 1075 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
| 1057 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 1076 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
| 1058 | 1077 |
| 1059 // An fade out animation should have been enqueued. | 1078 // An fade out animation should have been enqueued. |
| 1060 EXPECT_FALSE(client_.start_fade().is_null()); | 1079 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1061 EXPECT_EQ(kFadeDelay, client_.delay()); | 1080 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 1062 } | 1081 } |
| 1063 | 1082 |
| 1064 // Ensure we have a delay fadeout animation after mouse leave without a mouse | 1083 // Ensure we have a delay fadeout animation after mouse leave without a mouse |
| 1065 // move. | 1084 // move. |
| 1066 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { | 1085 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { |
| 1067 base::TimeTicks time; | 1086 base::TimeTicks time; |
| 1068 time += base::TimeDelta::FromSeconds(1); | 1087 time += base::TimeDelta::FromSeconds(1); |
| 1069 | 1088 |
| 1070 // Move mouse near scrollbar. | 1089 // Move mouse near scrollbar. |
| 1071 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0)); | 1090 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0), false); |
| 1072 | 1091 |
| 1073 // Scroll to make the scrollbars visible. | 1092 // Scroll to make the scrollbars visible. |
| 1074 scrollbar_controller_->DidScrollBegin(); | 1093 scrollbar_controller_->DidScrollBegin(); |
| 1075 scrollbar_controller_->DidScrollUpdate(); | 1094 scrollbar_controller_->DidScrollUpdate(); |
| 1076 scrollbar_controller_->DidScrollEnd(); | 1095 scrollbar_controller_->DidScrollEnd(); |
| 1077 | 1096 |
| 1078 // Should not have delay fadeout animation. | 1097 // Should not have delay fadeout animation. |
| 1079 EXPECT_TRUE(client_.start_fade().is_null() || | 1098 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1080 client_.start_fade().IsCancelled()); | 1099 client_.start_fade().IsCancelled()); |
| 1081 | 1100 |
| 1082 // Mouse leave. | 1101 // Mouse leave. |
| 1083 scrollbar_controller_->DidMouseLeave(); | 1102 scrollbar_controller_->DidMouseLeave(); |
| 1084 | 1103 |
| 1085 // An fade out animation should have been enqueued. | 1104 // An fade out animation should have been enqueued. |
| 1086 EXPECT_FALSE(client_.start_fade().is_null()); | 1105 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1087 EXPECT_EQ(kFadeDelay, client_.delay()); | 1106 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 1088 } | 1107 } |
| 1089 | 1108 |
| 1090 // Scrollbars should schedule a delay fade in when mouse hover the show | 1109 // Scrollbars should schedule a delay fade in when mouse hover the show |
| 1091 // scrollbar region of a hidden scrollbar. | 1110 // scrollbar region of a hidden scrollbar. |
| 1092 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) { | 1111 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) { |
| 1093 base::TimeTicks time; | 1112 base::TimeTicks time; |
| 1094 time += base::TimeDelta::FromSeconds(1); | 1113 time += base::TimeDelta::FromSeconds(1); |
| 1095 | 1114 |
| 1096 // Move mouse hover the fade in scrollbar region of scrollbar. | 1115 // Move mouse hover the fade in scrollbar region of scrollbar. |
| 1097 scrollbar_controller_->DidMouseMove( | 1116 scrollbar_controller_->DidMouseMove( |
| 1098 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0)); | 1117 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), |
| 1118 false); | |
| 1099 | 1119 |
| 1100 // An fade in animation should have been enqueued. | 1120 // An fade in animation should have been enqueued. |
| 1101 EXPECT_FALSE(client_.start_fade().is_null()); | 1121 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1102 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1122 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1103 EXPECT_EQ(kFadeDelay, client_.delay()); | 1123 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 1104 | 1124 |
| 1105 // Play the delay animation. | 1125 // Play the delay animation. |
| 1106 client_.start_fade().Run(); | 1126 client_.start_fade().Run(); |
| 1107 EXPECT_TRUE(client_.start_fade().IsCancelled()); | 1127 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 1108 | 1128 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1122 | 1142 |
| 1123 // Scrollbars should not schedule a new delay fade in when the mouse hovers | 1143 // Scrollbars should not schedule a new delay fade in when the mouse hovers |
| 1124 // inside a scrollbar already scheduled a delay fade in. | 1144 // inside a scrollbar already scheduled a delay fade in. |
| 1125 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1145 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1126 MouseHoverScrollbarAndMoveInside) { | 1146 MouseHoverScrollbarAndMoveInside) { |
| 1127 base::TimeTicks time; | 1147 base::TimeTicks time; |
| 1128 time += base::TimeDelta::FromSeconds(1); | 1148 time += base::TimeDelta::FromSeconds(1); |
| 1129 | 1149 |
| 1130 // Move mouse hover the fade in scrollbar region of scrollbar. | 1150 // Move mouse hover the fade in scrollbar region of scrollbar. |
| 1131 scrollbar_controller_->DidMouseMove( | 1151 scrollbar_controller_->DidMouseMove( |
| 1132 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0)); | 1152 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), |
| 1153 false); | |
| 1133 | 1154 |
| 1134 // An fade in animation should have been enqueued. | 1155 // An fade in animation should have been enqueued. |
| 1135 EXPECT_FALSE(client_.start_fade().is_null()); | 1156 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1136 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1157 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1137 EXPECT_EQ(kFadeDelay, client_.delay()); | 1158 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 1138 | 1159 |
| 1139 base::Closure& fade = client_.start_fade(); | 1160 base::Closure& fade = client_.start_fade(); |
| 1140 // Move mouse still hover the fade in scrollbar region of scrollbar should not | 1161 // Move mouse still hover the fade in scrollbar region of scrollbar should not |
| 1141 // post a new fade in. | 1162 // post a new fade in. |
| 1142 scrollbar_controller_->DidMouseMove( | 1163 scrollbar_controller_->DidMouseMove( |
| 1143 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 2, 0)); | 1164 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 2, 0), |
| 1165 false); | |
| 1144 | 1166 |
| 1145 EXPECT_TRUE(fade.Equals(client_.start_fade())); | 1167 EXPECT_TRUE(fade.Equals(client_.start_fade())); |
| 1146 } | 1168 } |
| 1147 | 1169 |
| 1148 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then | 1170 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then |
| 1149 // move far away. | 1171 // move far away. |
| 1150 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1172 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1151 MouseHoverThenOutShouldCancelFadeIn) { | 1173 MouseHoverThenOutShouldCancelFadeIn) { |
| 1152 base::TimeTicks time; | 1174 base::TimeTicks time; |
| 1153 time += base::TimeDelta::FromSeconds(1); | 1175 time += base::TimeDelta::FromSeconds(1); |
| 1154 | 1176 |
| 1155 // Move mouse hover the fade in scrollbar region of scrollbar. | 1177 // Move mouse hover the fade in scrollbar region of scrollbar. |
| 1156 scrollbar_controller_->DidMouseMove( | 1178 scrollbar_controller_->DidMouseMove( |
| 1157 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0)); | 1179 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), |
| 1180 false); | |
| 1158 | 1181 |
| 1159 // An fade in animation should have been enqueued. | 1182 // An fade in animation should have been enqueued. |
| 1160 EXPECT_FALSE(client_.start_fade().is_null()); | 1183 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1161 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1184 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1162 EXPECT_EQ(kFadeDelay, client_.delay()); | 1185 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 1163 | 1186 |
| 1164 // Move mouse far away,delay fade in should be canceled. | 1187 // Move mouse far away,delay fade in should be canceled. |
| 1165 scrollbar_controller_->DidMouseMove( | 1188 scrollbar_controller_->DidMouseMove( |
| 1166 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0)); | 1189 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0), false); |
| 1167 | 1190 |
| 1168 EXPECT_TRUE(client_.start_fade().is_null() || | 1191 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1169 client_.start_fade().IsCancelled()); | 1192 client_.start_fade().IsCancelled()); |
| 1170 } | 1193 } |
| 1171 | 1194 |
| 1172 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then | 1195 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then |
| 1173 // move out of window. | 1196 // move out of window. |
| 1174 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1197 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1175 MouseHoverThenLeaveShouldCancelShowThenEnterShouldFadeIn) { | 1198 MouseHoverThenLeaveShouldCancelShowThenEnterShouldFadeIn) { |
| 1176 base::TimeTicks time; | 1199 base::TimeTicks time; |
| 1177 time += base::TimeDelta::FromSeconds(1); | 1200 time += base::TimeDelta::FromSeconds(1); |
| 1178 | 1201 |
| 1179 // Move mouse hover the fade in scrollbar region of scrollbar. | 1202 // Move mouse hover the fade in scrollbar region of scrollbar. |
| 1180 scrollbar_controller_->DidMouseMove( | 1203 scrollbar_controller_->DidMouseMove( |
| 1181 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0)); | 1204 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), |
| 1205 false); | |
| 1182 | 1206 |
| 1183 // An fade in animation should have been enqueued. | 1207 // An fade in animation should have been enqueued. |
| 1184 EXPECT_FALSE(client_.start_fade().is_null()); | 1208 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1185 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1209 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1186 EXPECT_EQ(kFadeDelay, client_.delay()); | 1210 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 1187 | 1211 |
| 1188 // Move mouse out of window,delay fade in should be canceled. | 1212 // Move mouse out of window,delay fade in should be canceled. |
| 1189 scrollbar_controller_->DidMouseLeave(); | 1213 scrollbar_controller_->DidMouseLeave(); |
| 1190 EXPECT_TRUE(client_.start_fade().is_null() || | 1214 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1191 client_.start_fade().IsCancelled()); | 1215 client_.start_fade().IsCancelled()); |
| 1192 | 1216 |
| 1193 // Move mouse hover the fade in scrollbar region of scrollbar. | 1217 // Move mouse hover the fade in scrollbar region of scrollbar. |
| 1194 scrollbar_controller_->DidMouseMove( | 1218 scrollbar_controller_->DidMouseMove( |
| 1195 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0)); | 1219 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), |
| 1220 false); | |
| 1196 | 1221 |
| 1197 // An fade in animation should have been enqueued. | 1222 // An fade in animation should have been enqueued. |
| 1198 EXPECT_FALSE(client_.start_fade().is_null()); | 1223 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1224 EXPECT_FALSE(client_.start_fade().IsCancelled()); | |
| 1225 EXPECT_EQ(kFadeDelay, client_.delay()); | |
| 1226 | |
| 1227 // Play the delay animation. | |
| 1228 client_.start_fade().Run(); | |
| 1229 EXPECT_TRUE(client_.start_fade().IsCancelled()); | |
| 1230 | |
| 1231 scrollbar_controller_->Animate(time); | |
| 1232 time += kFadeDuration; | |
| 1233 scrollbar_controller_->Animate(time); | |
| 1234 | |
| 1235 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | |
| 1236 } | |
| 1237 | |
| 1238 // Make sure mouse down will cancel hover fade in timer, then mouse move with | |
| 1239 // press will not trigger hover fade in, mouse release near will trigger new | |
| 1240 // hover fade in. | |
| 1241 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | |
| 1242 MouseHoverThenMouseDownShouldCancelFadeInThenReleaseNearShouldFadeIn) { | |
| 1243 base::TimeTicks time; | |
| 1244 time += base::TimeDelta::FromSeconds(1); | |
| 1245 | |
| 1246 // Move mouse hover the fade in scrollbar region of scrollbar. | |
| 1247 scrollbar_controller_->DidMouseMove( | |
| 1248 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), | |
| 1249 false); | |
| 1250 | |
| 1251 // An fade in animation should have been enqueued. | |
| 1252 EXPECT_FALSE(client_.start_fade().is_null()); | |
| 1253 EXPECT_FALSE(client_.start_fade().IsCancelled()); | |
| 1254 EXPECT_EQ(kFadeDelay, client_.delay()); | |
| 1255 | |
| 1256 // Mouse down,delay fade in should be canceled. | |
| 1257 scrollbar_controller_->DidMouseDown(); | |
| 1258 EXPECT_TRUE(client_.start_fade().is_null() || | |
| 1259 client_.start_fade().IsCancelled()); | |
| 1260 | |
| 1261 // Move mouse hover the fade in scrollbar region of scrollbar with press. | |
| 1262 scrollbar_controller_->DidMouseMove( | |
| 1263 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), | |
| 1264 true); | |
| 1265 | |
| 1266 // Should not have delay fade animation. | |
| 1267 EXPECT_TRUE(client_.start_fade().is_null() || | |
| 1268 client_.start_fade().IsCancelled()); | |
| 1269 | |
| 1270 // Mouse up. | |
| 1271 scrollbar_controller_->DidMouseUp(); | |
| 1272 | |
| 1273 // An fade in animation should have been enqueued. | |
| 1274 EXPECT_FALSE(client_.start_fade().is_null()); | |
| 1199 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1275 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1200 EXPECT_EQ(kFadeDelay, client_.delay()); | 1276 EXPECT_EQ(kFadeDelay, client_.delay()); |
| 1201 | 1277 |
| 1202 // Play the delay animation. | 1278 // Play the delay animation. |
| 1203 client_.start_fade().Run(); | 1279 client_.start_fade().Run(); |
| 1204 EXPECT_TRUE(client_.start_fade().IsCancelled()); | 1280 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 1205 | 1281 |
| 1206 scrollbar_controller_->Animate(time); | 1282 scrollbar_controller_->Animate(time); |
| 1207 time += kFadeDuration; | 1283 time += kFadeDuration; |
| 1208 scrollbar_controller_->Animate(time); | 1284 scrollbar_controller_->Animate(time); |
| 1209 | 1285 |
| 1210 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 1286 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
| 1211 } | 1287 } |
| 1212 | 1288 |
| 1289 // Make sure mouse down will cancel hover fade in timer, then mouse move with | |
| 1290 // press will not trigger hover fade in, mouse release far will no trigger new | |
|
bokan
2017/06/08 14:02:38
nit: no -> not
| |
| 1291 // hover fade in. | |
| 1292 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | |
| 1293 MouseReleaseFarShouldNotFadeIn) { | |
| 1294 base::TimeTicks time; | |
| 1295 time += base::TimeDelta::FromSeconds(1); | |
| 1296 | |
| 1297 // Move mouse hover the fade in scrollbar region of scrollbar. | |
|
bokan
2017/06/08 14:02:38
nit: "Move mouse hover the fade in scrollbar" -> "
| |
| 1298 scrollbar_controller_->DidMouseMove( | |
| 1299 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0), | |
| 1300 false); | |
| 1301 | |
| 1302 // An fade in animation should have been enqueued. | |
| 1303 EXPECT_FALSE(client_.start_fade().is_null()); | |
| 1304 EXPECT_FALSE(client_.start_fade().IsCancelled()); | |
| 1305 EXPECT_EQ(kFadeDelay, client_.delay()); | |
| 1306 | |
| 1307 // Mouse down,delay fade in should be canceled. | |
| 1308 scrollbar_controller_->DidMouseDown(); | |
| 1309 EXPECT_TRUE(client_.start_fade().is_null() || | |
| 1310 client_.start_fade().IsCancelled()); | |
| 1311 | |
| 1312 // Move mouse far from hover the fade in scrollbar region of scrollbar with | |
|
bokan
2017/06/08 14:02:38
nit: ditto here and elsewhere
| |
| 1313 // press. | |
| 1314 scrollbar_controller_->DidMouseMove( | |
| 1315 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0), true); | |
| 1316 | |
| 1317 // Should not have delay fade animation. | |
| 1318 EXPECT_TRUE(client_.start_fade().is_null() || | |
| 1319 client_.start_fade().IsCancelled()); | |
| 1320 | |
| 1321 // Mouse up. | |
| 1322 scrollbar_controller_->DidMouseUp(); | |
| 1323 | |
| 1324 // Should not have delay fade animation. | |
| 1325 EXPECT_TRUE(client_.start_fade().is_null() || | |
| 1326 client_.start_fade().IsCancelled()); | |
| 1327 } | |
| 1328 | |
| 1213 class ScrollbarAnimationControllerAndroidTest | 1329 class ScrollbarAnimationControllerAndroidTest |
| 1214 : public testing::Test, | 1330 : public testing::Test, |
| 1215 public ScrollbarAnimationControllerClient { | 1331 public ScrollbarAnimationControllerClient { |
| 1216 public: | 1332 public: |
| 1217 ScrollbarAnimationControllerAndroidTest() | 1333 ScrollbarAnimationControllerAndroidTest() |
| 1218 : host_impl_(&task_runner_provider_, &task_graph_runner_), | 1334 : host_impl_(&task_runner_provider_, &task_graph_runner_), |
| 1219 did_request_redraw_(false), | 1335 did_request_redraw_(false), |
| 1220 did_request_animate_(false) {} | 1336 did_request_animate_(false) {} |
| 1221 | 1337 |
| 1222 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, | 1338 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1690 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1806 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1691 | 1807 |
| 1692 time += base::TimeDelta::FromSeconds(1); | 1808 time += base::TimeDelta::FromSeconds(1); |
| 1693 scrollbar_controller_->DidScrollEnd(); | 1809 scrollbar_controller_->DidScrollEnd(); |
| 1694 EXPECT_FALSE(did_request_animate_); | 1810 EXPECT_FALSE(did_request_animate_); |
| 1695 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1811 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1696 } | 1812 } |
| 1697 | 1813 |
| 1698 } // namespace | 1814 } // namespace |
| 1699 } // namespace cc | 1815 } // namespace cc |
| OLD | NEW |