| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCScrollbarAnimationControllerLinearFade.h" | 7 #include "CCScrollbarAnimationControllerLinearFade.h" |
| 8 | 8 |
| 9 #include "CCScrollbarLayerImpl.h" | 9 #include "CCScrollbarLayerImpl.h" |
| 10 #include "CCSingleThreadProxy.h" | 10 #include "CCSingleThreadProxy.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using namespace cc; | 13 using namespace cc; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class CCScrollbarAnimationControllerLinearFadeTest : public testing::Test { | 17 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { |
| 18 protected: | 18 protected: |
| 19 virtual void SetUp() | 19 virtual void SetUp() |
| 20 { | 20 { |
| 21 m_scrollLayer = CCLayerImpl::create(1); | 21 m_scrollLayer = LayerImpl::create(1); |
| 22 m_scrollLayer->addChild(CCLayerImpl::create(2)); | 22 m_scrollLayer->addChild(LayerImpl::create(2)); |
| 23 m_contentLayer = m_scrollLayer->children()[0]; | 23 m_contentLayer = m_scrollLayer->children()[0]; |
| 24 m_scrollbarLayer = CCScrollbarLayerImpl::create(3); | 24 m_scrollbarLayer = ScrollbarLayerImpl::create(3); |
| 25 | 25 |
| 26 m_scrollLayer->setMaxScrollPosition(IntSize(50, 50)); | 26 m_scrollLayer->setMaxScrollPosition(IntSize(50, 50)); |
| 27 m_contentLayer->setBounds(IntSize(50, 50)); | 27 m_contentLayer->setBounds(IntSize(50, 50)); |
| 28 | 28 |
| 29 m_scrollbarController = CCScrollbarAnimationControllerLinearFade::create
(m_scrollLayer.get(), 2, 3); | 29 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m
_scrollLayer.get(), 2, 3); |
| 30 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get(
)); | 30 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get(
)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 DebugScopedSetImplThread implThread; | 33 DebugScopedSetImplThread implThread; |
| 34 | 34 |
| 35 scoped_ptr<CCScrollbarAnimationControllerLinearFade> m_scrollbarController; | 35 scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController; |
| 36 scoped_ptr<CCLayerImpl> m_scrollLayer; | 36 scoped_ptr<LayerImpl> m_scrollLayer; |
| 37 CCLayerImpl* m_contentLayer; | 37 LayerImpl* m_contentLayer; |
| 38 scoped_ptr<CCScrollbarLayerImpl> m_scrollbarLayer; | 38 scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer; |
| 39 | 39 |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 TEST_F(CCScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin) | 42 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin) |
| 43 { | 43 { |
| 44 m_scrollbarController->animate(0); | 44 m_scrollbarController->animate(0); |
| 45 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); | 45 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); |
| 46 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0); | 46 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0); |
| 47 m_scrollbarController->animate(0); | 47 m_scrollbarController->animate(0); |
| 48 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); | 48 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 TEST_F(CCScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll) | 51 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll) |
| 52 { | 52 { |
| 53 m_scrollLayer->setScrollDelta(IntSize(1, 1)); | 53 m_scrollLayer->setScrollDelta(IntSize(1, 1)); |
| 54 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0); | 54 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0); |
| 55 m_scrollbarController->animate(0); | 55 m_scrollbarController->animate(0); |
| 56 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); | 56 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); |
| 57 m_scrollbarController->animate(1); | 57 m_scrollbarController->animate(1); |
| 58 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); | 58 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); |
| 59 m_scrollLayer->setScrollDelta(IntSize(2, 2)); | 59 m_scrollLayer->setScrollDelta(IntSize(2, 2)); |
| 60 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); | 60 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); |
| 61 m_scrollbarController->animate(2); | 61 m_scrollbarController->animate(2); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 75 m_scrollbarController->animate(7); | 75 m_scrollbarController->animate(7); |
| 76 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); | 76 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); |
| 77 m_scrollbarController->animate(8); | 77 m_scrollbarController->animate(8); |
| 78 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); | 78 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); |
| 79 m_scrollbarController->animate(9); | 79 m_scrollbarController->animate(9); |
| 80 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); | 80 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); |
| 81 m_scrollbarController->animate(10); | 81 m_scrollbarController->animate(10); |
| 82 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); | 82 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 TEST_F(CCScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch) | 85 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch) |
| 86 { | 86 { |
| 87 m_scrollbarController->didPinchGestureBeginAtTime(0); | 87 m_scrollbarController->didPinchGestureBeginAtTime(0); |
| 88 m_scrollbarController->didPinchGestureUpdateAtTime(0); | 88 m_scrollbarController->didPinchGestureUpdateAtTime(0); |
| 89 m_scrollbarController->animate(0); | 89 m_scrollbarController->animate(0); |
| 90 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); | 90 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); |
| 91 m_scrollbarController->animate(1); | 91 m_scrollbarController->animate(1); |
| 92 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); | 92 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); |
| 93 m_scrollLayer->setScrollDelta(IntSize(1, 1)); | 93 m_scrollLayer->setScrollDelta(IntSize(1, 1)); |
| 94 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); | 94 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); |
| 95 m_scrollbarController->animate(2); | 95 m_scrollbarController->animate(2); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 110 m_scrollbarController->animate(9); | 110 m_scrollbarController->animate(9); |
| 111 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); | 111 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); |
| 112 m_scrollbarController->animate(10); | 112 m_scrollbarController->animate(10); |
| 113 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); | 113 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); |
| 114 m_scrollbarController->animate(11); | 114 m_scrollbarController->animate(11); |
| 115 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); | 115 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); |
| 116 | 116 |
| 117 } | 117 } |
| 118 | 118 |
| 119 } | 119 } |
| OLD | NEW |