@@ -21,6 +21,8 @@ You should have received a copy of the GNU Affero General Public License
21
21
along with this program. If not, see <https://www.gnu.org/licenses/>.
22
22
*/
23
23
using System ;
24
+ using iText . Kernel . Geom ;
25
+ using iText . Svg . Exceptions ;
24
26
using iText . Svg . Renderers ;
25
27
using iText . Test ;
26
28
using iText . Test . Attributes ;
@@ -40,84 +42,161 @@ public static void BeforeClass() {
40
42
41
43
[ NUnit . Framework . Test ]
42
44
public virtual void WidthHeightXYInCmUnitDiffPatternUnitsTest ( ) {
43
- //TODO: DEVSIX-4782 support 'viewbox'
44
45
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInCmUnitDiffPatternUnits" ) ;
45
46
}
46
47
47
48
[ NUnit . Framework . Test ]
48
49
public virtual void WidthHeightXYInInchUnitDiffPatternUnitsTest ( ) {
49
- //TODO: DEVSIX-4782 support 'viewbox'
50
50
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInInchUnitDiffPatternUnits" ) ;
51
51
}
52
52
53
53
[ NUnit . Framework . Test ]
54
54
public virtual void WidthHeightXYInEmUnitDiffPatternUnitsTest ( ) {
55
- //TODO: DEVSIX-4782 support 'viewbox'
56
55
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInEmUnitDiffPatternUnits" ) ;
57
56
}
58
57
59
58
[ NUnit . Framework . Test ]
60
59
public virtual void WidthHeightXYInExUnitDiffPatternUnitsTest ( ) {
61
- //TODO: DEVSIX-4782 support 'viewbox'
62
60
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInExUnitDiffPatternUnits" ) ;
63
61
}
64
62
65
63
[ NUnit . Framework . Test ]
66
64
public virtual void WidthHeightXYInPercentsDiffPatternUnitsTest ( ) {
67
- //TODO: DEVSIX-4782 support viewbox
68
65
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInPercentsDiffPatternUnits" ) ;
69
66
}
70
67
71
68
[ NUnit . Framework . Test ]
72
69
public virtual void WidthHeightXYInPxUnitDiffPatternUnitsTest ( ) {
73
- //TODO: DEVSIX-4782 support viewbox
74
70
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInPxUnitDiffPatternUnits" ) ;
75
71
}
76
72
77
73
[ NUnit . Framework . Test ]
78
74
public virtual void WidthHeightXYInMmUnitDiffPatternUnitsTest ( ) {
79
- //TODO: DEVSIX-4782 support 'viewbox'
80
75
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInMmUnitDiffPatternUnits" ) ;
81
76
}
82
77
83
78
[ NUnit . Framework . Test ]
84
79
public virtual void WidthHeightXYInPtUnitDiffPatternUnitsTest ( ) {
85
- //TODO: DEVSIX-4782 support viewbox
86
80
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInPtUnitDiffPatternUnits" ) ;
87
81
}
88
82
89
83
[ NUnit . Framework . Test ]
90
84
public virtual void WidthHeightXYNoMeasureUnitTest ( ) {
91
- //TODO: DEVSIX-4782 support viewbox
92
85
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYNoMeasureUnit" ) ;
93
86
}
94
87
95
88
[ NUnit . Framework . Test ]
96
89
public virtual void HrefAttributeTest ( ) {
97
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
98
90
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "hrefAttribute" ) ;
99
91
}
100
92
101
93
[ NUnit . Framework . Test ]
102
94
public virtual void PatternUnitsObjectBoundingBoxTest ( ) {
103
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
104
95
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternUnitsObjectBoundingBox" ) ;
105
96
}
106
97
107
98
[ NUnit . Framework . Test ]
108
99
public virtual void PatternUnitsUserSpaceOnUseTest ( ) {
109
- //TODO: DEVSIX-4782 Support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
110
100
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternUnitsUserSpaceOnUse" ) ;
111
101
}
112
102
103
+ [ NUnit . Framework . Test ]
104
+ public virtual void PreserveAspectRatioObjBoundingBoxTest ( ) {
105
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioObjBoundingBox" , PageSize . A8 ) ;
106
+ }
107
+
108
+ [ NUnit . Framework . Test ]
109
+ public virtual void PreserveAspectRatioUserSpaceOnUseTest ( ) {
110
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioUserSpaceOnUse" , PageSize . A8 ) ;
111
+ }
112
+
113
+ [ NUnit . Framework . Test ]
114
+ public virtual void ObjectBoundingBoxXMinYMidMeetTest ( ) {
115
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMinYMidMeet" , PageSize . A8 ) ;
116
+ }
117
+
118
+ [ NUnit . Framework . Test ]
119
+ public virtual void ObjectBoundingBoxXMidYMidMeetTest ( ) {
120
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMidYMidMeet" , PageSize . A10 ) ;
121
+ }
122
+
123
+ [ NUnit . Framework . Test ]
124
+ public virtual void ObjectBoundingBoxXMaxYMidMeetTest ( ) {
125
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMaxYMidMeet" , PageSize . A10 ) ;
126
+ }
127
+
128
+ [ NUnit . Framework . Test ]
129
+ public virtual void ObjectBoundingBoxXMidYMinMeetTest ( ) {
130
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMidYMinMeet" , PageSize . A10 ) ;
131
+ }
132
+
133
+ [ NUnit . Framework . Test ]
134
+ public virtual void ObjectBoundingBoxXMidYMaxMeetTest ( ) {
135
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMidYMaxMeet" , PageSize . A10 ) ;
136
+ }
137
+
138
+ [ NUnit . Framework . Test ]
139
+ public virtual void ObjectBoundingBoxXMidYMidMeetVerticalTest ( ) {
140
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMidYMidMeetVertical" , PageSize . A10
141
+ ) ;
142
+ }
143
+
144
+ [ NUnit . Framework . Test ]
145
+ public virtual void ObjectBoundingBoxXMinYMinMeetTest ( ) {
146
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMinYMinMeet" , PageSize . A10 ) ;
147
+ }
148
+
149
+ [ NUnit . Framework . Test ]
150
+ public virtual void ObjectBoundingBoxXMinYMinMeetVerticalTest ( ) {
151
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMinYMinMeetVertical" , PageSize . A10
152
+ ) ;
153
+ }
154
+
155
+ [ NUnit . Framework . Test ]
156
+ public virtual void ObjectBoundingBoxXMinYMaxMeetVerticalTest ( ) {
157
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMinYMaxMeetVertical" , PageSize . A10
158
+ ) ;
159
+ }
160
+
161
+ [ NUnit . Framework . Test ]
162
+ public virtual void ObjectBoundingBoxXMinYMaxMeetTest ( ) {
163
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMinYMaxMeet" , PageSize . A10 ) ;
164
+ }
165
+
166
+ [ NUnit . Framework . Test ]
167
+ public virtual void ObjectBoundingBoxXMaxYMinMeetTest ( ) {
168
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMaxYMinMeet" , PageSize . A10 ) ;
169
+ }
170
+
171
+ [ NUnit . Framework . Test ]
172
+ public virtual void ObjectBoundingBoxXMaxYMinMeetVerticalTest ( ) {
173
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMaxYMinMeetVertical" , PageSize . A10
174
+ ) ;
175
+ }
176
+
177
+ [ NUnit . Framework . Test ]
178
+ public virtual void ObjectBoundingBoxXMaxYMaxMeetTest ( ) {
179
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMaxYMaxMeet" , PageSize . A10 ) ;
180
+ }
181
+
182
+ [ NUnit . Framework . Test ]
183
+ public virtual void ObjectBoundingBoxXMaxYMaxMeetVerticalTest ( ) {
184
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxXMaxYMaxMeetVertical" , PageSize . A10
185
+ ) ;
186
+ }
187
+
188
+ [ NUnit . Framework . Test ]
189
+ public virtual void ObjectBoundingBoxNoneTest ( ) {
190
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "objectBoundingBoxNone" , PageSize . A10 ) ;
191
+ }
192
+
113
193
[ NUnit . Framework . Test ]
114
194
public virtual void PatternContentUnitsUserSpaceOnUseTest ( ) {
115
195
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternContentUnitsUserSpaceOnUse" ) ;
116
196
}
117
197
118
198
[ NUnit . Framework . Test ]
119
199
public virtual void PatternContentUnitsObjBoundBoxTest ( ) {
120
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
121
200
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternContentUnitsObjBoundBox" ) ;
122
201
}
123
202
@@ -129,65 +208,57 @@ public virtual void PatternContentUnitsObjBoundBoxAbsoluteCoordTest() {
129
208
}
130
209
131
210
[ NUnit . Framework . Test ]
211
+ //TODO DEVSIX-4834 support relative units in attributes of svg elements
212
+ [ LogMessage ( iText . StyledXmlParser . LogMessageConstant . UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED , Count = 8 ) ]
132
213
public virtual void ViewBoxAndAbsoluteCoordinatesTest ( ) {
133
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
134
214
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "viewBoxAndAbsoluteCoordinates" ) ;
135
215
}
136
216
137
217
[ NUnit . Framework . Test ]
138
218
public virtual void PatternTransformSimpleTest ( ) {
139
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
140
219
//TODO DEVSIX-4811 support 'patternTransform' attribute for SVG pattern element
141
220
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternTransformSimple" ) ;
142
221
}
143
222
144
223
[ NUnit . Framework . Test ]
145
224
public virtual void PatternTransformUnitsObjectBoundingBoxTest ( ) {
146
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
147
225
//TODO DEVSIX-4811 support 'patternTransform' attribute for SVG pattern element
148
226
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternTransformUnitsObjectBoundingBox" ) ;
149
227
}
150
228
151
229
[ NUnit . Framework . Test ]
152
230
public virtual void PatternTransformUnitsUserSpaceOnUseTest ( ) {
153
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
154
231
//TODO DEVSIX-4811 support 'patternTransform' attribute for SVG pattern element
155
232
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternTransformUnitsUserSpaceOnUse" ) ;
156
233
}
157
234
158
235
[ NUnit . Framework . Test ]
159
236
public virtual void PreserveAspectRatioXMaxYMidMeetTest ( ) {
160
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
161
237
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMaxYMidMeet" ) ;
162
238
}
163
239
164
240
[ NUnit . Framework . Test ]
165
241
public virtual void PreserveAspectRatioXMaxYMidSliceTest ( ) {
166
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
167
242
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMaxYMidSlice" ) ;
168
243
}
169
244
170
245
[ NUnit . Framework . Test ]
171
246
public virtual void PreserveAspectRatioXMidYMaxMeetTest ( ) {
172
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
173
247
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMidYMaxMeet" ) ;
174
248
}
175
249
176
250
[ NUnit . Framework . Test ]
177
251
public virtual void PreserveAspectRatioXMidYMaxSliceTest ( ) {
178
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
179
252
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMidYMaxSlice" ) ;
180
253
}
181
254
182
255
[ NUnit . Framework . Test ]
183
256
public virtual void RelativeUnitsResolveFromDefsTest ( ) {
184
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
185
257
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "relativeUnitsResolveFromDefs" ) ;
186
258
}
187
259
188
260
[ NUnit . Framework . Test ]
189
261
public virtual void RelativeUnitsResolveFromPatternTest ( ) {
190
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
191
262
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "relativeUnitsResolveFromPattern" ) ;
192
263
}
193
264
@@ -210,7 +281,6 @@ public virtual void SeveralComplexElementsInsidePatternTest() {
210
281
211
282
[ NUnit . Framework . Test ]
212
283
public virtual void NestedPatternsWithComplexElementsInsideTest ( ) {
213
- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
214
284
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "nestedPatternsWithComplexElementsInside" ) ;
215
285
}
216
286
@@ -288,5 +358,74 @@ public virtual void PatternDefaultHeightTest() {
288
358
// we print the default color that is black
289
359
ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternDefaultHeight" ) ;
290
360
}
361
+
362
+ [ NUnit . Framework . Test ]
363
+ public virtual void ViewBoxPatternXYTest ( ) {
364
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "viewBoxPatternXY" ) ;
365
+ }
366
+
367
+ [ NUnit . Framework . Test ]
368
+ public virtual void ViewBoxClippedTest ( ) {
369
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "viewBoxClipped" ) ;
370
+ }
371
+
372
+ [ NUnit . Framework . Test ]
373
+ public virtual void CoordSystemTransformUserSpaceOnUseTest ( ) {
374
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "coordSystemTransformUserSpaceOnUse" ) ;
375
+ }
376
+
377
+ [ NUnit . Framework . Test ]
378
+ public virtual void CoordSystemTransformObjBoundingBoxTest ( ) {
379
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "coordSystemTransformObjBoundingBox" ) ;
380
+ }
381
+
382
+ [ NUnit . Framework . Test ]
383
+ public virtual void CoordSystemTransformMixed1Test ( ) {
384
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "coordSystemTransformMixed1" ) ;
385
+ }
386
+
387
+ [ NUnit . Framework . Test ]
388
+ public virtual void CoordSystemTransformMixed2Test ( ) {
389
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "coordSystemTransformMixed2" ) ;
390
+ }
391
+
392
+ [ NUnit . Framework . Test ]
393
+ public virtual void CoordSystemTransform ( ) {
394
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "coordSystemTransform" ) ;
395
+ }
396
+
397
+ [ NUnit . Framework . Test ]
398
+ [ LogMessage ( SvgLogMessageConstant . VIEWBOX_VALUE_MUST_BE_FOUR_NUMBERS , Count = 1 ) ]
399
+ public virtual void IncorrectViewBoxValuesNumberTest ( ) {
400
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "incorrectViewBoxValuesNumber" ) ;
401
+ }
402
+
403
+ [ NUnit . Framework . Test ]
404
+ [ LogMessage ( SvgLogMessageConstant . VIEWBOX_WIDTH_AND_HEIGHT_CANNOT_BE_NEGATIVE ) ]
405
+ public virtual void IncorrectViewBoxNegativeWidthTest ( ) {
406
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "incorrectViewBoxNegativeWidth" ) ;
407
+ }
408
+
409
+ [ NUnit . Framework . Test ]
410
+ [ LogMessage ( SvgLogMessageConstant . VIEWBOX_WIDTH_AND_HEIGHT_CANNOT_BE_NEGATIVE ) ]
411
+ public virtual void IncorrectViewBoxNegativeHeightTest ( ) {
412
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "incorrectViewBoxNegativeHeight" ) ;
413
+ }
414
+
415
+ [ NUnit . Framework . Test ]
416
+ public virtual void ViewBoxZeroWidthTest ( ) {
417
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "viewBoxZeroWidth" ) ;
418
+ }
419
+
420
+ [ NUnit . Framework . Test ]
421
+ public virtual void ViewBoxZeroHeightTest ( ) {
422
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "viewBoxZeroHeight" ) ;
423
+ }
424
+
425
+ [ NUnit . Framework . Test ]
426
+ [ LogMessage ( SvgLogMessageConstant . PATTERN_WIDTH_OR_HEIGHT_IS_NEGATIVE ) ]
427
+ public virtual void PatternNegativeWidthTest ( ) {
428
+ ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternNegativeWidth" ) ;
429
+ }
291
430
}
292
431
}
0 commit comments