Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: Source/core/layout/style/SVGLayoutStyleTest.cpp

Issue 975733002: Use Length for the stroke-dasharray property in SVGLayoutStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test for style-change responsive-ness. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/SVGLayoutStyle.h"
7 7
8 #include "core/layout/ClipPathOperation.h" 8 #include "core/svg/SVGLength.h"
9 #include "core/layout/style/ShapeValue.h"
10 9
11 #include <gtest/gtest.h> 10 #include <gtest/gtest.h>
12 11
13 using namespace blink; 12 using namespace blink;
14 13
15 namespace { 14 namespace {
16 15
17 // Ensures RefPtr values are compared by their values, not by pointers. 16 // Ensures RefPtrWillBePersistent values are compared by their values, not by po inters.
18 #define TEST_STYLE_REFPTR_VALUE_NO_DIFF(type, fieldName) \ 17 #define TEST_STYLE_REFPTRWILLBEPERSISTENT_VALUE_NO_DIFF(type, fieldName) \
19 { \ 18 { \
20 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); \ 19 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); \
21 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); \ 20 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); \
22 RefPtrWillBePersistent<type> value1 = type::create(); \ 21 RefPtrWillBePersistent<type> value1 = type::create(); \
23 RefPtrWillBePersistent<type> value2 = value1->clone(); \ 22 RefPtrWillBePersistent<type> value2 = value1->clone(); \
24 svg1->set##fieldName(value1); \ 23 svg1->set##fieldName(value1); \
25 svg2->set##fieldName(value2); \ 24 svg2->set##fieldName(value2); \
26 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ 25 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \
27 } 26 }
28 27
28 // Ensures RefPtr values are compared by their values, not by pointers.
29 #define TEST_STYLE_REFPTR_VALUE_NO_DIFF(type, fieldName) \
30 { \
31 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); \
32 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); \
33 RefPtr<type> value1 = type::create(); \
34 RefPtr<type> value2 = value1->copy(); \
35 svg1->set##fieldName(value1); \
36 svg2->set##fieldName(value2); \
37 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \
38 }
39
29 // This is not very useful for fields directly stored by values, because they ca n only be 40 // This is not very useful for fields directly stored by values, because they ca n only be
30 // compared by values. This macro mainly ensures that we update the comparisons and tests 41 // compared by values. This macro mainly ensures that we update the comparisons and tests
31 // when we change some field to RefPtr in the future. 42 // when we change some field to RefPtr in the future.
32 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \ 43 #define TEST_STYLE_VALUE_NO_DIFF(type, fieldName) \
33 { \ 44 { \
34 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); \ 45 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); \
35 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); \ 46 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); \
36 svg1->set##fieldName(SVGLayoutStyle::initial##fieldName()); \ 47 svg1->set##fieldName(SVGLayoutStyle::initial##fieldName()); \
37 svg2->set##fieldName(SVGLayoutStyle::initial##fieldName()); \ 48 svg2->set##fieldName(SVGLayoutStyle::initial##fieldName()); \
38 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \ 49 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); \
39 } 50 }
40 51
41 TEST(SVGLayoutStyleTest, StrokeStyleShouldCompareValue) 52 TEST(SVGLayoutStyleTest, StrokeStyleShouldCompareValue)
42 { 53 {
43 TEST_STYLE_VALUE_NO_DIFF(float, StrokeOpacity); 54 TEST_STYLE_VALUE_NO_DIFF(float, StrokeOpacity);
44 TEST_STYLE_VALUE_NO_DIFF(float, StrokeMiterLimit); 55 TEST_STYLE_VALUE_NO_DIFF(float, StrokeMiterLimit);
45 TEST_STYLE_REFPTR_VALUE_NO_DIFF(SVGLength, StrokeWidth); 56 TEST_STYLE_REFPTRWILLBEPERSISTENT_VALUE_NO_DIFF(SVGLength, StrokeWidth);
46 TEST_STYLE_VALUE_NO_DIFF(Length, StrokeDashOffset); 57 TEST_STYLE_VALUE_NO_DIFF(Length, StrokeDashOffset);
47 TEST_STYLE_REFPTR_VALUE_NO_DIFF(SVGLengthList, StrokeDashArray); 58 TEST_STYLE_REFPTR_VALUE_NO_DIFF(SVGDashArray, StrokeDashArray);
48 59
49 { 60 {
50 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); 61 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create();
51 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); 62 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create();
52 svg1->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), true, false); 63 svg1->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), true, false);
53 svg2->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), true, false); 64 svg2->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), true, false);
54 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); 65 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference());
55 } 66 }
56 { 67 {
57 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create(); 68 RefPtr<SVGLayoutStyle> svg1 = SVGLayoutStyle::create();
58 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create(); 69 RefPtr<SVGLayoutStyle> svg2 = SVGLayoutStyle::create();
59 svg1->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), false , true); 70 svg1->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), false , true);
60 svg2->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), false , true); 71 svg2->setStrokePaint(SVGLayoutStyle::initialStrokePaintType(), SVGLayout Style::initialStrokePaintColor(), SVGLayoutStyle::initialStrokePaintUri(), false , true);
61 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference()); 72 EXPECT_FALSE(svg1->diff(svg2.get()).hasDifference());
62 } 73 }
63 } 74 }
64 75
65 TEST(SVGLayoutStyleTest, MiscStyleShouldCompareValue) 76 TEST(SVGLayoutStyleTest, MiscStyleShouldCompareValue)
66 { 77 {
67 TEST_STYLE_VALUE_NO_DIFF(Color, FloodColor); 78 TEST_STYLE_VALUE_NO_DIFF(Color, FloodColor);
68 TEST_STYLE_VALUE_NO_DIFF(float, FloodOpacity); 79 TEST_STYLE_VALUE_NO_DIFF(float, FloodOpacity);
69 TEST_STYLE_VALUE_NO_DIFF(Color, LightingColor); 80 TEST_STYLE_VALUE_NO_DIFF(Color, LightingColor);
70 TEST_STYLE_VALUE_NO_DIFF(Length, BaselineShiftValue); 81 TEST_STYLE_VALUE_NO_DIFF(Length, BaselineShiftValue);
71 } 82 }
72 83
73 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698