This source file includes following definitions.
- TEST
- TEST
- TEST
- TEST
- TEST
- TEST
#include "config.h"
#include "core/animation/TimedItemCalculations.h"
#include <gtest/gtest.h>
using namespace WebCore;
namespace {
TEST(AnimationTimedItemCalculationsTest, ActiveTime)
{
Timing timing;
timing.startDelay = 10;
EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeForwards, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing)));
EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing)));
EXPECT_EQ(0, calculateActiveTime(20, Timing::FillModeBackwards, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing));
EXPECT_EQ(0, calculateActiveTime(20, Timing::FillModeBoth, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing));
timing.startDelay = 10;
EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 15, TimedItem::PhaseBefore, TimedItem::PhaseActive, timing)));
EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeForwards, 15, TimedItem::PhaseBefore, TimedItem::PhaseActive, timing)));
EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 15, TimedItem::PhaseAfter, TimedItem::PhaseActive, timing)));
EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeBackwards, 15, TimedItem::PhaseAfter, TimedItem::PhaseActive, timing)));
EXPECT_EQ(5, calculateActiveTime(20, Timing::FillModeForwards, 15, TimedItem::PhaseActive, TimedItem::PhaseActive, timing));
timing.startDelay = 10;
EXPECT_EQ(21, calculateActiveTime(21, Timing::FillModeForwards, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing));
EXPECT_EQ(21, calculateActiveTime(21, Timing::FillModeBoth, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing));
EXPECT_TRUE(isNull(calculateActiveTime(21, Timing::FillModeBackwards, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing)));
EXPECT_TRUE(isNull(calculateActiveTime(21, Timing::FillModeNone, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing)));
EXPECT_TRUE(isNull(calculateActiveTime(32, Timing::FillModeNone, nullValue(), TimedItem::PhaseNone, TimedItem::PhaseNone, timing)));
}
TEST(AnimationTimedItemCalculationsTest, ScaledActiveTime)
{
Timing timing;
EXPECT_TRUE(isNull(calculateScaledActiveTime(4, nullValue(), 5, timing)));
timing.playbackRate = -1;
EXPECT_EQ(35, calculateScaledActiveTime(40, 10, 5, timing));
timing.playbackRate = 0;
EXPECT_EQ(5, calculateScaledActiveTime(40, 10, 5, timing));
timing.playbackRate = 1;
EXPECT_EQ(15, calculateScaledActiveTime(40, 10, 5, timing));
timing.playbackRate = 0;
EXPECT_EQ(0, calculateScaledActiveTime(std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity(), 0, timing));
timing.playbackRate = 1;
EXPECT_EQ(std::numeric_limits<double>::infinity(), calculateScaledActiveTime(std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity(), 0, timing));
}
TEST(AnimationTimedItemCalculationsTest, IterationTime)
{
Timing timing;
EXPECT_TRUE(isNull(calculateIterationTime(1, 1, nullValue(), 1, timing)));
EXPECT_EQ(12, calculateIterationTime(12, 12, 12, 0, timing));
timing.iterationCount = 10;
EXPECT_EQ(5, calculateIterationTime(10, 100, 25, 4, timing));
EXPECT_EQ(7, calculateIterationTime(11, 110, 29, 1, timing));
timing.iterationStart = 1.1;
EXPECT_EQ(8, calculateIterationTime(12, 120, 20, 7, timing));
}
TEST(AnimationTimedItemCalculationsTest, CurrentIteration)
{
Timing timing;
EXPECT_TRUE(isNull(calculateCurrentIteration(1, 1, nullValue(), timing)));
EXPECT_EQ(0, calculateCurrentIteration(1, 1, 0, timing));
timing.iterationStart = 4;
timing.iterationCount = 7;
EXPECT_EQ(10, calculateCurrentIteration(5, 5, 9, timing));
EXPECT_EQ(3, calculateCurrentIteration(3.2, 3.1, 10, timing));
}
TEST(AnimationTimedItemCalculationsTest, DirectedTime)
{
Timing timing;
EXPECT_TRUE(isNull(calculateDirectedTime(1, 2, nullValue(), timing)));
EXPECT_EQ(17, calculateDirectedTime(0, 20, 17, timing));
EXPECT_EQ(17, calculateDirectedTime(1, 20, 17, timing));
timing.direction = Timing::PlaybackDirectionAlternate;
EXPECT_EQ(17, calculateDirectedTime(0, 20, 17, timing));
EXPECT_EQ(17, calculateDirectedTime(2, 20, 17, timing));
timing.direction = Timing::PlaybackDirectionAlternateReverse;
EXPECT_EQ(17, calculateDirectedTime(1, 20, 17, timing));
EXPECT_EQ(17, calculateDirectedTime(3, 20, 17, timing));
timing.direction = Timing::PlaybackDirectionReverse;
EXPECT_EQ(3, calculateDirectedTime(0, 20, 17, timing));
EXPECT_EQ(3, calculateDirectedTime(1, 20, 17, timing));
timing.direction = Timing::PlaybackDirectionAlternate;
EXPECT_EQ(3, calculateDirectedTime(1, 20, 17, timing));
EXPECT_EQ(3, calculateDirectedTime(3, 20, 17, timing));
timing.direction = Timing::PlaybackDirectionAlternateReverse;
EXPECT_EQ(3, calculateDirectedTime(0, 20, 17, timing));
EXPECT_EQ(3, calculateDirectedTime(2, 20, 17, timing));
}
TEST(AnimationTimedItemCalculationsTest, TransformedTime)
{
Timing timing;
EXPECT_TRUE(isNull(calculateTransformedTime(1, 2, nullValue(), timing)));
EXPECT_EQ(12, calculateTransformedTime(0, 20, 12, timing));
EXPECT_EQ(12, calculateTransformedTime(1, 20, 12, timing));
timing.timingFunction = StepsTimingFunction::create(4, StepsTimingFunction::StepAtEnd);
EXPECT_EQ(10, calculateTransformedTime(0, 20, 12, timing));
EXPECT_EQ(10, calculateTransformedTime(1, 20, 12, timing));
timing.timingFunction = Timing::defaults().timingFunction;
timing.direction = Timing::PlaybackDirectionReverse;
EXPECT_EQ(8, calculateTransformedTime(0, 20, 12, timing));
EXPECT_EQ(8, calculateTransformedTime(1, 20, 12, timing));
timing.timingFunction = StepsTimingFunction::create(4, StepsTimingFunction::StepAtEnd);
EXPECT_EQ(5, calculateTransformedTime(0, 20, 12, timing));
EXPECT_EQ(5, calculateTransformedTime(1, 20, 12, timing));
EXPECT_TRUE(isNull(calculateTransformedTime(1, 2, nullValue(), timing)));
timing.direction = Timing::PlaybackDirectionNormal;
EXPECT_EQ(0, calculateTransformedTime(0, std::numeric_limits<double>::infinity(), 0, timing));
EXPECT_EQ(1, calculateTransformedTime(0, std::numeric_limits<double>::infinity(), 1, timing));
timing.direction = Timing::PlaybackDirectionReverse;
EXPECT_EQ(std::numeric_limits<double>::infinity(), calculateTransformedTime(0, std::numeric_limits<double>::infinity(), 0, timing));
EXPECT_EQ(std::numeric_limits<double>::infinity(), calculateTransformedTime(0, std::numeric_limits<double>::infinity(), 1, timing));
}
}