Package org.jzy3d.junit
Class ChartTester
- java.lang.Object
-
- org.jzy3d.junit.ChartTester
-
- Direct Known Subclasses:
NativeChartTester
public class ChartTester extends Object
Primitives for chart tests. A chart having a screenshot different from the test case image will generate throw a ChartTestFailed exception.- Author:
- martin
-
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_IMAGE_FOLDER_DEFAULT
static String
EXPECTED_IMAGE_FOLDER
protected int
HEIGHT
static int
TEST_IMG_SIZE
protected String
testCaseInputFolder
protected String
testCaseOutputFolder
protected int
WIDTH
-
Constructor Summary
Constructors Constructor Description ChartTester()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertSimilar(Chart chart, String testImage)
void
build(Chart chart, String testImage)
void
clean(String testImage)
boolean
cleanFile(String file)
void
compare(BufferedImage actual, BufferedImage expected)
Perform the comparison between twoBufferedImage
.void
compare(Chart chart, String filename)
Compare the image displayed by the chart with an image given by filename.protected BufferedImage
copyImage(BufferedImage source)
void
execute(Chart chart)
void
execute(Chart chart, String testImage)
Run a chart and verify if its screenshot is pixelwise similar to the test case image.protected BufferedImage
getBufferedImage(Chart chart)
String
getTestCanvasType()
String
getTestCaseFailedFileName()
File
getTestCaseFile()
String
getTestCaseFileName()
String
getTestCaseFileName(String testName)
String
getTestCaseInputFolder()
String
getTestCaseOutputFolder()
String
getTestName()
boolean
isBuilt(String testImage)
protected BufferedImage
loadBufferedImage(String filename)
protected void
pixelHighlight(BufferedImage expected, List<IntegerCoord2d> diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates.protected void
pixelHighlight(BufferedImage expected, IntegerCoord2d diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates (IntegerCoord2d
)void
setTestCaseInputFolder(String testCaseFolder)
void
setTestCaseOutputFolder(String testCaseOutputFolder)
void
test(Chart chart, String testImage)
Perform a chart comparison to image and output 3 images in case of failure Expected image Actual image Diff image
-
-
-
Field Detail
-
TEST_IMG_SIZE
public static int TEST_IMG_SIZE
-
testCaseOutputFolder
protected String testCaseOutputFolder
-
testCaseInputFolder
protected String testCaseInputFolder
-
EXPECTED_IMAGE_FOLDER
public static final String EXPECTED_IMAGE_FOLDER
- See Also:
- Constant Field Values
-
ERROR_IMAGE_FOLDER_DEFAULT
public static final String ERROR_IMAGE_FOLDER_DEFAULT
- See Also:
- Constant Field Values
-
WIDTH
protected int WIDTH
-
HEIGHT
protected int HEIGHT
-
-
Method Detail
-
execute
public void execute(Chart chart, String testImage) throws IOException
Run a chart and verify if its screenshot is pixelwise similar to the test case image. If test case image does not exist, build it for the first time. Failure to compare the chart with the test case image will create an imagedata/tests/error-[name].png
. This image is always deleted before running a testcase. Calling clean() will delete the test case image.- Parameters:
chart
-testImage
-- Throws:
IOException
- if a non chart related error occurs. Actual chart test errors callfail(...)
-
execute
public void execute(Chart chart) throws IOException
- Throws:
IOException
-
clean
public void clean(String testImage)
-
cleanFile
public boolean cleanFile(String file)
-
build
public void build(Chart chart, String testImage) throws IOException
- Throws:
IOException
-
isBuilt
public boolean isBuilt(String testImage)
-
test
public void test(Chart chart, String testImage) throws IOException
Perform a chart comparison to image and output 3 images in case of failure- Expected image
- Actual image
- Diff image
- Parameters:
chart
-testImage
-- Throws:
IOException
-
copyImage
protected BufferedImage copyImage(BufferedImage source)
-
pixelHighlight
protected void pixelHighlight(BufferedImage expected, List<IntegerCoord2d> diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates.
-
pixelHighlight
protected void pixelHighlight(BufferedImage expected, IntegerCoord2d diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates (IntegerCoord2d
)
-
compare
public void compare(Chart chart, String filename) throws IOException, ChartTestFailed
Compare the image displayed by the chart with an image given by filename.- Parameters:
chart
-filename
-- Throws:
IOException
ChartTestFailed
- is thrown if at least one pixel differ. The exception holds all pixel coordinates where a difference exists.
-
getBufferedImage
protected BufferedImage getBufferedImage(Chart chart) throws IOException
- Throws:
IOException
-
loadBufferedImage
protected BufferedImage loadBufferedImage(String filename) throws IOException
- Throws:
IOException
-
compare
public void compare(BufferedImage actual, BufferedImage expected) throws ChartTestFailed
Perform the comparison between twoBufferedImage
.- Parameters:
actual
-expected
-- Throws:
ChartTestFailed
- is thrown if at least one pixel differ. The exception holds all pixel coordinates where a difference exists.
-
getTestCaseFile
public File getTestCaseFile()
-
getTestCaseFileName
public String getTestCaseFileName()
-
getTestCaseFailedFileName
public String getTestCaseFailedFileName()
-
getTestName
public String getTestName()
-
getTestCanvasType
public String getTestCanvasType()
-
getTestCaseInputFolder
public String getTestCaseInputFolder()
-
setTestCaseInputFolder
public void setTestCaseInputFolder(String testCaseFolder)
-
getTestCaseOutputFolder
public String getTestCaseOutputFolder()
-
setTestCaseOutputFolder
public void setTestCaseOutputFolder(String testCaseOutputFolder)
-
-