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$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileThe File where the candidate reference should be saved if there is not candidate reference or if it cannot be opened.protected static ResourceBundleThe configuration resource bundlestatic final StringThe gui resources file namestatic final StringMessages expressing that comparison images could not be created: {0} : exception class {1} : exception message {2} : exception stack trace.static final StringMessages expressing that an image could not be loaded.static final StringMessage expressing that the variation URL could not be open {0} : URLstatic final StringEntry describing the generated difference imagestatic final StringEntry describing the errorstatic final StringEntry describing that an internal error occured while generating the test failure descriptionstatic final StringEntry describing the reference/generated image filestatic final StringError when temp file cannot be created {0} = IOException messagestatic final StringError when temp file stream cannot be created {0} = temp file's cannonical path {1} = IOException messagestatic final StringError when the generated image cannot be read {0} = Cannonical path of the temp generated image {1} = IOException messagestatic final StringError when the reference image cannot be opened {0} = URI of the reference image {1} = IOException messagestatic final StringError when there is an IOException while comparing the two reference raster image with the new raster image built from the SVG.static final StringError when the generated image from the SVG file differs from the reference image.static final StringSuffix used for saved images (e.g., comparison and diff images)static final StringSuffix used for comparison imagesstatic final StringSuffix used for diff imagesprotected URLThe URL for the reference imageprotected FileThe File where the newly computed variation should be saved if different from the variationURLprotected URLThe URL where the SVG can be found.static final StringPrefix for the temporary files created by Tests of this classstatic final StringSuffix for the temporary files created by Tests of this classprotected static FileTemporary directoryprotected ListA list ofURLs of files containing an 'accepted' variation from the reference image.Fields inherited from class AbstractTest
id, name, parent -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFor subclassesAbstractRenderingAccuracyTest(String svgURL, String refImgURL) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVariationURL(String variationURL) Adds a URL for an acceptable variation from the reference image.static BufferedImagebuildDiffImage(BufferedImage ref, BufferedImage gen) Builds a new BufferedImage that is the difference between the two input imagesprotected booleancompare(InputStream refStream, InputStream newStream) Compare the two input streamsabstract TestReportencode(URL srcURL, FileOutputStream fos) protected BufferedImageLoads an image from a Fileprotected BufferedImageLoads an image from a URLgetName()Returns thisTest's name.protected FilegetNextTempFileName(String fileName) protected FilegetNextTempFileName(String fileName, int instance) static FileReturns the temporary directoryprotected StringgetURLFile(URL url) Extracts the file portion of the URLString[]protected FileimageToFile(BufferedImage img, String imageType) Creates a File into which the input image is saved.protected BufferedImagemakeCompareImage(BufferedImage ref, BufferedImage gen) protected FilemakeRandomFileName(String imageType) Creates a temporary File into which the input image is saved.protected FilemakeTempFileName(String svgFileName, String imageType) protected URLresolveURL(String url) Resolves the input string as follows.run()Requests thisTestto run and produce a report.protected voidsaveImage(BufferedImage img, File imgFile) Saves an image in a given Fileprotected voidsaveImage(BufferedImage img, OutputStream os) Saves an image in a given FilevoidsetCandidateReference(File candidateReference) voidSets this test's config.voidsetSaveVariation(File saveVariation) Sets the File where the variation from the reference image should be storedMethods inherited from class 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_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
-
IMAGE_TYPE_COMPARISON
-
IMAGE_TYPE_DIFF
-
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
-
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
-
AbstractRenderingAccuracyTest
protected AbstractRenderingAccuracyTest()For subclasses
-
-
Method Details
-
getTempDirectory
Returns the temporary directory -
setConfig
-
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:
getNamein interfaceTest- Overrides:
getNamein classAbstractTest
-
run
Requests thisTestto run and produce a report.- Specified by:
runin interfaceTest- Overrides:
runin 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
-
makeTempFileName
-
getNextTempFileName
-
getNextTempFileName
-
makeRandomFileName
Creates a temporary File into which the input image is saved.- Throws:
IOException
-