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

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

Issue 1689293002: cc: Move TryScroll from LayerImpl to LayerTreeHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master branch Created 4 years, 10 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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 // Now the fling should go ahead since we've started scrolling a layer 844 // Now the fling should go ahead since we've started scrolling a layer
845 status = host_impl_->FlingScrollBegin(); 845 status = host_impl_->FlingScrollBegin();
846 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 846 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
847 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 847 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
848 status.main_thread_scrolling_reasons); 848 status.main_thread_scrolling_reasons);
849 } 849 }
850 850
851 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { 851 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) {
852 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 852 SetupScrollAndContentsLayers(gfx::Size(100, 100));
853 host_impl_->SetViewportSize(gfx::Size(50, 50)); 853 host_impl_->SetViewportSize(gfx::Size(50, 50));
854 DrawFrame();
855 LayerImpl* root = host_impl_->active_tree()->root_layer(); 854 LayerImpl* root = host_impl_->active_tree()->root_layer();
856 855
857 root->set_main_thread_scrolling_reasons( 856 root->set_main_thread_scrolling_reasons(
858 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 857 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
859 858
859 SetNeedsRebuildPropertyTrees();
860 DrawFrame();
861
860 // Start scrolling a layer 862 // Start scrolling a layer
861 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 863 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
862 BeginState(gfx::Point()).get(), InputHandler::GESTURE); 864 BeginState(gfx::Point()).get(), InputHandler::GESTURE);
863 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 865 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
864 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, 866 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
865 status.main_thread_scrolling_reasons); 867 status.main_thread_scrolling_reasons);
866 868
867 // The fling should be ignored since there's no layer being scrolled impl-side 869 // The fling should be ignored since there's no layer being scrolled impl-side
868 status = host_impl_->FlingScrollBegin(); 870 status = host_impl_->FlingScrollBegin();
869 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 871 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
870 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, 872 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
871 status.main_thread_scrolling_reasons); 873 status.main_thread_scrolling_reasons);
872 } 874 }
873 875
874 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { 876 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) {
875 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 877 SetupScrollAndContentsLayers(gfx::Size(100, 100));
876 host_impl_->SetViewportSize(gfx::Size(50, 50)); 878 host_impl_->SetViewportSize(gfx::Size(50, 50));
877 DrawFrame();
878 LayerImpl* root = host_impl_->active_tree()->root_layer(); 879 LayerImpl* root = host_impl_->active_tree()->root_layer();
879 880
880 root->set_main_thread_scrolling_reasons( 881 root->set_main_thread_scrolling_reasons(
881 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 882 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
883 SetNeedsRebuildPropertyTrees();
884 DrawFrame();
882 885
883 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 886 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
884 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 887 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
885 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 888 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
886 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, 889 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
887 status.main_thread_scrolling_reasons); 890 status.main_thread_scrolling_reasons);
888 891
889 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 892 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
890 InputHandler::GESTURE); 893 InputHandler::GESTURE);
891 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 894 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
892 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, 895 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
893 status.main_thread_scrolling_reasons); 896 status.main_thread_scrolling_reasons);
894 } 897 }
895 898
896 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { 899 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) {
897 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 900 SetupScrollAndContentsLayers(gfx::Size(200, 200));
898 host_impl_->SetViewportSize(gfx::Size(100, 100)); 901 host_impl_->SetViewportSize(gfx::Size(100, 100));
899 902
900 LayerImpl* root = host_impl_->active_tree()->root_layer(); 903 LayerImpl* root = host_impl_->active_tree()->root_layer();
901 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 904 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
902 905
906 SetNeedsRebuildPropertyTrees();
903 DrawFrame(); 907 DrawFrame();
904 908
905 // All scroll types inside the non-fast scrollable region should fail. 909 // All scroll types inside the non-fast scrollable region should fail.
906 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 910 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
907 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); 911 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL);
908 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 912 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
909 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, 913 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion,
910 status.main_thread_scrolling_reasons); 914 status.main_thread_scrolling_reasons);
911 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), 915 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25),
912 InputHandler::WHEEL)); 916 InputHandler::WHEEL));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 954
951 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { 955 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) {
952 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 956 SetupScrollAndContentsLayers(gfx::Size(200, 200));
953 host_impl_->SetViewportSize(gfx::Size(100, 100)); 957 host_impl_->SetViewportSize(gfx::Size(100, 100));
954 958
955 LayerImpl* root = host_impl_->active_tree()->root_layer(); 959 LayerImpl* root = host_impl_->active_tree()->root_layer();
956 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 960 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
957 root->SetPosition(gfx::PointF(-25.f, 0.f)); 961 root->SetPosition(gfx::PointF(-25.f, 0.f));
958 root->SetDrawsContent(true); 962 root->SetDrawsContent(true);
959 963
964 SetNeedsRebuildPropertyTrees();
960 DrawFrame(); 965 DrawFrame();
961 966
962 // This point would fall into the non-fast scrollable region except that we've 967 // This point would fall into the non-fast scrollable region except that we've
963 // moved the layer down by 25 pixels. 968 // moved the layer down by 25 pixels.
964 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 969 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
965 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); 970 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL);
966 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 971 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
967 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 972 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
968 status.main_thread_scrolling_reasons); 973 status.main_thread_scrolling_reasons);
969 974
(...skipping 9146 matching lines...) Expand 10 before | Expand all | Expand 10 after
10116 // There should not be any jitter measured till we hit the fixed point hits 10121 // There should not be any jitter measured till we hit the fixed point hits
10117 // threshold. 10122 // threshold.
10118 float expected_jitter = 10123 float expected_jitter =
10119 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10124 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10120 EXPECT_EQ(jitter, expected_jitter); 10125 EXPECT_EQ(jitter, expected_jitter);
10121 } 10126 }
10122 } 10127 }
10123 10128
10124 } // namespace 10129 } // namespace
10125 } // namespace cc 10130 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698