| 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_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 ScrollbarAnimationControllerLinearFadeTest | 19 class ScrollbarAnimationControllerLinearFadeTest |
| 20 : public testing::Test, | 20 : public testing::Test, |
| 21 public ScrollbarAnimationControllerClient { | 21 public ScrollbarAnimationControllerClient { |
| 22 public: | 22 public: |
| 23 ScrollbarAnimationControllerLinearFadeTest() | 23 ScrollbarAnimationControllerLinearFadeTest() |
| 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 did_request_redraw_(false), | 27 did_request_redraw_(false), |
| 26 did_request_animate_(false) {} | 28 did_request_animate_(false) {} |
| 27 | 29 |
| 28 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, | 30 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, |
| 29 base::TimeDelta delay) override { | 31 base::TimeDelta delay) override { |
| 30 start_fade_ = start_fade; | 32 start_fade_ = start_fade; |
| 31 delay_ = delay; | 33 delay_ = delay; |
| 32 } | 34 } |
| 33 void SetNeedsRedrawForScrollbarAnimation() override { | 35 void SetNeedsRedrawForScrollbarAnimation() override { |
| 34 did_request_redraw_ = true; | 36 did_request_redraw_ = true; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 clip_layer_->SetBounds(gfx::Size(100, 100)); | 68 clip_layer_->SetBounds(gfx::Size(100, 100)); |
| 67 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); | 69 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); |
| 68 | 70 |
| 69 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( | 71 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( |
| 70 scroll_layer_ptr->id(), this, base::TimeDelta::FromSeconds(2), | 72 scroll_layer_ptr->id(), this, base::TimeDelta::FromSeconds(2), |
| 71 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); | 73 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); |
| 72 } | 74 } |
| 73 | 75 |
| 74 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; } | 76 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; } |
| 75 | 77 |
| 76 FakeImplProxy proxy_; | 78 FakeImplTaskRunnerProvider task_runner_provider_; |
| 77 TestSharedBitmapManager shared_bitmap_manager_; | 79 TestSharedBitmapManager shared_bitmap_manager_; |
| 78 TestTaskGraphRunner task_graph_runner_; | 80 TestTaskGraphRunner task_graph_runner_; |
| 79 FakeLayerTreeHostImpl host_impl_; | 81 FakeLayerTreeHostImpl host_impl_; |
| 80 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; | 82 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; |
| 81 scoped_ptr<LayerImpl> clip_layer_; | 83 scoped_ptr<LayerImpl> clip_layer_; |
| 82 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; | 84 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; |
| 83 | 85 |
| 84 base::Closure start_fade_; | 86 base::Closure start_fade_; |
| 85 base::TimeDelta delay_; | 87 base::TimeDelta delay_; |
| 86 bool did_request_redraw_; | 88 bool did_request_redraw_; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 479 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
| 478 | 480 |
| 479 time += base::TimeDelta::FromSeconds(1); | 481 time += base::TimeDelta::FromSeconds(1); |
| 480 scrollbar_controller_->DidScrollEnd(); | 482 scrollbar_controller_->DidScrollEnd(); |
| 481 EXPECT_FALSE(did_request_animate_); | 483 EXPECT_FALSE(did_request_animate_); |
| 482 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 484 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
| 483 } | 485 } |
| 484 | 486 |
| 485 } // namespace | 487 } // namespace |
| 486 } // namespace cc | 488 } // namespace cc |
| OLD | NEW |