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