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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2423143002: Scrollbar fade animation broken on Android regression resolved. (Closed)
Patch Set: review comments addressed. 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 679 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
680 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 680 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
681 status.main_thread_scrolling_reasons); 681 status.main_thread_scrolling_reasons);
682 682
683 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 683 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
684 InputHandler::WHEEL)); 684 InputHandler::WHEEL));
685 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 685 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
686 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), 686 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10),
687 InputHandler::WHEEL)); 687 InputHandler::WHEEL));
688 host_impl_->ScrollEnd(EndState().get()); 688 host_impl_->ScrollEnd(EndState().get());
689 host_impl_->ClearCurrentlyScrollingLayerForTesting();
690 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 689 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
691 InputHandler::WHEEL)); 690 InputHandler::WHEEL));
692 EXPECT_TRUE(did_request_redraw_); 691 EXPECT_TRUE(did_request_redraw_);
693 EXPECT_TRUE(did_request_commit_); 692 EXPECT_TRUE(did_request_commit_);
694 } 693 }
695 694
696 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { 695 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) {
697 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 696 SetupScrollAndContentsLayers(gfx::Size(100, 100));
698 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 697 host_impl_->active_tree()->BuildPropertyTreesForTesting();
699 698
700 host_impl_->SetViewportSize(gfx::Size(50, 50)); 699 host_impl_->SetViewportSize(gfx::Size(50, 50));
701 DrawFrame(); 700 DrawFrame();
702 701
703 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 702 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
704 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 703 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
705 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 704 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
706 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 705 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
707 status.main_thread_scrolling_reasons); 706 status.main_thread_scrolling_reasons);
708 707
709 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); 708 EXPECT_FALSE(host_impl_->IsActivelyScrolling());
710 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 709 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
711 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); 710 EXPECT_TRUE(host_impl_->IsActivelyScrolling());
712 host_impl_->ScrollEnd(EndState().get()); 711 host_impl_->ScrollEnd(EndState().get());
713 host_impl_->ClearCurrentlyScrollingLayerForTesting();
714 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); 712 EXPECT_FALSE(host_impl_->IsActivelyScrolling());
715 } 713 }
716 714
717 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { 715 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) {
718 // We should not crash when trying to scroll an empty layer tree. 716 // We should not crash when trying to scroll an empty layer tree.
719 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 717 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
720 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 718 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
721 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 719 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
722 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, 720 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
723 status.main_thread_scrolling_reasons); 721 status.main_thread_scrolling_reasons);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1028 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1031 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1029 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1032 status.main_thread_scrolling_reasons); 1030 status.main_thread_scrolling_reasons);
1033 1031
1034 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( 1032 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(
1035 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); 1033 gfx::Point(75, 75), InputHandler::TOUCHSCREEN));
1036 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 1034 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
1037 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( 1035 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(
1038 gfx::Point(25, 25), InputHandler::TOUCHSCREEN)); 1036 gfx::Point(25, 25), InputHandler::TOUCHSCREEN));
1039 host_impl_->ScrollEnd(EndState().get()); 1037 host_impl_->ScrollEnd(EndState().get());
1040 host_impl_->ClearCurrentlyScrollingLayerForTesting();
1041 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( 1038 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(
1042 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); 1039 gfx::Point(75, 75), InputHandler::TOUCHSCREEN));
1043 1040
1044 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), 1041 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(),
1045 InputHandler::TOUCHSCREEN); 1042 InputHandler::TOUCHSCREEN);
1046 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1043 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1047 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1044 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1048 status.main_thread_scrolling_reasons); 1045 status.main_thread_scrolling_reasons);
1049 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( 1046 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(
1050 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); 1047 gfx::Point(75, 75), InputHandler::TOUCHSCREEN));
1051 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 1048 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
1052 host_impl_->ScrollEnd(EndState().get()); 1049 host_impl_->ScrollEnd(EndState().get());
1053 host_impl_->ClearCurrentlyScrollingLayerForTesting();
1054 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( 1050 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(
1055 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); 1051 gfx::Point(75, 75), InputHandler::TOUCHSCREEN));
1056 } 1052 }
1057 1053
1058 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { 1054 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) {
1059 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1055 SetupScrollAndContentsLayers(gfx::Size(200, 200));
1060 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1056 host_impl_->SetViewportSize(gfx::Size(100, 100));
1061 1057
1062 LayerImpl* root = *host_impl_->active_tree()->begin(); 1058 LayerImpl* root = *host_impl_->active_tree()->begin();
1063 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 1059 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1102 SetupScrollAndContentsLayers(gfx::Size(200, 200));
1107 host_impl_->active_tree()->set_have_scroll_event_handlers(true); 1103 host_impl_->active_tree()->set_have_scroll_event_handlers(true);
1108 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1104 host_impl_->SetViewportSize(gfx::Size(50, 50));
1109 DrawFrame(); 1105 DrawFrame();
1110 1106
1111 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 1107 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
1112 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 1108 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
1113 InputHandler::TOUCHSCREEN); 1109 InputHandler::TOUCHSCREEN);
1114 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); 1110 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler());
1115 host_impl_->ScrollEnd(EndState().get()); 1111 host_impl_->ScrollEnd(EndState().get());
1116 host_impl_->ClearCurrentlyScrollingLayerForTesting();
1117 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 1112 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
1118 } 1113 }
1119 1114
1120 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { 1115 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) {
1121 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1116 SetupScrollAndContentsLayers(gfx::Size(200, 200));
1122 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1117 host_impl_->SetViewportSize(gfx::Size(100, 100));
1123 1118
1124 DrawFrame(); 1119 DrawFrame();
1125 1120
1126 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 1121 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2775 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2781 InputHandler::WHEEL); 2776 InputHandler::WHEEL);
2782 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 2777 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
2783 EXPECT_FALSE(did_request_next_frame_); 2778 EXPECT_FALSE(did_request_next_frame_);
2784 EXPECT_TRUE(did_request_redraw_); 2779 EXPECT_TRUE(did_request_redraw_);
2785 did_request_redraw_ = false; 2780 did_request_redraw_ = false;
2786 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2781 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2787 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2782 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2788 2783
2789 host_impl_->ScrollEnd(EndState().get()); 2784 host_impl_->ScrollEnd(EndState().get());
2790 host_impl_->ClearCurrentlyScrollingLayerForTesting();
2791 EXPECT_FALSE(did_request_next_frame_); 2785 EXPECT_FALSE(did_request_next_frame_);
2792 EXPECT_FALSE(did_request_redraw_); 2786 EXPECT_FALSE(did_request_redraw_);
2793 if (expecting_animations) { 2787 if (expecting_animations) {
2794 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2788 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2795 requested_animation_delay_); 2789 requested_animation_delay_);
2796 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2790 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2797 } else { 2791 } else {
2798 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2792 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2799 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2793 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2800 } 2794 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2868 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2875 InputHandler::WHEEL); 2869 InputHandler::WHEEL);
2876 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); 2870 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get());
2877 EXPECT_FALSE(did_request_next_frame_); 2871 EXPECT_FALSE(did_request_next_frame_);
2878 EXPECT_TRUE(did_request_redraw_); 2872 EXPECT_TRUE(did_request_redraw_);
2879 did_request_redraw_ = false; 2873 did_request_redraw_ = false;
2880 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2874 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2881 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2875 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2882 2876
2883 host_impl_->ScrollEnd(EndState().get()); 2877 host_impl_->ScrollEnd(EndState().get());
2884 host_impl_->ClearCurrentlyScrollingLayerForTesting();
2885 EXPECT_FALSE(did_request_next_frame_); 2878 EXPECT_FALSE(did_request_next_frame_);
2886 EXPECT_FALSE(did_request_redraw_); 2879 EXPECT_FALSE(did_request_redraw_);
2887 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2880 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2888 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2881 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2889 2882
2890 // Changing page scale triggers scrollbar animation. 2883 // Changing page scale triggers scrollbar animation.
2891 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); 2884 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f);
2892 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); 2885 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f);
2893 EXPECT_FALSE(did_request_next_frame_); 2886 EXPECT_FALSE(did_request_next_frame_);
2894 EXPECT_FALSE(did_request_redraw_); 2887 EXPECT_FALSE(did_request_redraw_);
(...skipping 6684 matching lines...) Expand 10 before | Expand all | Expand 10 after
9579 host_impl_->FlingScrollBegin().thread); 9572 host_impl_->FlingScrollBegin().thread);
9580 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); 9573 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
9581 9574
9582 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, 9575 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f,
9583 inner_viewport.height() / 2.f); 9576 inner_viewport.height() / 2.f);
9584 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 9577 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
9585 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); 9578 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y());
9586 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); 9579 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
9587 9580
9588 host_impl_->ScrollEnd(EndState().get()); 9581 host_impl_->ScrollEnd(EndState().get());
9589 host_impl_->ClearCurrentlyScrollingLayerForTesting();
9590 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); 9582 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer());
9591 9583
9592 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); 9584 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset());
9593 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); 9585 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset());
9594 9586
9595 // Fling past the inner viewport boundry, make sure outer viewport scrolls. 9587 // Fling past the inner viewport boundry, make sure outer viewport scrolls.
9596 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9588 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
9597 host_impl_ 9589 host_impl_
9598 ->ScrollBegin(BeginState(gfx::Point()).get(), 9590 ->ScrollBegin(BeginState(gfx::Point()).get(),
9599 InputHandler::TOUCHSCREEN) 9591 InputHandler::TOUCHSCREEN)
9600 .thread); 9592 .thread);
9601 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); 9593 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
9602 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9594 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
9603 host_impl_->FlingScrollBegin().thread); 9595 host_impl_->FlingScrollBegin().thread);
9604 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); 9596 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
9605 9597
9606 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 9598 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
9607 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); 9599 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y());
9608 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); 9600 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
9609 9601
9610 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 9602 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
9611 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); 9603 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y());
9612 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); 9604 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer());
9613 9605
9614 host_impl_->ScrollEnd(EndState().get()); 9606 host_impl_->ScrollEnd(EndState().get());
9615 host_impl_->ClearCurrentlyScrollingLayerForTesting();
9616 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); 9607 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer());
9617 9608
9618 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); 9609 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset());
9619 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); 9610 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset());
9620 } 9611 }
9621 } 9612 }
9622 9613
9623 TEST_F(LayerTreeHostImplVirtualViewportTest, 9614 TEST_F(LayerTreeHostImplVirtualViewportTest,
9624 DiagonalScrollBubblesPerfectlyToInner) { 9615 DiagonalScrollBubblesPerfectlyToInner) {
9625 gfx::Size content_size = gfx::Size(200, 320); 9616 gfx::Size content_size = gfx::Size(200, 320);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
9663 // Now diagonal scroll across the outer viewport boundary in a single event. 9654 // Now diagonal scroll across the outer viewport boundary in a single event.
9664 // The entirety of the scroll should be consumed, as bubbling between inner 9655 // The entirety of the scroll should be consumed, as bubbling between inner
9665 // and outer viewport layers is perfect. 9656 // and outer viewport layers is perfect.
9666 host_impl_->ScrollBy( 9657 host_impl_->ScrollBy(
9667 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); 9658 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get());
9668 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( 9659 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(
9669 gfx::Point(), InputHandler::TOUCHSCREEN)); 9660 gfx::Point(), InputHandler::TOUCHSCREEN));
9670 outer_expected += scroll_delta; 9661 outer_expected += scroll_delta;
9671 inner_expected += scroll_delta; 9662 inner_expected += scroll_delta;
9672 host_impl_->ScrollEnd(EndState().get()); 9663 host_impl_->ScrollEnd(EndState().get());
9673 host_impl_->ClearCurrentlyScrollingLayerForTesting();
9674 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( 9664 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(
9675 gfx::Point(), InputHandler::TOUCHSCREEN)); 9665 gfx::Point(), InputHandler::TOUCHSCREEN));
9676 9666
9677 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); 9667 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset());
9678 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); 9668 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset());
9679 } 9669 }
9680 } 9670 }
9681 9671
9682 TEST_F(LayerTreeHostImplVirtualViewportTest, 9672 TEST_F(LayerTreeHostImplVirtualViewportTest,
9683 TouchFlingDoesntSwitchScrollingLayer) { 9673 TouchFlingDoesntSwitchScrollingLayer) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
9736 EXPECT_TRUE( 9726 EXPECT_TRUE(
9737 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); 9727 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta));
9738 ExpectNone(*scroll_info, inner_scroll->id()); 9728 ExpectNone(*scroll_info, inner_scroll->id());
9739 9729
9740 // As the locked layer is at its limit, no further scrolling can occur. 9730 // As the locked layer is at its limit, no further scrolling can occur.
9741 EXPECT_FALSE( 9731 EXPECT_FALSE(
9742 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) 9732 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get())
9743 .did_scroll); 9733 .did_scroll);
9744 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); 9734 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll);
9745 host_impl_->ScrollEnd(EndState().get()); 9735 host_impl_->ScrollEnd(EndState().get());
9746 host_impl_->ClearCurrentlyScrollingLayerForTesting();
9747 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( 9736 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(
9748 gfx::Point(), InputHandler::TOUCHSCREEN)); 9737 gfx::Point(), InputHandler::TOUCHSCREEN));
9749 } 9738 }
9750 } 9739 }
9751 9740
9752 TEST_F(LayerTreeHostImplVirtualViewportTest, 9741 TEST_F(LayerTreeHostImplVirtualViewportTest,
9753 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { 9742 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) {
9754 gfx::Size content_size = gfx::Size(100, 160); 9743 gfx::Size content_size = gfx::Size(100, 160);
9755 gfx::Size outer_viewport = gfx::Size(50, 80); 9744 gfx::Size outer_viewport = gfx::Size(50, 80);
9756 gfx::Size inner_viewport = gfx::Size(25, 40); 9745 gfx::Size inner_viewport = gfx::Size(25, 40);
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
10386 InputHandler::WHEEL) 10375 InputHandler::WHEEL)
10387 .thread); 10376 .thread);
10388 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), 10377 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y),
10389 InputHandler::WHEEL)); 10378 InputHandler::WHEEL));
10390 host_impl_->ScrollBy( 10379 host_impl_->ScrollBy(
10391 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); 10380 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get());
10392 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), 10381 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50),
10393 InputHandler::WHEEL)); 10382 InputHandler::WHEEL));
10394 std::unique_ptr<ScrollState> scroll_state_end = EndState(); 10383 std::unique_ptr<ScrollState> scroll_state_end = EndState();
10395 host_impl_->ScrollEnd(scroll_state_end.get()); 10384 host_impl_->ScrollEnd(scroll_state_end.get());
10396 host_impl_->ClearCurrentlyScrollingLayerForTesting();
10397 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 10385 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
10398 InputHandler::WHEEL)); 10386 InputHandler::WHEEL));
10399 10387
10400 // The instant scroll should have marked the smooth scroll animation as 10388 // The instant scroll should have marked the smooth scroll animation as
10401 // aborted. 10389 // aborted.
10402 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( 10390 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting(
10403 scrolling_layer->element_id())); 10391 scrolling_layer->element_id()));
10404 10392
10405 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), 10393 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50),
10406 scrolling_layer->CurrentScrollOffset()); 10394 scrolling_layer->CurrentScrollOffset());
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
10899 .thread); 10887 .thread);
10900 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 10888 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
10901 10889
10902 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 10890 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
10903 host_impl_->ScrollEnd(EndState().get()); 10891 host_impl_->ScrollEnd(EndState().get());
10904 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), 10892 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5),
10905 scroll_layer->CurrentScrollOffset()); 10893 scroll_layer->CurrentScrollOffset());
10906 } 10894 }
10907 } 10895 }
10908 10896
10897 TEST_F(LayerTreeHostImplTest, ScrollbarAnimationEndsAfterScrollEnd) {
10898 LayerTreeSettings settings = DefaultSettings();
10899 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500);
10900 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300);
10901 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE;
10902 CreateHostImpl(settings, CreateCompositorFrameSink());
10903 SetupScrollAndContentsLayers(gfx::Size(100, 100));
10904 host_impl_->SetViewportSize(gfx::Size(50, 50));
10905
10906 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
10907 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400,
10908 VERTICAL, 10, 0, false, true);
10909 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer();
10910 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer();
10911 scrollbar->SetScrollLayerId(scroll->id());
10912 root->test_properties()->AddChild(std::move(scrollbar));
10913 host_impl_->active_tree()->BuildPropertyTreesForTesting();
10914 host_impl_->active_tree()->DidBecomeActive();
10915 ScrollbarAnimationController* scrollbar_animation_controller =
10916 host_impl_->ScrollbarAnimationControllerForId(scroll->id());
10917
10918 EXPECT_TRUE(scrollbar_animation_controller);
10919 EXPECT_FALSE(host_impl_->CurrentlyScrollingLayer());
10920 EXPECT_FALSE(scrollbar_animation_controller->currently_scrolling());
10921 gfx::Vector2dF scroll_delta(0, 5);
10922
10923 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
10924 host_impl_
10925 ->ScrollBegin(BeginState(gfx::Point()).get(),
10926 InputHandler::TOUCHSCREEN)
10927 .thread);
10928 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll->CurrentScrollOffset());
10929
10930 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
10931 EXPECT_TRUE(scrollbar_animation_controller->currently_scrolling());
10932 host_impl_->ScrollEnd(EndState().get());
10933 EXPECT_FALSE(scrollbar_animation_controller->currently_scrolling());
10934 }
10935
10909 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { 10936 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest {
10910 public: 10937 public:
10911 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} 10938 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {}
10912 void DidLoseCompositorFrameSinkOnImplThread() override { 10939 void DidLoseCompositorFrameSinkOnImplThread() override {
10913 num_lost_surfaces_++; 10940 num_lost_surfaces_++;
10914 } 10941 }
10915 10942
10916 protected: 10943 protected:
10917 int num_lost_surfaces_; 10944 int num_lost_surfaces_;
10918 }; 10945 };
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
11617 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11644 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11618 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11645 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11619 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11646 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11620 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11647 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11621 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11648 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11622 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11649 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11623 } 11650 }
11624 11651
11625 } // namespace 11652 } // namespace
11626 } // namespace cc 11653 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698