OLD | NEW |
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/style/ComputedStyle.h" | 5 #include "core/style/ComputedStyle.h" |
6 | 6 |
7 #include "core/style/ClipPathOperation.h" | 7 #include "core/style/ClipPathOperation.h" |
8 #include "core/style/ShapeValue.h" | 8 #include "core/style/ShapeValue.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 // This is not very useful for fields directly stored by values, because they |
| 14 // can only be compared by values. This macro mainly ensures that we update the |
| 15 // comparisons and tests when we change some field to RefPtr in the future. |
| 16 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \ |
| 17 { \ |
| 18 RefPtr<ComputedStyle> style1 = ComputedStyle::create(); \ |
| 19 RefPtr<ComputedStyle> style2 = ComputedStyle::create(); \ |
| 20 style1->set##fieldName(ComputedStyle::initial##fieldName()); \ |
| 21 style2->set##fieldName(ComputedStyle::initial##fieldName()); \ |
| 22 ASSERT_EQ(*style1, *style2); \ |
| 23 } |
| 24 |
13 TEST(ComputedStyleTest, ShapeOutsideBoxEqual) { | 25 TEST(ComputedStyleTest, ShapeOutsideBoxEqual) { |
14 ShapeValue* shape1 = ShapeValue::createBoxShapeValue(ContentBox); | 26 ShapeValue* shape1 = ShapeValue::createBoxShapeValue(ContentBox); |
15 ShapeValue* shape2 = ShapeValue::createBoxShapeValue(ContentBox); | 27 ShapeValue* shape2 = ShapeValue::createBoxShapeValue(ContentBox); |
16 RefPtr<ComputedStyle> style1 = ComputedStyle::create(); | 28 RefPtr<ComputedStyle> style1 = ComputedStyle::create(); |
17 RefPtr<ComputedStyle> style2 = ComputedStyle::create(); | 29 RefPtr<ComputedStyle> style2 = ComputedStyle::create(); |
18 style1->setShapeOutside(shape1); | 30 style1->setShapeOutside(shape1); |
19 style2->setShapeOutside(shape2); | 31 style2->setShapeOutside(shape2); |
20 ASSERT_EQ(*style1, *style2); | 32 ASSERT_EQ(*style1, *style2); |
21 } | 33 } |
22 | 34 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 EXPECT_TRUE(style->hasAnyPublicPseudoStyles()); | 97 EXPECT_TRUE(style->hasAnyPublicPseudoStyles()); |
86 } | 98 } |
87 | 99 |
88 TEST(ComputedStyleTest, LastPublicPseudoStyle) { | 100 TEST(ComputedStyleTest, LastPublicPseudoStyle) { |
89 RefPtr<ComputedStyle> style = ComputedStyle::create(); | 101 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
90 style->setHasPseudoStyle(PseudoIdScrollbar); | 102 style->setHasPseudoStyle(PseudoIdScrollbar); |
91 EXPECT_TRUE(style->hasPseudoStyle(PseudoIdScrollbar)); | 103 EXPECT_TRUE(style->hasPseudoStyle(PseudoIdScrollbar)); |
92 EXPECT_TRUE(style->hasAnyPublicPseudoStyles()); | 104 EXPECT_TRUE(style->hasAnyPublicPseudoStyles()); |
93 } | 105 } |
94 | 106 |
| 107 TEST(ComputedStyleTest, MiscStyleShouldCompareValue) { |
| 108 TEST_STYLE_VALUE_NO_DIFF(UnzoomedLength, StrokeWidth); |
| 109 TEST_STYLE_VALUE_NO_DIFF(unsigned, PaintOrder); |
| 110 TEST_STYLE_VALUE_NO_DIFF(unsigned, CapStyle); |
| 111 TEST_STYLE_VALUE_NO_DIFF(unsigned, JoinStyle); |
| 112 } |
| 113 |
95 } // namespace blink | 114 } // namespace blink |
OLD | NEW |