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

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

Issue 330933002: Revert of Removing "using" declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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') | no next file » | 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 19 matching lines...) Expand all
30 #include "platform/scroll/ScrollAnimatorNone.h" 30 #include "platform/scroll/ScrollAnimatorNone.h"
31 31
32 #include "platform/Logging.h" 32 #include "platform/Logging.h"
33 #include "platform/geometry/FloatPoint.h" 33 #include "platform/geometry/FloatPoint.h"
34 #include "platform/geometry/IntRect.h" 34 #include "platform/geometry/IntRect.h"
35 #include "platform/scroll/ScrollAnimator.h" 35 #include "platform/scroll/ScrollAnimator.h"
36 #include "platform/scroll/ScrollableArea.h" 36 #include "platform/scroll/ScrollableArea.h"
37 #include <gmock/gmock.h> 37 #include <gmock/gmock.h>
38 #include <gtest/gtest.h> 38 #include <gtest/gtest.h>
39 39
40 using namespace std;
40 using namespace WebCore; 41 using namespace WebCore;
41 42
42 using testing::AtLeast; 43 using testing::AtLeast;
43 using testing::Return; 44 using testing::Return;
44 using testing::_; 45 using testing::_;
45 46
46 class MockScrollableArea : public ScrollableArea { 47 class MockScrollableArea : public ScrollableArea {
47 public: 48 public:
48 MockScrollableArea(bool scrollAnimatorEnabled) 49 MockScrollableArea(bool scrollAnimatorEnabled)
49 : m_scrollAnimatorEnabled(scrollAnimatorEnabled) { } 50 : m_scrollAnimatorEnabled(scrollAnimatorEnabled) { }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 double oldDesiredVelocity = m_data->m_desiredVelocity; 270 double oldDesiredVelocity = m_data->m_desiredVelocity;
270 double oldTimeLeft = m_data->m_animationTime - (m_data->m_lastAnimationTime - m_data->m_startTime); 271 double oldTimeLeft = m_data->m_animationTime - (m_data->m_lastAnimationTime - m_data->m_startTime);
271 bool result = m_data->updateDataFromParameters(step, multiplier, scrollableS ize, currentTime, parameters); 272 bool result = m_data->updateDataFromParameters(step, multiplier, scrollableS ize, currentTime, parameters);
272 if (m_scrollingDown) 273 if (m_scrollingDown)
273 EXPECT_LE(oldVelocity, m_data->m_currentVelocity); 274 EXPECT_LE(oldVelocity, m_data->m_currentVelocity);
274 else 275 else
275 EXPECT_GE(oldVelocity, m_data->m_currentVelocity); 276 EXPECT_GE(oldVelocity, m_data->m_currentVelocity);
276 277
277 double deltaTime = m_data->m_lastAnimationTime - m_data->m_startTime; 278 double deltaTime = m_data->m_lastAnimationTime - m_data->m_startTime;
278 double timeLeft = m_data->m_animationTime - deltaTime; 279 double timeLeft = m_data->m_animationTime - deltaTime;
279 double releaseTimeLeft = std::min(timeLeft, m_data->m_releaseTime); 280 double releaseTimeLeft = min(timeLeft, m_data->m_releaseTime);
280 double attackTimeLeft = std::max(0., m_data->m_attackTime - deltaTime); 281 double attackTimeLeft = max(0., m_data->m_attackTime - deltaTime);
281 double sustainTimeLeft = std::max(0., timeLeft - releaseTimeLeft - attackTim eLeft); 282 double sustainTimeLeft = max(0., timeLeft - releaseTimeLeft - attackTimeLeft );
282 283
283 // If we're getting near the finish, the desired velocity can decrease since the time left gets increased. 284 // If we're getting near the finish, the desired velocity can decrease since the time left gets increased.
284 if (step * multiplier) { 285 if (step * multiplier) {
285 double allowedVelocityDecreaseFactor = 0.99 * oldTimeLeft / timeLeft; 286 double allowedVelocityDecreaseFactor = 0.99 * oldTimeLeft / timeLeft;
286 allowedVelocityDecreaseFactor *= allowedVelocityDecreaseFactor; 287 allowedVelocityDecreaseFactor *= allowedVelocityDecreaseFactor;
287 if (m_scrollingDown) 288 if (m_scrollingDown)
288 EXPECT_LE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data ->m_desiredVelocity); 289 EXPECT_LE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data ->m_desiredVelocity);
289 else 290 else
290 EXPECT_GE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data ->m_desiredVelocity); 291 EXPECT_GE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data ->m_desiredVelocity);
291 292
292 double startPosition = attackTimeLeft ? m_data->m_attackPosition : m_cur rentPosition; 293 double startPosition = attackTimeLeft ? m_data->m_attackPosition : m_cur rentPosition;
293 double expectedReleasePosition = startPosition + sustainTimeLeft * m_dat a->m_desiredVelocity; 294 double expectedReleasePosition = startPosition + sustainTimeLeft * m_dat a->m_desiredVelocity;
294 EXPECT_NEAR(expectedReleasePosition, m_data->m_releasePosition, result ? .0001 : 1); 295 EXPECT_NEAR(expectedReleasePosition, m_data->m_releasePosition, result ? .0001 : 1);
295 } 296 }
296 297
297 return result; 298 return result;
298 } 299 }
299 300
300 bool ScrollAnimatorNoneTest::animateScroll(double currentTime) 301 bool ScrollAnimatorNoneTest::animateScroll(double currentTime)
301 { 302 {
302 double oldPosition = *m_data->m_currentPosition; 303 double oldPosition = *m_data->m_currentPosition;
303 bool testEstimatedMaxVelocity = m_data->m_startTime + m_data->m_animationTim e - m_data->m_lastAnimationTime > m_data->m_releaseTime; 304 bool testEstimatedMaxVelocity = m_data->m_startTime + m_data->m_animationTim e - m_data->m_lastAnimationTime > m_data->m_releaseTime;
304 305
305 bool result = m_data->animateScroll(currentTime); 306 bool result = m_data->animateScroll(currentTime);
306 307
307 double deltaTime = m_data->m_lastAnimationTime - m_data->m_startTime; 308 double deltaTime = m_data->m_lastAnimationTime - m_data->m_startTime;
308 double timeLeft = m_data->m_animationTime - deltaTime; 309 double timeLeft = m_data->m_animationTime - deltaTime;
309 double releaseTimeLeft = std::min(timeLeft, m_data->m_releaseTime); 310 double releaseTimeLeft = min(timeLeft, m_data->m_releaseTime);
310 double attackTimeLeft = std::max(0., m_data->m_attackTime - deltaTime); 311 double attackTimeLeft = max(0., m_data->m_attackTime - deltaTime);
311 double sustainTimeLeft = std::max(0., timeLeft - releaseTimeLeft - attackTim eLeft); 312 double sustainTimeLeft = max(0., timeLeft - releaseTimeLeft - attackTimeLeft );
312 double distanceLeft = m_data->m_desiredPosition - *m_data->m_currentPosition ; 313 double distanceLeft = m_data->m_desiredPosition - *m_data->m_currentPosition ;
313 314
314 if (m_scrollingDown) { 315 if (m_scrollingDown) {
315 EXPECT_LE(0, m_data->m_currentVelocity); 316 EXPECT_LE(0, m_data->m_currentVelocity);
316 EXPECT_LE(oldPosition, *m_data->m_currentPosition); 317 EXPECT_LE(oldPosition, *m_data->m_currentPosition);
317 } else { 318 } else {
318 EXPECT_GE(0, m_data->m_currentVelocity); 319 EXPECT_GE(0, m_data->m_currentVelocity);
319 EXPECT_GE(oldPosition, *m_data->m_currentPosition); 320 EXPECT_GE(oldPosition, *m_data->m_currentPosition);
320 } 321 }
321 EXPECT_GE(fabs(m_data->m_desiredVelocity) * 2, fabs(m_data->m_currentVelocit y)); 322 EXPECT_GE(fabs(m_data->m_desiredVelocity) * 2, fabs(m_data->m_currentVelocit y));
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 EXPECT_TRUE(result); 1044 EXPECT_TRUE(result);
1044 result = result && animateScroll(t); 1045 result = result && animateScroll(t);
1045 double after = m_currentPosition; 1046 double after = m_currentPosition;
1046 EXPECT_GE(before, after); 1047 EXPECT_GE(before, after);
1047 1048
1048 t += kAnimationTime; 1049 t += kAnimationTime;
1049 for (; result && t < kEndTime; t += kAnimationTime) 1050 for (; result && t < kEndTime; t += kAnimationTime)
1050 result = result && animateScroll(t); 1051 result = result && animateScroll(t);
1051 EXPECT_GE(before, m_currentPosition); 1052 EXPECT_GE(before, m_currentPosition);
1052 } 1053 }
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698