Package org.apache.batik.test.svg
Class ImageCompareTest
java.lang.Object
org.apache.batik.test.AbstractTest
org.apache.batik.test.svg.ImageCompareTest
- All Implemented Interfaces:
Test
This test does a pixel comparison of two images and passes if the
two images are identical. It fails otherwise, producing a report
describing why the two images are different.
- Version:
- $Id: ImageCompareTest.java 1808001 2017-09-11 09:51:29Z ssteiner $
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
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 URL
protected String
URL for the first image to be compared.protected URL
protected String
URL for the second image to be comparedFields inherited from class org.apache.batik.test.AbstractTest
id, name, parent
-
Constructor Summary
ConstructorsConstructorDescriptionImageCompareTest
(String urlA, String urlB) This test makes a binary comparison of the two images (and not a pixel comparison). -
Method Summary
Modifier and TypeMethodDescriptionprotected BufferedImage
buildCompareImage
(BufferedImage ref, BufferedImage gen) static BufferedImage
buildDiffImage
(BufferedImage ref, BufferedImage gen) Builds a new BufferedImage that is the difference between the two input imagesstatic boolean
compare
(InputStream refStream, InputStream newStream) Compare the two input streamsprotected BufferedImage
Loads an image from a URLprotected File
imageToFile
(BufferedImage img, String imageType) Creates a temporary File into which the input image is saved.protected void
initURLs()
protected File
makeRandomFileName
(String imageType) Creates a temporary File into which the input image is saved.protected URL
resolveURL
(String url) Resolves the input string as follows.rumImpl()
Methods inherited from class org.apache.batik.test.AbstractTest
assertEquals, assertEquals, assertNull, assertTrue, error, getId, getName, getParent, getQualifiedId, reportError, reportException, reportSuccess, run, runImpl, runImplBasic, setId, setName, setParent
-
Field Details
-
ERROR_COULD_NOT_OPEN_IMAGE
- See Also:
-
ERROR_COULD_NOT_LOAD_IMAGE
- See Also:
-
ERROR_DIFFERENCES
- See Also:
-
ERROR_WHILE_COMPARING_FILES
- See Also:
-
ENTRY_KEY_FIRST_IMAGE
- See Also:
-
ENTRY_KEY_SECOND_IMAGE
- See Also:
-
ENTRY_KEY_COMPARISON
- See Also:
-
ENTRY_KEY_DIFFERENCE
- See Also:
-
ENTRY_KEY_IMAGE_URL
- See Also:
-
IMAGE_TYPE_DIFFERENCE
- See Also:
-
IMAGE_TYPE_COMPARISON
- See Also:
-
TEMP_FILE_PREFIX
Prefix for the temporary files created by Tests of this class- See Also:
-
TEMP_FILE_SUFFIX
Suffix for the temporary files created by Tests of this class- See Also:
-
urlAStr
URL for the first image to be compared. -
urlA
-
urlBStr
URL for the second image to be compared -
urlB
-
-
Constructor Details
-
ImageCompareTest
This test makes a binary comparison of the two images (and not a pixel comparison). If the images are different, the test generates a report containing the two images and a delta images to help the user visualize the difference.- Parameters:
urlA
- first imageurlB
- second image
-
-
Method Details
-
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. -
initURLs
protected void initURLs() -
rumImpl
- Throws:
Exception
-
buildCompareImage
-
imageToFile
Creates a temporary File into which the input image is saved.- Throws:
IOException
-
makeRandomFileName
Creates a temporary File into which the input image is saved.- Throws:
IOException
-
buildDiffImage
Builds a new BufferedImage that is the difference between the two input images -
compare
Compare the two input streams- Throws:
IOException
-
getImage
Loads an image from a URL
-