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$
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringPrefix for the temporary files created by Tests of this classstatic final StringSuffix for the temporary files created by Tests of this classprotected URLprotected StringURL for the first image to be compared.protected URLprotected StringURL for the second image to be comparedFields inherited from class 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 BufferedImagebuildCompareImage(BufferedImage ref, BufferedImage gen) static BufferedImagebuildDiffImage(BufferedImage ref, BufferedImage gen) Builds a new BufferedImage that is the difference between the two input imagesstatic booleancompare(InputStream refStream, InputStream newStream) Compare the two input streamsprotected BufferedImageLoads an image from a URLprotected FileimageToFile(BufferedImage img, String imageType) Creates a temporary File into which the input image is saved.protected voidinitURLs()protected FilemakeRandomFileName(String imageType) Creates a temporary File into which the input image is saved.protected URLresolveURL(String url) Resolves the input string as follows.rumImpl()Methods inherited from class 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
-