@@ -21,6 +21,8 @@ You should have received a copy of the GNU Affero General Public License
2121along with this program. If not, see <https://www.gnu.org/licenses/>.
2222*/
2323using System ;
24+ using iText . Kernel . Geom ;
25+ using iText . Svg . Exceptions ;
2426using iText . Svg . Renderers ;
2527using iText . Test ;
2628using iText . Test . Attributes ;
@@ -40,84 +42,161 @@ public static void BeforeClass() {
4042
4143 [ NUnit . Framework . Test ]
4244 public virtual void WidthHeightXYInCmUnitDiffPatternUnitsTest ( ) {
43- //TODO: DEVSIX-4782 support 'viewbox'
4445 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInCmUnitDiffPatternUnits" ) ;
4546 }
4647
4748 [ NUnit . Framework . Test ]
4849 public virtual void WidthHeightXYInInchUnitDiffPatternUnitsTest ( ) {
49- //TODO: DEVSIX-4782 support 'viewbox'
5050 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInInchUnitDiffPatternUnits" ) ;
5151 }
5252
5353 [ NUnit . Framework . Test ]
5454 public virtual void WidthHeightXYInEmUnitDiffPatternUnitsTest ( ) {
55- //TODO: DEVSIX-4782 support 'viewbox'
5655 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInEmUnitDiffPatternUnits" ) ;
5756 }
5857
5958 [ NUnit . Framework . Test ]
6059 public virtual void WidthHeightXYInExUnitDiffPatternUnitsTest ( ) {
61- //TODO: DEVSIX-4782 support 'viewbox'
6260 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInExUnitDiffPatternUnits" ) ;
6361 }
6462
6563 [ NUnit . Framework . Test ]
6664 public virtual void WidthHeightXYInPercentsDiffPatternUnitsTest ( ) {
67- //TODO: DEVSIX-4782 support viewbox
6865 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInPercentsDiffPatternUnits" ) ;
6966 }
7067
7168 [ NUnit . Framework . Test ]
7269 public virtual void WidthHeightXYInPxUnitDiffPatternUnitsTest ( ) {
73- //TODO: DEVSIX-4782 support viewbox
7470 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInPxUnitDiffPatternUnits" ) ;
7571 }
7672
7773 [ NUnit . Framework . Test ]
7874 public virtual void WidthHeightXYInMmUnitDiffPatternUnitsTest ( ) {
79- //TODO: DEVSIX-4782 support 'viewbox'
8075 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInMmUnitDiffPatternUnits" ) ;
8176 }
8277
8378 [ NUnit . Framework . Test ]
8479 public virtual void WidthHeightXYInPtUnitDiffPatternUnitsTest ( ) {
85- //TODO: DEVSIX-4782 support viewbox
8680 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYInPtUnitDiffPatternUnits" ) ;
8781 }
8882
8983 [ NUnit . Framework . Test ]
9084 public virtual void WidthHeightXYNoMeasureUnitTest ( ) {
91- //TODO: DEVSIX-4782 support viewbox
9285 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "widthHeightXYNoMeasureUnit" ) ;
9386 }
9487
9588 [ NUnit . Framework . Test ]
9689 public virtual void HrefAttributeTest ( ) {
97- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
9890 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "hrefAttribute" ) ;
9991 }
10092
10193 [ NUnit . Framework . Test ]
10294 public virtual void PatternUnitsObjectBoundingBoxTest ( ) {
103- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
10495 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternUnitsObjectBoundingBox" ) ;
10596 }
10697
10798 [ NUnit . Framework . Test ]
10899 public virtual void PatternUnitsUserSpaceOnUseTest ( ) {
109- //TODO: DEVSIX-4782 Support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
110100 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternUnitsUserSpaceOnUse" ) ;
111101 }
112102
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+
113193 [ NUnit . Framework . Test ]
114194 public virtual void PatternContentUnitsUserSpaceOnUseTest ( ) {
115195 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternContentUnitsUserSpaceOnUse" ) ;
116196 }
117197
118198 [ NUnit . Framework . Test ]
119199 public virtual void PatternContentUnitsObjBoundBoxTest ( ) {
120- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
121200 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternContentUnitsObjBoundBox" ) ;
122201 }
123202
@@ -129,65 +208,57 @@ public virtual void PatternContentUnitsObjBoundBoxAbsoluteCoordTest() {
129208 }
130209
131210 [ 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 ) ]
132213 public virtual void ViewBoxAndAbsoluteCoordinatesTest ( ) {
133- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
134214 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "viewBoxAndAbsoluteCoordinates" ) ;
135215 }
136216
137217 [ NUnit . Framework . Test ]
138218 public virtual void PatternTransformSimpleTest ( ) {
139- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
140219 //TODO DEVSIX-4811 support 'patternTransform' attribute for SVG pattern element
141220 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternTransformSimple" ) ;
142221 }
143222
144223 [ NUnit . Framework . Test ]
145224 public virtual void PatternTransformUnitsObjectBoundingBoxTest ( ) {
146- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
147225 //TODO DEVSIX-4811 support 'patternTransform' attribute for SVG pattern element
148226 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternTransformUnitsObjectBoundingBox" ) ;
149227 }
150228
151229 [ NUnit . Framework . Test ]
152230 public virtual void PatternTransformUnitsUserSpaceOnUseTest ( ) {
153- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
154231 //TODO DEVSIX-4811 support 'patternTransform' attribute for SVG pattern element
155232 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternTransformUnitsUserSpaceOnUse" ) ;
156233 }
157234
158235 [ NUnit . Framework . Test ]
159236 public virtual void PreserveAspectRatioXMaxYMidMeetTest ( ) {
160- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
161237 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMaxYMidMeet" ) ;
162238 }
163239
164240 [ NUnit . Framework . Test ]
165241 public virtual void PreserveAspectRatioXMaxYMidSliceTest ( ) {
166- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
167242 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMaxYMidSlice" ) ;
168243 }
169244
170245 [ NUnit . Framework . Test ]
171246 public virtual void PreserveAspectRatioXMidYMaxMeetTest ( ) {
172- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
173247 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMidYMaxMeet" ) ;
174248 }
175249
176250 [ NUnit . Framework . Test ]
177251 public virtual void PreserveAspectRatioXMidYMaxSliceTest ( ) {
178- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
179252 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "preserveAspectRatioXMidYMaxSlice" ) ;
180253 }
181254
182255 [ NUnit . Framework . Test ]
183256 public virtual void RelativeUnitsResolveFromDefsTest ( ) {
184- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
185257 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "relativeUnitsResolveFromDefs" ) ;
186258 }
187259
188260 [ NUnit . Framework . Test ]
189261 public virtual void RelativeUnitsResolveFromPatternTest ( ) {
190- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
191262 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "relativeUnitsResolveFromPattern" ) ;
192263 }
193264
@@ -210,7 +281,6 @@ public virtual void SeveralComplexElementsInsidePatternTest() {
210281
211282 [ NUnit . Framework . Test ]
212283 public virtual void NestedPatternsWithComplexElementsInsideTest ( ) {
213- //TODO DEVSIX-4782 support 'viewbox' and `preserveAspectRatio' attribute for SVG pattern element
214284 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "nestedPatternsWithComplexElementsInside" ) ;
215285 }
216286
@@ -288,5 +358,74 @@ public virtual void PatternDefaultHeightTest() {
288358 // we print the default color that is black
289359 ConvertAndCompare ( SOURCE_FOLDER , DESTINATION_FOLDER , "patternDefaultHeight" ) ;
290360 }
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+ }
291430 }
292431}
0 commit comments