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/scrollbar_layer_impl.h" | 7 #include "cc/layers/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/fake_web_scrollbar_theme_geometry.h" | 10 #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
11 #include "cc/trees/single_thread_proxy.h" | 11 #include "cc/trees/single_thread_proxy.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 namespace { | 15 namespace { |
16 | 16 |
17 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { | 17 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { |
18 public: | 18 public: |
19 ScrollbarAnimationControllerLinearFadeTest() : host_impl_(&proxy_) {} | 19 ScrollbarAnimationControllerLinearFadeTest() : host_impl_(&proxy_) {} |
20 | 20 |
21 protected: | 21 protected: |
22 virtual void SetUp() { | 22 virtual void SetUp() { |
23 scroll_layer_ = LayerImpl::Create(host_impl_.active_tree(), 1); | 23 scroll_layer_ = LayerImpl::Create(host_impl_.active_tree(), 1); |
24 scoped_ptr<ScrollbarGeometryFixedThumb> geometry( | 24 scoped_ptr<ScrollbarGeometryFixedThumb> geometry( |
25 ScrollbarGeometryFixedThumb::Create( | 25 ScrollbarGeometryFixedThumb::Create( |
26 FakeWebScrollbarThemeGeometry::create(false))); | 26 FakeWebScrollbarThemeGeometry::Create(false))); |
27 scrollbar_layer_ = ScrollbarLayerImpl::Create( | 27 scrollbar_layer_ = ScrollbarLayerImpl::Create( |
28 host_impl_.active_tree(), 2, geometry.Pass()); | 28 host_impl_.active_tree(), 2, geometry.Pass()); |
29 | 29 |
30 scroll_layer_->SetMaxScrollOffset(gfx::Vector2d(50, 50)); | 30 scroll_layer_->SetMaxScrollOffset(gfx::Vector2d(50, 50)); |
31 scroll_layer_->SetBounds(gfx::Size(50, 50)); | 31 scroll_layer_->SetBounds(gfx::Size(50, 50)); |
32 scroll_layer_->SetHorizontalScrollbarLayer(scrollbar_layer_.get()); | 32 scroll_layer_->SetHorizontalScrollbarLayer(scrollbar_layer_.get()); |
33 | 33 |
34 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( | 34 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( |
35 scroll_layer_.get(), | 35 scroll_layer_.get(), |
36 base::TimeDelta::FromSeconds(2), | 36 base::TimeDelta::FromSeconds(2), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 scrollbar_controller_->Animate(time); | 157 scrollbar_controller_->Animate(time); |
158 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); | 158 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); |
159 | 159 |
160 time += base::TimeDelta::FromSeconds(1); | 160 time += base::TimeDelta::FromSeconds(1); |
161 scrollbar_controller_->Animate(time); | 161 scrollbar_controller_->Animate(time); |
162 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); | 162 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); |
163 } | 163 } |
164 | 164 |
165 } // namespace | 165 } // namespace |
166 } // namespace cc | 166 } // namespace cc |
OLD | NEW |