Package org.apache.batik.test.svg
Class AbstractRenderingAccuracyTest
java.lang.Object
org.apache.batik.test.AbstractTest
org.apache.batik.test.svg.AbstractRenderingAccuracyTest
- All Implemented Interfaces:
Test
- Direct Known Subclasses:
SVGRenderingAccuracyTest
Checks for regressions in rendering a specific SVG document.
The
Test
will rasterize and SVG document and
compare it to a reference image. The test passes if the
rasterized SVG and the reference image match exactly (i.e.,
all pixel values are the same).- Version:
- $Id: AbstractRenderingAccuracyTest.java 1808888 2017-09-19 14:22:11Z ssteiner $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected File
The File where the candidate reference should be saved if there is not candidate reference or if it cannot be opened.protected static ResourceBundle
The configuration resource bundlestatic final String
The gui resources file namestatic final String
Messages expressing that comparison images could not be created: {0} : exception class {1} : exception message {2} : exception stack trace.static final String
Messages expressing that an image could not be loaded.static final String
Message expressing that the variation URL could not be open {0} : URLstatic final String
Entry describing the generated difference imagestatic final String
Entry describing the errorstatic final String
Entry describing that an internal error occured while generating the test failure descriptionstatic final String
Entry describing the reference/generated image filestatic final String
Error when temp file cannot be created {0} = IOException messagestatic final String
Error when temp file stream cannot be created {0} = temp file's cannonical path {1} = IOException messagestatic final String
Error when the generated image cannot be read {0} = Cannonical path of the temp generated image {1} = IOException messagestatic final String
Error when the reference image cannot be opened {0} = URI of the reference image {1} = IOException messagestatic final String
Error when there is an IOException while comparing the two reference raster image with the new raster image built from the SVG.static final String
Error when the generated image from the SVG file differs from the reference image.static final String
Suffix used for saved images (e.g., comparison and diff images)static final String
Suffix used for comparison imagesstatic final String
Suffix used for diff imagesprotected URL
The URL for the reference imageprotected File
The File where the newly computed variation should be saved if different from the variationURLprotected URL
The URL where the SVG can be found.static final String
Prefix for the temporary files created by Tests of this classstatic final String
Suffix for the temporary files created by Tests of this classprotected static File
Temporary directoryprotected List
A list ofURL
s of files containing an 'accepted' variation from the reference image.Fields inherited from class org.apache.batik.test.AbstractTest
id, name, parent
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
For subclassesAbstractRenderingAccuracyTest
(String svgURL, String refImgURL) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addVariationURL
(String variationURL) Adds a URL for an acceptable variation from the reference image.static BufferedImage
buildDiffImage
(BufferedImage ref, BufferedImage gen) Builds a new BufferedImage that is the difference between the two input imagesprotected boolean
compare
(InputStream refStream, InputStream newStream) Compare the two input streamsabstract TestReport
encode
(URL srcURL, FileOutputStream fos) protected BufferedImage
Loads an image from a Fileprotected BufferedImage
Loads an image from a URLgetName()
Returns thisTest
's name.protected File
getNextTempFileName
(String fileName) protected File
getNextTempFileName
(String fileName, int instance) static File
Returns the temporary directoryprotected String
getURLFile
(URL url) Extracts the file portion of the URLString[]
protected File
imageToFile
(BufferedImage img, String imageType) Creates a File into which the input image is saved.protected BufferedImage
makeCompareImage
(BufferedImage ref, BufferedImage gen) protected File
makeRandomFileName
(String imageType) Creates a temporary File into which the input image is saved.protected File
makeTempFileName
(String svgFileName, String imageType) protected URL
resolveURL
(String url) Resolves the input string as follows.run()
Requests thisTest
to run and produce a report.protected void
saveImage
(BufferedImage img, File imgFile) Saves an image in a given Fileprotected void
saveImage
(BufferedImage img, OutputStream os) Saves an image in a given Filevoid
setCandidateReference
(File candidateReference) void
Sets this test's config.void
setSaveVariation
(File saveVariation) Sets the File where the variation from the reference image should be storedMethods inherited from class org.apache.batik.test.AbstractTest
assertEquals, assertEquals, assertNull, assertTrue, error, getId, getParent, getQualifiedId, reportError, reportException, reportSuccess, runImpl, runImplBasic, setId, setName, setParent
-
Field Details
-
ERROR_CANNOT_CREATE_TEMP_FILE
Error when temp file cannot be created {0} = IOException message- See Also:
-
ERROR_CANNOT_CREATE_TEMP_FILE_STREAM
Error when temp file stream cannot be created {0} = temp file's cannonical path {1} = IOException message- See Also:
-
ERROR_CANNOT_OPEN_REFERENCE_IMAGE
Error when the reference image cannot be opened {0} = URI of the reference image {1} = IOException message- See Also:
-
ERROR_CANNOT_OPEN_GENERATED_IMAGE
Error when the generated image cannot be read {0} = Cannonical path of the temp generated image {1} = IOException message- See Also:
-
ERROR_ERROR_WHILE_COMPARING_FILES
Error when there is an IOException while comparing the two reference raster image with the new raster image built from the SVG. {0} = URI of the reference image {1} = Connical path for the temp generated image {2} = IOException message.- See Also:
-
ERROR_SVG_RENDERING_NOT_ACCURATE
Error when the generated image from the SVG file differs from the reference image.- See Also:
-
ENTRY_KEY_ERROR_DESCRIPTION
Entry describing the error- See Also:
-
ENTRY_KEY_REFERENCE_GENERATED_IMAGE_URI
Entry describing the reference/generated image file- See Also:
-
ENTRY_KEY_DIFFERENCE_IMAGE
Entry describing the generated difference image- See Also:
-
ENTRY_KEY_INTERNAL_ERROR
Entry describing that an internal error occured while generating the test failure description- See Also:
-
COULD_NOT_GENERATE_COMPARISON_IMAGES
Messages expressing that comparison images could not be created: {0} : exception class {1} : exception message {2} : exception stack trace.- See Also:
-
COULD_NOT_LOAD_IMAGE
Messages expressing that an image could not be loaded. {0} : URL for the reference image.- See Also:
-
COULD_NOT_OPEN_VARIATION_URL
Message expressing that the variation URL could not be open {0} : URL- See Also:
-
CONFIGURATION_RESOURCES
The gui resources file name- See Also:
-
IMAGE_TYPE_COMPARISON
Suffix used for comparison images- See Also:
-
IMAGE_TYPE_DIFF
Suffix used for diff images- See Also:
-
IMAGE_FILE_EXTENSION
Suffix used for saved images (e.g., comparison and diff images)- See Also:
-
configuration
The configuration resource bundle -
TEMP_FILE_PREFIX
Prefix for the temporary files created by Tests of this class -
TEMP_FILE_SUFFIX
Suffix for the temporary files created by Tests of this class -
svgURL
The URL where the SVG can be found. -
refImgURL
The URL for the reference image -
variationURLs
A list ofURL
s of files containing an 'accepted' variation from the reference image. -
saveVariation
The File where the newly computed variation should be saved if different from the variationURL -
candidateReference
The File where the candidate reference should be saved if there is not candidate reference or if it cannot be opened. -
tempDirectory
Temporary directory
-
-
Constructor Details
-
AbstractRenderingAccuracyTest
Constructor.- Parameters:
svgURL
- the URL String for the SVG document being tested.refImgURL
- the URL for the reference image.
-
AbstractRenderingAccuracyTest
protected AbstractRenderingAccuracyTest()For subclasses
-
-
Method Details
-
getTempDirectory
Returns the temporary directory -
setConfig
Sets this test's config. -
resolveURL
Resolves the input string as follows. + First, the string is interpreted as a file description. If the file exists, then the file name is turned into a URL. + Otherwise, the string is supposed to be a URL. If it is an invalid URL, an IllegalArgumentException is thrown. -
setSaveVariation
Sets the File where the variation from the reference image should be stored -
getSaveVariation
-
getVariationURLs
-
addVariationURL
Adds a URL for an acceptable variation from the reference image. -
setCandidateReference
-
getCandidateReference
-
getName
Returns thisTest
's name. The name is the URL of the SVG being rendered.- Specified by:
getName
in interfaceTest
- Overrides:
getName
in classAbstractTest
-
run
Requests thisTest
to run and produce a report.- Specified by:
run
in interfaceTest
- Overrides:
run
in classAbstractTest
-
encode
-
compare
Compare the two input streams- Throws:
IOException
-
saveImage
Saves an image in a given File- Throws:
IOException
-
saveImage
Saves an image in a given File- Throws:
IOException
-
buildDiffImage
Builds a new BufferedImage that is the difference between the two input images -
getImage
Loads an image from a File- Throws:
Exception
-
getImage
Loads an image from a URL- Throws:
IOException
-
makeCompareImage
-
imageToFile
Creates a File into which the input image is saved. If there is a "file" component in the SVG url, then a temporary file is created with that name and the imageType suffix in the temp directory of the test-reports directory.- Throws:
IOException
-
getURLFile
Extracts the file portion of the URL -
makeTempFileName
-
getNextTempFileName
-
getNextTempFileName
-
makeRandomFileName
Creates a temporary File into which the input image is saved.- Throws:
IOException
-