| 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/input/scrollbar_animation_controller_thinning.h" | 5 #include "cc/input/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_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" |
| 11 #include "cc/test/test_shared_bitmap_manager.h" | |
| 12 #include "cc/test/test_task_graph_runner.h" | 11 #include "cc/test/test_task_graph_runner.h" |
| 13 #include "cc/trees/layer_tree_impl.h" | 12 #include "cc/trees/layer_tree_impl.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 14 |
| 16 namespace cc { | 15 namespace cc { |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 // These constants are hard-coded and should match the values in | 18 // These constants are hard-coded and should match the values in |
| 20 // scrollbar_animation_controller_thinning.cc. | 19 // scrollbar_animation_controller_thinning.cc. |
| 21 const float kIdleThicknessScale = 0.4f; | 20 const float kIdleThicknessScale = 0.4f; |
| 22 const float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f; | 21 const float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f; |
| 23 | 22 |
| 24 class ScrollbarAnimationControllerThinningTest | 23 class ScrollbarAnimationControllerThinningTest |
| 25 : public testing::Test, | 24 : public testing::Test, |
| 26 public ScrollbarAnimationControllerClient { | 25 public ScrollbarAnimationControllerClient { |
| 27 public: | 26 public: |
| 28 ScrollbarAnimationControllerThinningTest() | 27 ScrollbarAnimationControllerThinningTest() |
| 29 : host_impl_(&task_runner_provider_, | 28 : host_impl_(&task_runner_provider_, |
| 30 &shared_bitmap_manager_, | |
| 31 &task_graph_runner_) {} | 29 &task_graph_runner_) {} |
| 32 | 30 |
| 33 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, | 31 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, |
| 34 base::TimeDelta delay) override { | 32 base::TimeDelta delay) override { |
| 35 start_fade_ = start_fade; | 33 start_fade_ = start_fade; |
| 36 delay_ = delay; | 34 delay_ = delay; |
| 37 } | 35 } |
| 38 void SetNeedsRedrawForScrollbarAnimation() override { | 36 void SetNeedsRedrawForScrollbarAnimation() override { |
| 39 did_request_redraw_ = true; | 37 did_request_redraw_ = true; |
| 40 } | 38 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 clip_layer_->SetBounds(gfx::Size(100, 100)); | 80 clip_layer_->SetBounds(gfx::Size(100, 100)); |
| 83 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); | 81 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); |
| 84 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 82 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 85 | 83 |
| 86 scrollbar_controller_ = ScrollbarAnimationControllerThinning::Create( | 84 scrollbar_controller_ = ScrollbarAnimationControllerThinning::Create( |
| 87 scroll_layer_ptr->id(), this, kDelayBeforeStarting, | 85 scroll_layer_ptr->id(), this, kDelayBeforeStarting, |
| 88 kResizeDelayBeforeStarting, kFadeDuration, kThinningDuration); | 86 kResizeDelayBeforeStarting, kFadeDuration, kThinningDuration); |
| 89 } | 87 } |
| 90 | 88 |
| 91 FakeImplTaskRunnerProvider task_runner_provider_; | 89 FakeImplTaskRunnerProvider task_runner_provider_; |
| 92 TestSharedBitmapManager shared_bitmap_manager_; | |
| 93 TestTaskGraphRunner task_graph_runner_; | 90 TestTaskGraphRunner task_graph_runner_; |
| 94 FakeLayerTreeHostImpl host_impl_; | 91 FakeLayerTreeHostImpl host_impl_; |
| 95 std::unique_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_; | 92 std::unique_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_; |
| 96 LayerImpl* clip_layer_; | 93 LayerImpl* clip_layer_; |
| 97 SolidColorScrollbarLayerImpl* scrollbar_layer_; | 94 SolidColorScrollbarLayerImpl* scrollbar_layer_; |
| 98 | 95 |
| 99 base::Closure start_fade_; | 96 base::Closure start_fade_; |
| 100 base::TimeDelta delay_; | 97 base::TimeDelta delay_; |
| 101 bool did_request_redraw_; | 98 bool did_request_redraw_; |
| 102 bool did_request_animate_; | 99 bool did_request_animate_; |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 scrollbar_controller_->Animate(time); | 923 scrollbar_controller_->Animate(time); |
| 927 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity()); | 924 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity()); |
| 928 | 925 |
| 929 time += kFadeDuration / 2; | 926 time += kFadeDuration / 2; |
| 930 scrollbar_controller_->Animate(time); | 927 scrollbar_controller_->Animate(time); |
| 931 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 928 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
| 932 } | 929 } |
| 933 | 930 |
| 934 } // namespace | 931 } // namespace |
| 935 } // namespace cc | 932 } // namespace cc |
| OLD | NEW |