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

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

Issue 2309873003: Extend PropertyHandle to include custom property identifiers (Closed)
Patch Set: Add unit tests Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/PropertyHandle.h" 5 #include "core/animation/PropertyHandle.h"
6 6
7 #include "core/SVGNames.h" 7 #include "core/SVGNames.h"
8 #include "core/XLinkNames.h" 8 #include "core/XLinkNames.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 using namespace SVGNames; 13 using namespace SVGNames;
14 14
15 class PropertyHandleTest : public ::testing::Test { 15 class PropertyHandleTest : public ::testing::Test {
16 }; 16 };
17 17
18 TEST_F(PropertyHandleTest, Equality) 18 TEST_F(PropertyHandleTest, Equality)
19 { 19 {
20 AtomicString nameA = "--a";
21 AtomicString nameB = "--b";
22
20 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity) == PropertyHandle(CSSProperty Opacity)); 23 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity) == PropertyHandle(CSSProperty Opacity));
21 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity) != PropertyHandle(CSSPropert yOpacity)); 24 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity) != PropertyHandle(CSSPropert yOpacity));
22 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity) == PropertyHandle(CSSPropert yTransform)); 25 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity) == PropertyHandle(CSSPropert yTransform));
23 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity) != PropertyHandle(CSSProperty Transform)); 26 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity) != PropertyHandle(CSSProperty Transform));
27 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity) == PropertyHandle(nameA));
28 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity) != PropertyHandle(nameA));
24 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity) == PropertyHandle(amplitudeA ttr)); 29 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity) == PropertyHandle(amplitudeA ttr));
25 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity) != PropertyHandle(amplitudeAt tr)); 30 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity) != PropertyHandle(amplitudeAt tr));
26 31
32 EXPECT_FALSE(PropertyHandle(nameA) == PropertyHandle(CSSPropertyOpacity));
33 EXPECT_TRUE(PropertyHandle(nameA) != PropertyHandle(CSSPropertyOpacity));
34 EXPECT_FALSE(PropertyHandle(nameA) == PropertyHandle(CSSPropertyTransform));
35 EXPECT_TRUE(PropertyHandle(nameA) != PropertyHandle(CSSPropertyTransform));
36 EXPECT_TRUE(PropertyHandle(nameA) == PropertyHandle(nameA));
37 EXPECT_FALSE(PropertyHandle(nameA) != PropertyHandle(nameA));
38 EXPECT_FALSE(PropertyHandle(nameA) == PropertyHandle(nameB));
39 EXPECT_TRUE(PropertyHandle(nameA) != PropertyHandle(nameB));
40 EXPECT_FALSE(PropertyHandle(nameA) == PropertyHandle(amplitudeAttr));
41 EXPECT_TRUE(PropertyHandle(nameA) != PropertyHandle(amplitudeAttr));
42
27 EXPECT_FALSE(PropertyHandle(amplitudeAttr) == PropertyHandle(CSSPropertyOpac ity)); 43 EXPECT_FALSE(PropertyHandle(amplitudeAttr) == PropertyHandle(CSSPropertyOpac ity));
28 EXPECT_TRUE(PropertyHandle(amplitudeAttr) != PropertyHandle(CSSPropertyOpaci ty)); 44 EXPECT_TRUE(PropertyHandle(amplitudeAttr) != PropertyHandle(CSSPropertyOpaci ty));
45 EXPECT_FALSE(PropertyHandle(amplitudeAttr) == PropertyHandle(nameA));
46 EXPECT_TRUE(PropertyHandle(amplitudeAttr) != PropertyHandle(nameA));
29 EXPECT_TRUE(PropertyHandle(amplitudeAttr) == PropertyHandle(amplitudeAttr)); 47 EXPECT_TRUE(PropertyHandle(amplitudeAttr) == PropertyHandle(amplitudeAttr));
30 EXPECT_FALSE(PropertyHandle(amplitudeAttr) != PropertyHandle(amplitudeAttr)) ; 48 EXPECT_FALSE(PropertyHandle(amplitudeAttr) != PropertyHandle(amplitudeAttr)) ;
31 EXPECT_FALSE(PropertyHandle(amplitudeAttr) == PropertyHandle(exponentAttr)); 49 EXPECT_FALSE(PropertyHandle(amplitudeAttr) == PropertyHandle(exponentAttr));
32 EXPECT_TRUE(PropertyHandle(amplitudeAttr) != PropertyHandle(exponentAttr)); 50 EXPECT_TRUE(PropertyHandle(amplitudeAttr) != PropertyHandle(exponentAttr));
33 } 51 }
34 52
35 TEST_F(PropertyHandleTest, Hash) 53 TEST_F(PropertyHandleTest, Hash)
36 { 54 {
55 AtomicString nameA = "--a";
56 AtomicString nameB = "--b";
57
37 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity).hash() == PropertyHandle(CSSP ropertyOpacity).hash()); 58 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity).hash() == PropertyHandle(CSSP ropertyOpacity).hash());
59 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).hash() == PropertyHandle(nam eA).hash());
38 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).hash() == PropertyHandle(CSS PropertyTransform).hash()); 60 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).hash() == PropertyHandle(CSS PropertyTransform).hash());
39 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).hash() == PropertyHandle(amp litudeAttr).hash()); 61 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).hash() == PropertyHandle(amp litudeAttr).hash());
40 62
63 EXPECT_FALSE(PropertyHandle(nameA).hash() == PropertyHandle(CSSPropertyOpaci ty).hash());
64 EXPECT_TRUE(PropertyHandle(nameA).hash() == PropertyHandle(nameA).hash());
65 EXPECT_FALSE(PropertyHandle(nameA).hash() == PropertyHandle(nameB).hash());
66 EXPECT_FALSE(PropertyHandle(nameA).hash() == PropertyHandle(exponentAttr).ha sh());
67
41 EXPECT_FALSE(PropertyHandle(amplitudeAttr).hash() == PropertyHandle(CSSPrope rtyOpacity).hash()); 68 EXPECT_FALSE(PropertyHandle(amplitudeAttr).hash() == PropertyHandle(CSSPrope rtyOpacity).hash());
69 EXPECT_FALSE(PropertyHandle(amplitudeAttr).hash() == PropertyHandle(nameA).h ash());
42 EXPECT_TRUE(PropertyHandle(amplitudeAttr).hash() == PropertyHandle(amplitude Attr).hash()); 70 EXPECT_TRUE(PropertyHandle(amplitudeAttr).hash() == PropertyHandle(amplitude Attr).hash());
43 EXPECT_FALSE(PropertyHandle(amplitudeAttr).hash() == PropertyHandle(exponent Attr).hash()); 71 EXPECT_FALSE(PropertyHandle(amplitudeAttr).hash() == PropertyHandle(exponent Attr).hash());
44 } 72 }
45 73
46 TEST_F(PropertyHandleTest, Accessors) 74 TEST_F(PropertyHandleTest, Accessors)
47 { 75 {
76 AtomicString name = "--x";
77
48 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity).isCSSProperty()); 78 EXPECT_TRUE(PropertyHandle(CSSPropertyOpacity).isCSSProperty());
49 EXPECT_EQ(PropertyHandle(CSSPropertyOpacity).cssProperty(), CSSPropertyOpaci ty); 79 EXPECT_TRUE(PropertyHandle(name).isCSSProperty());
50 EXPECT_FALSE(PropertyHandle(amplitudeAttr).isCSSProperty()); 80 EXPECT_FALSE(PropertyHandle(amplitudeAttr).isCSSProperty());
51 81
52 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).isSVGAttribute()); 82 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).isSVGAttribute());
83 EXPECT_FALSE(PropertyHandle(name).isSVGAttribute());
53 EXPECT_TRUE(PropertyHandle(amplitudeAttr).isSVGAttribute()); 84 EXPECT_TRUE(PropertyHandle(amplitudeAttr).isSVGAttribute());
85
86 EXPECT_FALSE(PropertyHandle(CSSPropertyOpacity).isCSSCustomProperty());
87 EXPECT_TRUE(PropertyHandle(name).isCSSCustomProperty());
88 EXPECT_FALSE(PropertyHandle(amplitudeAttr).isCSSCustomProperty());
89
90 EXPECT_EQ(PropertyHandle(CSSPropertyOpacity).cssProperty(), CSSPropertyOpaci ty);
91 EXPECT_EQ(PropertyHandle(name).cssProperty(), CSSPropertyVariable);
92 EXPECT_EQ(PropertyHandle(name).customPropertyName(), name);
54 EXPECT_EQ(PropertyHandle(amplitudeAttr).svgAttribute(), amplitudeAttr); 93 EXPECT_EQ(PropertyHandle(amplitudeAttr).svgAttribute(), amplitudeAttr);
55 } 94 }
56 95
57 } // namespace blink 96 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698