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/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 Loading... |
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 clearing non-set reasons doesn't set needs commit. |
| 969 reasons_to_clear = 0; |
| 970 reasons_to_clear |= MainThreadScrollingReason::kThreadedScrollingDisabled; |
| 971 reasons_to_clear |= MainThreadScrollingReason::kNoScrollingLayer; |
| 972 EXPECT_SET_NEEDS_COMMIT( |
| 973 0, test_layer->ClearMainThreadScrollingReasons(reasons_to_clear)); |
| 974 EXPECT_EQ(reasons_after_clearing, |
| 975 test_layer->main_thread_scrolling_reasons()); |
| 976 |
| 977 // Check that adding an existing condition doesn't set needs commit. |
| 978 EXPECT_SET_NEEDS_COMMIT(0, test_layer->AddMainThreadScrollingReasons( |
| 979 MainThreadScrollingReason::kEventHandlers)); |
| 980 } |
| 981 |
931 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 982 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
932 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); | 983 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
933 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 984 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
934 1, layer_tree_host_->SetRootLayer(test_layer)); | 985 1, layer_tree_host_->SetRootLayer(test_layer)); |
935 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 986 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
936 | 987 |
937 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); | 988 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); |
938 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); | 989 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); |
939 | 990 |
940 // sanity check of initial test condition | 991 // sanity check of initial test condition |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2169 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
2119 | 2170 |
2120 test_layer->PushPropertiesTo(impl_layer.get()); | 2171 test_layer->PushPropertiesTo(impl_layer.get()); |
2121 | 2172 |
2122 EXPECT_EQ(2lu, impl_layer->element_id()); | 2173 EXPECT_EQ(2lu, impl_layer->element_id()); |
2123 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2174 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
2124 } | 2175 } |
2125 | 2176 |
2126 } // namespace | 2177 } // namespace |
2127 } // namespace cc | 2178 } // namespace cc |
OLD | NEW |