| 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 | 6 |
| 7 #include "platform/scroll/ScrollableArea.h" | 7 #include "platform/scroll/ScrollableArea.h" |
| 8 | 8 |
| 9 #include <gmock/gmock.h> | 9 #include <gmock/gmock.h> |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); | 22 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); |
| 23 MOCK_METHOD2(invalidateScrollbar, void(Scrollbar*, const IntRect&)); | 23 MOCK_METHOD2(invalidateScrollbar, void(Scrollbar*, const IntRect&)); |
| 24 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); | 24 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); |
| 25 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); | 25 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); |
| 26 MOCK_METHOD2(invalidateScrollbarRect, void(Scrollbar*, const IntRect&)); | 26 MOCK_METHOD2(invalidateScrollbarRect, void(Scrollbar*, const IntRect&)); |
| 27 MOCK_METHOD1(invalidateScrollCornerRect, void(const IntRect&)); | 27 MOCK_METHOD1(invalidateScrollCornerRect, void(const IntRect&)); |
| 28 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); | 28 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); |
| 29 MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint()); | 29 MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint()); |
| 30 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); | 30 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); |
| 31 MOCK_CONST_METHOD0(contentsSize, IntSize()); | 31 MOCK_CONST_METHOD0(contentsSize, IntSize()); |
| 32 MOCK_CONST_METHOD0(overhangAmount, IntSize()); | |
| 33 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); | 32 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); |
| 34 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); | 33 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); |
| 35 | 34 |
| 36 virtual bool userInputScrollable(ScrollbarOrientation) const override { retu
rn true; } | 35 virtual bool userInputScrollable(ScrollbarOrientation) const override { retu
rn true; } |
| 37 virtual bool shouldPlaceVerticalScrollbarOnLeft() const override { return fa
lse; } | 36 virtual bool shouldPlaceVerticalScrollbarOnLeft() const override { return fa
lse; } |
| 38 virtual void setScrollOffset(const IntPoint& offset) override { m_scrollPosi
tion = offset.shrunkTo(m_maximumScrollPosition); } | 37 virtual void setScrollOffset(const IntPoint& offset) override { m_scrollPosi
tion = offset.shrunkTo(m_maximumScrollPosition); } |
| 39 virtual IntPoint scrollPosition() const override { return m_scrollPosition;
} | 38 virtual IntPoint scrollPosition() const override { return m_scrollPosition;
} |
| 40 virtual IntPoint maximumScrollPosition() const override { return m_maximumSc
rollPosition; } | 39 virtual IntPoint maximumScrollPosition() const override { return m_maximumSc
rollPosition; } |
| 41 virtual int visibleHeight() const override { return 768; } | 40 virtual int visibleHeight() const override { return 768; } |
| 42 virtual int visibleWidth() const override { return 1024; } | 41 virtual int visibleWidth() const override { return 1024; } |
| 43 virtual bool scrollAnimatorEnabled() const override { return false; } | 42 virtual bool scrollAnimatorEnabled() const override { return false; } |
| 44 virtual int pageStep(ScrollbarOrientation) const override { return 0; } | 43 virtual int pageStep(ScrollbarOrientation) const override { return 0; } |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 IntPoint m_scrollPosition; | 46 IntPoint m_scrollPosition; |
| 48 IntPoint m_maximumScrollPosition; | 47 IntPoint m_maximumScrollPosition; |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 TEST(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) | 50 TEST(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) |
| 52 { | 51 { |
| 53 MockScrollableArea scrollableArea(IntPoint(0, 100)); | 52 MockScrollableArea scrollableArea(IntPoint(0, 100)); |
| 54 scrollableArea.notifyScrollPositionChanged(IntPoint(0, 10000)); | 53 scrollableArea.notifyScrollPositionChanged(IntPoint(0, 10000)); |
| 55 EXPECT_EQ(100.0, scrollableArea.scrollAnimator()->currentPosition().y()); | 54 EXPECT_EQ(100.0, scrollableArea.scrollAnimator()->currentPosition().y()); |
| 56 } | 55 } |
| 57 | 56 |
| 58 } // unnamed namespace | 57 } // unnamed namespace |
| 59 | 58 |
| 60 | 59 |
| OLD | NEW |