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

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

Issue 2762123004: cc: LayerTreeHostImpl uses element id to tick animations (Closed)
Patch Set: review comments Created 3 years, 8 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 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 bool did_request_animate_; 1178 bool did_request_animate_;
1179 }; 1179 };
1180 1180
1181 class VerticalScrollbarAnimationControllerAndroidTest 1181 class VerticalScrollbarAnimationControllerAndroidTest
1182 : public ScrollbarAnimationControllerAndroidTest { 1182 : public ScrollbarAnimationControllerAndroidTest {
1183 protected: 1183 protected:
1184 ScrollbarOrientation orientation() const override { return VERTICAL; } 1184 ScrollbarOrientation orientation() const override { return VERTICAL; }
1185 }; 1185 };
1186 1186
1187 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) { 1187 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) {
1188 scrollbar_layer_->layer_tree_impl() 1188 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1189 ->property_trees()
1190 ->effect_tree.OnOpacityAnimated(0.0f,
1191 scrollbar_layer_->effect_tree_index(),
1192 scrollbar_layer_->layer_tree_impl());
1193 // We should use the gesture delay rather than the resize delay if we're in a 1189 // We should use the gesture delay rather than the resize delay if we're in a
1194 // gesture scroll, even if it is resizing. 1190 // gesture scroll, even if it is resizing.
1195 scrollbar_controller_->DidScrollBegin(); 1191 scrollbar_controller_->DidScrollBegin();
1196 scrollbar_controller_->DidResize(); 1192 scrollbar_controller_->DidResize();
1197 scrollbar_controller_->DidScrollEnd(); 1193 scrollbar_controller_->DidScrollEnd();
1198 // Normal Animation delay of 2 seconds. 1194 // Normal Animation delay of 2 seconds.
1199 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1195 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
1200 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2)); 1196 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2));
1201 1197
1202 scrollbar_layer_->layer_tree_impl() 1198 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1203 ->property_trees()
1204 ->effect_tree.OnOpacityAnimated(0.0f,
1205 scrollbar_layer_->effect_tree_index(),
1206 scrollbar_layer_->layer_tree_impl());
1207 scrollbar_controller_->DidResize(); 1199 scrollbar_controller_->DidResize();
1208 // Delay animation on resize to 5 seconds. 1200 // Delay animation on resize to 5 seconds.
1209 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1201 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
1210 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5)); 1202 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5));
1211 } 1203 }
1212 1204
1213 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) { 1205 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) {
1214 scrollbar_layer_->layer_tree_impl() 1206 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1215 ->property_trees()
1216 ->effect_tree.OnOpacityAnimated(0.0f,
1217 scrollbar_layer_->effect_tree_index(),
1218 scrollbar_layer_->layer_tree_impl());
1219 scrollbar_controller_->Animate(base::TimeTicks()); 1207 scrollbar_controller_->Animate(base::TimeTicks());
1220 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1208 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
1221 } 1209 }
1222 1210
1223 TEST_F(ScrollbarAnimationControllerAndroidTest, 1211 TEST_F(ScrollbarAnimationControllerAndroidTest,
1224 HiddenAfterNonScrollingGesture) { 1212 HiddenAfterNonScrollingGesture) {
1225 scrollbar_layer_->layer_tree_impl() 1213 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1226 ->property_trees()
1227 ->effect_tree.OnOpacityAnimated(0.0f,
1228 scrollbar_layer_->effect_tree_index(),
1229 scrollbar_layer_->layer_tree_impl());
1230 scrollbar_controller_->DidScrollBegin(); 1214 scrollbar_controller_->DidScrollBegin();
1231 1215
1232 base::TimeTicks time; 1216 base::TimeTicks time;
1233 time += base::TimeDelta::FromSeconds(100); 1217 time += base::TimeDelta::FromSeconds(100);
1234 scrollbar_controller_->Animate(time); 1218 scrollbar_controller_->Animate(time);
1235 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1219 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
1236 scrollbar_controller_->DidScrollEnd(); 1220 scrollbar_controller_->DidScrollEnd();
1237 1221
1238 EXPECT_TRUE(start_fade_.Equals(base::Closure())); 1222 EXPECT_TRUE(start_fade_.Equals(base::Closure()));
1239 1223
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1587 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1604 1588
1605 time += base::TimeDelta::FromSeconds(1); 1589 time += base::TimeDelta::FromSeconds(1);
1606 scrollbar_controller_->DidScrollEnd(); 1590 scrollbar_controller_->DidScrollEnd();
1607 EXPECT_FALSE(did_request_animate_); 1591 EXPECT_FALSE(did_request_animate_);
1608 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1592 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1609 } 1593 }
1610 1594
1611 } // namespace 1595 } // namespace
1612 } // namespace cc 1596 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698