| OLD | NEW |
| 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/animation/scrollbar_animation_controller_thinning.h" | 5 #include "cc/animation/scrollbar_animation_controller_thinning.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_proxy.h" | 8 #include "cc/test/fake_impl_proxy.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" |
| 11 #include "cc/test/test_shared_bitmap_manager.h" | 11 #include "cc/test/test_shared_bitmap_manager.h" |
| 12 #include "cc/test/test_task_graph_runner.h" |
| 12 #include "cc/trees/layer_tree_impl.h" | 13 #include "cc/trees/layer_tree_impl.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 class ScrollbarAnimationControllerThinningTest | 19 class ScrollbarAnimationControllerThinningTest |
| 19 : public testing::Test, | 20 : public testing::Test, |
| 20 public ScrollbarAnimationControllerClient { | 21 public ScrollbarAnimationControllerClient { |
| 21 public: | 22 public: |
| 22 ScrollbarAnimationControllerThinningTest() | 23 ScrollbarAnimationControllerThinningTest() |
| 23 : host_impl_(&proxy_, &shared_bitmap_manager_) {} | 24 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} |
| 24 | 25 |
| 25 void StartAnimatingScrollbarAnimationController( | 26 void StartAnimatingScrollbarAnimationController( |
| 26 ScrollbarAnimationController* controller) override { | 27 ScrollbarAnimationController* controller) override { |
| 27 is_animating_ = true; | 28 is_animating_ = true; |
| 28 } | 29 } |
| 29 void StopAnimatingScrollbarAnimationController( | 30 void StopAnimatingScrollbarAnimationController( |
| 30 ScrollbarAnimationController* controller) override { | 31 ScrollbarAnimationController* controller) override { |
| 31 is_animating_ = false; | 32 is_animating_ = false; |
| 32 } | 33 } |
| 33 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, | 34 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 clip_layer_->SetBounds(gfx::Size(100, 100)); | 68 clip_layer_->SetBounds(gfx::Size(100, 100)); |
| 68 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); | 69 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); |
| 69 | 70 |
| 70 scrollbar_controller_ = ScrollbarAnimationControllerThinning::Create( | 71 scrollbar_controller_ = ScrollbarAnimationControllerThinning::Create( |
| 71 scroll_layer_ptr, this, base::TimeDelta::FromSeconds(2), | 72 scroll_layer_ptr, this, base::TimeDelta::FromSeconds(2), |
| 72 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); | 73 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 FakeImplProxy proxy_; | 76 FakeImplProxy proxy_; |
| 76 TestSharedBitmapManager shared_bitmap_manager_; | 77 TestSharedBitmapManager shared_bitmap_manager_; |
| 78 TestTaskGraphRunner task_graph_runner_; |
| 77 FakeLayerTreeHostImpl host_impl_; | 79 FakeLayerTreeHostImpl host_impl_; |
| 78 scoped_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_; | 80 scoped_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_; |
| 79 scoped_ptr<LayerImpl> clip_layer_; | 81 scoped_ptr<LayerImpl> clip_layer_; |
| 80 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; | 82 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; |
| 81 | 83 |
| 82 base::Closure start_fade_; | 84 base::Closure start_fade_; |
| 83 base::TimeDelta delay_; | 85 base::TimeDelta delay_; |
| 84 bool is_animating_; | 86 bool is_animating_; |
| 85 bool did_request_redraw_; | 87 bool did_request_redraw_; |
| 86 }; | 88 }; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 378 |
| 377 time += base::TimeDelta::FromSeconds(1); | 379 time += base::TimeDelta::FromSeconds(1); |
| 378 scrollbar_controller_->Animate(time); | 380 scrollbar_controller_->Animate(time); |
| 379 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->opacity()); | 381 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->opacity()); |
| 380 // The thickness now gets big again. | 382 // The thickness now gets big again. |
| 381 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 383 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 382 } | 384 } |
| 383 | 385 |
| 384 } // namespace | 386 } // namespace |
| 385 } // namespace cc | 387 } // namespace cc |
| OLD | NEW |