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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 host_impl_->ScrollEnd(EndState().get()); | 707 host_impl_->ScrollEnd(EndState().get()); |
708 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 708 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
709 EXPECT_TRUE( | 709 EXPECT_TRUE( |
710 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); | 710 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); |
711 } | 711 } |
712 | 712 |
713 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 713 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
714 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 714 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
715 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 715 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
716 DrawFrame(); | 716 DrawFrame(); |
717 LayerImpl* root = host_impl_->active_tree()->root_layer(); | |
718 | 717 |
719 // With registered event handlers, wheel scrolls don't necessarily | 718 // With registered event handlers, wheel scrolls don't necessarily |
720 // have to go to the main thread. | 719 // have to go to the main thread. |
721 root->SetHaveWheelEventHandlers(true); | 720 host_impl_->active_tree()->set_have_wheel_event_handlers(true); |
722 InputHandler::ScrollStatus status = | 721 InputHandler::ScrollStatus status = |
723 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 722 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
724 InputHandler::WHEEL); | 723 InputHandler::WHEEL); |
725 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 724 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
726 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, | 725 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, |
727 status.main_thread_scrolling_reasons); | 726 status.main_thread_scrolling_reasons); |
728 | 727 |
729 // But gesture scrolls can still be handled. | 728 // But gesture scrolls can still be handled. |
730 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 729 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
731 InputHandler::GESTURE); | 730 InputHandler::GESTURE); |
732 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 731 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
733 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 732 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
734 status.main_thread_scrolling_reasons); | 733 status.main_thread_scrolling_reasons); |
735 host_impl_->ScrollEnd(EndState().get()); | 734 host_impl_->ScrollEnd(EndState().get()); |
736 | 735 |
737 // And if the handlers go away, wheel scrolls can again be processed | 736 // And if the handlers go away, wheel scrolls can again be processed |
738 // on impl (despite the scroll-blocks-on mode). | 737 // on impl (despite the scroll-blocks-on mode). |
739 root->SetHaveWheelEventHandlers(false); | 738 host_impl_->active_tree()->set_have_wheel_event_handlers(false); |
740 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 739 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
741 InputHandler::WHEEL); | 740 InputHandler::WHEEL); |
742 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 741 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
743 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 742 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
744 status.main_thread_scrolling_reasons); | 743 status.main_thread_scrolling_reasons); |
745 host_impl_->ScrollEnd(EndState().get()); | 744 host_impl_->ScrollEnd(EndState().get()); |
746 } | 745 } |
747 | 746 |
748 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 747 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
749 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 748 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 9212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9962 // There should not be any jitter measured till we hit the fixed point hits | 9961 // There should not be any jitter measured till we hit the fixed point hits |
9963 // threshold. | 9962 // threshold. |
9964 float expected_jitter = | 9963 float expected_jitter = |
9965 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 9964 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
9966 EXPECT_EQ(jitter, expected_jitter); | 9965 EXPECT_EQ(jitter, expected_jitter); |
9967 } | 9966 } |
9968 } | 9967 } |
9969 | 9968 |
9970 } // namespace | 9969 } // namespace |
9971 } // namespace cc | 9970 } // namespace cc |
OLD | NEW |