vhardy 01/10/26 04:37:12 Modified: test-sources/org/apache/batik/apps/rasterizer SVGConverterTest.java Log: Added rendering test for converter. Revision Changes Path 1.3 +56 -2 xml-batik/test-sources/org/apache/batik/apps/rasterizer/SVGConverterTest.java Index: SVGConverterTest.java =================================================================== RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/apps/rasterizer/SVGConverterTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SVGConverterTest.java 2001/10/25 13:56:11 1.2 +++ SVGConverterTest.java 2001/10/26 11:37:12 1.3 @@ -9,6 +9,7 @@ package org.apache.batik.apps.rasterizer; import org.apache.batik.test.*; +import org.apache.batik.test.util.ImageCompareTest; import org.apache.batik.transcoder.Transcoder; import org.apache.batik.transcoder.image.ImageTranscoder; import org.apache.batik.transcoder.image.JPEGTranscoder; @@ -23,7 +24,7 @@ * of source and destination sources. * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Hardy</a> - * @version $Id: SVGConverterTest.java,v 1.2 2001/10/25 13:56:11 vhardy Exp $ + * @version $Id: SVGConverterTest.java,v 1.3 2001/10/26 11:37:12 vhardy Exp $ */ public class SVGConverterTest extends DefaultTestSuite { public SVGConverterTest(){ @@ -287,7 +288,25 @@ addTest(t); t.setId("ConfigErrorTest(SVGConverter.ERROR_WHILE_RASTERIZING_FILE"); - + // + // Test that files are created as expected and are producing the + // expected result. + // + + // Plain file + t = new ConverterOutputTest("samples/anne.svg", // File to convert + "test-reports/anne.png", // Output + "test-references/samples/anne.png"); // reference + addTest(t); + t.setId("OutputTest.plain"); + + // File with reference + t = new ConverterOutputTest("samples/anne.svg#svgView(viewBox(0,0,100,200))", // File to convert + "test-reports/anne.png", // Output + "test-references/samples/anneViewBox1.png"); // reference + addTest(t); + t.setId("OutputTest.reference"); + } } @@ -915,5 +934,40 @@ public void onSourceTranscodingSuccess(SVGConverterSource source, File dest){ System.out.println(" ... SUCCESS"); + } +} + +/** + * This test checks that a file is indeed created and that it is identical to + * an expected reference. + */ +class ConverterOutputTest extends AbstractTest { + String svgSource; + String pngDest; + String pngRef; + + public ConverterOutputTest(String svgSource, + String pngDest, + String pngRef){ + this.svgSource = svgSource; + this.pngDest = pngDest; + this.pngRef = pngRef; + } + + public TestReport runImpl() throws Exception { + SVGConverter c = new SVGConverter(); + System.out.println("Converting : " + svgSource); + c.setSourcesStrings(new String[]{svgSource}); + c.setDstFile(new File(pngDest)); + + c.setDestinationType(DestinationType.PNG); + + c.execute(); + + ImageCompareTest t = new ImageCompareTest(pngDest, + pngRef); + TestReport r = t.run(); + (new File(pngDest)).delete(); + return r; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]