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

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: Rebase and update UseCounters again 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 18 matching lines...) Expand all
49 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-epub-text-tra nsform")); 60 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-epub-text-tra nsform"));
50 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("EpubTextTransf orm")); 61 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("EpubTextTransf orm"));
51 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-internal-marq uee-repetition")); 62 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-internal-marq uee-repetition"));
52 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("InternalMarque eRepetition")); 63 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("InternalMarque eRepetition"));
53 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-filter ")); 64 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-filter "));
54 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-transf orm")); 65 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("-webkit-transf orm"));
55 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("webkitTransfor m")); 66 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("webkitTransfor m"));
56 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("WebkitTransfor m")); 67 EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("WebkitTransfor m"));
57 } 68 }
58 69
59 static bool timingFunctionRoundTrips(const String& string)
60 {
61 RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFu nction(string);
62 return timingFunction && string == timingFunction->toString();
63 }
64
65 TEST_F(AnimationAnimationInputHelpersTest, ParseAnimationTimingFunction) 70 TEST_F(AnimationAnimationInputHelpersTest, ParseAnimationTimingFunction)
66 { 71 {
67 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("initial")); 72 EXPECT_EQ(nullptr, parseTimingFunction("initial"));
68 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("inherit")); 73 EXPECT_EQ(nullptr, parseTimingFunction("inherit"));
69 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("unset")); 74 EXPECT_EQ(nullptr, parseTimingFunction("unset"));
70 75
71 EXPECT_TRUE(timingFunctionRoundTrips("ease")); 76 EXPECT_TRUE(timingFunctionRoundTrips("ease"));
72 EXPECT_TRUE(timingFunctionRoundTrips("linear")); 77 EXPECT_TRUE(timingFunctionRoundTrips("linear"));
73 EXPECT_TRUE(timingFunctionRoundTrips("ease-in")); 78 EXPECT_TRUE(timingFunctionRoundTrips("ease-in"));
74 EXPECT_TRUE(timingFunctionRoundTrips("ease-out")); 79 EXPECT_TRUE(timingFunctionRoundTrips("ease-out"));
75 EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out")); 80 EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out"));
76 EXPECT_TRUE(timingFunctionRoundTrips("step-start")); 81 EXPECT_TRUE(timingFunctionRoundTrips("step-start"));
77 EXPECT_TRUE(timingFunctionRoundTrips("step-middle")); 82 EXPECT_TRUE(timingFunctionRoundTrips("step-middle"));
78 EXPECT_TRUE(timingFunctionRoundTrips("step-end")); 83 EXPECT_TRUE(timingFunctionRoundTrips("step-end"));
79 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)")); 84 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)"));
80 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)")); 85 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)"));
81 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)")); 86 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)"));
82 EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)")); 87 EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)"));
83 88
84 EXPECT_EQ("steps(3, end)", AnimationInputHelpers::parseTimingFunction("steps (3)")->toString()); 89 EXPECT_EQ("steps(3, end)", parseTimingFunction("steps(3)")->toString());
85 90
86 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(3, nowh ere)")); 91 EXPECT_EQ(nullptr, parseTimingFunction("steps(3, nowhere)"));
87 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(-3, end )")); 92 EXPECT_EQ(nullptr, parseTimingFunction("steps(-3, end)"));
88 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("cubic-bezier( 0.1, 0, 4, 0.4)")); 93 EXPECT_EQ(nullptr, parseTimingFunction("cubic-bezier(0.1, 0, 4, 0.4)"));
89 } 94 }
90 95
91 } // namespace blink 96 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698