Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 6665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9560 host_impl_->FlingScrollBegin().thread); | 9553 host_impl_->FlingScrollBegin().thread); |
| 9561 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9554 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9562 | 9555 |
| 9563 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, | 9556 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, |
| 9564 inner_viewport.height() / 2.f); | 9557 inner_viewport.height() / 2.f); |
| 9565 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9558 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9566 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9559 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9567 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9560 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9568 | 9561 |
| 9569 host_impl_->ScrollEnd(EndState().get()); | 9562 host_impl_->ScrollEnd(EndState().get()); |
| 9570 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9571 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9563 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 9572 | 9564 |
| 9573 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9565 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9574 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9566 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9575 | 9567 |
| 9576 // Fling past the inner viewport boundry, make sure outer viewport scrolls. | 9568 // Fling past the inner viewport boundry, make sure outer viewport scrolls. |
| 9577 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9569 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9578 host_impl_ | 9570 host_impl_ |
| 9579 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9571 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9580 InputHandler::TOUCHSCREEN) | 9572 InputHandler::TOUCHSCREEN) |
| 9581 .thread); | 9573 .thread); |
| 9582 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9574 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9583 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9575 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9584 host_impl_->FlingScrollBegin().thread); | 9576 host_impl_->FlingScrollBegin().thread); |
| 9585 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9577 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9586 | 9578 |
| 9587 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9579 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9588 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9580 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9589 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9581 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9590 | 9582 |
| 9591 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9583 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9592 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9584 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9593 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9585 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9594 | 9586 |
| 9595 host_impl_->ScrollEnd(EndState().get()); | 9587 host_impl_->ScrollEnd(EndState().get()); |
| 9596 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9597 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9588 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 9598 | 9589 |
| 9599 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9590 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9600 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9591 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9601 } | 9592 } |
| 9602 } | 9593 } |
| 9603 | 9594 |
| 9604 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9595 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9605 DiagonalScrollBubblesPerfectlyToInner) { | 9596 DiagonalScrollBubblesPerfectlyToInner) { |
| 9606 gfx::Size content_size = gfx::Size(200, 320); | 9597 gfx::Size content_size = gfx::Size(200, 320); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9644 // Now diagonal scroll across the outer viewport boundary in a single event. | 9635 // Now diagonal scroll across the outer viewport boundary in a single event. |
| 9645 // The entirety of the scroll should be consumed, as bubbling between inner | 9636 // The entirety of the scroll should be consumed, as bubbling between inner |
| 9646 // and outer viewport layers is perfect. | 9637 // and outer viewport layers is perfect. |
| 9647 host_impl_->ScrollBy( | 9638 host_impl_->ScrollBy( |
| 9648 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); | 9639 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); |
| 9649 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 9640 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9650 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9641 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9651 outer_expected += scroll_delta; | 9642 outer_expected += scroll_delta; |
| 9652 inner_expected += scroll_delta; | 9643 inner_expected += scroll_delta; |
| 9653 host_impl_->ScrollEnd(EndState().get()); | 9644 host_impl_->ScrollEnd(EndState().get()); |
| 9654 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9655 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 9645 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9656 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9646 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9657 | 9647 |
| 9658 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9648 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9659 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9649 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9660 } | 9650 } |
| 9661 } | 9651 } |
| 9662 | 9652 |
| 9663 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9653 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9664 TouchFlingDoesntSwitchScrollingLayer) { | 9654 TouchFlingDoesntSwitchScrollingLayer) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9717 EXPECT_TRUE( | 9707 EXPECT_TRUE( |
| 9718 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 9708 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 9719 ExpectNone(*scroll_info, inner_scroll->id()); | 9709 ExpectNone(*scroll_info, inner_scroll->id()); |
| 9720 | 9710 |
| 9721 // As the locked layer is at its limit, no further scrolling can occur. | 9711 // As the locked layer is at its limit, no further scrolling can occur. |
| 9722 EXPECT_FALSE( | 9712 EXPECT_FALSE( |
| 9723 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 9713 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 9724 .did_scroll); | 9714 .did_scroll); |
| 9725 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9715 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 9726 host_impl_->ScrollEnd(EndState().get()); | 9716 host_impl_->ScrollEnd(EndState().get()); |
| 9727 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9728 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 9717 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9729 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9718 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9730 } | 9719 } |
| 9731 } | 9720 } |
| 9732 | 9721 |
| 9733 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9722 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9734 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { | 9723 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { |
| 9735 gfx::Size content_size = gfx::Size(100, 160); | 9724 gfx::Size content_size = gfx::Size(100, 160); |
| 9736 gfx::Size outer_viewport = gfx::Size(50, 80); | 9725 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 9737 gfx::Size inner_viewport = gfx::Size(25, 40); | 9726 gfx::Size inner_viewport = gfx::Size(25, 40); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10367 InputHandler::WHEEL) | 10356 InputHandler::WHEEL) |
| 10368 .thread); | 10357 .thread); |
| 10369 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), | 10358 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), |
| 10370 InputHandler::WHEEL)); | 10359 InputHandler::WHEEL)); |
| 10371 host_impl_->ScrollBy( | 10360 host_impl_->ScrollBy( |
| 10372 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); | 10361 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); |
| 10373 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 10362 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
| 10374 InputHandler::WHEEL)); | 10363 InputHandler::WHEEL)); |
| 10375 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 10364 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
| 10376 host_impl_->ScrollEnd(scroll_state_end.get()); | 10365 host_impl_->ScrollEnd(scroll_state_end.get()); |
| 10377 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 10378 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 10366 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 10379 InputHandler::WHEEL)); | 10367 InputHandler::WHEEL)); |
| 10380 | 10368 |
| 10381 // The instant scroll should have marked the smooth scroll animation as | 10369 // The instant scroll should have marked the smooth scroll animation as |
| 10382 // aborted. | 10370 // aborted. |
| 10383 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 10371 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
| 10384 scrolling_layer->element_id())); | 10372 scrolling_layer->element_id())); |
| 10385 | 10373 |
| 10386 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 10374 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
| 10387 scrolling_layer->CurrentScrollOffset()); | 10375 scrolling_layer->CurrentScrollOffset()); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10880 .thread); | 10868 .thread); |
| 10881 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 10869 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 10882 | 10870 |
| 10883 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 10871 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 10884 host_impl_->ScrollEnd(EndState().get()); | 10872 host_impl_->ScrollEnd(EndState().get()); |
| 10885 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), | 10873 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
| 10886 scroll_layer->CurrentScrollOffset()); | 10874 scroll_layer->CurrentScrollOffset()); |
| 10887 } | 10875 } |
| 10888 } | 10876 } |
| 10889 | 10877 |
| 10878 TEST_F(LayerTreeHostImplTest, ScrollbarAnimationEndsAfterScrollEnd) { | |
|
bokan
2016/10/25 17:29:22
This tests that the CL fixes the bug, but we also
sahel
2016/10/25 17:53:41
I've already written tests for latching. In this p
bokan
2016/10/25 19:19:22
Good point, ok, existing tests should be enough.
| |
| 10879 LayerTreeSettings settings = DefaultSettings(); | |
| 10880 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); | |
| 10881 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); | |
| 10882 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; | |
| 10883 CreateHostImpl(settings, CreateCompositorFrameSink()); | |
| 10884 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
| 10885 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
| 10886 | |
| 10887 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | |
| 10888 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, | |
| 10889 VERTICAL, 10, 0, false, true); | |
| 10890 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); | |
| 10891 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); | |
| 10892 scrollbar->SetScrollLayerId(scroll->id()); | |
| 10893 root->test_properties()->AddChild(std::move(scrollbar)); | |
| 10894 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
| 10895 host_impl_->active_tree()->DidBecomeActive(); | |
| 10896 ScrollbarAnimationController* scrollbar_animation_controller = | |
| 10897 host_impl_->ScrollbarAnimationControllerForId(scroll->id()); | |
| 10898 | |
| 10899 EXPECT_TRUE(scrollbar_animation_controller); | |
| 10900 | |
| 10901 EXPECT_FALSE(scrollbar_animation_controller->currently_scrolling()); | |
| 10902 gfx::Vector2dF scroll_delta(0, 5); | |
| 10903 | |
| 10904 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | |
| 10905 host_impl_ | |
| 10906 ->ScrollBegin(BeginState(gfx::Point()).get(), | |
| 10907 InputHandler::TOUCHSCREEN) | |
| 10908 .thread); | |
| 10909 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll->CurrentScrollOffset()); | |
| 10910 | |
| 10911 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | |
| 10912 EXPECT_TRUE(scrollbar_animation_controller->currently_scrolling()); | |
| 10913 host_impl_->ScrollEnd(EndState().get()); | |
| 10914 EXPECT_FALSE(scrollbar_animation_controller->currently_scrolling()); | |
|
bokan
2016/10/25 17:29:22
You're basically testing that we call ClearCurrent
sahel
2016/10/26 14:11:44
The name of the ClearCurrentlyScrollingLayer doesn
bokan
2016/10/26 14:17:43
Acknowledged.
| |
| 10915 } | |
| 10916 | |
| 10890 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 10917 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
| 10891 public: | 10918 public: |
| 10892 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} | 10919 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} |
| 10893 void DidLoseCompositorFrameSinkOnImplThread() override { | 10920 void DidLoseCompositorFrameSinkOnImplThread() override { |
| 10894 num_lost_surfaces_++; | 10921 num_lost_surfaces_++; |
| 10895 } | 10922 } |
| 10896 | 10923 |
| 10897 protected: | 10924 protected: |
| 10898 int num_lost_surfaces_; | 10925 int num_lost_surfaces_; |
| 10899 }; | 10926 }; |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11473 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11500 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11474 | 11501 |
| 11475 // Re-initialize with a software output surface. | 11502 // Re-initialize with a software output surface. |
| 11476 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11503 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 11477 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11504 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 11478 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11505 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11479 } | 11506 } |
| 11480 | 11507 |
| 11481 } // namespace | 11508 } // namespace |
| 11482 } // namespace cc | 11509 } // namespace cc |
| OLD | NEW |