public abstract class AbstractRenderingAccuracyTest extends AbstractTest
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).Modifier and Type | Field and Description |
---|---|
protected java.io.File |
candidateReference
The File where the candidate reference
should be saved if there is not candidate reference
or if it cannot be opened.
|
protected static java.util.ResourceBundle |
configuration
The configuration resource bundle
|
static java.lang.String |
CONFIGURATION_RESOURCES
The gui resources file name
|
static java.lang.String |
COULD_NOT_GENERATE_COMPARISON_IMAGES
Messages expressing that comparison images could not be
created:
{0} : exception class
{1} : exception message
{2} : exception stack trace.
|
static java.lang.String |
COULD_NOT_LOAD_IMAGE
Messages expressing that an image could not be loaded.
|
static java.lang.String |
COULD_NOT_OPEN_VARIATION_URL
Message expressing that the variation URL could not be open
{0} : URL
|
static java.lang.String |
ENTRY_KEY_DIFFERENCE_IMAGE
Entry describing the generated difference image
|
static java.lang.String |
ENTRY_KEY_ERROR_DESCRIPTION
Entry describing the error
|
static java.lang.String |
ENTRY_KEY_INTERNAL_ERROR
Entry describing that an internal error occured while
generating the test failure description
|
static java.lang.String |
ENTRY_KEY_REFERENCE_GENERATED_IMAGE_URI
Entry describing the reference/generated image file
|
static java.lang.String |
ERROR_CANNOT_CREATE_TEMP_FILE
Error when temp file cannot be created
{0} = IOException message
|
static java.lang.String |
ERROR_CANNOT_CREATE_TEMP_FILE_STREAM
Error when temp file stream cannot be created
{0} = temp file's cannonical path
{1} = IOException message
|
static java.lang.String |
ERROR_CANNOT_OPEN_GENERATED_IMAGE
Error when the generated image cannot be read
{0} = Cannonical path of the temp generated image
{1} = IOException message
|
static java.lang.String |
ERROR_CANNOT_OPEN_REFERENCE_IMAGE
Error when the reference image cannot be opened
{0} = URI of the reference image
{1} = IOException message
|
static java.lang.String |
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.
|
static java.lang.String |
ERROR_SVG_RENDERING_NOT_ACCURATE
Error when the generated image from the SVG file differs from
the reference image.
|
static java.lang.String |
IMAGE_FILE_EXTENSION
Suffix used for saved images (e.g., comparison and diff images)
|
static java.lang.String |
IMAGE_TYPE_COMPARISON
Suffix used for comparison images
|
static java.lang.String |
IMAGE_TYPE_DIFF
Suffix used for diff images
|
protected java.net.URL |
refImgURL
The URL for the reference image
|
protected java.io.File |
saveVariation
The File where the newly computed variation
should be saved if different from the
variationURL
|
protected java.net.URL |
svgURL
The URL where the SVG can be found.
|
static java.lang.String |
TEMP_FILE_PREFIX
Prefix for the temporary files created by Tests
of this class
|
static java.lang.String |
TEMP_FILE_SUFFIX
Suffix for the temporary files created by
Tests of this class
|
protected static java.io.File |
tempDirectory
Temporary directory
|
protected java.util.List |
variationURLs
A list of
URL s of files containing an 'accepted'
variation from the reference image. |
id, name, parent
Modifier | Constructor and Description |
---|---|
protected |
AbstractRenderingAccuracyTest()
For subclasses
|
|
AbstractRenderingAccuracyTest(java.lang.String svgURL,
java.lang.String refImgURL)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addVariationURL(java.lang.String variationURL)
Adds a URL for an acceptable variation from the reference image.
|
static java.awt.image.BufferedImage |
buildDiffImage(java.awt.image.BufferedImage ref,
java.awt.image.BufferedImage gen)
Builds a new BufferedImage that is the difference between the
two input images
|
protected boolean |
compare(java.io.InputStream refStream,
java.io.InputStream newStream)
Compare the two input streams
|
abstract TestReport |
encode(java.net.URL srcURL,
java.io.FileOutputStream fos) |
java.io.File |
getCandidateReference() |
protected java.awt.image.BufferedImage |
getImage(java.io.File file)
Loads an image from a File
|
protected java.awt.image.BufferedImage |
getImage(java.net.URL url)
Loads an image from a URL
|
java.lang.String |
getName()
Returns this
Test 's name. |
protected java.io.File |
getNextTempFileName(java.lang.String fileName) |
protected java.io.File |
getNextTempFileName(java.lang.String fileName,
int instance) |
java.io.File |
getSaveVariation() |
static java.io.File |
getTempDirectory()
Returns the temporary directory
|
protected java.lang.String |
getURLFile(java.net.URL url)
Extracts the file portion of the URL
|
java.lang.String[] |
getVariationURLs() |
protected java.io.File |
imageToFile(java.awt.image.BufferedImage img,
java.lang.String imageType)
Creates a File into which the input image is
saved.
|
protected java.awt.image.BufferedImage |
makeCompareImage(java.awt.image.BufferedImage ref,
java.awt.image.BufferedImage gen) |
protected java.io.File |
makeRandomFileName(java.lang.String imageType)
Creates a temporary File into which the input image is
saved.
|
protected java.io.File |
makeTempFileName(java.lang.String svgFileName,
java.lang.String imageType) |
protected java.net.URL |
resolveURL(java.lang.String url)
Resolves the input string as follows.
|
TestReport |
run()
Requests this
Test to run and produce a
report. |
protected void |
saveImage(java.awt.image.BufferedImage img,
java.io.File imgFile)
Saves an image in a given File
|
protected void |
saveImage(java.awt.image.BufferedImage img,
java.io.OutputStream os)
Saves an image in a given File
|
void |
setCandidateReference(java.io.File candidateReference)
|
void |
setConfig(java.lang.String svgURL,
java.lang.String refImgURL)
Sets this test's config.
|
void |
setSaveVariation(java.io.File saveVariation)
Sets the File where the variation from the reference image should be
stored
|
assertEquals, assertEquals, assertNull, assertTrue, error, getId, getParent, getQualifiedId, reportError, reportException, reportSuccess, runImpl, runImplBasic, setId, setName, setParent
public static final java.lang.String ERROR_CANNOT_CREATE_TEMP_FILE
public static final java.lang.String ERROR_CANNOT_CREATE_TEMP_FILE_STREAM
public static final java.lang.String ERROR_CANNOT_OPEN_REFERENCE_IMAGE
public static final java.lang.String ERROR_CANNOT_OPEN_GENERATED_IMAGE
public static final java.lang.String ERROR_ERROR_WHILE_COMPARING_FILES
public static final java.lang.String ERROR_SVG_RENDERING_NOT_ACCURATE
public static final java.lang.String ENTRY_KEY_ERROR_DESCRIPTION
public static final java.lang.String ENTRY_KEY_REFERENCE_GENERATED_IMAGE_URI
public static final java.lang.String ENTRY_KEY_DIFFERENCE_IMAGE
public static final java.lang.String ENTRY_KEY_INTERNAL_ERROR
public static final java.lang.String COULD_NOT_GENERATE_COMPARISON_IMAGES
public static final java.lang.String COULD_NOT_LOAD_IMAGE
public static final java.lang.String COULD_NOT_OPEN_VARIATION_URL
public static final java.lang.String CONFIGURATION_RESOURCES
public static final java.lang.String IMAGE_TYPE_COMPARISON
public static final java.lang.String IMAGE_TYPE_DIFF
public static final java.lang.String IMAGE_FILE_EXTENSION
protected static java.util.ResourceBundle configuration
public static final java.lang.String TEMP_FILE_PREFIX
public static final java.lang.String TEMP_FILE_SUFFIX
protected java.net.URL svgURL
protected java.net.URL refImgURL
protected java.util.List variationURLs
URL
s of files containing an 'accepted'
variation from the reference image.protected java.io.File saveVariation
protected java.io.File candidateReference
protected static java.io.File tempDirectory
public AbstractRenderingAccuracyTest(java.lang.String svgURL, java.lang.String refImgURL)
svgURL
- the URL String for the SVG document being tested.refImgURL
- the URL for the reference image.protected AbstractRenderingAccuracyTest()
public static java.io.File getTempDirectory()
public void setConfig(java.lang.String svgURL, java.lang.String refImgURL)
protected java.net.URL resolveURL(java.lang.String url)
public void setSaveVariation(java.io.File saveVariation)
public java.io.File getSaveVariation()
public java.lang.String[] getVariationURLs()
public void addVariationURL(java.lang.String variationURL)
public void setCandidateReference(java.io.File candidateReference)
public java.io.File getCandidateReference()
public java.lang.String getName()
Test
's name. The name is the
URL of the SVG being rendered.getName
in interface Test
getName
in class AbstractTest
public TestReport run()
Test
to run and produce a
report.run
in interface Test
run
in class AbstractTest
public abstract TestReport encode(java.net.URL srcURL, java.io.FileOutputStream fos)
protected boolean compare(java.io.InputStream refStream, java.io.InputStream newStream) throws java.io.IOException
java.io.IOException
protected void saveImage(java.awt.image.BufferedImage img, java.io.File imgFile) throws java.io.IOException
java.io.IOException
protected void saveImage(java.awt.image.BufferedImage img, java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public static java.awt.image.BufferedImage buildDiffImage(java.awt.image.BufferedImage ref, java.awt.image.BufferedImage gen)
protected java.awt.image.BufferedImage getImage(java.io.File file) throws java.lang.Exception
java.lang.Exception
protected java.awt.image.BufferedImage getImage(java.net.URL url) throws java.io.IOException
java.io.IOException
protected java.awt.image.BufferedImage makeCompareImage(java.awt.image.BufferedImage ref, java.awt.image.BufferedImage gen)
protected java.io.File imageToFile(java.awt.image.BufferedImage img, java.lang.String imageType) throws java.io.IOException
java.io.IOException
protected java.lang.String getURLFile(java.net.URL url)
protected java.io.File makeTempFileName(java.lang.String svgFileName, java.lang.String imageType)
protected java.io.File getNextTempFileName(java.lang.String fileName)
protected java.io.File getNextTempFileName(java.lang.String fileName, int instance)
protected java.io.File makeRandomFileName(java.lang.String imageType) throws java.io.IOException
java.io.IOException