Example #1
0
TEST_F(AnimationAnimationTest, TimingInputIterationCount)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope scope(isolate);
    v8::Local<v8::Context> context = v8::Context::New(isolate);
    v8::Context::Scope contextScope(context);

    Timing timing;
    EXPECT_EQ(1, timing.iterationCount);

    applyTimingInputNumber(timing, isolate, "iterations", 2.1);
    EXPECT_EQ(2.1, timing.iterationCount);
    timing.iterationCount = 1;

    applyTimingInputNumber(timing, isolate, "iterations", -1);
    EXPECT_EQ(0, timing.iterationCount);
    timing.iterationCount = 1;

    applyTimingInputString(timing, isolate, "iterations", "Infinity");
    EXPECT_TRUE(std::isinf(timing.iterationCount) && (timing.iterationCount > 0));
    timing.iterationCount = 1;

    applyTimingInputString(timing, isolate, "iterations", "-Infinity");
    EXPECT_EQ(0, timing.iterationCount);
    timing.iterationCount = 1;

    applyTimingInputString(timing, isolate, "iterations", "NaN");
    EXPECT_EQ(1, timing.iterationCount);
    timing.iterationCount = 1;

    applyTimingInputString(timing, isolate, "iterations", "rubbish");
    EXPECT_EQ(1, timing.iterationCount);
    timing.iterationCount = 1;
}
Example #2
0
TEST_F(AnimationAnimationTest, TimingInputIterationStart)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope scope(isolate);
    v8::Local<v8::Context> context = v8::Context::New(isolate);
    v8::Context::Scope contextScope(context);

    Timing timing;
    EXPECT_EQ(0, timing.iterationStart);

    applyTimingInputNumber(timing, isolate, "iterationStart", 1.1);
    EXPECT_EQ(1.1, timing.iterationStart);
    timing.iterationStart = 0;

    applyTimingInputNumber(timing, isolate, "iterationStart", -1);
    EXPECT_EQ(0, timing.iterationStart);
    timing.iterationStart = 0;

    applyTimingInputString(timing, isolate, "iterationStart", "Infinity");
    EXPECT_EQ(0, timing.iterationStart);
    timing.iterationStart = 0;

    applyTimingInputString(timing, isolate, "iterationStart", "-Infinity");
    EXPECT_EQ(0, timing.iterationStart);
    timing.iterationStart = 0;

    applyTimingInputString(timing, isolate, "iterationStart", "NaN");
    EXPECT_EQ(0, timing.iterationStart);
    timing.iterationStart = 0;

    applyTimingInputString(timing, isolate, "iterationStart", "rubbish");
    EXPECT_EQ(0, timing.iterationStart);
    timing.iterationStart = 0;
}
Example #3
0
TEST_F(AnimationTimingInputTest, TimingInputIterationStart)
{
    EXPECT_EQ(1.1, applyTimingInputNumber("iterationStart", 1.1).iterationStart);
    EXPECT_EQ(0, applyTimingInputNumber("iterationStart", -1).iterationStart);
    EXPECT_EQ(0, applyTimingInputString("iterationStart", "Infinity").iterationStart);
    EXPECT_EQ(0, applyTimingInputString("iterationStart", "-Infinity").iterationStart);
    EXPECT_EQ(0, applyTimingInputString("iterationStart", "NaN").iterationStart);
    EXPECT_EQ(0, applyTimingInputString("iterationStart", "rubbish").iterationStart);
}
Example #4
0
TEST_F(AnimationTimingInputTest, TimingInputPlaybackRate)
{
    EXPECT_EQ(2.1, applyTimingInputNumber("playbackRate", 2.1).playbackRate);
    EXPECT_EQ(-1, applyTimingInputNumber("playbackRate", -1).playbackRate);
    EXPECT_EQ(1, applyTimingInputString("playbackRate", "Infinity").playbackRate);
    EXPECT_EQ(1, applyTimingInputString("playbackRate", "-Infinity").playbackRate);
    EXPECT_EQ(1, applyTimingInputString("playbackRate", "NaN").playbackRate);
    EXPECT_EQ(1, applyTimingInputString("playbackRate", "rubbish").playbackRate);
}
Example #5
0
TEST_F(AnimationTimingInputTest, TimingInputDirection)
{
    Timing::PlaybackDirection defaultPlaybackDirection = Timing::PlaybackDirectionNormal;

    EXPECT_EQ(Timing::PlaybackDirectionNormal, applyTimingInputString("direction", "normal").direction);
    EXPECT_EQ(Timing::PlaybackDirectionReverse, applyTimingInputString("direction", "reverse").direction);
    EXPECT_EQ(Timing::PlaybackDirectionAlternate, applyTimingInputString("direction", "alternate").direction);
    EXPECT_EQ(Timing::PlaybackDirectionAlternateReverse, applyTimingInputString("direction", "alternate-reverse").direction);
    EXPECT_EQ(defaultPlaybackDirection, applyTimingInputString("direction", "rubbish").direction);
    EXPECT_EQ(defaultPlaybackDirection, applyTimingInputNumber("direction", 2).direction);
}
TEST(AnimationTimingInputTest, TimingInputPlaybackRate)
{
    V8TestingScope scope;
    bool ignoredSuccess;
    EXPECT_EQ(2.1, applyTimingInputNumber(scope.isolate(), "playbackRate", 2.1, ignoredSuccess).playbackRate);
    EXPECT_EQ(-1, applyTimingInputNumber(scope.isolate(), "playbackRate", -1, ignoredSuccess).playbackRate);
    EXPECT_EQ(1, applyTimingInputString(scope.isolate(), "playbackRate", "Infinity", ignoredSuccess).playbackRate);
    EXPECT_EQ(1, applyTimingInputString(scope.isolate(), "playbackRate", "-Infinity", ignoredSuccess).playbackRate);
    EXPECT_EQ(1, applyTimingInputString(scope.isolate(), "playbackRate", "NaN", ignoredSuccess).playbackRate);
    EXPECT_EQ(1, applyTimingInputString(scope.isolate(), "playbackRate", "rubbish", ignoredSuccess).playbackRate);
}
Example #7
0
TEST_F(AnimationTimingInputTest, TimingInputIterationCount)
{
    EXPECT_EQ(2.1, applyTimingInputNumber("iterations", 2.1).iterationCount);
    EXPECT_EQ(0, applyTimingInputNumber("iterations", -1).iterationCount);

    Timing timing = applyTimingInputString("iterations", "Infinity");
    EXPECT_TRUE(std::isinf(timing.iterationCount));
    EXPECT_GT(timing.iterationCount, 0);

    EXPECT_EQ(0, applyTimingInputString("iterations", "-Infinity").iterationCount);
    EXPECT_EQ(1, applyTimingInputString("iterations", "NaN").iterationCount);
    EXPECT_EQ(1, applyTimingInputString("iterations", "rubbish").iterationCount);
}
TEST(AnimationTimingInputTest, TimingInputDirection)
{
    V8TestingScope scope;
    Timing::PlaybackDirection defaultPlaybackDirection = Timing::PlaybackDirectionNormal;
    bool ignoredSuccess;

    EXPECT_EQ(Timing::PlaybackDirectionNormal, applyTimingInputString(scope.isolate(), "direction", "normal", ignoredSuccess).direction);
    EXPECT_EQ(Timing::PlaybackDirectionReverse, applyTimingInputString(scope.isolate(), "direction", "reverse", ignoredSuccess).direction);
    EXPECT_EQ(Timing::PlaybackDirectionAlternate, applyTimingInputString(scope.isolate(), "direction", "alternate", ignoredSuccess).direction);
    EXPECT_EQ(Timing::PlaybackDirectionAlternateReverse, applyTimingInputString(scope.isolate(), "direction", "alternate-reverse", ignoredSuccess).direction);
    EXPECT_EQ(defaultPlaybackDirection, applyTimingInputString(scope.isolate(), "direction", "rubbish", ignoredSuccess).direction);
    EXPECT_EQ(defaultPlaybackDirection, applyTimingInputNumber(scope.isolate(), "direction", 2, ignoredSuccess).direction);
}
TEST(AnimationTimingInputTest, TimingInputIterationStart)
{
    V8TestingScope scope;
    bool success;
    EXPECT_EQ(1.1, applyTimingInputNumber(scope.isolate(), "iterationStart", 1.1, success).iterationStart);
    EXPECT_TRUE(success);

    applyTimingInputNumber(scope.isolate(), "iterationStart", -1, success);
    EXPECT_FALSE(success);

    applyTimingInputString(scope.isolate(), "iterationStart", "Infinity", success);
    EXPECT_FALSE(success);

    applyTimingInputString(scope.isolate(), "iterationStart", "-Infinity", success);
    EXPECT_FALSE(success);

    applyTimingInputString(scope.isolate(), "iterationStart", "NaN", success);
    EXPECT_FALSE(success);

    applyTimingInputString(scope.isolate(), "iterationStart", "rubbish", success);
    EXPECT_FALSE(success);
}
Example #10
0
TEST_F(AnimationTimingInputTest, TimingInputFillMode)
{
    Timing::FillMode defaultFillMode = Timing::FillModeAuto;

    EXPECT_EQ(Timing::FillModeAuto, applyTimingInputString("fill", "auto").fillMode);
    EXPECT_EQ(Timing::FillModeForwards, applyTimingInputString("fill", "forwards").fillMode);
    EXPECT_EQ(Timing::FillModeNone, applyTimingInputString("fill", "none").fillMode);
    EXPECT_EQ(Timing::FillModeBackwards, applyTimingInputString("fill", "backwards").fillMode);
    EXPECT_EQ(Timing::FillModeBoth, applyTimingInputString("fill", "both").fillMode);
    EXPECT_EQ(defaultFillMode, applyTimingInputString("fill", "everything!").fillMode);
    EXPECT_EQ(defaultFillMode, applyTimingInputString("fill", "backwardsandforwards").fillMode);
    EXPECT_EQ(defaultFillMode, applyTimingInputNumber("fill", 2).fillMode);
}
TEST(AnimationTimingInputTest, TimingInputIterationCount)
{
    V8TestingScope scope;
    bool success;
    EXPECT_EQ(2.1, applyTimingInputNumber(scope.isolate(), "iterations", 2.1, success).iterationCount);
    EXPECT_TRUE(success);

    Timing timing = applyTimingInputString(scope.isolate(), "iterations", "Infinity", success);
    EXPECT_TRUE(success);
    EXPECT_TRUE(std::isinf(timing.iterationCount));
    EXPECT_GT(timing.iterationCount, 0);

    applyTimingInputNumber(scope.isolate(), "iterations", -1, success);
    EXPECT_FALSE(success);

    applyTimingInputString(scope.isolate(), "iterations", "-Infinity", success);
    EXPECT_FALSE(success);

    applyTimingInputString(scope.isolate(), "iterations", "NaN", success);
    EXPECT_FALSE(success);

    applyTimingInputString(scope.isolate(), "iterations", "rubbish", success);
    EXPECT_FALSE(success);
}
TEST(AnimationTimingInputTest, TimingInputTimingFunction)
{
    V8TestingScope scope;
    const RefPtr<TimingFunction> defaultTimingFunction = LinearTimingFunction::shared();
    bool success;

    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseType::EASE), *applyTimingInputString(scope.isolate(), "easing", "ease", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseType::EASE_IN), *applyTimingInputString(scope.isolate(), "easing", "ease-in", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseType::EASE_OUT), *applyTimingInputString(scope.isolate(), "easing", "ease-out", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseType::EASE_IN_OUT), *applyTimingInputString(scope.isolate(), "easing", "ease-in-out", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*LinearTimingFunction::shared(), *applyTimingInputString(scope.isolate(), "easing", "linear", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::StepPosition::START), *applyTimingInputString(scope.isolate(), "easing", "step-start", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::StepPosition::MIDDLE), *applyTimingInputString(scope.isolate(), "easing", "step-middle", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::StepPosition::END), *applyTimingInputString(scope.isolate(), "easing", "step-end", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*CubicBezierTimingFunction::create(1, 1, 0.3, 0.3), *applyTimingInputString(scope.isolate(), "easing", "cubic-bezier(1, 1, 0.3, 0.3)", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*StepsTimingFunction::create(3, StepsTimingFunction::StepPosition::START), *applyTimingInputString(scope.isolate(), "easing", "steps(3, start)", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::StepPosition::MIDDLE), *applyTimingInputString(scope.isolate(), "easing", "steps(5, middle)", success).timingFunction);
    EXPECT_TRUE(success);
    EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::StepPosition::END), *applyTimingInputString(scope.isolate(), "easing", "steps(5, end)", success).timingFunction);
    EXPECT_TRUE(success);

    applyTimingInputString(scope.isolate(), "easing", "", success);
    EXPECT_FALSE(success);
    applyTimingInputString(scope.isolate(), "easing", "steps(5.6, end)", success);
    EXPECT_FALSE(success);
    applyTimingInputString(scope.isolate(), "easing", "cubic-bezier(2, 2, 0.3, 0.3)", success);
    EXPECT_FALSE(success);
    applyTimingInputString(scope.isolate(), "easing", "rubbish", success);
    EXPECT_FALSE(success);
    applyTimingInputNumber(scope.isolate(), "easing", 2, success);
    EXPECT_FALSE(success);
    applyTimingInputString(scope.isolate(), "easing", "initial", success);
    EXPECT_FALSE(success);
}
Example #13
0
TEST_F(AnimationTimingInputTest, TimingInputStartDelay)
{
    EXPECT_EQ(1.1, applyTimingInputNumber("delay", 1100).startDelay);
    EXPECT_EQ(-1, applyTimingInputNumber("delay", -1000).startDelay);
    EXPECT_EQ(1, applyTimingInputString("delay", "1000").startDelay);
    EXPECT_EQ(0, applyTimingInputString("delay", "1s").startDelay);
    EXPECT_EQ(0, applyTimingInputString("delay", "Infinity").startDelay);
    EXPECT_EQ(0, applyTimingInputString("delay", "-Infinity").startDelay);
    EXPECT_EQ(0, applyTimingInputString("delay", "NaN").startDelay);
    EXPECT_EQ(0, applyTimingInputString("delay", "rubbish").startDelay);
}
TEST(AnimationTimingInputTest, TimingInputFillMode)
{
    V8TestingScope scope;
    Timing::FillMode defaultFillMode = Timing::FillModeAuto;
    bool ignoredSuccess;

    EXPECT_EQ(Timing::FillModeAuto, applyTimingInputString(scope.isolate(), "fill", "auto", ignoredSuccess).fillMode);
    EXPECT_EQ(Timing::FillModeForwards, applyTimingInputString(scope.isolate(), "fill", "forwards", ignoredSuccess).fillMode);
    EXPECT_EQ(Timing::FillModeNone, applyTimingInputString(scope.isolate(), "fill", "none", ignoredSuccess).fillMode);
    EXPECT_EQ(Timing::FillModeBackwards, applyTimingInputString(scope.isolate(), "fill", "backwards", ignoredSuccess).fillMode);
    EXPECT_EQ(Timing::FillModeBoth, applyTimingInputString(scope.isolate(), "fill", "both", ignoredSuccess).fillMode);
    EXPECT_EQ(defaultFillMode, applyTimingInputString(scope.isolate(), "fill", "everything!", ignoredSuccess).fillMode);
    EXPECT_EQ(defaultFillMode, applyTimingInputString(scope.isolate(), "fill", "backwardsandforwards", ignoredSuccess).fillMode);
    EXPECT_EQ(defaultFillMode, applyTimingInputNumber(scope.isolate(), "fill", 2, ignoredSuccess).fillMode);
}
TEST(AnimationTimingInputTest, TimingInputStartDelay)
{
    V8TestingScope scope;
    bool ignoredSuccess;
    EXPECT_EQ(1.1, applyTimingInputNumber(scope.isolate(), "delay", 1100, ignoredSuccess).startDelay);
    EXPECT_EQ(-1, applyTimingInputNumber(scope.isolate(), "delay", -1000, ignoredSuccess).startDelay);
    EXPECT_EQ(1, applyTimingInputString(scope.isolate(), "delay", "1000", ignoredSuccess).startDelay);
    EXPECT_EQ(0, applyTimingInputString(scope.isolate(), "delay", "1s", ignoredSuccess).startDelay);
    EXPECT_EQ(0, applyTimingInputString(scope.isolate(), "delay", "Infinity", ignoredSuccess).startDelay);
    EXPECT_EQ(0, applyTimingInputString(scope.isolate(), "delay", "-Infinity", ignoredSuccess).startDelay);
    EXPECT_EQ(0, applyTimingInputString(scope.isolate(), "delay", "NaN", ignoredSuccess).startDelay);
    EXPECT_EQ(0, applyTimingInputString(scope.isolate(), "delay", "rubbish", ignoredSuccess).startDelay);
}
Example #16
0
TEST_F(AnimationTimingInputTest, TimingInputIterationDuration)
{
    EXPECT_EQ(1.1, applyTimingInputNumber("duration", 1100).iterationDuration);
    EXPECT_TRUE(std::isnan(applyTimingInputNumber("duration", -1000).iterationDuration));
    EXPECT_EQ(1, applyTimingInputString("duration", "1000").iterationDuration);

    Timing timing = applyTimingInputString("duration", "Infinity");
    EXPECT_TRUE(std::isinf(timing.iterationDuration));
    EXPECT_GT(timing.iterationDuration, 0);

    EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "-Infinity").iterationDuration));
    EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "NaN").iterationDuration));
    EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "auto").iterationDuration));
    EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "rubbish").iterationDuration));
}
Example #17
0
TEST_F(AnimationAnimationTest, TimingInputFillMode)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope scope(isolate);
    v8::Local<v8::Context> context = v8::Context::New(isolate);
    v8::Context::Scope contextScope(context);

    Timing timing;
    Timing::FillMode defaultFillMode = Timing::FillModeAuto;
    EXPECT_EQ(defaultFillMode, timing.fillMode);

    applyTimingInputString(timing, isolate, "fill", "auto");
    EXPECT_EQ(Timing::FillModeAuto, timing.fillMode);
    timing.fillMode = defaultFillMode;

    applyTimingInputString(timing, isolate, "fill", "forwards");
    EXPECT_EQ(Timing::FillModeForwards, timing.fillMode);
    timing.fillMode = defaultFillMode;

    applyTimingInputString(timing, isolate, "fill", "none");
    EXPECT_EQ(Timing::FillModeNone, timing.fillMode);
    timing.fillMode = defaultFillMode;

    applyTimingInputString(timing, isolate, "fill", "backwards");
    EXPECT_EQ(Timing::FillModeBackwards, timing.fillMode);
    timing.fillMode = defaultFillMode;

    applyTimingInputString(timing, isolate, "fill", "both");
    EXPECT_EQ(Timing::FillModeBoth, timing.fillMode);
    timing.fillMode = defaultFillMode;

    applyTimingInputString(timing, isolate, "fill", "everything!");
    EXPECT_EQ(defaultFillMode, timing.fillMode);
    timing.fillMode = defaultFillMode;

    applyTimingInputString(timing, isolate, "fill", "backwardsandforwards");
    EXPECT_EQ(defaultFillMode, timing.fillMode);
    timing.fillMode = defaultFillMode;

    applyTimingInputNumber(timing, isolate, "fill", 2);
    EXPECT_EQ(defaultFillMode, timing.fillMode);
    timing.fillMode = defaultFillMode;
}
Example #18
0
TEST_F(AnimationAnimationTest, TimingInputIterationDuration)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope scope(isolate);
    v8::Local<v8::Context> context = v8::Context::New(isolate);
    v8::Context::Scope contextScope(context);

    Timing timing;
    EXPECT_TRUE(std::isnan(timing.iterationDuration));

    applyTimingInputNumber(timing, isolate, "duration", 1.1);
    EXPECT_EQ(1.1, timing.iterationDuration);
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();

    applyTimingInputNumber(timing, isolate, "duration", -1);
    EXPECT_TRUE(std::isnan(timing.iterationDuration));
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();

    applyTimingInputString(timing, isolate, "duration", "1");
    EXPECT_EQ(1, timing.iterationDuration);
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();

    applyTimingInputString(timing, isolate, "duration", "Infinity");
    EXPECT_TRUE(std::isinf(timing.iterationDuration) && (timing.iterationDuration > 0));
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();

    applyTimingInputString(timing, isolate, "duration", "-Infinity");
    EXPECT_TRUE(std::isnan(timing.iterationDuration));
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();

    applyTimingInputString(timing, isolate, "duration", "NaN");
    EXPECT_TRUE(std::isnan(timing.iterationDuration));
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();

    applyTimingInputString(timing, isolate, "duration", "auto");
    EXPECT_TRUE(std::isnan(timing.iterationDuration));
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();

    applyTimingInputString(timing, isolate, "duration", "rubbish");
    EXPECT_TRUE(std::isnan(timing.iterationDuration));
    timing.iterationDuration = std::numeric_limits<double>::quiet_NaN();
}
Example #19
0
TEST_F(AnimationAnimationTest, TimingInputTimingFunction)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope scope(isolate);
    v8::Local<v8::Context> context = v8::Context::New(isolate);
    v8::Context::Scope contextScope(context);

    Timing timing;
    const RefPtr<TimingFunction> defaultTimingFunction = LinearTimingFunction::create();
    EXPECT_EQ(*defaultTimingFunction.get(), *timing.timingFunction.get());

    applyTimingInputString(timing, isolate, "easing", "ease");
    EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease)), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "ease-in");
    EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn)), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "ease-out");
    EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut)), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "ease-in-out");
    EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut)), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "linear");
    EXPECT_EQ(*(LinearTimingFunction::create()), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "initial");
    EXPECT_EQ(*defaultTimingFunction.get(), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "step-start");
    EXPECT_EQ(*(StepsTimingFunction::preset(StepsTimingFunction::Start)), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "step-end");
    EXPECT_EQ(*(StepsTimingFunction::preset(StepsTimingFunction::End)), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "cubic-bezier(1, 1, 0.3, 0.3)");
    EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "steps(3, start)");
    EXPECT_EQ(*(StepsTimingFunction::create(3, true).get()), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "steps(5, end)");
    EXPECT_EQ(*(StepsTimingFunction::create(5, false).get()), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "steps(5.6, end)");
    EXPECT_EQ(*defaultTimingFunction.get(), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    // FIXME: Step-middle not yet implemented. Change this test when it is working.
    applyTimingInputString(timing, isolate, "easing", "steps(5, middle)");
    EXPECT_EQ(*defaultTimingFunction.get(), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "cubic-bezier(2, 2, 0.3, 0.3)");
    EXPECT_EQ(*defaultTimingFunction.get(), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputString(timing, isolate, "easing", "rubbish");
    EXPECT_EQ(*defaultTimingFunction.get(), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;

    applyTimingInputNumber(timing, isolate, "easing", 2);
    EXPECT_EQ(*defaultTimingFunction.get(), *timing.timingFunction.get());
    timing.timingFunction = defaultTimingFunction;
}
Example #20
0
TEST_F(AnimationTimingInputTest, TimingInputTimingFunction)
{
    const RefPtr<TimingFunction> defaultTimingFunction = LinearTimingFunction::shared();

    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), *applyTimingInputString("easing", "ease").timingFunction);
    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn), *applyTimingInputString("easing", "ease-in").timingFunction);
    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut), *applyTimingInputString("easing", "ease-out").timingFunction);
    EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut), *applyTimingInputString("easing", "ease-in-out").timingFunction);
    EXPECT_EQ(*LinearTimingFunction::shared(), *applyTimingInputString("easing", "linear").timingFunction);
    EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::Start), *applyTimingInputString("easing", "step-start").timingFunction);
    EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::Middle), *applyTimingInputString("easing", "step-middle").timingFunction);
    EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::End), *applyTimingInputString("easing", "step-end").timingFunction);
    EXPECT_EQ(*CubicBezierTimingFunction::create(1, 1, 0.3, 0.3), *applyTimingInputString("easing", "cubic-bezier(1, 1, 0.3, 0.3)").timingFunction);
    EXPECT_EQ(*StepsTimingFunction::create(3, StepsTimingFunction::StepAtStart), *applyTimingInputString("easing", "steps(3, start)").timingFunction);
    EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::StepAtMiddle), *applyTimingInputString("easing", "steps(5, middle)").timingFunction);
    EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::StepAtEnd), *applyTimingInputString("easing", "steps(5, end)").timingFunction);
    EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "steps(5.6, end)").timingFunction);
    EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "cubic-bezier(2, 2, 0.3, 0.3)").timingFunction);
    EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "rubbish").timingFunction);
    EXPECT_EQ(*defaultTimingFunction, *applyTimingInputNumber("easing", 2).timingFunction);
    EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "initial").timingFunction);
}