| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "platform/scroll/ScrollableArea.h" | 6 #include "platform/scroll/ScrollableArea.h" |
| 7 | 7 |
| 8 #include "platform/TestingPlatformSupport.h" | 8 #include "platform/TestingPlatformSupport.h" |
| 9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 10 #include "public/platform/WebScheduler.h" | 10 #include "public/platform/WebScheduler.h" |
| 11 #include "public/platform/WebThread.h" | 11 #include "public/platform/WebThread.h" |
| 12 #include <gmock/gmock.h> | 12 #include <gmock/gmock.h> |
| 13 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 namespace { |
| 18 |
| 17 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro
llableArea>, public ScrollableArea { | 19 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro
llableArea>, public ScrollableArea { |
| 18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); | 20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); |
| 19 public: | 21 public: |
| 20 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(const IntPoint& max
imumScrollPosition) | 22 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(const IntPoint& max
imumScrollPosition) |
| 21 { | 23 { |
| 22 return adoptPtrWillBeNoop(new MockScrollableArea(maximumScrollPosition))
; | 24 return adoptPtrWillBeNoop(new MockScrollableArea(maximumScrollPosition))
; |
| 23 } | 25 } |
| 24 | 26 |
| 25 MOCK_CONST_METHOD0(isActive, bool()); | 27 MOCK_CONST_METHOD0(isActive, bool()); |
| 26 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); | 28 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 93 |
| 92 WebThread* currentThread() override | 94 WebThread* currentThread() override |
| 93 { | 95 { |
| 94 return &m_webThread; | 96 return &m_webThread; |
| 95 } | 97 } |
| 96 | 98 |
| 97 private: | 99 private: |
| 98 FakeWebThread m_webThread; | 100 FakeWebThread m_webThread; |
| 99 }; | 101 }; |
| 100 | 102 |
| 103 } // namespace |
| 104 |
| 101 class ScrollableAreaTest : public testing::Test { | 105 class ScrollableAreaTest : public testing::Test { |
| 102 public: | 106 public: |
| 103 ScrollableAreaTest() : m_oldPlatform(nullptr) { } | 107 ScrollableAreaTest() : m_oldPlatform(nullptr) { } |
| 104 | 108 |
| 105 void SetUp() override | 109 void SetUp() override |
| 106 { | 110 { |
| 107 m_oldPlatform = Platform::current(); | 111 m_oldPlatform = Platform::current(); |
| 108 Platform::initialize(&m_fakePlatform); | 112 Platform::initialize(&m_fakePlatform); |
| 109 } | 113 } |
| 110 | 114 |
| 111 void TearDown() override | 115 void TearDown() override |
| 112 { | 116 { |
| 113 Platform::initialize(m_oldPlatform); | 117 Platform::initialize(m_oldPlatform); |
| 114 } | 118 } |
| 115 | 119 |
| 116 private: | 120 private: |
| 117 FakePlatform m_fakePlatform; | 121 FakePlatform m_fakePlatform; |
| 118 Platform* m_oldPlatform; // Not owned. | 122 Platform* m_oldPlatform; // Not owned. |
| 119 }; | 123 }; |
| 120 | 124 |
| 121 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) | 125 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) |
| 122 { | 126 { |
| 123 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(IntPoint(0, 100)); | 127 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(IntPoint(0, 100)); |
| 124 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll); | 128 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll); |
| 125 EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y()); | 129 EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y()); |
| 126 } | 130 } |
| 127 | 131 |
| 128 } // namespace blink | 132 } // namespace blink |
| OLD | NEW |