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

Side by Side Diff: cc/input/scrollbar_animation_controller_thinning_unittest.cc

Issue 2422353002: Iframe/div MD scrollbars get idle when mouse leaves the nested elements. (Closed)
Patch Set: Unittest passes asan build bot. Created 4 years, 1 month 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
« no previous file with comments | « cc/input/scrollbar_animation_controller_thinning.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_thinning.h" 5 #include "cc/input/scrollbar_animation_controller_thinning.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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 scrollbar_controller_->DidScrollUpdate(false); 270 scrollbar_controller_->DidScrollUpdate(false);
271 scrollbar_controller_->DidScrollEnd(); 271 scrollbar_controller_->DidScrollEnd();
272 272
273 // An animation should have been enqueued. 273 // An animation should have been enqueued.
274 EXPECT_EQ(kDelayBeforeStarting, delay_); 274 EXPECT_EQ(kDelayBeforeStarting, delay_);
275 EXPECT_FALSE(start_fade_.is_null()); 275 EXPECT_FALSE(start_fade_.is_null());
276 276
277 // Now move the mouse over the scrollbar and capture it. It should become 277 // Now move the mouse over the scrollbar and capture it. It should become
278 // thick without need for an animation. 278 // thick without need for an animation.
279 scrollbar_controller_->DidMouseMoveNear(0); 279 scrollbar_controller_->DidMouseMoveNear(0);
280 scrollbar_controller_->DidCaptureScrollbarBegin(); 280 scrollbar_controller_->DidMouseDown();
281 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 281 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
282 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 282 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
283 283
284 // The fade animation should have been cancelled. 284 // The fade animation should have been cancelled.
285 EXPECT_FALSE(start_fade_.is_null()); 285 EXPECT_FALSE(start_fade_.is_null());
286 EXPECT_TRUE(start_fade_.IsCancelled()); 286 EXPECT_TRUE(start_fade_.IsCancelled());
287 } 287 }
288 288
289 // Make sure a scrollbar captured after a thickening animation doesn't try to 289 // Make sure a scrollbar captured after a thickening animation doesn't try to
290 // fade out. 290 // fade out.
(...skipping 15 matching lines...) Expand all
306 time += kThinningDuration; 306 time += kThinningDuration;
307 scrollbar_controller_->Animate(time); 307 scrollbar_controller_->Animate(time);
308 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 308 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
309 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 309 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
310 310
311 // Since the scrollbar became thick, it should have queued up a fade. 311 // Since the scrollbar became thick, it should have queued up a fade.
312 EXPECT_FALSE(start_fade_.is_null()); 312 EXPECT_FALSE(start_fade_.is_null());
313 EXPECT_FALSE(start_fade_.IsCancelled()); 313 EXPECT_FALSE(start_fade_.IsCancelled());
314 314
315 // Make sure capturing the scrollbar stops the fade. 315 // Make sure capturing the scrollbar stops the fade.
316 scrollbar_controller_->DidCaptureScrollbarBegin(); 316 scrollbar_controller_->DidMouseDown();
317 EXPECT_FALSE(start_fade_.is_null()); 317 EXPECT_FALSE(start_fade_.is_null());
318 EXPECT_TRUE(start_fade_.IsCancelled()); 318 EXPECT_TRUE(start_fade_.IsCancelled());
319 } 319 }
320 320
321 // Make sure releasing a captured scrollbar causes it to fade out. 321 // Make sure releasing a captured scrollbar causes it to fade out.
322 TEST_F(ScrollbarAnimationControllerThinningTest, FadeAfterReleased) { 322 TEST_F(ScrollbarAnimationControllerThinningTest, FadeAfterReleased) {
323 base::TimeTicks time; 323 base::TimeTicks time;
324 time += base::TimeDelta::FromSeconds(1); 324 time += base::TimeDelta::FromSeconds(1);
325 325
326 scrollbar_controller_->DidScrollBegin(); 326 scrollbar_controller_->DidScrollBegin();
327 scrollbar_controller_->DidScrollUpdate(false); 327 scrollbar_controller_->DidScrollUpdate(false);
328 scrollbar_controller_->DidScrollEnd(); 328 scrollbar_controller_->DidScrollEnd();
329 329
330 // An animation should have been enqueued. 330 // An animation should have been enqueued.
331 EXPECT_EQ(kDelayBeforeStarting, delay_); 331 EXPECT_EQ(kDelayBeforeStarting, delay_);
332 EXPECT_FALSE(start_fade_.is_null()); 332 EXPECT_FALSE(start_fade_.is_null());
333 333
334 // Now move the mouse over the scrollbar and capture it. 334 // Now move the mouse over the scrollbar and capture it.
335 scrollbar_controller_->DidMouseMoveNear(0); 335 scrollbar_controller_->DidMouseMoveNear(0);
336 scrollbar_controller_->DidCaptureScrollbarBegin(); 336 scrollbar_controller_->DidMouseDown();
337 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 337 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
338 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 338 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
339 339
340 // Since the scrollbar became thick, it should have queued up a fade. 340 // Since the scrollbar became thick, it should have queued up a fade.
341 EXPECT_FALSE(start_fade_.is_null()); 341 EXPECT_FALSE(start_fade_.is_null());
342 EXPECT_TRUE(start_fade_.IsCancelled()); 342 EXPECT_TRUE(start_fade_.IsCancelled());
343 343
344 scrollbar_controller_->DidCaptureScrollbarEnd(); 344 scrollbar_controller_->DidMouseUp();
345 EXPECT_FALSE(start_fade_.is_null()); 345 EXPECT_FALSE(start_fade_.is_null());
346 EXPECT_FALSE(start_fade_.IsCancelled()); 346 EXPECT_FALSE(start_fade_.IsCancelled());
347 } 347 }
348 348
349 // Make sure moving near a scrollbar while it's fading out causes it to reset 349 // Make sure moving near a scrollbar while it's fading out causes it to reset
350 // the opacity and thicken. 350 // the opacity and thicken.
351 TEST_F(ScrollbarAnimationControllerThinningTest, MoveNearScrollbarWhileFading) { 351 TEST_F(ScrollbarAnimationControllerThinningTest, MoveNearScrollbarWhileFading) {
352 base::TimeTicks time; 352 base::TimeTicks time;
353 time += base::TimeDelta::FromSeconds(1); 353 time += base::TimeDelta::FromSeconds(1);
354 354
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 scrollbar_controller_->Animate(time); 409 scrollbar_controller_->Animate(time);
410 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 410 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
411 411
412 // Proceed half way through the fade out animation. 412 // Proceed half way through the fade out animation.
413 time += kFadeDuration / 2; 413 time += kFadeDuration / 2;
414 scrollbar_controller_->Animate(time); 414 scrollbar_controller_->Animate(time);
415 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity()); 415 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity());
416 416
417 // Now capture the scrollbar. It should reset opacity to 1 instantly. 417 // Now capture the scrollbar. It should reset opacity to 1 instantly.
418 scrollbar_controller_->DidCaptureScrollbarBegin(); 418 scrollbar_controller_->DidMouseDown();
419 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 419 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
420 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 420 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
421 } 421 }
422 422
423 // Make sure we can't capture scrollbar that's completely faded out 423 // Make sure we can't capture scrollbar that's completely faded out
424 TEST_F(ScrollbarAnimationControllerThinningTest, TestCantCaptureWhenFaded) { 424 TEST_F(ScrollbarAnimationControllerThinningTest, TestCantCaptureWhenFaded) {
425 base::TimeTicks time; 425 base::TimeTicks time;
426 time += base::TimeDelta::FromSeconds(1); 426 time += base::TimeDelta::FromSeconds(1);
427 427
428 scrollbar_controller_->DidScrollBegin(); 428 scrollbar_controller_->DidScrollBegin();
(...skipping 18 matching lines...) Expand all
447 // Fade the scrollbar out completely. 447 // Fade the scrollbar out completely.
448 time += kFadeDuration; 448 time += kFadeDuration;
449 scrollbar_controller_->Animate(time); 449 scrollbar_controller_->Animate(time);
450 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 450 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
451 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 451 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
452 452
453 start_fade_.Reset(); 453 start_fade_.Reset();
454 454
455 // Now try to capture the scrollbar. It shouldn't do anything since it's 455 // Now try to capture the scrollbar. It shouldn't do anything since it's
456 // completely faded out. 456 // completely faded out.
457 scrollbar_controller_->DidCaptureScrollbarBegin(); 457 scrollbar_controller_->DidMouseDown();
458 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 458 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
459 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 459 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
460 EXPECT_TRUE(start_fade_.is_null()); 460 EXPECT_TRUE(start_fade_.is_null());
461 461
462 // Similarly, releasing the scrollbar should have no effect. 462 // Similarly, releasing the scrollbar should have no effect.
463 scrollbar_controller_->DidCaptureScrollbarEnd(); 463 scrollbar_controller_->DidMouseUp();
464 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 464 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
465 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 465 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
466 EXPECT_TRUE(start_fade_.is_null()); 466 EXPECT_TRUE(start_fade_.is_null());
467 } 467 }
468 468
469 // Initiate a scroll when the pointer is already near the scrollbar. It should 469 // Initiate a scroll when the pointer is already near the scrollbar. It should
470 // appear thick and remain thick. 470 // appear thick and remain thick.
471 TEST_F(ScrollbarAnimationControllerThinningTest, ScrollWithMouseNear) { 471 TEST_F(ScrollbarAnimationControllerThinningTest, ScrollWithMouseNear) {
472 base::TimeTicks time; 472 base::TimeTicks time;
473 time += base::TimeDelta::FromSeconds(1); 473 time += base::TimeDelta::FromSeconds(1);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 617 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
618 EXPECT_FLOAT_EQ(kIdleThicknessScale, 618 EXPECT_FLOAT_EQ(kIdleThicknessScale,
619 scrollbar_layer_->thumb_thickness_scale_factor()); 619 scrollbar_layer_->thumb_thickness_scale_factor());
620 620
621 // Should animate to thickened. 621 // Should animate to thickened.
622 time += kThinningDuration; 622 time += kThinningDuration;
623 scrollbar_controller_->Animate(time); 623 scrollbar_controller_->Animate(time);
624 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 624 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
625 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 625 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
626 626
627 // This is tricky. The DidMouseMoveOffScrollbar() is sent before the 627 // This is tricky. The DidMouseLeave() is sent before the
628 // subsequent DidMouseMoveNear(), if the mouse moves in that direction. 628 // subsequent DidMouseMoveNear(), if the mouse moves in that direction.
629 // This results in the thumb thinning. We want to make sure that when the 629 // This results in the thumb thinning. We want to make sure that when the
630 // thumb starts expanding it doesn't first narrow to the idle thinness. 630 // thumb starts expanding it doesn't first narrow to the idle thinness.
631 time += base::TimeDelta::FromSeconds(1); 631 time += base::TimeDelta::FromSeconds(1);
632 scrollbar_controller_->DidMouseMoveOffScrollbar(); 632 scrollbar_controller_->DidMouseLeave();
633 scrollbar_controller_->Animate(time); 633 scrollbar_controller_->Animate(time);
634 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 634 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
635 635
636 // Let the animation run half of the way through the thinning animation. 636 // Let the animation run half of the way through the thinning animation.
637 time += kThinningDuration / 2; 637 time += kThinningDuration / 2;
638 scrollbar_controller_->Animate(time); 638 scrollbar_controller_->Animate(time);
639 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f, 639 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
640 scrollbar_layer_->thumb_thickness_scale_factor()); 640 scrollbar_layer_->thumb_thickness_scale_factor());
641 641
642 // Now we get a notification for the mouse moving over the scroller. The 642 // Now we get a notification for the mouse moving over the scroller. The
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 time += base::TimeDelta::FromSeconds(1); 685 time += base::TimeDelta::FromSeconds(1);
686 686
687 // Move over the scrollbar. 687 // Move over the scrollbar.
688 scrollbar_controller_->DidMouseMoveNear(0); 688 scrollbar_controller_->DidMouseMoveNear(0);
689 scrollbar_controller_->Animate(time); 689 scrollbar_controller_->Animate(time);
690 time += kFadeDuration; 690 time += kFadeDuration;
691 scrollbar_controller_->Animate(time); 691 scrollbar_controller_->Animate(time);
692 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 692 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
693 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 693 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
694 694
695 // Capture. 695 // Capture
696 scrollbar_controller_->DidCaptureScrollbarBegin(); 696 scrollbar_controller_->DidMouseDown();
697 time += base::TimeDelta::FromSeconds(1); 697 time += base::TimeDelta::FromSeconds(1);
698 scrollbar_controller_->Animate(time); 698 scrollbar_controller_->Animate(time);
699 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 699 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
700 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 700 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
701 701
702 // Should stay thick for a while. 702 // Should stay thick for a while.
703 time += base::TimeDelta::FromSeconds(10); 703 time += base::TimeDelta::FromSeconds(10);
704 scrollbar_controller_->Animate(time); 704 scrollbar_controller_->Animate(time);
705 705
706 // Move outside the "near" threshold. Because the scrollbar is captured it 706 // Move outside the "near" threshold. Because the scrollbar is captured it
707 // should remain thick. 707 // should remain thick.
708 scrollbar_controller_->DidMouseMoveNear( 708 scrollbar_controller_->DidMouseMoveNear(
709 kDefaultMouseMoveDistanceToTriggerAnimation); 709 kDefaultMouseMoveDistanceToTriggerAnimation);
710 time += kThinningDuration; 710 time += kThinningDuration;
711 scrollbar_controller_->Animate(time); 711 scrollbar_controller_->Animate(time);
712 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 712 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
713 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 713 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
714 714
715 // Release. 715 // Release.
716 scrollbar_controller_->DidCaptureScrollbarEnd(); 716 scrollbar_controller_->DidMouseUp();
717 717
718 // Should become thin. 718 // Should become thin.
719 time += base::TimeDelta::FromSeconds(1); 719 time += base::TimeDelta::FromSeconds(1);
720 scrollbar_controller_->Animate(time); 720 scrollbar_controller_->Animate(time);
721 time += kThinningDuration; 721 time += kThinningDuration;
722 scrollbar_controller_->Animate(time); 722 scrollbar_controller_->Animate(time);
723 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 723 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
724 EXPECT_FLOAT_EQ(kIdleThicknessScale, 724 EXPECT_FLOAT_EQ(kIdleThicknessScale,
725 scrollbar_layer_->thumb_thickness_scale_factor()); 725 scrollbar_layer_->thumb_thickness_scale_factor());
726 } 726 }
(...skipping 12 matching lines...) Expand all
739 739
740 // Move over scrollbar. 740 // Move over scrollbar.
741 scrollbar_controller_->DidMouseMoveNear(0); 741 scrollbar_controller_->DidMouseMoveNear(0);
742 scrollbar_controller_->Animate(time); 742 scrollbar_controller_->Animate(time);
743 time += kThinningDuration; 743 time += kThinningDuration;
744 scrollbar_controller_->Animate(time); 744 scrollbar_controller_->Animate(time);
745 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 745 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
746 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 746 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
747 747
748 // Capture. Nothing should change. 748 // Capture. Nothing should change.
749 scrollbar_controller_->DidCaptureScrollbarBegin(); 749 scrollbar_controller_->DidMouseDown();
750 time += base::TimeDelta::FromSeconds(1); 750 time += base::TimeDelta::FromSeconds(1);
751 scrollbar_controller_->Animate(time); 751 scrollbar_controller_->Animate(time);
752 time += base::TimeDelta::FromSeconds(10); 752 time += base::TimeDelta::FromSeconds(10);
753 scrollbar_controller_->Animate(time); 753 scrollbar_controller_->Animate(time);
754 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 754 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
755 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 755 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
756 756
757 // Move away from scrollbar. Nothing should change. 757 // Move away from scrollbar. Nothing should change.
758 scrollbar_controller_->DidMouseMoveNear( 758 scrollbar_controller_->DidMouseMoveNear(
759 kDefaultMouseMoveDistanceToTriggerAnimation); 759 kDefaultMouseMoveDistanceToTriggerAnimation);
760 time += base::TimeDelta::FromSeconds(1); 760 time += base::TimeDelta::FromSeconds(1);
761 scrollbar_controller_->Animate(time); 761 scrollbar_controller_->Animate(time);
762 time += base::TimeDelta::FromSeconds(10); 762 time += base::TimeDelta::FromSeconds(10);
763 scrollbar_controller_->Animate(time); 763 scrollbar_controller_->Animate(time);
764 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 764 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
765 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 765 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
766 766
767 // Move over scrollbar and release. Since we're near the scrollbar, it should 767 // Move over scrollbar and release. Since we're near the scrollbar, it should
768 // remain thick. 768 // remain thick.
769 scrollbar_controller_->DidMouseMoveNear(0); 769 scrollbar_controller_->DidMouseMoveNear(0);
770 scrollbar_controller_->DidCaptureScrollbarEnd(); 770 scrollbar_controller_->DidMouseUp();
771 time += base::TimeDelta::FromSeconds(1); 771 time += base::TimeDelta::FromSeconds(1);
772 scrollbar_controller_->Animate(time); 772 scrollbar_controller_->Animate(time);
773 time += base::TimeDelta::FromSeconds(10); 773 time += base::TimeDelta::FromSeconds(10);
774 scrollbar_controller_->Animate(time); 774 scrollbar_controller_->Animate(time);
775 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 775 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
776 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 776 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
777 } 777 }
778 778
779 // Move mouse on scrollbar and capture then move out of window. Confirm that 779 // Move mouse on scrollbar and capture then move out of window. Confirm that
780 // the bar stays thick. 780 // the bar stays thick.
781 TEST_F(ScrollbarAnimationControllerThinningTest, 781 TEST_F(ScrollbarAnimationControllerThinningTest,
782 MouseCapturedAndExitWindowFromScrollbar) { 782 MouseCapturedAndExitWindowFromScrollbar) {
783 // Scroll to make the scrollbars visible. 783 // Scroll to make the scrollbars visible.
784 scrollbar_controller_->DidScrollBegin(); 784 scrollbar_controller_->DidScrollBegin();
785 scrollbar_controller_->DidScrollUpdate(false); 785 scrollbar_controller_->DidScrollUpdate(false);
786 scrollbar_controller_->DidScrollEnd(); 786 scrollbar_controller_->DidScrollEnd();
787 787
788 base::TimeTicks time; 788 base::TimeTicks time;
789 time += base::TimeDelta::FromSeconds(1); 789 time += base::TimeDelta::FromSeconds(1);
790 790
791 // Move mouse over scrollbar. 791 // Move mouse over scrollbar.
792 scrollbar_controller_->DidMouseMoveNear(0); 792 scrollbar_controller_->DidMouseMoveNear(0);
793 scrollbar_controller_->Animate(time); 793 scrollbar_controller_->Animate(time);
794 time += kThinningDuration; 794 time += kThinningDuration;
795 scrollbar_controller_->Animate(time); 795 scrollbar_controller_->Animate(time);
796 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 796 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
797 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 797 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
798 798
799 // Capture. 799 // Capture.
800 scrollbar_controller_->DidCaptureScrollbarBegin(); 800 scrollbar_controller_->DidMouseDown();
801 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 801 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
802 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 802 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
803 803
804 // Move out of window. Since the scrollbar is capture, it shouldn't change in 804 // Move out of window. Since the scrollbar is capture, it shouldn't change in
805 // any way. 805 // any way.
806 scrollbar_controller_->DidMouseMoveOffScrollbar(); 806 scrollbar_controller_->DidMouseLeave();
807 scrollbar_controller_->Animate(time); 807 scrollbar_controller_->Animate(time);
808 time += kThinningDuration; 808 time += kThinningDuration;
809 scrollbar_controller_->Animate(time); 809 scrollbar_controller_->Animate(time);
810 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 810 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
811 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 811 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
812 } 812 }
813 813
814 // Tests that the thickening/thinning effects are animated. 814 // Tests that the thickening/thinning effects are animated.
815 TEST_F(ScrollbarAnimationControllerThinningTest, ThicknessAnimated) { 815 TEST_F(ScrollbarAnimationControllerThinningTest, ThicknessAnimated) {
816 // Scroll to make the scrollbars visible. 816 // Scroll to make the scrollbars visible.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 scrollbar_controller_->Animate(time); 926 scrollbar_controller_->Animate(time);
927 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity()); 927 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity());
928 928
929 time += kFadeDuration / 2; 929 time += kFadeDuration / 2;
930 scrollbar_controller_->Animate(time); 930 scrollbar_controller_->Animate(time);
931 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 931 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
932 } 932 }
933 933
934 } // namespace 934 } // namespace
935 } // namespace cc 935 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/scrollbar_animation_controller_thinning.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698