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

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

Issue 1639363002: Move have_wheel_event_handlers to WebLayerTreeView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 4 years, 11 months 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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 713 }
714 714
715 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { 715 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) {
716 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 716 SetupScrollAndContentsLayers(gfx::Size(100, 100));
717 host_impl_->SetViewportSize(gfx::Size(50, 50)); 717 host_impl_->SetViewportSize(gfx::Size(50, 50));
718 DrawFrame(); 718 DrawFrame();
719 LayerImpl* root = host_impl_->active_tree()->root_layer(); 719 LayerImpl* root = host_impl_->active_tree()->root_layer();
720 720
721 // With registered event handlers, wheel scrolls don't necessarily 721 // With registered event handlers, wheel scrolls don't necessarily
722 // have to go to the main thread. 722 // have to go to the main thread.
723 root->SetHaveWheelEventHandlers(true); 723 host_impl_->active_tree()->set_have_wheel_event_handlers(true);
724 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 724 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
725 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 725 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
726 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 726 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
727 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 727 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
728 status.main_thread_scrolling_reasons); 728 status.main_thread_scrolling_reasons);
729 host_impl_->ScrollEnd(EndState().get()); 729 host_impl_->ScrollEnd(EndState().get());
730 730
731 // But typically the scroll-blocks-on mode will require them to. 731 // But typically the scroll-blocks-on mode will require them to.
732 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT | 732 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT |
733 SCROLL_BLOCKS_ON_START_TOUCH); 733 SCROLL_BLOCKS_ON_START_TOUCH);
734 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 734 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
735 InputHandler::WHEEL); 735 InputHandler::WHEEL);
736 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 736 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
737 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, 737 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
738 status.main_thread_scrolling_reasons); 738 status.main_thread_scrolling_reasons);
739 739
740 // But gesture scrolls can still be handled. 740 // But gesture scrolls can still be handled.
741 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 741 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
742 InputHandler::GESTURE); 742 InputHandler::GESTURE);
743 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 743 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
744 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 744 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
745 status.main_thread_scrolling_reasons); 745 status.main_thread_scrolling_reasons);
746 host_impl_->ScrollEnd(EndState().get()); 746 host_impl_->ScrollEnd(EndState().get());
747 747
748 // And if the handlers go away, wheel scrolls can again be processed 748 // And if the handlers go away, wheel scrolls can again be processed
749 // on impl (despite the scroll-blocks-on mode). 749 // on impl (despite the scroll-blocks-on mode).
750 root->SetHaveWheelEventHandlers(false); 750 host_impl_->active_tree()->set_have_wheel_event_handlers(false);
751 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 751 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
752 InputHandler::WHEEL); 752 InputHandler::WHEEL);
753 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 753 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
754 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 754 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
755 status.main_thread_scrolling_reasons); 755 status.main_thread_scrolling_reasons);
756 host_impl_->ScrollEnd(EndState().get()); 756 host_impl_->ScrollEnd(EndState().get());
757 } 757 }
758 758
759 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { 759 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
760 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 760 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 855
856 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) { 856 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) {
857 host_impl_->SetViewportSize(gfx::Size(50, 50)); 857 host_impl_->SetViewportSize(gfx::Size(50, 50));
858 858
859 // Create a normal scrollable root layer 859 // Create a normal scrollable root layer
860 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 860 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100));
861 LayerImpl* root_child = root_scroll->children()[0].get(); 861 LayerImpl* root_child = root_scroll->children()[0].get();
862 LayerImpl* root = host_impl_->active_tree()->root_layer(); 862 LayerImpl* root = host_impl_->active_tree()->root_layer();
863 DrawFrame(); 863 DrawFrame();
864 864
865 host_impl_->active_tree()->set_have_wheel_event_handlers(true);
866
865 // Create two child scrollable layers 867 // Create two child scrollable layers
866 LayerImpl* child1 = 0; 868 LayerImpl* child1 = 0;
867 { 869 {
868 scoped_ptr<LayerImpl> scrollable_child_clip_1 = 870 scoped_ptr<LayerImpl> scrollable_child_clip_1 =
869 LayerImpl::Create(host_impl_->active_tree(), 6); 871 LayerImpl::Create(host_impl_->active_tree(), 6);
870 scoped_ptr<LayerImpl> scrollable_child_1 = CreateScrollableLayer( 872 scoped_ptr<LayerImpl> scrollable_child_1 = CreateScrollableLayer(
871 7, gfx::Size(10, 10), scrollable_child_clip_1.get()); 873 7, gfx::Size(10, 10), scrollable_child_clip_1.get());
872 child1 = scrollable_child_1.get(); 874 child1 = scrollable_child_1.get();
873 scrollable_child_1->SetPosition(gfx::PointF(5.f, 5.f)); 875 scrollable_child_1->SetPosition(gfx::PointF(5.f, 5.f));
874 scrollable_child_1->SetHaveWheelEventHandlers(true);
875 scrollable_child_1->SetHaveScrollEventHandlers(true); 876 scrollable_child_1->SetHaveScrollEventHandlers(true);
876 scrollable_child_clip_1->AddChild(std::move(scrollable_child_1)); 877 scrollable_child_clip_1->AddChild(std::move(scrollable_child_1));
877 root_child->AddChild(std::move(scrollable_child_clip_1)); 878 root_child->AddChild(std::move(scrollable_child_clip_1));
878 RebuildPropertyTrees(); 879 RebuildPropertyTrees();
879 } 880 }
880 881
881 LayerImpl* child2 = 0; 882 LayerImpl* child2 = 0;
882 { 883 {
883 scoped_ptr<LayerImpl> scrollable_child_clip_2 = 884 scoped_ptr<LayerImpl> scrollable_child_clip_2 =
884 LayerImpl::Create(host_impl_->active_tree(), 8); 885 LayerImpl::Create(host_impl_->active_tree(), 8);
885 scoped_ptr<LayerImpl> scrollable_child_2 = CreateScrollableLayer( 886 scoped_ptr<LayerImpl> scrollable_child_2 = CreateScrollableLayer(
886 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); 887 9, gfx::Size(10, 10), scrollable_child_clip_2.get());
887 child2 = scrollable_child_2.get(); 888 child2 = scrollable_child_2.get();
888 scrollable_child_2->SetPosition(gfx::PointF(5.f, 20.f)); 889 scrollable_child_2->SetPosition(gfx::PointF(5.f, 20.f));
889 scrollable_child_2->SetHaveWheelEventHandlers(true);
890 scrollable_child_2->SetHaveScrollEventHandlers(true); 890 scrollable_child_2->SetHaveScrollEventHandlers(true);
891 scrollable_child_clip_2->AddChild(std::move(scrollable_child_2)); 891 scrollable_child_clip_2->AddChild(std::move(scrollable_child_2));
892 root_child->AddChild(std::move(scrollable_child_clip_2)); 892 root_child->AddChild(std::move(scrollable_child_clip_2));
893 RebuildPropertyTrees(); 893 RebuildPropertyTrees();
894 } 894 }
895 895
896 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 896 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
897 BeginState(gfx::Point(10, 10)).get(), InputHandler::GESTURE); 897 BeginState(gfx::Point(10, 10)).get(), InputHandler::GESTURE);
898 // Scroll-blocks-on on a layer affects scrolls that hit that layer. 898 // Scroll-blocks-on on a layer affects scrolls that hit that layer.
899 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 899 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
(...skipping 9200 matching lines...) Expand 10 before | Expand all | Expand 10 after
10100 // There should not be any jitter measured till we hit the fixed point hits 10100 // There should not be any jitter measured till we hit the fixed point hits
10101 // threshold. 10101 // threshold.
10102 float expected_jitter = 10102 float expected_jitter =
10103 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10103 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10104 EXPECT_EQ(jitter, expected_jitter); 10104 EXPECT_EQ(jitter, expected_jitter);
10105 } 10105 }
10106 } 10106 }
10107 10107
10108 } // namespace 10108 } // namespace
10109 } // namespace cc 10109 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698