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