| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef ScrollbarTestSuite_h | 5 #ifndef ScrollbarTestSuite_h | 
| 6 #define ScrollbarTestSuite_h | 6 #define ScrollbarTestSuite_h | 
| 7 | 7 | 
| 8 #include "platform/heap/GarbageCollected.h" | 8 #include "platform/heap/GarbageCollected.h" | 
| 9 #include "platform/scroll/ScrollableArea.h" | 9 #include "platform/scroll/ScrollableArea.h" | 
| 10 #include "platform/scroll/Scrollbar.h" | 10 #include "platform/scroll/Scrollbar.h" | 
| 11 #include "platform/scroll/ScrollbarThemeMock.h" | 11 #include "platform/scroll/ScrollbarThemeMock.h" | 
| 12 #include "platform/testing/TestingPlatformSupport.h" | 12 #include "platform/testing/TestingPlatformSupport.h" | 
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" | 
| 14 #include "wtf/PtrUtil.h" | 14 #include "wtf/PtrUtil.h" | 
| 15 #include <memory> | 15 #include <memory> | 
| 16 | 16 | 
| 17 namespace blink { | 17 namespace blink { | 
| 18 | 18 | 
| 19 class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, | 19 class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, | 
| 20                            public ScrollableArea { | 20                            public ScrollableArea { | 
| 21   USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); | 21   USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); | 
| 22 | 22 | 
| 23  public: | 23  public: | 
| 24   static MockScrollableArea* create() { return new MockScrollableArea(); } | 24   static MockScrollableArea* create() { return new MockScrollableArea(); } | 
| 25 | 25 | 
| 26   static MockScrollableArea* create(const IntPoint& maximumScrollPosition) { | 26   static MockScrollableArea* create(const ScrollOffset& maximumScrollOffset) { | 
| 27     MockScrollableArea* mock = create(); | 27     MockScrollableArea* mock = create(); | 
| 28     mock->setMaximumScrollPosition(maximumScrollPosition); | 28     mock->setMaximumScrollOffset(maximumScrollOffset); | 
| 29     return mock; | 29     return mock; | 
| 30   } | 30   } | 
| 31 | 31 | 
| 32   MOCK_CONST_METHOD0(visualRectForScrollbarParts, LayoutRect()); | 32   MOCK_CONST_METHOD0(visualRectForScrollbarParts, LayoutRect()); | 
| 33   MOCK_CONST_METHOD0(isActive, bool()); | 33   MOCK_CONST_METHOD0(isActive, bool()); | 
| 34   MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); | 34   MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); | 
| 35   MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); | 35   MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); | 
| 36   MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); | 36   MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); | 
| 37   MOCK_CONST_METHOD0(horizontalScrollbar, Scrollbar*()); | 37   MOCK_CONST_METHOD0(horizontalScrollbar, Scrollbar*()); | 
| 38   MOCK_CONST_METHOD0(verticalScrollbar, Scrollbar*()); | 38   MOCK_CONST_METHOD0(verticalScrollbar, Scrollbar*()); | 
| 39   MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); | 39   MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); | 
| 40   MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); | 40   MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); | 
| 41   MOCK_CONST_METHOD0(contentsSize, IntSize()); | 41   MOCK_CONST_METHOD0(contentsSize, IntSize()); | 
| 42   MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); | 42   MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); | 
| 43   MOCK_CONST_METHOD0(layerForHorizontalScrollbar, GraphicsLayer*()); | 43   MOCK_CONST_METHOD0(layerForHorizontalScrollbar, GraphicsLayer*()); | 
| 44   MOCK_CONST_METHOD0(layerForVerticalScrollbar, GraphicsLayer*()); | 44   MOCK_CONST_METHOD0(layerForVerticalScrollbar, GraphicsLayer*()); | 
| 45 | 45 | 
| 46   bool userInputScrollable(ScrollbarOrientation) const override { return true; } | 46   bool userInputScrollable(ScrollbarOrientation) const override { return true; } | 
| 47   bool scrollbarsCanBeActive() const override { return true; } | 47   bool scrollbarsCanBeActive() const override { return true; } | 
| 48   bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } | 48   bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } | 
| 49   void setScrollOffset(const DoublePoint& offset, ScrollType) override { | 49   void updateScrollOffset(const ScrollOffset& offset, ScrollType) override { | 
| 50     m_scrollPosition = | 50     m_scrollOffset = offset.shrunkTo(m_maximumScrollOffset); | 
| 51         flooredIntPoint(offset).shrunkTo(m_maximumScrollPosition); |  | 
| 52   } | 51   } | 
| 53   IntPoint scrollPosition() const override { return m_scrollPosition; } | 52   IntSize scrollOffsetInt() const override { | 
| 54   IntPoint minimumScrollPosition() const override { return IntPoint(); } | 53     return flooredIntSize(m_scrollOffset); | 
| 55   IntPoint maximumScrollPosition() const override { | 54   } | 
| 56     return m_maximumScrollPosition; | 55   IntSize minimumScrollOffsetInt() const override { return IntSize(); } | 
|  | 56   IntSize maximumScrollOffsetInt() const override { | 
|  | 57     return expandedIntSize(m_maximumScrollOffset); | 
| 57   } | 58   } | 
| 58   int visibleHeight() const override { return 768; } | 59   int visibleHeight() const override { return 768; } | 
| 59   int visibleWidth() const override { return 1024; } | 60   int visibleWidth() const override { return 1024; } | 
| 60   bool scrollAnimatorEnabled() const override { return false; } | 61   bool scrollAnimatorEnabled() const override { return false; } | 
| 61   int pageStep(ScrollbarOrientation) const override { return 0; } | 62   int pageStep(ScrollbarOrientation) const override { return 0; } | 
| 62   void scrollControlWasSetNeedsPaintInvalidation() {} | 63   void scrollControlWasSetNeedsPaintInvalidation() {} | 
| 63 | 64 | 
| 64   using ScrollableArea::horizontalScrollbarNeedsPaintInvalidation; | 65   using ScrollableArea::horizontalScrollbarNeedsPaintInvalidation; | 
| 65   using ScrollableArea::verticalScrollbarNeedsPaintInvalidation; | 66   using ScrollableArea::verticalScrollbarNeedsPaintInvalidation; | 
| 66   using ScrollableArea::clearNeedsPaintInvalidationForScrollControls; | 67   using ScrollableArea::clearNeedsPaintInvalidationForScrollControls; | 
| 67 | 68 | 
| 68   DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); } | 69   DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); } | 
| 69 | 70 | 
| 70  private: | 71  private: | 
| 71   void setMaximumScrollPosition(const IntPoint& maximumScrollPosition) { | 72   void setMaximumScrollOffset(const ScrollOffset& maximumScrollOffset) { | 
| 72     m_maximumScrollPosition = maximumScrollPosition; | 73     m_maximumScrollOffset = maximumScrollOffset; | 
| 73   } | 74   } | 
| 74 | 75 | 
| 75   explicit MockScrollableArea() : m_maximumScrollPosition(IntPoint(0, 100)) {} | 76   explicit MockScrollableArea() : m_maximumScrollOffset(ScrollOffset(0, 100)) {} | 
| 76 | 77 | 
| 77   IntPoint m_scrollPosition; | 78   ScrollOffset m_scrollOffset; | 
| 78   IntPoint m_maximumScrollPosition; | 79   ScrollOffset m_maximumScrollOffset; | 
| 79 }; | 80 }; | 
| 80 | 81 | 
| 81 class ScrollbarTestSuite : public testing::Test { | 82 class ScrollbarTestSuite : public testing::Test { | 
| 82  public: | 83  public: | 
| 83   ScrollbarTestSuite() {} | 84   ScrollbarTestSuite() {} | 
| 84 | 85 | 
| 85   void SetUp() override { | 86   void SetUp() override { | 
| 86     TestingPlatformSupport::Config config; | 87     TestingPlatformSupport::Config config; | 
| 87     config.compositorSupport = Platform::current()->compositorSupport(); | 88     config.compositorSupport = Platform::current()->compositorSupport(); | 
| 88     m_fakePlatform = | 89     m_fakePlatform = | 
| 89         wrapUnique(new TestingPlatformSupportWithMockScheduler(config)); | 90         wrapUnique(new TestingPlatformSupportWithMockScheduler(config)); | 
| 90   } | 91   } | 
| 91 | 92 | 
| 92   void TearDown() override { m_fakePlatform = nullptr; } | 93   void TearDown() override { m_fakePlatform = nullptr; } | 
| 93 | 94 | 
| 94  private: | 95  private: | 
| 95   std::unique_ptr<TestingPlatformSupportWithMockScheduler> m_fakePlatform; | 96   std::unique_ptr<TestingPlatformSupportWithMockScheduler> m_fakePlatform; | 
| 96 }; | 97 }; | 
| 97 | 98 | 
| 98 }  // namespace blink | 99 }  // namespace blink | 
| 99 | 100 | 
| 100 #endif | 101 #endif | 
| OLD | NEW | 
|---|