Skip to content

Commit

Permalink
Tests: test images from canvg's test suite #92
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Jun 23, 2024
1 parent fb97989 commit be91d3d
Show file tree
Hide file tree
Showing 435 changed files with 31,977 additions and 5 deletions.
11 changes: 8 additions & 3 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright 2020-2024 Contributors to the EchoSVG project
Copyright 1999-2020 The Apache Software Foundation

This product includes software developed at The Apache Software Foundation
(http://www.apache.org/) under the 'Apache Batik' project.
(https://www.apache.org/) under the 'Apache Batik' project.

This software contains code from the World Wide Web Consortium (W3C) for the
Document Object Model API (DOM API) and SVG Document Type Definition (DTD).
Expand All @@ -14,7 +14,12 @@ Standardization for the definition of character entities used in the software's
documentation.

This product includes images from the Tango Desktop Project
(http://tango.freedesktop.org/).
(Former website http://tango.freedesktop.org/ archived at
https://web.archive.org/web/20201024165718/http://tango-project.org/).

This product includes images from the Pasodoble Icon Theme
(http://www.jesusda.com/projects/pasodoble).
(https://www.jesusda.com/projects/pasodoble).

This product's test suite includes images from the Canvg Project
(https://canvg.js.org/, https://github.com/canvg/canvg), which uses a MIT
license. See samples/canvg/LICENSE.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,13 @@ void testResolutionPxMM(String file, float pxToMM) throws TranscoderException, I
}

void testAnim(String file, float[] times) throws TranscoderException, IOException {
testAnim(file, times, true);
}

void testAnim(String file, float[] times, boolean validate) throws TranscoderException, IOException {
for (float time : times) {
RenderingTest runner = new SVGAnimationRenderingAccuracyTest(time);
runner.setValidating(validate);
runner.setFile(file);
runner.runTest(0.000001f, 0.000001f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import io.sf.carte.echosvg.dom.util.SAXDocumentFactory;
import io.sf.carte.echosvg.transcoder.DummyErrorHandler;
import io.sf.carte.echosvg.transcoder.ErrorHandler;
import io.sf.carte.echosvg.transcoder.SVGAbstractTranscoder;
import io.sf.carte.echosvg.transcoder.image.ImageTranscoder;
import io.sf.carte.echosvg.util.SVGConstants;

Expand Down Expand Up @@ -83,7 +82,8 @@ protected UserAgent createUserAgent() {
return new TestTranscoderUserAgent();
}

class TestTranscoderUserAgent extends SVGAbstractTranscoder.SVGAbstractTranscoderUserAgent {
class TestTranscoderUserAgent
extends NoStackTraceTranscoder.NoStackTraceTranscoderUserAgent {

public TestTranscoderUserAgent() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,47 @@ protected void transcode(Document document, String uri, TranscoderOutput output)
SVGRenderingAccuracyTest.this.manipulateSVGDocument(document);
super.transcode(document, uri, output);
}

@Override
protected UserAgent createUserAgent() {
return new FailOnErrorTranscoderUserAgent();
}

/**
* A Transcoder user agent that does not print a stack trace.
*/
class FailOnErrorTranscoderUserAgent
extends SVGAbstractTranscoder.SVGAbstractTranscoderUserAgent {

@Override
public void displayError(String message) {
TranscoderException ex = new TranscoderException(message);
try {
InternalPNGTranscoder.this.handler.error(ex);
} catch (TranscoderException e) {
throw new RuntimeException(e);
}
throw new RuntimeException(message);
}

/**
* Displays the specified error using the <code>ErrorHandler</code>.
* <p>
* And does not print a stack trace.
* </p>
*/
@Override
public void displayError(Exception e) {
try {
InternalPNGTranscoder.this.handler.error(new TranscoderException(e));
} catch (TranscoderException ex) {
throw new RuntimeException(ex);
}
throw new RuntimeException(e);
}

}

}

/**
Expand Down
Loading

0 comments on commit be91d3d

Please sign in to comment.