| 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/test_shared_bitmap_manager.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace cc { | 13 namespace cc { |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { | 16 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { |
| 16 public: | 17 public: |
| 17 ScrollbarAnimationControllerLinearFadeTest() : host_impl_(&proxy_) {} | 18 ScrollbarAnimationControllerLinearFadeTest() |
| 19 : host_impl_(&proxy_, &shared_bitmap_manager_) {} |
| 18 | 20 |
| 19 protected: | 21 protected: |
| 20 virtual void SetUp() { | 22 virtual void SetUp() { |
| 21 const int kThumbThickness = 10; | 23 const int kThumbThickness = 10; |
| 22 const bool kIsLeftSideVerticalScrollbar = false; | 24 const bool kIsLeftSideVerticalScrollbar = false; |
| 23 const bool kIsOverlayScrollbar = true; // Allow opacity animations. | 25 const bool kIsOverlayScrollbar = true; // Allow opacity animations. |
| 24 | 26 |
| 25 scoped_ptr<LayerImpl> scroll_layer = | 27 scoped_ptr<LayerImpl> scroll_layer = |
| 26 LayerImpl::Create(host_impl_.active_tree(), 1); | 28 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 27 scrollbar_layer_ = | 29 scrollbar_layer_ = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 clip_layer_->SetBounds(gfx::Size(100, 100)); | 43 clip_layer_->SetBounds(gfx::Size(100, 100)); |
| 42 scroll_layer_ptr->SetBounds(gfx::Size(50, 50)); | 44 scroll_layer_ptr->SetBounds(gfx::Size(50, 50)); |
| 43 | 45 |
| 44 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( | 46 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( |
| 45 scroll_layer_ptr, | 47 scroll_layer_ptr, |
| 46 base::TimeDelta::FromSeconds(2), | 48 base::TimeDelta::FromSeconds(2), |
| 47 base::TimeDelta::FromSeconds(3)); | 49 base::TimeDelta::FromSeconds(3)); |
| 48 } | 50 } |
| 49 | 51 |
| 50 FakeImplProxy proxy_; | 52 FakeImplProxy proxy_; |
| 53 TestSharedBitmapManager shared_bitmap_manager_; |
| 51 FakeLayerTreeHostImpl host_impl_; | 54 FakeLayerTreeHostImpl host_impl_; |
| 52 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; | 55 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; |
| 53 scoped_ptr<LayerImpl> clip_layer_; | 56 scoped_ptr<LayerImpl> clip_layer_; |
| 54 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; | 57 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; |
| 55 }; | 58 }; |
| 56 | 59 |
| 57 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) { | 60 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) { |
| 58 scrollbar_controller_->Animate(base::TimeTicks()); | 61 scrollbar_controller_->Animate(base::TimeTicks()); |
| 59 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); | 62 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); |
| 60 } | 63 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 255 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
| 253 | 256 |
| 254 time += base::TimeDelta::FromSeconds(1); | 257 time += base::TimeDelta::FromSeconds(1); |
| 255 scrollbar_controller_->DidScrollGestureEnd(time); | 258 scrollbar_controller_->DidScrollGestureEnd(time); |
| 256 EXPECT_TRUE(scrollbar_controller_->IsAnimating()); | 259 EXPECT_TRUE(scrollbar_controller_->IsAnimating()); |
| 257 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 260 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
| 258 } | 261 } |
| 259 | 262 |
| 260 } // namespace | 263 } // namespace |
| 261 } // namespace cc | 264 } // namespace cc |
| OLD | NEW |