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/SVGComputedStyle.h" | 5 #include "core/style/SVGComputedStyle.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 // Ensures RefPtr values are compared by their values, not by pointers. | 11 // Ensures RefPtr values are compared by their values, not by pointers. |
12 #define TEST_STYLE_REFPTR_VALUE_NO_DIFF(type, fieldName) \ | 12 #define TEST_STYLE_REFPTR_VALUE_NO_DIFF(type, fieldName) \ |
13 { \ | 13 { \ |
14 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \ | 14 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \ |
15 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \ | 15 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \ |
16 RefPtr<type> value1 = type::create(); \ | 16 RefPtr<type> value1 = type::create(); \ |
17 RefPtr<type> value2 = value1->copy(); \ | 17 RefPtr<type> value2 = value1->copy(); \ |
18 svg1->set##fieldName(value1); \ | 18 svg1->set##fieldName(value1); \ |
19 svg2->set##fieldName(value2); \ | 19 svg2->set##fieldName(value2); \ |
20 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ | 20 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ |
21 } | 21 } |
22 | 22 |
23 // This is not very useful for fields directly stored by values, because they ca
n only be | 23 // This is not very useful for fields directly stored by values, because they |
24 // compared by values. This macro mainly ensures that we update the comparisons
and tests | 24 // can only be compared by values. This macro mainly ensures that we update the |
25 // when we change some field to RefPtr in the future. | 25 // comparisons and tests when we change some field to RefPtr in the future. |
26 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \ | 26 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \ |
27 { \ | 27 { \ |
28 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \ | 28 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \ |
29 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \ | 29 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \ |
30 svg1->set##fieldName(SVGComputedStyle::initial##fieldName()); \ | 30 svg1->set##fieldName(SVGComputedStyle::initial##fieldName()); \ |
31 svg2->set##fieldName(SVGComputedStyle::initial##fieldName()); \ | 31 svg2->set##fieldName(SVGComputedStyle::initial##fieldName()); \ |
32 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ | 32 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ |
33 } | 33 } |
34 | 34 |
35 TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue) { | 35 TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 TEST(SVGComputedStyleTest, MiscStyleShouldCompareValue) { | 70 TEST(SVGComputedStyleTest, MiscStyleShouldCompareValue) { |
71 TEST_STYLE_VALUE_NO_DIFF(Color, FloodColor); | 71 TEST_STYLE_VALUE_NO_DIFF(Color, FloodColor); |
72 TEST_STYLE_VALUE_NO_DIFF(float, FloodOpacity); | 72 TEST_STYLE_VALUE_NO_DIFF(float, FloodOpacity); |
73 TEST_STYLE_VALUE_NO_DIFF(Color, LightingColor); | 73 TEST_STYLE_VALUE_NO_DIFF(Color, LightingColor); |
74 TEST_STYLE_VALUE_NO_DIFF(Length, BaselineShiftValue); | 74 TEST_STYLE_VALUE_NO_DIFF(Length, BaselineShiftValue); |
75 } | 75 } |
76 | 76 |
77 } // namespace blink | 77 } // namespace blink |
OLD | NEW |