#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;
class MockScrollAnimatorNone : public ScrollAnimatorNone {
public:
- MockScrollAnimatorNone()
- : ScrollAnimatorNone(new MockScrollableArea(true)) { }
MockScrollAnimatorNone(ScrollableArea* scrollableArea)
: ScrollAnimatorNone(scrollableArea) { }
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;
{
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)
{
}
static double kStartTime;
static double kEndTime;
float m_currentPosition;
+ MockScrollableArea m_mockScrollableArea;
MockScrollAnimatorNone m_mockScrollAnimatorNone;
bool m_scrollingDown;
ScrollAnimatorNone::PerAxisData* m_data;
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) {
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) {