| 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 "platform/scroll/ScrollableArea.h" | 5 #include "platform/scroll/ScrollableArea.h" |
| 6 | 6 |
| 7 #include "platform/graphics/Color.h" | 7 #include "platform/graphics/Color.h" |
| 8 #include "platform/graphics/GraphicsLayer.h" | 8 #include "platform/graphics/GraphicsLayer.h" |
| 9 #include "platform/scroll/ScrollbarTheme.h" | 9 #include "platform/scroll/ScrollbarTheme.h" |
| 10 #include "platform/scroll/ScrollbarThemeMock.h" | 10 #include "platform/scroll/ScrollbarThemeMock.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 : m_maximumScrollPosition(maximumScrollPosition) { } | 68 : m_maximumScrollPosition(maximumScrollPosition) { } |
| 69 | 69 |
| 70 IntPoint m_scrollPosition; | 70 IntPoint m_scrollPosition; |
| 71 IntPoint m_maximumScrollPosition; | 71 IntPoint m_maximumScrollPosition; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 class ScrollableAreaTest : public testing::Test { | 76 class ScrollableAreaTest : public testing::Test { |
| 77 public: | 77 public: |
| 78 ScrollableAreaTest() : m_oldPlatform(nullptr) { } | 78 ScrollableAreaTest() { } |
| 79 | 79 |
| 80 void SetUp() override | 80 void SetUp() override |
| 81 { | 81 { |
| 82 m_oldPlatform = Platform::current(); | |
| 83 TestingPlatformSupport::Config config; | 82 TestingPlatformSupport::Config config; |
| 84 config.compositorSupport = m_oldPlatform->compositorSupport(); | 83 config.compositorSupport = Platform::current()->compositorSupport(); |
| 85 m_fakePlatform = adoptPtr(new TestingPlatformSupportWithMockScheduler(co
nfig)); | 84 m_fakePlatform = adoptPtr(new TestingPlatformSupportWithMockScheduler(co
nfig)); |
| 86 Platform::initialize(m_fakePlatform.get()); | |
| 87 } | 85 } |
| 88 | 86 |
| 89 void TearDown() override | 87 void TearDown() override |
| 90 { | 88 { |
| 91 Platform::initialize(m_oldPlatform); | |
| 92 m_fakePlatform = nullptr; | 89 m_fakePlatform = nullptr; |
| 93 } | 90 } |
| 94 | 91 |
| 95 private: | 92 private: |
| 96 OwnPtr<TestingPlatformSupportWithMockScheduler> m_fakePlatform; | 93 OwnPtr<TestingPlatformSupportWithMockScheduler> m_fakePlatform; |
| 97 Platform* m_oldPlatform; // Not owned. | |
| 98 }; | 94 }; |
| 99 | 95 |
| 100 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) | 96 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) |
| 101 { | 97 { |
| 102 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(IntPoint(0, 100)); | 98 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(IntPoint(0, 100)); |
| 103 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll); | 99 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll); |
| 104 EXPECT_EQ(100.0, scrollableArea->scrollAnimator().currentPosition().y()); | 100 EXPECT_EQ(100.0, scrollableArea->scrollAnimator().currentPosition().y()); |
| 105 } | 101 } |
| 106 | 102 |
| 107 namespace { | 103 namespace { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(IntPoint(0, 100)); | 282 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(IntPoint(0, 100)); |
| 287 | 283 |
| 288 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); | 284 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); |
| 289 scrollableArea->recalculateScrollbarOverlayStyle(Color(34, 85, 51)); | 285 scrollableArea->recalculateScrollbarOverlayStyle(Color(34, 85, 51)); |
| 290 EXPECT_EQ(ScrollbarOverlayStyleLight, scrollableArea->getScrollbarOverlaySty
le()); | 286 EXPECT_EQ(ScrollbarOverlayStyleLight, scrollableArea->getScrollbarOverlaySty
le()); |
| 291 scrollableArea->recalculateScrollbarOverlayStyle(Color(236, 143, 185)); | 287 scrollableArea->recalculateScrollbarOverlayStyle(Color(236, 143, 185)); |
| 292 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); | 288 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); |
| 293 } | 289 } |
| 294 | 290 |
| 295 } // namespace blink | 291 } // namespace blink |
| OLD | NEW |