| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_linear_fade.h" | 5 #include "cc/animation/scrollbar_animation_controller_linear_fade.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 ScrollbarAnimationControllerLinearFadeTest | 19 class ScrollbarAnimationControllerLinearFadeTest |
| 19 : public testing::Test, | 20 : public testing::Test, |
| 20 public ScrollbarAnimationControllerClient { | 21 public ScrollbarAnimationControllerClient { |
| 21 public: | 22 public: |
| 22 ScrollbarAnimationControllerLinearFadeTest() | 23 ScrollbarAnimationControllerLinearFadeTest() |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 69 |
| 69 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( | 70 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( |
| 70 scroll_layer_ptr, this, base::TimeDelta::FromSeconds(2), | 71 scroll_layer_ptr, this, base::TimeDelta::FromSeconds(2), |
| 71 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); | 72 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); |
| 72 } | 73 } |
| 73 | 74 |
| 74 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; } | 75 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; } |
| 75 | 76 |
| 76 FakeImplProxy proxy_; | 77 FakeImplProxy proxy_; |
| 77 TestSharedBitmapManager shared_bitmap_manager_; | 78 TestSharedBitmapManager shared_bitmap_manager_; |
| 79 TestTaskGraphRunner task_graph_runner_; |
| 78 FakeLayerTreeHostImpl host_impl_; | 80 FakeLayerTreeHostImpl host_impl_; |
| 79 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; | 81 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; |
| 80 scoped_ptr<LayerImpl> clip_layer_; | 82 scoped_ptr<LayerImpl> clip_layer_; |
| 81 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; | 83 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; |
| 82 | 84 |
| 83 base::Closure start_fade_; | 85 base::Closure start_fade_; |
| 84 base::TimeDelta delay_; | 86 base::TimeDelta delay_; |
| 85 bool is_animating_; | 87 bool is_animating_; |
| 86 bool did_request_redraw_; | 88 bool did_request_redraw_; |
| 87 }; | 89 }; |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 scrollbar_controller_->DidScrollUpdate(false); | 438 scrollbar_controller_->DidScrollUpdate(false); |
| 437 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 439 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
| 438 | 440 |
| 439 time += base::TimeDelta::FromSeconds(1); | 441 time += base::TimeDelta::FromSeconds(1); |
| 440 scrollbar_controller_->DidScrollEnd(); | 442 scrollbar_controller_->DidScrollEnd(); |
| 441 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 443 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
| 442 } | 444 } |
| 443 | 445 |
| 444 } // namespace | 446 } // namespace |
| 445 } // namespace cc | 447 } // namespace cc |
| OLD | NEW |