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 24 matching lines...) Loading... |
35 #include "platform/scroll/ScrollableArea.h" | 35 #include "platform/scroll/ScrollableArea.h" |
36 #include <gmock/gmock.h> | 36 #include <gmock/gmock.h> |
37 #include <gtest/gtest.h> | 37 #include <gtest/gtest.h> |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 using testing::AtLeast; | 41 using testing::AtLeast; |
42 using testing::Return; | 42 using testing::Return; |
43 using testing::_; | 43 using testing::_; |
44 | 44 |
| 45 namespace { |
| 46 |
45 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro
llableArea>, public ScrollableArea { | 47 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro
llableArea>, public ScrollableArea { |
46 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); | 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); |
47 public: | 49 public: |
48 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(bool scrollAnimator
Enabled) | 50 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(bool scrollAnimator
Enabled) |
49 { | 51 { |
50 return adoptPtrWillBeNoop(new MockScrollableArea(scrollAnimatorEnabled))
; | 52 return adoptPtrWillBeNoop(new MockScrollableArea(scrollAnimatorEnabled))
; |
51 } | 53 } |
52 | 54 |
53 MOCK_CONST_METHOD0(isActive, bool()); | 55 MOCK_CONST_METHOD0(isActive, bool()); |
54 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); | 56 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); |
(...skipping 60 matching lines...) Loading... |
115 m_fp = fp; | 117 m_fp = fp; |
116 m_count++; | 118 m_count++; |
117 } | 119 } |
118 | 120 |
119 private: | 121 private: |
120 explicit MockScrollAnimatorNone(ScrollableArea* scrollableArea) | 122 explicit MockScrollAnimatorNone(ScrollableArea* scrollableArea) |
121 : ScrollAnimator(scrollableArea) { } | 123 : ScrollAnimator(scrollableArea) { } |
122 | 124 |
123 }; | 125 }; |
124 | 126 |
| 127 } // namespace |
| 128 |
125 TEST(ScrollAnimatorEnabled, Enabled) | 129 TEST(ScrollAnimatorEnabled, Enabled) |
126 { | 130 { |
127 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(true); | 131 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(true); |
128 OwnPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone::
create(scrollableArea.get()); | 132 OwnPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone::
create(scrollableArea.get()); |
129 | 133 |
130 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint())); | 134 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint())); |
131 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint(1000, 1000))); | 135 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint(1000, 1000))); |
132 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(4); | 136 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(4); |
133 | 137 |
134 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); | 138 scrollAnimatorNone->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); |
(...skipping 951 matching lines...) Loading... |
1086 double after = m_currentPosition; | 1090 double after = m_currentPosition; |
1087 EXPECT_GE(before, after); | 1091 EXPECT_GE(before, after); |
1088 | 1092 |
1089 t += kAnimationTime; | 1093 t += kAnimationTime; |
1090 for (; result && t < kEndTime; t += kAnimationTime) | 1094 for (; result && t < kEndTime; t += kAnimationTime) |
1091 result = result && animateScroll(t); | 1095 result = result && animateScroll(t); |
1092 EXPECT_GE(before, m_currentPosition); | 1096 EXPECT_GE(before, m_currentPosition); |
1093 } | 1097 } |
1094 | 1098 |
1095 } // namespace blink | 1099 } // namespace blink |
OLD | NEW |