| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 class MockScrollableArea : public ScrollableArea { | 46 class MockScrollableArea : public ScrollableArea { |
| 47 public: | 47 public: |
| 48 MockScrollableArea(bool scrollAnimatorEnabled) | 48 MockScrollableArea(bool scrollAnimatorEnabled) |
| 49 : m_scrollAnimatorEnabled(scrollAnimatorEnabled) { } | 49 : m_scrollAnimatorEnabled(scrollAnimatorEnabled) { } |
| 50 | 50 |
| 51 MOCK_CONST_METHOD0(isActive, bool()); | 51 MOCK_CONST_METHOD0(isActive, bool()); |
| 52 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); | 52 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); |
| 53 MOCK_METHOD2(invalidateScrollbar, void(Scrollbar*, const IntRect&)); | 53 MOCK_METHOD2(invalidateScrollbar, void(Scrollbar*, const IntRect&)); |
| 54 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); | 54 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); |
| 55 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); | 55 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); |
| 56 MOCK_METHOD1(setScrollOffset, void(const IntPoint&)); | 56 MOCK_METHOD2(setScrollOffset, void(const IntPoint&, ScrollType)); |
| 57 MOCK_METHOD2(invalidateScrollbarRect, void(Scrollbar*, const IntRect&)); | 57 MOCK_METHOD2(invalidateScrollbarRect, void(Scrollbar*, const IntRect&)); |
| 58 MOCK_METHOD1(invalidateScrollCornerRect, void(const IntRect&)); | 58 MOCK_METHOD1(invalidateScrollCornerRect, void(const IntRect&)); |
| 59 MOCK_METHOD1(setScrollOffsetFromAnimation, void(const IntPoint&)); | 59 MOCK_METHOD1(setScrollOffsetFromAnimation, void(const IntPoint&)); |
| 60 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); | 60 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); |
| 61 MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint()); | 61 MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint()); |
| 62 MOCK_CONST_METHOD0(maximumScrollPosition, IntPoint()); | 62 MOCK_CONST_METHOD0(maximumScrollPosition, IntPoint()); |
| 63 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); | 63 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); |
| 64 MOCK_CONST_METHOD0(contentsSize, IntSize()); | 64 MOCK_CONST_METHOD0(contentsSize, IntSize()); |
| 65 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); | 65 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); |
| 66 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); | 66 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 m_fp = FloatPoint::zero(); | 100 m_fp = FloatPoint::zero(); |
| 101 m_count = 0; | 101 m_count = 0; |
| 102 } | 102 } |
| 103 | 103 |
| 104 virtual void fireUpAnAnimation(FloatPoint fp) | 104 virtual void fireUpAnAnimation(FloatPoint fp) |
| 105 { | 105 { |
| 106 m_fp = fp; | 106 m_fp = fp; |
| 107 m_count++; | 107 m_count++; |
| 108 } | 108 } |
| 109 | 109 |
| 110 MOCK_METHOD1(scrollToOffsetWithoutAnimation, void(const FloatPoint&)); | |
| 111 private: | 110 private: |
| 112 explicit MockScrollAnimatorNone(ScrollableArea* scrollableArea) | 111 explicit MockScrollAnimatorNone(ScrollableArea* scrollableArea) |
| 113 : ScrollAnimatorNone(scrollableArea) { } | 112 : ScrollAnimatorNone(scrollableArea) { } |
| 114 | 113 |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 TEST(ScrollAnimatorEnabled, Enabled) | 116 TEST(ScrollAnimatorEnabled, Enabled) |
| 118 { | 117 { |
| 119 MockScrollableArea scrollableArea(true); | 118 MockScrollableArea scrollableArea(true); |
| 120 RefPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone::
create(&scrollableArea); | 119 RefPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone::
create(&scrollableArea); |
| 121 | 120 |
| 122 EXPECT_CALL(scrollableArea, scrollSize(_)).Times(AtLeast(1)).WillRepeatedly(
Return(1000)); | 121 EXPECT_CALL(scrollableArea, scrollSize(_)).Times(AtLeast(1)).WillRepeatedly(
Return(1000)); |
| 123 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint())); | 122 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint())); |
| 124 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint(1000, 1000))); | 123 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint(1000, 1000))); |
| 125 EXPECT_CALL(scrollableArea, setScrollOffset(_)).Times(4); | 124 EXPECT_CALL(scrollableArea, setScrollOffset(_, _)).Times(4); |
| 126 | 125 |
| 127 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); | 126 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); |
| 128 EXPECT_NE(100, scrollAnimatorNone->currentX()); | 127 EXPECT_NE(100, scrollAnimatorNone->currentX()); |
| 129 EXPECT_NE(0, scrollAnimatorNone->currentX()); | 128 EXPECT_NE(0, scrollAnimatorNone->currentX()); |
| 130 EXPECT_EQ(0, scrollAnimatorNone->currentY()); | 129 EXPECT_EQ(0, scrollAnimatorNone->currentY()); |
| 131 scrollAnimatorNone->reset(); | 130 scrollAnimatorNone->reset(); |
| 132 | 131 |
| 133 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); | 132 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); |
| 134 EXPECT_NE(100, scrollAnimatorNone->currentX()); | 133 EXPECT_NE(100, scrollAnimatorNone->currentX()); |
| 135 EXPECT_NE(0, scrollAnimatorNone->currentX()); | 134 EXPECT_NE(0, scrollAnimatorNone->currentX()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 149 scrollAnimatorNone->reset(); | 148 scrollAnimatorNone->reset(); |
| 150 } | 149 } |
| 151 | 150 |
| 152 TEST(ScrollAnimatorEnabled, Disabled) | 151 TEST(ScrollAnimatorEnabled, Disabled) |
| 153 { | 152 { |
| 154 MockScrollableArea scrollableArea(false); | 153 MockScrollableArea scrollableArea(false); |
| 155 RefPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone::
create(&scrollableArea); | 154 RefPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone::
create(&scrollableArea); |
| 156 | 155 |
| 157 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint())); | 156 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint())); |
| 158 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint(1000, 1000))); | 157 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR
epeatedly(Return(IntPoint(1000, 1000))); |
| 159 EXPECT_CALL(scrollableArea, setScrollOffset(_)).Times(4); | 158 EXPECT_CALL(scrollableArea, setScrollOffset(_, _)).Times(4); |
| 160 | 159 |
| 161 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); | 160 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); |
| 162 EXPECT_EQ(100, scrollAnimatorNone->currentX()); | 161 EXPECT_EQ(100, scrollAnimatorNone->currentX()); |
| 163 EXPECT_EQ(0, scrollAnimatorNone->currentY()); | 162 EXPECT_EQ(0, scrollAnimatorNone->currentY()); |
| 164 scrollAnimatorNone->reset(); | 163 scrollAnimatorNone->reset(); |
| 165 | 164 |
| 166 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); | 165 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); |
| 167 EXPECT_EQ(100, scrollAnimatorNone->currentX()); | 166 EXPECT_EQ(100, scrollAnimatorNone->currentX()); |
| 168 EXPECT_EQ(0, scrollAnimatorNone->currentY()); | 167 EXPECT_EQ(0, scrollAnimatorNone->currentY()); |
| 169 scrollAnimatorNone->reset(); | 168 scrollAnimatorNone->reset(); |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 EXPECT_TRUE(result); | 1047 EXPECT_TRUE(result); |
| 1049 result = result && animateScroll(t); | 1048 result = result && animateScroll(t); |
| 1050 double after = m_currentPosition; | 1049 double after = m_currentPosition; |
| 1051 EXPECT_GE(before, after); | 1050 EXPECT_GE(before, after); |
| 1052 | 1051 |
| 1053 t += kAnimationTime; | 1052 t += kAnimationTime; |
| 1054 for (; result && t < kEndTime; t += kAnimationTime) | 1053 for (; result && t < kEndTime; t += kAnimationTime) |
| 1055 result = result && animateScroll(t); | 1054 result = result && animateScroll(t); |
| 1056 EXPECT_GE(before, m_currentPosition); | 1055 EXPECT_GE(before, m_currentPosition); |
| 1057 } | 1056 } |
| OLD | NEW |