| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 bool m_scrollAnimatorEnabled; | 94 bool m_scrollAnimatorEnabled; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| 98 | 98 |
| 99 static void reset(ScrollAnimator& scrollAnimator) | 99 static void reset(ScrollAnimator& scrollAnimator) |
| 100 { | 100 { |
| 101 scrollAnimator.scrollToOffsetWithoutAnimation(FloatPoint()); | 101 scrollAnimator.scrollToOffsetWithoutAnimation(FloatPoint()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // TODO(skobes): Add unit tests for composited scrolling paths. |
| 105 |
| 104 TEST(ScrollAnimatorTest, MainThreadEnabled) | 106 TEST(ScrollAnimatorTest, MainThreadEnabled) |
| 105 { | 107 { |
| 106 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(true); | 108 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::
create(true); |
| 107 OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(new S
crollAnimator(scrollableArea.get(), getMockedTime)); | 109 OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(new S
crollAnimator(scrollableArea.get(), getMockedTime)); |
| 108 | 110 |
| 109 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint())); | 111 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint())); |
| 110 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint(1000, 1000))); | 112 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will
Repeatedly(Return(IntPoint(1000, 1000))); |
| 111 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(9); | 113 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(9); |
| 112 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3); | 114 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(6); |
| 113 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)).WillRepe
atedly(Return(true)); | 115 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)).WillRepe
atedly(Return(true)); |
| 114 | 116 |
| 115 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); | 117 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
| 116 | 118 |
| 117 ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScr
ollbar, ScrollByLine, 100, -1); | 119 ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScr
ollbar, ScrollByLine, 100, -1); |
| 118 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); | 120 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
| 119 EXPECT_FALSE(result.didScroll); | 121 EXPECT_FALSE(result.didScroll); |
| 120 EXPECT_FLOAT_EQ(-1.0f, result.unusedScrollDelta); | 122 EXPECT_FLOAT_EQ(-1.0f, result.unusedScrollDelta); |
| 121 | 123 |
| 122 result = scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100,
1); | 124 result = scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100,
1); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); | 201 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
| 200 reset(*scrollAnimator); | 202 reset(*scrollAnimator); |
| 201 | 203 |
| 202 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 100, 1); | 204 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 100, 1); |
| 203 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); | 205 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
| 204 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); | 206 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
| 205 reset(*scrollAnimator); | 207 reset(*scrollAnimator); |
| 206 } | 208 } |
| 207 | 209 |
| 208 } // namespace blink | 210 } // namespace blink |
| OLD | NEW |