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 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 ResourceBundle |
configuration
The configuration resource bundle
|
static String |
CONFIGURATION_RESOURCES
The gui resources file name
|
static 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 String |
COULD_NOT_LOAD_IMAGE
Messages expressing that an image could not be loaded.
|
static String |
COULD_NOT_OPEN_VARIATION_URL
Message expressing that the variation URL could not be open
{0} : URL
|
static String |
ENTRY_KEY_DIFFERENCE_IMAGE
Entry describing the generated difference image
|
static String |
ENTRY_KEY_ERROR_DESCRIPTION
Entry describing the error
|
static String |
ENTRY_KEY_INTERNAL_ERROR
Entry describing that an internal error occured while
generating the test failure description
|
static String |
ENTRY_KEY_REFERENCE_GENERATED_IMAGE_URI
Entry describing the reference/generated image file
|
static String |
ERROR_CANNOT_CREATE_TEMP_FILE
Error when temp file cannot be created
{0} = IOException message
|
static 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 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 String |
ERROR_CANNOT_OPEN_REFERENCE_IMAGE
Error when the reference image cannot be opened
{0} = URI of the reference image
{1} = IOException message
|
static 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 String |
ERROR_SVG_RENDERING_NOT_ACCURATE
Error when the generated image from the SVG file differs from
the reference image.
|
static String |
IMAGE_FILE_EXTENSION
Suffix used for saved images (e.g., comparison and diff images)
|
static String |
IMAGE_TYPE_COMPARISON
Suffix used for comparison images
|
static String |
IMAGE_TYPE_DIFF
Suffix used for diff images
|
protected URL |
refImgURL
The URL for the reference image
|
protected File |
saveVariation
The File where the newly computed variation
should be saved if different from the
variationURL
|
protected URL |
svgURL
The URL where the SVG can be found.
|
static String |
TEMP_FILE_PREFIX
Prefix for the temporary files created by Tests
of this class
|
static String |
TEMP_FILE_SUFFIX
Suffix for the temporary files created by
Tests of this class
|
protected static File |
tempDirectory
Temporary directory
|
protected 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(String svgURL,
String refImgURL)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
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 images
|
protected boolean |
compare(InputStream refStream,
InputStream newStream)
Compare the two input streams
|
abstract TestReport |
encode(URL srcURL,
FileOutputStream fos) |
File |
getCandidateReference() |
protected BufferedImage |
getImage(File file)
Loads an image from a File
|
protected BufferedImage |
getImage(URL url)
Loads an image from a URL
|
String |
getName()
Returns this
Test 's name. |
protected File |
getNextTempFileName(String fileName) |
protected File |
getNextTempFileName(String fileName,
int instance) |
File |
getSaveVariation() |
static File |
getTempDirectory()
Returns the temporary directory
|
protected String |
getURLFile(URL url)
Extracts the file portion of the URL
|
String[] |
getVariationURLs() |
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.
|
TestReport |
run()
Requests this
Test to run and produce a
report. |
protected void |
saveImage(BufferedImage img,
File imgFile)
Saves an image in a given File
|
protected void |
saveImage(BufferedImage img,
OutputStream os)
Saves an image in a given File
|
void |
setCandidateReference(File candidateReference)
|
void |
setConfig(String svgURL,
String refImgURL)
Sets this test's config.
|
void |
setSaveVariation(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 String ERROR_CANNOT_CREATE_TEMP_FILE
public static final String ERROR_CANNOT_CREATE_TEMP_FILE_STREAM
public static final String ERROR_CANNOT_OPEN_REFERENCE_IMAGE
public static final String ERROR_CANNOT_OPEN_GENERATED_IMAGE
public static final String ERROR_ERROR_WHILE_COMPARING_FILES
public static final String ERROR_SVG_RENDERING_NOT_ACCURATE
public static final String ENTRY_KEY_ERROR_DESCRIPTION
public static final String ENTRY_KEY_REFERENCE_GENERATED_IMAGE_URI
public static final String ENTRY_KEY_DIFFERENCE_IMAGE
public static final String ENTRY_KEY_INTERNAL_ERROR
public static final String COULD_NOT_GENERATE_COMPARISON_IMAGES
public static final String COULD_NOT_LOAD_IMAGE
public static final String COULD_NOT_OPEN_VARIATION_URL
public static final String CONFIGURATION_RESOURCES
public static final String IMAGE_TYPE_COMPARISON
public static final String IMAGE_TYPE_DIFF
public static final String IMAGE_FILE_EXTENSION
protected static ResourceBundle configuration
public static final String TEMP_FILE_PREFIX
public static final String TEMP_FILE_SUFFIX
protected URL svgURL
protected URL refImgURL
protected List variationURLs
URL
s of files containing an 'accepted'
variation from the reference image.protected File saveVariation
protected File candidateReference
protected static File tempDirectory
public AbstractRenderingAccuracyTest(String svgURL, String refImgURL)
svgURL
- the URL String for the SVG document being tested.refImgURL
- the URL for the reference image.protected AbstractRenderingAccuracyTest()
public static File getTempDirectory()
protected URL resolveURL(String url)
public void setSaveVariation(File saveVariation)
public File getSaveVariation()
public String[] getVariationURLs()
public void addVariationURL(String variationURL)
public void setCandidateReference(File candidateReference)
public File getCandidateReference()
public 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(URL srcURL, FileOutputStream fos)
protected boolean compare(InputStream refStream, InputStream newStream) throws IOException
IOException
protected void saveImage(BufferedImage img, File imgFile) throws IOException
IOException
protected void saveImage(BufferedImage img, OutputStream os) throws IOException
IOException
public static BufferedImage buildDiffImage(BufferedImage ref, BufferedImage gen)
protected BufferedImage getImage(File file) throws Exception
Exception
protected BufferedImage getImage(URL url) throws IOException
IOException
protected BufferedImage makeCompareImage(BufferedImage ref, BufferedImage gen)
protected File imageToFile(BufferedImage img, String imageType) throws IOException
IOException
protected File makeRandomFileName(String imageType) throws IOException
IOException
Copyright © 2000–2023 Apache Software Foundation. All rights reserved.