vhardy 01/10/08 07:51:35 Modified: test-sources/org/apache/batik/test/svg SVGRenderingAccuracyTest.java SVGRenderingAccuracyTestValidator.java Log: Added template method (manipulateSVGDocument) in SVGRenderingAccuracyTest so that it can be subclassed for tests which need to manipulate the SVG DOM before rendering. Added generation of anchors in the output HTML. Revision Changes Path 1.13 +40 -4 xml-batik/test-sources/org/apache/batik/test/svg/SVGRenderingAccuracyTest.java Index: SVGRenderingAccuracyTest.java =================================================================== RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/test/svg/SVGRenderingAccuracyTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- SVGRenderingAccuracyTest.java 2001/10/08 14:15:04 1.12 +++ SVGRenderingAccuracyTest.java 2001/10/08 14:51:35 1.13 @@ -53,7 +53,9 @@ import org.apache.batik.test.Test; import org.apache.batik.test.TestReport; +import org.w3c.dom.Document; + /** * Checks for regressions in rendering a specific SVG document. * The <tt>Test</tt> will rasterize and SVG document and @@ -62,7 +64,7 @@ * all pixel values are the same). * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Hardy</a> - * @version $Id: SVGRenderingAccuracyTest.java,v 1.12 2001/10/08 14:15:04 vhardy Exp $ + * @version $Id: SVGRenderingAccuracyTest.java,v 1.13 2001/10/08 14:51:35 vhardy Exp $ */ public class SVGRenderingAccuracyTest extends AbstractTest { /** @@ -348,6 +350,18 @@ } /** + * Template method which subclasses can override if they + * need to manipulate the DOM in some way before running + * the accuracy test. For example, this can be useful to + * test the alternate stylesheet support. + */ + private final Document manipulateSVGDocument(Document doc) { + return doc; + } + + + + /** * Requests this <tt>Test</tt> to run and produce a * report. * @@ -394,7 +408,7 @@ return report; } - ImageTranscoder transcoder = getImageTranscoder(); + ImageTranscoder transcoder = getTestImageTranscoder(); TranscoderInput src = new TranscoderInput(svgURL.toString()); TranscoderOutput dst = new TranscoderOutput(tmpFileOS); @@ -800,12 +814,34 @@ * Returns the <tt>ImageTranscoder</tt> the Test should * use */ - public static ImageTranscoder getImageTranscoder(){ - ImageTranscoder t = new PNGTranscoder(); + public ImageTranscoder getTestImageTranscoder(){ + ImageTranscoder t = new InternalPNGTranscoder(); t.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME, PARSER_CLASS_NAME); t.addTranscodingHint(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE, new Boolean(false)); return t; + } + + /** + * Inner class which derives from the PNGTranscoder and calls the + * manipulateSVGDocument just before encoding happens. + */ + protected class InternalPNGTranscoder extends PNGTranscoder{ + /** + * Transcodes the specified Document as an image in the specified output. + * + * @param document the document to transcode + * @param uri the uri of the document or null if any + * @param output the ouput where to transcode + * @exception TranscoderException if an error occured while transcoding + */ + protected void transcode(Document document, + String uri, + TranscoderOutput output) + throws TranscoderException { + SVGRenderingAccuracyTest.this.manipulateSVGDocument(document); + super.transcode(document, uri, output); + } } } 1.4 +3 -2 xml-batik/test-sources/org/apache/batik/test/svg/SVGRenderingAccuracyTestValidator.java Index: SVGRenderingAccuracyTestValidator.java =================================================================== RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/test/svg/SVGRenderingAccuracyTestValidator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SVGRenderingAccuracyTestValidator.java 2001/10/01 06:48:38 1.3 +++ SVGRenderingAccuracyTestValidator.java 2001/10/08 14:51:35 1.4 @@ -19,6 +19,7 @@ import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.image.ImageTranscoder; +import org.apache.batik.transcoder.image.PNGTranscoder; import org.apache.batik.test.Test; import org.apache.batik.test.AbstractTest; @@ -33,7 +34,7 @@ * they are handled properly by the class. * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Hardy</a> - * @version $Id: SVGRenderingAccuracyTestValidator.java,v 1.3 2001/10/01 06:48:38 vhardy Exp $ + * @version $Id: SVGRenderingAccuracyTestValidator.java,v 1.4 2001/10/08 14:51:35 vhardy Exp $ */ public class SVGRenderingAccuracyTestValidator extends DefaultTestSuite { /** @@ -132,7 +133,7 @@ = new TranscoderOutput(new FileOutputStream(tmpFile)); ImageTranscoder transcoder - = SVGRenderingAccuracyTest.getImageTranscoder(); + = new PNGTranscoder(); transcoder.transcode(validSrc, validDst);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]