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/scrollbar_animation_controller_linear_fade.h" | 5 #include "cc/scrollbar_animation_controller_linear_fade.h" |
6 | 6 |
7 #include "cc/scrollbar_layer_impl.h" | 7 #include "cc/scrollbar_layer_impl.h" |
8 #include "cc/single_thread_proxy.h" | 8 #include "cc/single_thread_proxy.h" |
| 9 #include "cc/test/fake_impl_proxy.h" |
| 10 #include "cc/test/fake_layer_tree_host_impl.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 | 12 |
11 namespace cc { | 13 namespace cc { |
12 namespace { | 14 namespace { |
13 | 15 |
14 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { | 16 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { |
| 17 public: |
| 18 ScrollbarAnimationControllerLinearFadeTest() |
| 19 : m_hostImpl(&m_proxy) |
| 20 { |
| 21 } |
| 22 |
15 protected: | 23 protected: |
16 virtual void SetUp() | 24 virtual void SetUp() |
17 { | 25 { |
18 m_scrollLayer = LayerImpl::create(1); | 26 m_scrollLayer = LayerImpl::create(&m_hostImpl, 1); |
19 m_scrollLayer->addChild(LayerImpl::create(2)); | 27 m_scrollLayer->addChild(LayerImpl::create(&m_hostImpl, 2)); |
20 m_contentLayer = m_scrollLayer->children()[0]; | 28 m_contentLayer = m_scrollLayer->children()[0]; |
21 m_scrollbarLayer = ScrollbarLayerImpl::create(3); | 29 m_scrollbarLayer = ScrollbarLayerImpl::create(&m_hostImpl, 3); |
22 | 30 |
23 m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50)); | 31 m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50)); |
24 m_contentLayer->setBounds(gfx::Size(50, 50)); | 32 m_contentLayer->setBounds(gfx::Size(50, 50)); |
25 | 33 |
26 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m
_scrollLayer.get(), 2, 3); | 34 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m
_scrollLayer.get(), 2, 3); |
27 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get(
)); | 35 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get(
)); |
28 } | 36 } |
29 | 37 |
| 38 FakeImplProxy m_proxy; |
| 39 FakeLayerTreeHostImpl m_hostImpl; |
30 scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController; | 40 scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController; |
31 scoped_ptr<LayerImpl> m_scrollLayer; | 41 scoped_ptr<LayerImpl> m_scrollLayer; |
32 LayerImpl* m_contentLayer; | 42 LayerImpl* m_contentLayer; |
33 scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer; | 43 scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer; |
34 | 44 |
35 }; | 45 }; |
36 | 46 |
37 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin) | 47 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin) |
38 { | 48 { |
39 m_scrollbarController->animate(0); | 49 m_scrollbarController->animate(0); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); | 116 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); |
107 m_scrollbarController->animate(10); | 117 m_scrollbarController->animate(10); |
108 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); | 118 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); |
109 m_scrollbarController->animate(11); | 119 m_scrollbarController->animate(11); |
110 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); | 120 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); |
111 | 121 |
112 } | 122 } |
113 | 123 |
114 } // namespace | 124 } // namespace |
115 } // namespace cc | 125 } // namespace cc |
OLD | NEW |