Chromium Code Reviews| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 TEST(ScrollAnimatorTest, Enabled) | 104 TEST(ScrollAnimatorTest, Enabled) |
| 105 { | 105 { |
| 106 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(true); | 106 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(true); |
| 107 OwnPtr<ScrollAnimator> scrollAnimator = adoptPtr(new ScrollAnimator(scrollab leArea.get(), getMockedTime)); | 107 ScrollAnimator* scrollAnimator = new ScrollAnimator(scrollableArea.get(), ge tMockedTime); |
|
haraken
2015/12/03 10:45:49
Doesn't this need to be OwnPtrWillBeRawPtr?
peria
2015/12/03 13:42:08
Done.
| |
| 108 | 108 |
| 109 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint())); | 109 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))); | 110 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint(1000, 1000))); |
| 111 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(12); | 111 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(12); |
| 112 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3); | 112 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3); |
| 113 | 113 |
| 114 EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); | 114 EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); |
| 115 | 115 |
| 116 ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScr ollbar, ScrollByLine, 100, -1); | 116 ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScr ollbar, ScrollByLine, 100, -1); |
| 117 EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); | 117 EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 165 |
| 166 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); | 166 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
| 167 EXPECT_NE(0, scrollAnimator->currentPosition().x()); | 167 EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
| 168 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); | 168 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
| 169 reset(*scrollAnimator); | 169 reset(*scrollAnimator); |
| 170 } | 170 } |
| 171 | 171 |
| 172 TEST(ScrollAnimatorTest, Disabled) | 172 TEST(ScrollAnimatorTest, Disabled) |
| 173 { | 173 { |
| 174 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(false); | 174 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(false); |
| 175 OwnPtr<ScrollAnimator> scrollAnimator = adoptPtr(new ScrollAnimator(scrollab leArea.get(), getMockedTime)); | 175 ScrollAnimator* scrollAnimator = new ScrollAnimator(scrollableArea.get(), ge tMockedTime); |
|
haraken
2015/12/03 10:45:49
Ditto.
peria
2015/12/03 13:42:08
Done.
| |
| 176 | 176 |
| 177 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint())); | 177 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint())); |
| 178 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint(1000, 1000))); | 178 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint(1000, 1000))); |
| 179 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(8); | 179 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(8); |
| 180 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(0); | 180 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(0); |
| 181 | 181 |
| 182 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); | 182 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); |
| 183 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); | 183 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
| 184 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); | 184 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
| 185 reset(*scrollAnimator); | 185 reset(*scrollAnimator); |
| 186 | 186 |
| 187 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); | 187 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); |
| 188 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); | 188 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
| 189 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); | 189 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
| 190 reset(*scrollAnimator); | 190 reset(*scrollAnimator); |
| 191 | 191 |
| 192 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByDocument, 100, 1); | 192 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByDocument, 100, 1); |
| 193 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); | 193 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
| 194 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); | 194 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
| 195 reset(*scrollAnimator); | 195 reset(*scrollAnimator); |
| 196 | 196 |
| 197 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 100, 1); | 197 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 100, 1); |
| 198 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); | 198 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
| 199 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); | 199 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
| 200 reset(*scrollAnimator); | 200 reset(*scrollAnimator); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |