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/input/scrollbar_animation_controller_linear_fade.h" | 5 #include "cc/input/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_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 class ScrollbarAnimationControllerLinearFadeTest | 18 class ScrollbarAnimationControllerLinearFadeTest |
20 : public testing::Test, | 19 : public testing::Test, |
21 public ScrollbarAnimationControllerClient { | 20 public ScrollbarAnimationControllerClient { |
22 public: | 21 public: |
23 ScrollbarAnimationControllerLinearFadeTest() | 22 ScrollbarAnimationControllerLinearFadeTest() |
24 : host_impl_(&task_runner_provider_, | 23 : host_impl_(&task_runner_provider_, |
25 &shared_bitmap_manager_, | |
26 &task_graph_runner_), | 24 &task_graph_runner_), |
27 did_request_redraw_(false), | 25 did_request_redraw_(false), |
28 did_request_animate_(false) {} | 26 did_request_animate_(false) {} |
29 | 27 |
30 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, | 28 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, |
31 base::TimeDelta delay) override { | 29 base::TimeDelta delay) override { |
32 start_fade_ = start_fade; | 30 start_fade_ = start_fade; |
33 delay_ = delay; | 31 delay_ = delay; |
34 } | 32 } |
35 void SetNeedsRedrawForScrollbarAnimation() override { | 33 void SetNeedsRedrawForScrollbarAnimation() override { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 70 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
73 | 71 |
74 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( | 72 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( |
75 scroll_layer_ptr->id(), this, base::TimeDelta::FromSeconds(2), | 73 scroll_layer_ptr->id(), this, base::TimeDelta::FromSeconds(2), |
76 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); | 74 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); |
77 } | 75 } |
78 | 76 |
79 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; } | 77 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; } |
80 | 78 |
81 FakeImplTaskRunnerProvider task_runner_provider_; | 79 FakeImplTaskRunnerProvider task_runner_provider_; |
82 TestSharedBitmapManager shared_bitmap_manager_; | |
83 TestTaskGraphRunner task_graph_runner_; | 80 TestTaskGraphRunner task_graph_runner_; |
84 FakeLayerTreeHostImpl host_impl_; | 81 FakeLayerTreeHostImpl host_impl_; |
85 std::unique_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; | 82 std::unique_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; |
86 LayerImpl* clip_layer_; | 83 LayerImpl* clip_layer_; |
87 SolidColorScrollbarLayerImpl* scrollbar_layer_; | 84 SolidColorScrollbarLayerImpl* scrollbar_layer_; |
88 | 85 |
89 base::Closure start_fade_; | 86 base::Closure start_fade_; |
90 base::TimeDelta delay_; | 87 base::TimeDelta delay_; |
91 bool did_request_redraw_; | 88 bool did_request_redraw_; |
92 bool did_request_animate_; | 89 bool did_request_animate_; |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 495 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
499 | 496 |
500 time += base::TimeDelta::FromSeconds(1); | 497 time += base::TimeDelta::FromSeconds(1); |
501 scrollbar_controller_->DidScrollEnd(); | 498 scrollbar_controller_->DidScrollEnd(); |
502 EXPECT_FALSE(did_request_animate_); | 499 EXPECT_FALSE(did_request_animate_); |
503 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 500 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
504 } | 501 } |
505 | 502 |
506 } // namespace | 503 } // namespace |
507 } // namespace cc | 504 } // namespace cc |
OLD | NEW |