@@ -46,21 +46,63 @@ This file is part of the iText (R) project.
46
46
import com .itextpdf .styledxmlparser .css .CssDeclaration ;
47
47
import com .itextpdf .test .ExtendedITextTest ;
48
48
import com .itextpdf .test .annotations .type .UnitTest ;
49
- import org .junit .Test ;
50
- import org .junit .experimental .categories .Category ;
51
49
52
50
import java .util .Set ;
53
51
import java .util .HashSet ;
54
52
import java .util .Arrays ;
55
53
import java .util .List ;
56
54
import java .util .TreeSet ;
57
55
58
- import static org .junit .Assert .assertNotNull ;
59
- import static org .junit .Assert .fail ;
56
+ import org .junit .Assert ;
57
+ import org .junit .Test ;
58
+ import org .junit .experimental .categories .Category ;
60
59
61
60
@ Category (UnitTest .class )
62
61
public class CssShorthandResolverTest extends ExtendedITextTest {
62
+ @ Test
63
+ public void linearGradientInlistStyleImageTest () {
64
+ String shorthandExpression = "inside linear-gradient(red, green, blue)" ;
65
+ Set <String > expectedResolvedProperties = new HashSet <>(Arrays .asList (
66
+ "list-style-type: initial" ,
67
+ "list-style-position: inside" ,
68
+ "list-style-image: linear-gradient(red,green,blue)"
69
+ ));
70
+
71
+ IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver (CommonCssConstants .LIST_STYLE );
72
+ Assert .assertNotNull (resolver );
73
+ List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand (shorthandExpression );
74
+ compareResolvedProps (resolvedShorthandProps , expectedResolvedProperties );
75
+ }
63
76
77
+ @ Test
78
+ public void repeatingLinearGradientInlistStyleImageTest () {
79
+ String shorthandExpression = "square inside repeating-linear-gradient(45deg, blue 7%, red 10%)" ;
80
+ Set <String > expectedResolvedProperties = new HashSet <>(Arrays .asList (
81
+ "list-style-type: square" ,
82
+ "list-style-position: inside" ,
83
+ "list-style-image: repeating-linear-gradient(45deg,blue 7%,red 10%)"
84
+ ));
85
+
86
+ IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver (CommonCssConstants .LIST_STYLE );
87
+ Assert .assertNotNull (resolver );
88
+ List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand (shorthandExpression );
89
+ compareResolvedProps (resolvedShorthandProps , expectedResolvedProperties );
90
+ }
91
+
92
+ @ Test
93
+ public void noneInlistStyleImageTest () {
94
+ String shorthandExpression = "circle none inside" ;
95
+ Set <String > expectedResolvedProperties = new HashSet <>(Arrays .asList (
96
+ "list-style-type: circle" ,
97
+ "list-style-position: inside" ,
98
+ "list-style-image: none"
99
+ ));
100
+
101
+ IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver (CommonCssConstants .LIST_STYLE );
102
+ Assert .assertNotNull (resolver );
103
+ List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand (shorthandExpression );
104
+ compareResolvedProps (resolvedShorthandProps , expectedResolvedProperties );
105
+ }
64
106
65
107
@ Test
66
108
public void fontTest01 () {
@@ -75,7 +117,7 @@ public void fontTest01() {
75
117
) );
76
118
77
119
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
78
- assertNotNull ( resolver );
120
+ Assert . assertNotNull ( resolver );
79
121
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
80
122
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
81
123
}
@@ -93,7 +135,7 @@ public void fontTest02() {
93
135
) );
94
136
95
137
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
96
- assertNotNull ( resolver );
138
+ Assert . assertNotNull ( resolver );
97
139
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
98
140
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
99
141
}
@@ -111,7 +153,7 @@ public void fontTest03() {
111
153
) );
112
154
113
155
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
114
- assertNotNull ( resolver );
156
+ Assert . assertNotNull ( resolver );
115
157
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
116
158
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
117
159
}
@@ -129,7 +171,7 @@ public void fontTest04() {
129
171
) );
130
172
131
173
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
132
- assertNotNull ( resolver );
174
+ Assert . assertNotNull ( resolver );
133
175
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
134
176
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
135
177
}
@@ -147,7 +189,7 @@ public void fontTest05() {
147
189
) );
148
190
149
191
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
150
- assertNotNull ( resolver );
192
+ Assert . assertNotNull ( resolver );
151
193
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
152
194
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
153
195
}
@@ -165,7 +207,7 @@ public void fontTest06() {
165
207
) );
166
208
167
209
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
168
- assertNotNull ( resolver );
210
+ Assert . assertNotNull ( resolver );
169
211
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
170
212
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
171
213
}
@@ -183,7 +225,7 @@ public void fontTest07() {
183
225
) );
184
226
185
227
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
186
- assertNotNull ( resolver );
228
+ Assert . assertNotNull ( resolver );
187
229
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
188
230
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
189
231
}
@@ -201,7 +243,7 @@ public void fontTest08() {
201
243
) );
202
244
203
245
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
204
- assertNotNull ( resolver );
246
+ Assert . assertNotNull ( resolver );
205
247
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
206
248
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
207
249
}
@@ -219,7 +261,7 @@ public void fontTest09() {
219
261
) );
220
262
221
263
IShorthandResolver resolver = ShorthandResolverFactory .getShorthandResolver ( CommonCssConstants .FONT );
222
- assertNotNull ( resolver );
264
+ Assert . assertNotNull ( resolver );
223
265
List <CssDeclaration > resolvedShorthandProps = resolver .resolveShorthand ( shorthandExpression );
224
266
compareResolvedProps ( resolvedShorthandProps , expectedResolvedProperties );
225
267
}
@@ -253,7 +295,7 @@ private void compareResolvedProps(List<CssDeclaration> actual, Set<String> expec
253
295
}
254
296
255
297
if (areDifferent ) {
256
- fail ( sb .toString () );
298
+ Assert . fail ( sb .toString () );
257
299
}
258
300
}
259
301
}
0 commit comments