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" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 namespace { | 14 namespace { |
15 | 15 |
16 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { | 16 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { |
17 public: | 17 public: |
18 ScrollbarAnimationControllerLinearFadeTest() | 18 ScrollbarAnimationControllerLinearFadeTest() |
19 : m_hostImpl(&m_proxy) | 19 : m_hostImpl(&m_proxy) |
20 { | 20 { |
21 } | 21 } |
22 | 22 |
23 protected: | 23 protected: |
24 virtual void SetUp() | 24 virtual void SetUp() |
25 { | 25 { |
26 m_scrollLayer = LayerImpl::create(&m_hostImpl, 1); | 26 m_scrollLayer = LayerImpl::create(m_hostImpl.activeTree(), 1); |
27 m_scrollLayer->addChild(LayerImpl::create(&m_hostImpl, 2)); | 27 m_scrollLayer->addChild(LayerImpl::create(m_hostImpl.activeTree(), 2)); |
28 m_contentLayer = m_scrollLayer->children()[0]; | 28 m_contentLayer = m_scrollLayer->children()[0]; |
29 m_scrollbarLayer = ScrollbarLayerImpl::create(&m_hostImpl, 3); | 29 m_scrollbarLayer = ScrollbarLayerImpl::create(m_hostImpl.activeTree(), 3
); |
30 | 30 |
31 m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50)); | 31 m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50)); |
32 m_contentLayer->setBounds(gfx::Size(50, 50)); | 32 m_contentLayer->setBounds(gfx::Size(50, 50)); |
33 | 33 |
34 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m
_scrollLayer.get(), 2, 3); | 34 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m
_scrollLayer.get(), 2, 3); |
35 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get(
)); | 35 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get(
)); |
36 } | 36 } |
37 | 37 |
38 FakeImplProxy m_proxy; | 38 FakeImplProxy m_proxy; |
39 FakeLayerTreeHostImpl m_hostImpl; | 39 FakeLayerTreeHostImpl m_hostImpl; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); | 116 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); |
117 m_scrollbarController->animate(10); | 117 m_scrollbarController->animate(10); |
118 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); | 118 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); |
119 m_scrollbarController->animate(11); | 119 m_scrollbarController->animate(11); |
120 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); | 120 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); |
121 | 121 |
122 } | 122 } |
123 | 123 |
124 } // namespace | 124 } // namespace |
125 } // namespace cc | 125 } // namespace cc |
OLD | NEW |