Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 static double gMockedTime = 0.0; 44 static double gMockedTime = 0.0;
45 45
46 static double getMockedTime() 46 static double getMockedTime()
47 { 47 {
48 return gMockedTime; 48 return gMockedTime;
49 } 49 }
50 50
51 namespace { 51 namespace {
52 52
53 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro llableArea>, public ScrollableArea { 53 class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, public ScrollableArea {
54 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); 54 USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea);
55 public: 55 public:
56 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(bool scrollAnimator Enabled) 56 static RawPtr<MockScrollableArea> create(bool scrollAnimatorEnabled)
57 { 57 {
58 return adoptPtrWillBeNoop(new MockScrollableArea(scrollAnimatorEnabled)) ; 58 return (new MockScrollableArea(scrollAnimatorEnabled));
59 } 59 }
60 60
61 MOCK_CONST_METHOD0(isActive, bool()); 61 MOCK_CONST_METHOD0(isActive, bool());
62 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); 62 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation));
63 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); 63 MOCK_CONST_METHOD0(isScrollCornerVisible, bool());
64 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); 64 MOCK_CONST_METHOD0(scrollCornerRect, IntRect());
65 MOCK_METHOD2(setScrollOffset, void(const IntPoint&, ScrollType)); 65 MOCK_METHOD2(setScrollOffset, void(const IntPoint&, ScrollType));
66 MOCK_METHOD0(scrollControlWasSetNeedsPaintInvalidation, void()); 66 MOCK_METHOD0(scrollControlWasSetNeedsPaintInvalidation, void());
67 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); 67 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*());
68 MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint()); 68 MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint());
(...skipping 29 matching lines...) Expand all
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. 104 // TODO(skobes): Add unit tests for composited scrolling paths.
105 105
106 TEST(ScrollAnimatorTest, MainThreadEnabled) 106 TEST(ScrollAnimatorTest, MainThreadEnabled)
107 { 107 {
108 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(true); 108 RawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::create(true) ;
109 OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(new S crollAnimator(scrollableArea.get(), getMockedTime)); 109 RawPtr<ScrollAnimator> scrollAnimator = (new ScrollAnimator(scrollableArea.g et(), getMockedTime));
110 110
111 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint())); 111 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint()));
112 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)));
113 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(9); 113 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(9);
114 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(6); 114 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(6);
115 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)).WillRepe atedly(Return(true)); 115 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)).WillRepe atedly(Return(true));
116 116
117 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); 117 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService());
118 118
119 ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScr ollbar, ScrollByLine, 100, -1); 119 ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScr ollbar, ScrollByLine, 100, -1);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); 173 EXPECT_EQ(100, scrollAnimator->currentPosition().x());
174 EXPECT_NE(0, scrollAnimator->currentPosition().x()); 174 EXPECT_NE(0, scrollAnimator->currentPosition().x());
175 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); 175 EXPECT_EQ(0, scrollAnimator->currentPosition().y());
176 reset(*scrollAnimator); 176 reset(*scrollAnimator);
177 } 177 }
178 178
179 // Test that a smooth scroll offset animation is aborted when followed by a 179 // Test that a smooth scroll offset animation is aborted when followed by a
180 // non-smooth scroll offset animation. 180 // non-smooth scroll offset animation.
181 TEST(ScrollAnimatorTest, AnimatedScrollAborted) 181 TEST(ScrollAnimatorTest, AnimatedScrollAborted)
182 { 182 {
183 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = 183 RawPtr<MockScrollableArea> scrollableArea =
184 MockScrollableArea::create(true); 184 MockScrollableArea::create(true);
185 OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop( 185 RawPtr<ScrollAnimator> scrollAnimator = (
186 new ScrollAnimator(scrollableArea.get(), getMockedTime)); 186 new ScrollAnimator(scrollableArea.get(), getMockedTime));
187 187
188 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)) 188 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1))
189 .WillRepeatedly(Return(IntPoint())); 189 .WillRepeatedly(Return(IntPoint()));
190 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)) 190 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1))
191 .WillRepeatedly(Return(IntPoint(1000, 1000))); 191 .WillRepeatedly(Return(IntPoint(1000, 1000)));
192 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(3); 192 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(3);
193 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2); 193 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2);
194 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)) 194 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1))
195 .WillRepeatedly(Return(true)); 195 .WillRepeatedly(Return(true));
(...skipping 24 matching lines...) Expand all
220 EXPECT_TRUE(result.didScroll); 220 EXPECT_TRUE(result.didScroll);
221 EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); 221 EXPECT_FALSE(scrollAnimator->hasRunningAnimation());
222 EXPECT_EQ(x + 100, scrollAnimator->currentPosition().x()); 222 EXPECT_EQ(x + 100, scrollAnimator->currentPosition().x());
223 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); 223 EXPECT_EQ(0, scrollAnimator->currentPosition().y());
224 224
225 reset(*scrollAnimator); 225 reset(*scrollAnimator);
226 } 226 }
227 227
228 TEST(ScrollAnimatorTest, Disabled) 228 TEST(ScrollAnimatorTest, Disabled)
229 { 229 {
230 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(false); 230 RawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::create(false );
231 OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(new S crollAnimator(scrollableArea.get(), getMockedTime)); 231 RawPtr<ScrollAnimator> scrollAnimator = (new ScrollAnimator(scrollableArea.g et(), getMockedTime));
232 232
233 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint())); 233 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint()));
234 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint(1000, 1000))); 234 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).Will Repeatedly(Return(IntPoint(1000, 1000)));
235 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(8); 235 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(8);
236 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(0); 236 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(0);
237 237
238 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); 238 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1);
239 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); 239 EXPECT_EQ(100, scrollAnimator->currentPosition().x());
240 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); 240 EXPECT_EQ(0, scrollAnimator->currentPosition().y());
241 reset(*scrollAnimator); 241 reset(*scrollAnimator);
242 242
243 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); 243 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1);
244 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); 244 EXPECT_EQ(100, scrollAnimator->currentPosition().x());
245 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); 245 EXPECT_EQ(0, scrollAnimator->currentPosition().y());
246 reset(*scrollAnimator); 246 reset(*scrollAnimator);
247 247
248 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByDocument, 100, 1); 248 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByDocument, 100, 1);
249 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); 249 EXPECT_EQ(100, scrollAnimator->currentPosition().x());
250 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); 250 EXPECT_EQ(0, scrollAnimator->currentPosition().y());
251 reset(*scrollAnimator); 251 reset(*scrollAnimator);
252 252
253 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 100, 1); 253 scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 100, 1);
254 EXPECT_EQ(100, scrollAnimator->currentPosition().x()); 254 EXPECT_EQ(100, scrollAnimator->currentPosition().x());
255 EXPECT_EQ(0, scrollAnimator->currentPosition().y()); 255 EXPECT_EQ(0, scrollAnimator->currentPosition().y());
256 reset(*scrollAnimator); 256 reset(*scrollAnimator);
257 } 257 }
258 258
259 } // namespace blink 259 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698