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