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

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 1648293003: Fix smooth scroll jump when switching scroll handling between MT and CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: finish animations on main 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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 921 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
922 922
923 // Case 4: SetNeedsDisplay() with a non-drawable layer 923 // Case 4: SetNeedsDisplay() with a non-drawable layer
924 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); 924 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false));
925 test_layer->ResetNeedsDisplayForTesting(); 925 test_layer->ResetNeedsDisplayForTesting();
926 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 926 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
927 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty1)); 927 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty1));
928 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); 928 EXPECT_TRUE(test_layer->NeedsDisplayForTesting());
929 } 929 }
930 930
931 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) {
932 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_);
933 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
934 layer_tree_host_->SetRootLayer(test_layer));
935 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
936
937 // sanity check of initial test condition
938 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
939
940 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0;
941 reasons |= MainThreadScrollingReason::kEventHandlers;
942 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll;
943 reasons |= MainThreadScrollingReason::kScrollbarScrolling;
944
945 reasons_to_clear |= MainThreadScrollingReason::kContinuingMainThreadScroll;
946 reasons_to_clear |= MainThreadScrollingReason::kThreadedScrollingDisabled;
947
948 reasons_after_clearing |= MainThreadScrollingReason::kEventHandlers;
949 reasons_after_clearing |= MainThreadScrollingReason::kScrollbarScrolling;
950
951 // Check that the reasons are added correctly.
952 EXPECT_SET_NEEDS_COMMIT(1, test_layer->AddMainThreadScrollingReasons(
953 MainThreadScrollingReason::kEventHandlers));
954 EXPECT_SET_NEEDS_COMMIT(
955 1, test_layer->AddMainThreadScrollingReasons(
956 MainThreadScrollingReason::kContinuingMainThreadScroll));
957 EXPECT_SET_NEEDS_COMMIT(1,
958 test_layer->AddMainThreadScrollingReasons(
959 MainThreadScrollingReason::kScrollbarScrolling));
960 EXPECT_EQ(reasons, test_layer->main_thread_scrolling_reasons());
961
962 // Check that the reasons can be selectively cleared.
963 EXPECT_SET_NEEDS_COMMIT(
964 1, test_layer->ClearMainThreadScrollingReasons(reasons_to_clear));
965 EXPECT_EQ(reasons_after_clearing,
966 test_layer->main_thread_scrolling_reasons());
967
968 // Check that all reasons can be cleared.
969 EXPECT_SET_NEEDS_COMMIT(1, test_layer->ClearMainThreadScrollingReasons());
970 EXPECT_EQ((uint32_t)0, test_layer->main_thread_scrolling_reasons());
971 }
972
931 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { 973 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
932 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); 974 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_);
933 EXPECT_SET_NEEDS_FULL_TREE_SYNC( 975 EXPECT_SET_NEEDS_FULL_TREE_SYNC(
934 1, layer_tree_host_->SetRootLayer(test_layer)); 976 1, layer_tree_host_->SetRootLayer(test_layer));
935 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); 977 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
936 978
937 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); 979 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_);
938 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); 980 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_);
939 981
940 // sanity check of initial test condition 982 // sanity check of initial test condition
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2160 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2119 2161
2120 test_layer->PushPropertiesTo(impl_layer.get()); 2162 test_layer->PushPropertiesTo(impl_layer.get());
2121 2163
2122 EXPECT_EQ(2lu, impl_layer->element_id()); 2164 EXPECT_EQ(2lu, impl_layer->element_id());
2123 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2165 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2124 } 2166 }
2125 2167
2126 } // namespace 2168 } // namespace
2127 } // namespace cc 2169 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698