Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / tests / ScrollAnimatorNoneTest.cpp
index 791176b..265f10a 100644 (file)
 
 #include "platform/scroll/ScrollAnimatorNone.h"
 
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
 #include "platform/Logging.h"
 #include "platform/geometry/FloatPoint.h"
 #include "platform/geometry/IntRect.h"
 #include "platform/scroll/ScrollAnimator.h"
 #include "platform/scroll/ScrollableArea.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
 
-using namespace std;
-using namespace WebCore;
+using namespace blink;
 
 using testing::AtLeast;
 using testing::Return;
@@ -81,8 +80,6 @@ private:
 
 class MockScrollAnimatorNone : public ScrollAnimatorNone {
 public:
-    MockScrollAnimatorNone()
-        : ScrollAnimatorNone(new MockScrollableArea(true)) { }
     MockScrollAnimatorNone(ScrollableArea* scrollableArea)
         : ScrollAnimatorNone(scrollableArea) { }
 
@@ -182,6 +179,8 @@ public:
     struct SavePerAxisData : public ScrollAnimatorNone::PerAxisData {
         SavePerAxisData(const ScrollAnimatorNone::PerAxisData& data)
             : ScrollAnimatorNone::PerAxisData(&m_mockScrollAnimatorNone, 0, 768)
+            , m_mockScrollableArea(true)
+            , m_mockScrollAnimatorNone(&m_mockScrollableArea)
         {
             this->m_currentVelocity = data.m_currentVelocity;
             this->m_desiredPosition = data.m_desiredPosition;
@@ -203,10 +202,13 @@ public:
         {
             return m_currentVelocity == other.m_currentVelocity && m_desiredPosition == 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_animationTime && 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_releaseTime == other.m_releaseTime && m_releaseCurve == other.m_releaseCurve;
         }
+        MockScrollableArea m_mockScrollableArea;
         MockScrollAnimatorNone m_mockScrollAnimatorNone;
     };
 
     ScrollAnimatorNoneTest()
+        : m_mockScrollableArea(true)
+        , m_mockScrollAnimatorNone(&m_mockScrollableArea)
     {
     }
 
@@ -241,6 +243,7 @@ public:
     static double kStartTime;
     static double kEndTime;
     float m_currentPosition;
+    MockScrollableArea m_mockScrollableArea;
     MockScrollAnimatorNone m_mockScrollAnimatorNone;
     bool m_scrollingDown;
     ScrollAnimatorNone::PerAxisData* m_data;
@@ -273,9 +276,9 @@ bool ScrollAnimatorNoneTest::updateDataFromParameters(float step, float multipli
 
     double deltaTime = m_data->m_lastAnimationTime - m_data->m_startTime;
     double timeLeft = m_data->m_animationTime - deltaTime;
-    double releaseTimeLeft = min(timeLeft, m_data->m_releaseTime);
-    double attackTimeLeft = max(0., m_data->m_attackTime - deltaTime);
-    double sustainTimeLeft = max(0., timeLeft - releaseTimeLeft - attackTimeLeft);
+    double releaseTimeLeft = std::min(timeLeft, m_data->m_releaseTime);
+    double attackTimeLeft = std::max(0., m_data->m_attackTime - deltaTime);
+    double sustainTimeLeft = std::max(0., timeLeft - releaseTimeLeft - attackTimeLeft);
 
     // If we're getting near the finish, the desired velocity can decrease since the time left gets increased.
     if (step * multiplier) {
@@ -303,9 +306,9 @@ bool ScrollAnimatorNoneTest::animateScroll(double currentTime)
 
     double deltaTime = m_data->m_lastAnimationTime - m_data->m_startTime;
     double timeLeft = m_data->m_animationTime - deltaTime;
-    double releaseTimeLeft = min(timeLeft, m_data->m_releaseTime);
-    double attackTimeLeft = max(0., m_data->m_attackTime - deltaTime);
-    double sustainTimeLeft = max(0., timeLeft - releaseTimeLeft - attackTimeLeft);
+    double releaseTimeLeft = std::min(timeLeft, m_data->m_releaseTime);
+    double attackTimeLeft = std::max(0., m_data->m_attackTime - deltaTime);
+    double sustainTimeLeft = std::max(0., timeLeft - releaseTimeLeft - attackTimeLeft);
     double distanceLeft = m_data->m_desiredPosition - *m_data->m_currentPosition;
 
     if (m_scrollingDown) {