Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / style / SVGComputedStyleTest.cpp
bloba4191af1f5eddcafaa04a546141f2f9c0f0b1bbb
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.
5 #include "config.h"
6 #include "core/style/SVGComputedStyle.h"
8 #include <gtest/gtest.h>
10 namespace blink {
12 // Ensures RefPtr values are compared by their values, not by pointers.
13 #define TEST_STYLE_REFPTR_VALUE_NO_DIFF(type, fieldName) \
14 { \
15 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \
16 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \
17 RefPtr<type> value1 = type::create(); \
18 RefPtr<type> value2 = value1->copy(); \
19 svg1->set##fieldName(value1); \
20 svg2->set##fieldName(value2); \
21 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \
24 // This is not very useful for fields directly stored by values, because they can only be
25 // compared by values. This macro mainly ensures that we update the comparisons and tests
26 // when we change some field to RefPtr in the future.
27 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \
28 { \
29 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create(); \
30 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create(); \
31 svg1->set##fieldName(SVGComputedStyle::initial##fieldName()); \
32 svg2->set##fieldName(SVGComputedStyle::initial##fieldName()); \
33 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \
36 TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue)
38 TEST_STYLE_VALUE_NO_DIFF(float, StrokeOpacity);
39 TEST_STYLE_VALUE_NO_DIFF(float, StrokeMiterLimit);
40 TEST_STYLE_VALUE_NO_DIFF(UnzoomedLength, StrokeWidth);
41 TEST_STYLE_VALUE_NO_DIFF(Length, StrokeDashOffset);
42 TEST_STYLE_REFPTR_VALUE_NO_DIFF(SVGDashArray, StrokeDashArray);
45 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create();
46 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create();
47 svg1->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComputedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(), true, false);
48 svg2->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComputedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(), true, false);
49 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference());
52 RefPtr<SVGComputedStyle> svg1 = SVGComputedStyle::create();
53 RefPtr<SVGComputedStyle> svg2 = SVGComputedStyle::create();
54 svg1->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComputedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(), false, true);
55 svg2->setStrokePaint(SVGComputedStyle::initialStrokePaintType(), SVGComputedStyle::initialStrokePaintColor(), SVGComputedStyle::initialStrokePaintUri(), false, true);
56 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference());
60 TEST(SVGComputedStyleTest, MiscStyleShouldCompareValue)
62 TEST_STYLE_VALUE_NO_DIFF(Color, FloodColor);
63 TEST_STYLE_VALUE_NO_DIFF(float, FloodOpacity);
64 TEST_STYLE_VALUE_NO_DIFF(Color, LightingColor);
65 TEST_STYLE_VALUE_NO_DIFF(Length, BaselineShiftValue);
68 } // namespace blink