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 "config.h" | 5 #include "config.h" |
6 #include "core/layout/style/SVGLayoutStyle.h" | 6 #include "core/layout/style/SVGComputedStyle.h" |
7 | 7 |
8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
9 | 9 |
10 using namespace blink; | 10 using namespace blink; |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // Ensures RefPtr values are compared by their values, not by pointers. | 14 // Ensures RefPtr values are compared by their values, not by pointers. |
15 #define TEST_STYLE_REFPTR_VALUE_NO_DIFF(type, fieldName) \ | 15 #define TEST_STYLE_REFPTR_VALUE_NO_DIFF(type, fieldName) \ |
16 { \ | 16 { \ |
17 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); \ | 17 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \ |
18 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); \ | 18 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \ |
19 RefPtr<type> value1 = type::create(); \ | 19 RefPtr<type> value1 = type::create(); \ |
20 RefPtr<type> value2 = value1->copy(); \ | 20 RefPtr<type> value2 = value1->copy(); \ |
21 svg1->set##fieldName(value1); \ | 21 svg1->set##fieldName(value1); \ |
22 svg2->set##fieldName(value2); \ | 22 svg2->set##fieldName(value2); \ |
23 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ | 23 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ |
24 } | 24 } |
25 | 25 |
26 // This is not very useful for fields directly stored by values, because they ca
n only be | 26 // This is not very useful for fields directly stored by values, because they ca
n only be |
27 // compared by values. This macro mainly ensures that we update the comparisons
and tests | 27 // compared by values. This macro mainly ensures that we update the comparisons
and tests |
28 // when we change some field to RefPtr in the future. | 28 // when we change some field to RefPtr in the future. |
29 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \ | 29 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \ |
30 { \ | 30 { \ |
31 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); \ | 31 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \ |
32 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); \ | 32 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \ |
33 svg1->set##fieldName(SVGLayoutStyle::initial##fieldName()); \ | 33 svg1->set##fieldName(SVGComputedStyle::initial##fieldName()); \ |
34 svg2->set##fieldName(SVGLayoutStyle::initial##fieldName()); \ | 34 svg2->set##fieldName(SVGComputedStyle::initial##fieldName()); \ |
35 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ | 35 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ |
36 } | 36 } |
37 | 37 |
38 TEST(SVGLayoutStyleTest, StrokeStyleShouldCompareValue) | 38 TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue) |
39 { | 39 { |
40 TEST_STYLE_VALUE_NO_DIFF(float, StrokeOpacity); | 40 TEST_STYLE_VALUE_NO_DIFF(float, StrokeOpacity); |
41 TEST_STYLE_VALUE_NO_DIFF(float, StrokeMiterLimit); | 41 TEST_STYLE_VALUE_NO_DIFF(float, StrokeMiterLimit); |
42 TEST_STYLE_VALUE_NO_DIFF(UnzoomedLength, StrokeWidth); | 42 TEST_STYLE_VALUE_NO_DIFF(UnzoomedLength, StrokeWidth); |
43 TEST_STYLE_VALUE_NO_DIFF(Length, StrokeDashOffset); | 43 TEST_STYLE_VALUE_NO_DIFF(Length, StrokeDashOffset); |
44 TEST_STYLE_REFPTR_VALUE_NO_DIFF(SVGDashArray, StrokeDashArray); | 44 TEST_STYLE_REFPTR_VALUE_NO_DIFF(SVGDashArray, StrokeDashArray); |
45 | 45 |
46 { | 46 { |
47 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); | 47 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); |
48 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); | 48 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); |
49 svg1->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout
Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), true,
false); | 49 svg1->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComp
utedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(),
true, false); |
50 svg2->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout
Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), true,
false); | 50 svg2->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComp
utedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(),
true, false); |
51 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); | 51 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); |
52 } | 52 } |
53 { | 53 { |
54 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); | 54 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); |
55 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); | 55 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); |
56 svg1->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout
Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), false
, true); | 56 svg1->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComp
utedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(),
false, true); |
57 svg2->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout
Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), false
, true); | 57 svg2->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComp
utedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(),
false, true); |
58 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); | 58 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 TEST(SVGLayoutStyleTest, MiscStyleShouldCompareValue) | 62 TEST(SVGComputedStyleTest, MiscStyleShouldCompareValue) |
63 { | 63 { |
64 TEST_STYLE_VALUE_NO_DIFF(Color, FloodColor); | 64 TEST_STYLE_VALUE_NO_DIFF(Color, FloodColor); |
65 TEST_STYLE_VALUE_NO_DIFF(float, FloodOpacity); | 65 TEST_STYLE_VALUE_NO_DIFF(float, FloodOpacity); |
66 TEST_STYLE_VALUE_NO_DIFF(Color, LightingColor); | 66 TEST_STYLE_VALUE_NO_DIFF(Color, LightingColor); |
67 TEST_STYLE_VALUE_NO_DIFF(Length, BaselineShiftValue); | 67 TEST_STYLE_VALUE_NO_DIFF(Length, BaselineShiftValue); |
68 } | 68 } |
69 | 69 |
70 } | 70 } |
OLD | NEW |