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

Side by Side Diff: Source/web/tests/ScrollAnimatorNoneTest.cpp

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch LocalFrame::m_pluginElements rep to HashSet<HTMLPlugInElement*> Created 6 years, 2 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
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 virtual int visibleWidth() const override { return 1024; } 73 virtual int visibleWidth() const override { return 1024; }
74 virtual bool scrollAnimatorEnabled() const override { return m_scrollAnimato rEnabled; } 74 virtual bool scrollAnimatorEnabled() const override { return m_scrollAnimato rEnabled; }
75 virtual int pageStep(ScrollbarOrientation) const override { return 0; } 75 virtual int pageStep(ScrollbarOrientation) const override { return 0; }
76 76
77 private: 77 private:
78 bool m_scrollAnimatorEnabled; 78 bool m_scrollAnimatorEnabled;
79 }; 79 };
80 80
81 class MockScrollAnimatorNone : public ScrollAnimatorNone { 81 class MockScrollAnimatorNone : public ScrollAnimatorNone {
82 public: 82 public:
83 MockScrollAnimatorNone(ScrollableArea* scrollableArea) 83 static PassRefPtr<MockScrollAnimatorNone> create(ScrollableArea* scrollableA rea)
84 : ScrollAnimatorNone(scrollableArea) { } 84 {
85 return adoptRef(new MockScrollAnimatorNone(scrollableArea));
86 }
85 87
86 float currentX() { return m_currentPosX; } 88 float currentX() { return m_currentPosX; }
87 float currentY() { return m_currentPosY; } 89 float currentY() { return m_currentPosY; }
88 90
89 FloatPoint m_fp; 91 FloatPoint m_fp;
90 int m_count; 92 int m_count;
91 93
92 void reset() 94 void reset()
93 { 95 {
94 stopAnimationTimerIfNeeded(); 96 stopAnimationTimerIfNeeded();
95 m_currentPosX = 0; 97 m_currentPosX = 0;
96 m_currentPosY = 0; 98 m_currentPosY = 0;
97 m_horizontalData.reset(); 99 m_horizontalData.reset();
98 m_verticalData.reset(); 100 m_verticalData.reset();
99 m_fp = FloatPoint::zero(); 101 m_fp = FloatPoint::zero();
100 m_count = 0; 102 m_count = 0;
101 } 103 }
102 104
103 virtual void fireUpAnAnimation(FloatPoint fp) 105 virtual void fireUpAnAnimation(FloatPoint fp)
104 { 106 {
105 m_fp = fp; 107 m_fp = fp;
106 m_count++; 108 m_count++;
107 } 109 }
108 110
109 MOCK_METHOD1(scrollToOffsetWithoutAnimation, void(const FloatPoint&)); 111 MOCK_METHOD1(scrollToOffsetWithoutAnimation, void(const FloatPoint&));
112 private:
113 explicit MockScrollAnimatorNone(ScrollableArea* scrollableArea)
114 : ScrollAnimatorNone(scrollableArea) { }
115
110 }; 116 };
111 117
112 TEST(ScrollAnimatorEnabled, Enabled) 118 TEST(ScrollAnimatorEnabled, Enabled)
113 { 119 {
114 MockScrollableArea scrollableArea(true); 120 MockScrollableArea scrollableArea(true);
115 MockScrollAnimatorNone scrollAnimatorNone(&scrollableArea); 121 RefPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone:: create(&scrollableArea);
116 122
117 EXPECT_CALL(scrollableArea, scrollSize(_)).Times(AtLeast(1)).WillRepeatedly( Return(1000)); 123 EXPECT_CALL(scrollableArea, scrollSize(_)).Times(AtLeast(1)).WillRepeatedly( Return(1000));
118 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint())); 124 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint()));
119 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint(1000, 1000))); 125 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint(1000, 1000)));
120 EXPECT_CALL(scrollableArea, setScrollOffset(_)).Times(4); 126 EXPECT_CALL(scrollableArea, setScrollOffset(_)).Times(4);
121 127
122 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByLine, 100, 1); 128 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByLine, 100, 1);
123 EXPECT_NE(100, scrollAnimatorNone.currentX()); 129 EXPECT_NE(100, scrollAnimatorNone->currentX());
124 EXPECT_NE(0, scrollAnimatorNone.currentX()); 130 EXPECT_NE(0, scrollAnimatorNone->currentX());
125 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 131 EXPECT_EQ(0, scrollAnimatorNone->currentY());
126 scrollAnimatorNone.reset(); 132 scrollAnimatorNone->reset();
127 133
128 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByPage, 100, 1); 134 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByPage, 100, 1);
129 EXPECT_NE(100, scrollAnimatorNone.currentX()); 135 EXPECT_NE(100, scrollAnimatorNone->currentX());
130 EXPECT_NE(0, scrollAnimatorNone.currentX()); 136 EXPECT_NE(0, scrollAnimatorNone->currentX());
131 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 137 EXPECT_EQ(0, scrollAnimatorNone->currentY());
132 scrollAnimatorNone.reset(); 138 scrollAnimatorNone->reset();
133 139
134 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByPixel, 4, 25); 140 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByPixel, 4, 25);
135 EXPECT_NE(100, scrollAnimatorNone.currentX()); 141 EXPECT_NE(100, scrollAnimatorNone->currentX());
136 EXPECT_NE(0, scrollAnimatorNone.currentX()); 142 EXPECT_NE(0, scrollAnimatorNone->currentX());
137 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 143 EXPECT_EQ(0, scrollAnimatorNone->currentY());
138 scrollAnimatorNone.reset(); 144 scrollAnimatorNone->reset();
139 145
140 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByPrecisePixel, 4, 25); 146 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByPrecisePixel, 4, 25) ;
141 EXPECT_EQ(100, scrollAnimatorNone.currentX()); 147 EXPECT_EQ(100, scrollAnimatorNone->currentX());
142 EXPECT_NE(0, scrollAnimatorNone.currentX()); 148 EXPECT_NE(0, scrollAnimatorNone->currentX());
143 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 149 EXPECT_EQ(0, scrollAnimatorNone->currentY());
144 scrollAnimatorNone.reset(); 150 scrollAnimatorNone->reset();
145 } 151 }
146 152
147 TEST(ScrollAnimatorEnabled, Disabled) 153 TEST(ScrollAnimatorEnabled, Disabled)
148 { 154 {
149 MockScrollableArea scrollableArea(false); 155 MockScrollableArea scrollableArea(false);
150 MockScrollAnimatorNone scrollAnimatorNone(&scrollableArea); 156 RefPtr<MockScrollAnimatorNone> scrollAnimatorNone = MockScrollAnimatorNone:: create(&scrollableArea);
151 157
152 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint())); 158 EXPECT_CALL(scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint()));
153 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint(1000, 1000))); 159 EXPECT_CALL(scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillR epeatedly(Return(IntPoint(1000, 1000)));
154 EXPECT_CALL(scrollableArea, setScrollOffset(_)).Times(4); 160 EXPECT_CALL(scrollableArea, setScrollOffset(_)).Times(4);
155 161
156 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByLine, 100, 1); 162 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByLine, 100, 1);
157 EXPECT_EQ(100, scrollAnimatorNone.currentX()); 163 EXPECT_EQ(100, scrollAnimatorNone->currentX());
158 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 164 EXPECT_EQ(0, scrollAnimatorNone->currentY());
159 scrollAnimatorNone.reset(); 165 scrollAnimatorNone->reset();
160 166
161 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByPage, 100, 1); 167 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByPage, 100, 1);
162 EXPECT_EQ(100, scrollAnimatorNone.currentX()); 168 EXPECT_EQ(100, scrollAnimatorNone->currentX());
163 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 169 EXPECT_EQ(0, scrollAnimatorNone->currentY());
164 scrollAnimatorNone.reset(); 170 scrollAnimatorNone->reset();
165 171
166 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByDocument, 100, 1); 172 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByDocument, 100, 1);
167 EXPECT_EQ(100, scrollAnimatorNone.currentX()); 173 EXPECT_EQ(100, scrollAnimatorNone->currentX());
168 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 174 EXPECT_EQ(0, scrollAnimatorNone->currentY());
169 scrollAnimatorNone.reset(); 175 scrollAnimatorNone->reset();
170 176
171 scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByPixel, 100, 1); 177 scrollAnimatorNone->scroll(HorizontalScrollbar, ScrollByPixel, 100, 1);
172 EXPECT_EQ(100, scrollAnimatorNone.currentX()); 178 EXPECT_EQ(100, scrollAnimatorNone->currentX());
173 EXPECT_EQ(0, scrollAnimatorNone.currentY()); 179 EXPECT_EQ(0, scrollAnimatorNone->currentY());
174 scrollAnimatorNone.reset(); 180 scrollAnimatorNone->reset();
175 } 181 }
176 182
177 class ScrollAnimatorNoneTest : public testing::Test { 183 class ScrollAnimatorNoneTest : public testing::Test {
178 public: 184 public:
179 struct SavePerAxisData : public ScrollAnimatorNone::PerAxisData { 185 struct SavePerAxisData : public ScrollAnimatorNone::PerAxisData {
180 SavePerAxisData(const ScrollAnimatorNone::PerAxisData& data) 186 SavePerAxisData(const ScrollAnimatorNone::PerAxisData& data)
181 : ScrollAnimatorNone::PerAxisData(&m_mockScrollAnimatorNone, 0, 768) 187 : ScrollAnimatorNone::PerAxisData(m_mockScrollAnimatorNone.get(), 0, 768)
Nico 2014/10/13 15:41:13 clang/win bot says: ..\..\third_party\WebKit\Sour
182 , m_mockScrollableArea(true) 188 , m_mockScrollableArea(true)
183 , m_mockScrollAnimatorNone(&m_mockScrollableArea) 189 , m_mockScrollAnimatorNone(MockScrollAnimatorNone::create(&m_mockScr ollableArea))
184 { 190 {
185 this->m_currentVelocity = data.m_currentVelocity; 191 this->m_currentVelocity = data.m_currentVelocity;
186 this->m_desiredPosition = data.m_desiredPosition; 192 this->m_desiredPosition = data.m_desiredPosition;
187 this->m_desiredVelocity = data.m_desiredVelocity; 193 this->m_desiredVelocity = data.m_desiredVelocity;
188 this->m_startPosition = data.m_startPosition; 194 this->m_startPosition = data.m_startPosition;
189 this->m_startTime = data.m_startTime; 195 this->m_startTime = data.m_startTime;
190 this->m_startVelocity = data.m_startVelocity; 196 this->m_startVelocity = data.m_startVelocity;
191 this->m_animationTime = data.m_animationTime; 197 this->m_animationTime = data.m_animationTime;
192 this->m_lastAnimationTime = data.m_lastAnimationTime; 198 this->m_lastAnimationTime = data.m_lastAnimationTime;
193 this->m_attackPosition = data.m_attackPosition; 199 this->m_attackPosition = data.m_attackPosition;
194 this->m_attackTime = data.m_attackTime; 200 this->m_attackTime = data.m_attackTime;
195 this->m_attackCurve = data.m_attackCurve; 201 this->m_attackCurve = data.m_attackCurve;
196 this->m_releasePosition = data.m_releasePosition; 202 this->m_releasePosition = data.m_releasePosition;
197 this->m_releaseTime = data.m_releaseTime; 203 this->m_releaseTime = data.m_releaseTime;
198 this->m_releaseCurve = data.m_releaseCurve; 204 this->m_releaseCurve = data.m_releaseCurve;
199 } 205 }
200 206
201 bool operator==(const SavePerAxisData& other) const 207 bool operator==(const SavePerAxisData& other) const
202 { 208 {
203 return m_currentVelocity == other.m_currentVelocity && m_desiredPosi tion == other.m_desiredPosition && m_desiredVelocity == other.m_desiredVelocity && m_startPosition == other.m_startPosition && m_startTime == other.m_startTime && m_startVelocity == other.m_startVelocity && m_animationTime == other.m_animat ionTime && m_lastAnimationTime == other.m_lastAnimationTime && m_attackPosition == other.m_attackPosition && m_attackTime == other.m_attackTime && m_attackCurve == other.m_attackCurve && m_releasePosition == other.m_releasePosition && m_rel easeTime == other.m_releaseTime && m_releaseCurve == other.m_releaseCurve; 209 return m_currentVelocity == other.m_currentVelocity && m_desiredPosi tion == other.m_desiredPosition && m_desiredVelocity == other.m_desiredVelocity && m_startPosition == other.m_startPosition && m_startTime == other.m_startTime && m_startVelocity == other.m_startVelocity && m_animationTime == other.m_animat ionTime && m_lastAnimationTime == other.m_lastAnimationTime && m_attackPosition == other.m_attackPosition && m_attackTime == other.m_attackTime && m_attackCurve == other.m_attackCurve && m_releasePosition == other.m_releasePosition && m_rel easeTime == other.m_releaseTime && m_releaseCurve == other.m_releaseCurve;
204 } 210 }
205 MockScrollableArea m_mockScrollableArea; 211 MockScrollableArea m_mockScrollableArea;
206 MockScrollAnimatorNone m_mockScrollAnimatorNone; 212 RefPtr<MockScrollAnimatorNone> m_mockScrollAnimatorNone;
207 }; 213 };
208 214
209 ScrollAnimatorNoneTest() 215 ScrollAnimatorNoneTest()
210 : m_mockScrollableArea(true) 216 : m_mockScrollableArea(true)
211 , m_mockScrollAnimatorNone(&m_mockScrollableArea) 217 , m_mockScrollAnimatorNone(MockScrollAnimatorNone::create(&m_mockScrolla bleArea))
212 { 218 {
213 } 219 }
214 220
215 virtual void SetUp() 221 virtual void SetUp()
216 { 222 {
217 m_currentPosition = 100; 223 m_currentPosition = 100;
218 m_data = new ScrollAnimatorNone::PerAxisData(&m_mockScrollAnimatorNone, &m_currentPosition, 768); 224 m_data = new ScrollAnimatorNone::PerAxisData(m_mockScrollAnimatorNone.ge t(), &m_currentPosition, 768);
219 } 225 }
220 virtual void TearDown() 226 virtual void TearDown()
221 { 227 {
222 delete m_data; 228 delete m_data;
223 } 229 }
224 230
225 void reset(); 231 void reset();
226 bool updateDataFromParameters(float step, float multiplier, float scrollable Size, double currentTime, ScrollAnimatorNone::Parameters*); 232 bool updateDataFromParameters(float step, float multiplier, float scrollable Size, double currentTime, ScrollAnimatorNone::Parameters*);
227 bool animateScroll(double currentTime); 233 bool animateScroll(double currentTime);
228 234
229 double attackArea(ScrollAnimatorNone::Curve, double startT, double endT); 235 double attackArea(ScrollAnimatorNone::Curve, double startT, double endT);
230 double releaseArea(ScrollAnimatorNone::Curve, double startT, double endT); 236 double releaseArea(ScrollAnimatorNone::Curve, double startT, double endT);
231 double attackCurve(ScrollAnimatorNone::Curve, double deltaT, double curveT, double startPosition, double attackPosition); 237 double attackCurve(ScrollAnimatorNone::Curve, double deltaT, double curveT, double startPosition, double attackPosition);
232 double releaseCurve(ScrollAnimatorNone::Curve, double deltaT, double curveT, double releasePosition, double desiredPosition); 238 double releaseCurve(ScrollAnimatorNone::Curve, double deltaT, double curveT, double releasePosition, double desiredPosition);
233 double coastCurve(ScrollAnimatorNone::Curve, double factor); 239 double coastCurve(ScrollAnimatorNone::Curve, double factor);
234 240
235 void curveTestInner(ScrollAnimatorNone::Curve, double step, double time); 241 void curveTestInner(ScrollAnimatorNone::Curve, double step, double time);
236 void curveTest(ScrollAnimatorNone::Curve); 242 void curveTest(ScrollAnimatorNone::Curve);
237 243
238 void checkDesiredPosition(float expectedPosition); 244 void checkDesiredPosition(float expectedPosition);
239 void checkSoftLanding(float expectedPosition); 245 void checkSoftLanding(float expectedPosition);
240 246
241 static double kTickTime; 247 static double kTickTime;
242 static double kAnimationTime; 248 static double kAnimationTime;
243 static double kStartTime; 249 static double kStartTime;
244 static double kEndTime; 250 static double kEndTime;
245 float m_currentPosition; 251 float m_currentPosition;
246 MockScrollableArea m_mockScrollableArea; 252 MockScrollableArea m_mockScrollableArea;
247 MockScrollAnimatorNone m_mockScrollAnimatorNone; 253 RefPtr<MockScrollAnimatorNone> m_mockScrollAnimatorNone;
248 bool m_scrollingDown; 254 bool m_scrollingDown;
249 ScrollAnimatorNone::PerAxisData* m_data; 255 ScrollAnimatorNone::PerAxisData* m_data;
250 }; 256 };
251 257
252 double ScrollAnimatorNoneTest::kTickTime = 1 / 60.0; 258 double ScrollAnimatorNoneTest::kTickTime = 1 / 60.0;
253 double ScrollAnimatorNoneTest::kAnimationTime = 0.01; 259 double ScrollAnimatorNoneTest::kAnimationTime = 0.01;
254 double ScrollAnimatorNoneTest::kStartTime = 10.0; 260 double ScrollAnimatorNoneTest::kStartTime = 10.0;
255 double ScrollAnimatorNoneTest::kEndTime = 20.0; 261 double ScrollAnimatorNoneTest::kEndTime = 20.0;
256 262
257 void ScrollAnimatorNoneTest::reset() 263 void ScrollAnimatorNoneTest::reset()
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 EXPECT_TRUE(result); 1049 EXPECT_TRUE(result);
1044 result = result && animateScroll(t); 1050 result = result && animateScroll(t);
1045 double after = m_currentPosition; 1051 double after = m_currentPosition;
1046 EXPECT_GE(before, after); 1052 EXPECT_GE(before, after);
1047 1053
1048 t += kAnimationTime; 1054 t += kAnimationTime;
1049 for (; result && t < kEndTime; t += kAnimationTime) 1055 for (; result && t < kEndTime; t += kAnimationTime)
1050 result = result && animateScroll(t); 1056 result = result && animateScroll(t);
1051 EXPECT_GE(before, m_currentPosition); 1057 EXPECT_GE(before, m_currentPosition);
1052 } 1058 }
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698