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

Side by Side Diff: cc/input/scrollbar_animation_controller_unittest.cc

Issue 2762123004: cc: LayerTreeHostImpl uses element id to tick animations (Closed)
Patch Set: remove accidental debug print Created 3 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/input/scrollbar_animation_controller.h" 5 #include "cc/input/scrollbar_animation_controller.h"
6 6
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
8 #include "cc/test/fake_impl_task_runner_provider.h" 8 #include "cc/test/fake_impl_task_runner_provider.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 bool did_request_animate_; 1136 bool did_request_animate_;
1137 }; 1137 };
1138 1138
1139 class VerticalScrollbarAnimationControllerAndroidTest 1139 class VerticalScrollbarAnimationControllerAndroidTest
1140 : public ScrollbarAnimationControllerAndroidTest { 1140 : public ScrollbarAnimationControllerAndroidTest {
1141 protected: 1141 protected:
1142 ScrollbarOrientation orientation() const override { return VERTICAL; } 1142 ScrollbarOrientation orientation() const override { return VERTICAL; }
1143 }; 1143 };
1144 1144
1145 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) { 1145 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) {
1146 scrollbar_layer_->layer_tree_impl() 1146 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1147 ->property_trees()
1148 ->effect_tree.OnOpacityAnimated(0.0f,
1149 scrollbar_layer_->effect_tree_index(),
1150 scrollbar_layer_->layer_tree_impl());
1151 scrollbar_controller_->DidScrollBegin(); 1147 scrollbar_controller_->DidScrollBegin();
1152 scrollbar_controller_->DidScrollUpdate(true); 1148 scrollbar_controller_->DidScrollUpdate(true);
1153 scrollbar_controller_->DidScrollEnd(); 1149 scrollbar_controller_->DidScrollEnd();
1154 // Normal Animation delay of 2 seconds. 1150 // Normal Animation delay of 2 seconds.
1155 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1151 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
1156 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2)); 1152 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2));
1157 1153
1158 scrollbar_layer_->layer_tree_impl() 1154 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1159 ->property_trees()
1160 ->effect_tree.OnOpacityAnimated(0.0f,
1161 scrollbar_layer_->effect_tree_index(),
1162 scrollbar_layer_->layer_tree_impl());
1163 scrollbar_controller_->DidScrollUpdate(true); 1155 scrollbar_controller_->DidScrollUpdate(true);
1164 // Delay animation on resize to 5 seconds. 1156 // Delay animation on resize to 5 seconds.
1165 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1157 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
1166 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5)); 1158 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5));
1167 } 1159 }
1168 1160
1169 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) { 1161 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) {
1170 scrollbar_layer_->layer_tree_impl() 1162 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1171 ->property_trees()
1172 ->effect_tree.OnOpacityAnimated(0.0f,
1173 scrollbar_layer_->effect_tree_index(),
1174 scrollbar_layer_->layer_tree_impl());
1175 scrollbar_controller_->Animate(base::TimeTicks()); 1163 scrollbar_controller_->Animate(base::TimeTicks());
1176 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1164 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
1177 } 1165 }
1178 1166
1179 TEST_F(ScrollbarAnimationControllerAndroidTest, 1167 TEST_F(ScrollbarAnimationControllerAndroidTest,
1180 HiddenAfterNonScrollingGesture) { 1168 HiddenAfterNonScrollingGesture) {
1181 scrollbar_layer_->layer_tree_impl() 1169 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1182 ->property_trees()
1183 ->effect_tree.OnOpacityAnimated(0.0f,
1184 scrollbar_layer_->effect_tree_index(),
1185 scrollbar_layer_->layer_tree_impl());
1186 scrollbar_controller_->DidScrollBegin(); 1170 scrollbar_controller_->DidScrollBegin();
1187 1171
1188 base::TimeTicks time; 1172 base::TimeTicks time;
1189 time += base::TimeDelta::FromSeconds(100); 1173 time += base::TimeDelta::FromSeconds(100);
1190 scrollbar_controller_->Animate(time); 1174 scrollbar_controller_->Animate(time);
1191 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1175 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
1192 scrollbar_controller_->DidScrollEnd(); 1176 scrollbar_controller_->DidScrollEnd();
1193 1177
1194 EXPECT_TRUE(start_fade_.Equals(base::Closure())); 1178 EXPECT_TRUE(start_fade_.Equals(base::Closure()));
1195 1179
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1524 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1541 1525
1542 time += base::TimeDelta::FromSeconds(1); 1526 time += base::TimeDelta::FromSeconds(1);
1543 scrollbar_controller_->DidScrollEnd(); 1527 scrollbar_controller_->DidScrollEnd();
1544 EXPECT_FALSE(did_request_animate_); 1528 EXPECT_FALSE(did_request_animate_);
1545 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1529 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1546 } 1530 }
1547 1531
1548 } // namespace 1532 } // namespace
1549 } // namespace cc 1533 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698