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

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp

Issue 1867803002: Add use counters for function values of easing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/AnimationInputHelpers.h" 5 #include "core/animation/AnimationInputHelpers.h"
6 6
7 #include "core/dom/Element.h" 7 #include "core/dom/Element.h"
8 #include "core/testing/DummyPageHolder.h" 8 #include "core/testing/DummyPageHolder.h"
9 #include "platform/animation/TimingFunction.h" 9 #include "platform/animation/TimingFunction.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class AnimationAnimationInputHelpersTest : public ::testing::Test { 14 class AnimationAnimationInputHelpersTest : public ::testing::Test {
15 public: 15 public:
16 CSSPropertyID keyframeAttributeToCSSProperty(const String& property) 16 CSSPropertyID keyframeAttributeToCSSProperty(const String& property)
17 { 17 {
18 return AnimationInputHelpers::keyframeAttributeToCSSProperty(property, * document); 18 return AnimationInputHelpers::keyframeAttributeToCSSProperty(property, * document);
19 } 19 }
20 20
21 PassRefPtr<TimingFunction> parseTimingFunction(const String& string)
22 {
23 return AnimationInputHelpers::parseTimingFunction(string, document);
24 }
25
26 bool timingFunctionRoundTrips(const String& string)
27 {
28 RefPtr<TimingFunction> timingFunction = parseTimingFunction(string);
29 return timingFunction && string == timingFunction->toString();
30 }
31
21 protected: 32 protected:
22 void SetUp() override 33 void SetUp() override
23 { 34 {
24 pageHolder = DummyPageHolder::create(); 35 pageHolder = DummyPageHolder::create();
25 document = &pageHolder->document(); 36 document = &pageHolder->document();
26 } 37 }
27 38
28 void TearDown() override 39 void TearDown() override
29 { 40 {
30 document.release(); 41 document.release();
(...skipping 20 matching lines...) Expand all
51 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-epub-text-tra nsform")); 62 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-epub-text-tra nsform"));
52 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("EpubTextTransf orm")); 63 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("EpubTextTransf orm"));
53 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-internal-marq uee-repetition")); 64 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-internal-marq uee-repetition"));
54 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("InternalMarque eRepetition")); 65 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("InternalMarque eRepetition"));
55 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-filter ")); 66 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-filter "));
56 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-transf orm")); 67 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-transf orm"));
57 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("webkitTransfor m")); 68 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("webkitTransfor m"));
58 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("WebkitTransfor m")); 69 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("WebkitTransfor m"));
59 } 70 }
60 71
61 static bool timingFunctionRoundTrips(const String& string)
62 {
63 RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFu nction(string);
64 return timingFunction && string == timingFunction->toString();
65 }
66
67 TEST_F(AnimationAnimationInputHelpersTest, ParseAnimationTimingFunction) 72 TEST_F(AnimationAnimationInputHelpersTest, ParseAnimationTimingFunction)
68 { 73 {
69 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("initial")); 74 EXPECT_EQ(nullptr, parseTimingFunction("initial"));
70 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("inherit")); 75 EXPECT_EQ(nullptr, parseTimingFunction("inherit"));
71 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("unset")); 76 EXPECT_EQ(nullptr, parseTimingFunction("unset"));
72 77
73 EXPECT_TRUE(timingFunctionRoundTrips("ease")); 78 EXPECT_TRUE(timingFunctionRoundTrips("ease"));
74 EXPECT_TRUE(timingFunctionRoundTrips("linear")); 79 EXPECT_TRUE(timingFunctionRoundTrips("linear"));
75 EXPECT_TRUE(timingFunctionRoundTrips("ease-in")); 80 EXPECT_TRUE(timingFunctionRoundTrips("ease-in"));
76 EXPECT_TRUE(timingFunctionRoundTrips("ease-out")); 81 EXPECT_TRUE(timingFunctionRoundTrips("ease-out"));
77 EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out")); 82 EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out"));
78 EXPECT_TRUE(timingFunctionRoundTrips("step-start")); 83 EXPECT_TRUE(timingFunctionRoundTrips("step-start"));
79 EXPECT_TRUE(timingFunctionRoundTrips("step-middle")); 84 EXPECT_TRUE(timingFunctionRoundTrips("step-middle"));
80 EXPECT_TRUE(timingFunctionRoundTrips("step-end")); 85 EXPECT_TRUE(timingFunctionRoundTrips("step-end"));
81 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)")); 86 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)"));
82 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)")); 87 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)"));
83 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)")); 88 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)"));
84 EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)")); 89 EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)"));
85 90
86 EXPECT_EQ("steps(3, end)", AnimationInputHelpers::parseTimingFunction("steps (3)")->toString()); 91 EXPECT_EQ("steps(3, end)", parseTimingFunction("steps(3)")->toString());
87 92
88 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(3, nowh ere)")); 93 EXPECT_EQ(nullptr, parseTimingFunction("steps(3, nowhere)"));
89 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(-3, end )")); 94 EXPECT_EQ(nullptr, parseTimingFunction("steps(-3, end)"));
90 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("cubic-bezier( 0.1, 0, 4, 0.4)")); 95 EXPECT_EQ(nullptr, parseTimingFunction("cubic-bezier(0.1, 0, 4, 0.4)"));
91 } 96 }
92 97
93 } // namespace blink 98 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698