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 protected Dimension
colorbarDimension
static String
FILE_LABEL_ACTUAL
static String
FILE_LABEL_DIFF
static String
FILE_LABEL_EXPECT
static String
FILE_LABEL_ZOOM
protected int
HEIGHT
static String
MAVEN_TARGET_PATH
static int
TEST_IMG_SIZE
protected String
testCaseInputFolder
protected String
testCaseOutputFolder
protected boolean
textInvisible
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
assertSimilar(IColorMap colormap, String testImage)
void
build(Chart chart, String testImage)
void
build(IColorMap colormap, 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.void
compare(IColorMap colormap, String filename)
void
compare(AWTColorbarImageGenerator colorbar, String filename)
Compare a colorbar image with a reference image given by filename.protected BufferedImage
copy(BufferedImage source)
protected void
doHighlightPixels(BufferedImage expected, IntegerCoord2d diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates (IntegerCoord2d
)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.void
execute(IColorMap chart)
void
execute(IColorMap colormap, String testImage)
protected BufferedImage
getBufferedImage(Chart chart)
protected BufferedImage
getBufferedImage(AWTColorbarImageGenerator colorbar)
protected BufferedImage
getErroneousArea(BufferedImage expected, List<IntegerCoord2d> diffs)
protected AWTColorbarImageGenerator
getImageGenerator(IColorMap colormap)
String
getTestCanvasType()
String
getTestCaseFailedFileName()
File
getTestCaseFile()
String
getTestCaseFileName()
String
getTestCaseFileName(String testName)
String
getTestCaseInputFolder()
String
getTestCaseOutputFolder()
String
getTestName()
protected void
highlightPixel(BufferedImage expected, List<IntegerCoord2d> diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates.protected void
highlightSize(BufferedImage diffImage, String m)
boolean
isBuilt(String testImage)
boolean
isTextInvisible()
protected BufferedImage
loadBufferedImage(String filename)
String
path(Class<?> clazz)
String
path(Object obj)
String
path(String filename)
void
setTestCaseInputFolder(String testCaseFolder)
void
setTestCaseOutputFolder(String testCaseOutputFolder)
void
setTextInvisible(boolean textInvisible)
void
test(Chart chart, String testImage)
Perform a chart comparison to image and output multiple diagnostic images in case of failure Expected image Actual image Diff image Zoom imagevoid
test(IColorMap chart, String testImage)
Perform a chart comparison to image and output multiple diagnostic images in case of failure Expected image Actual image Diff image Zoom image
-
-
-
Field Detail
-
FILE_LABEL_ACTUAL
public static final String FILE_LABEL_ACTUAL
- See Also:
- Constant Field Values
-
FILE_LABEL_EXPECT
public static final String FILE_LABEL_EXPECT
- See Also:
- Constant Field Values
-
FILE_LABEL_DIFF
public static final String FILE_LABEL_DIFF
- See Also:
- Constant Field Values
-
FILE_LABEL_ZOOM
public static final String FILE_LABEL_ZOOM
- See Also:
- Constant Field Values
-
TEST_IMG_SIZE
public static int TEST_IMG_SIZE
-
textInvisible
protected boolean textInvisible
-
testCaseOutputFolder
protected String testCaseOutputFolder
-
testCaseInputFolder
protected String testCaseInputFolder
-
MAVEN_TARGET_PATH
public static final String MAVEN_TARGET_PATH
- See Also:
- Constant Field Values
-
colorbarDimension
protected Dimension colorbarDimension
-
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 multiple diagnostic images in case of failure- Expected image
- Actual image
- Diff image
- Zoom image
- Parameters:
chart
-testImage
-- Throws:
IOException
-
execute
public void execute(IColorMap colormap, String testImage) throws IOException
- Throws:
IOException
-
execute
public void execute(IColorMap chart) throws IOException
- Throws:
IOException
-
build
public void build(IColorMap colormap, String testImage) throws IOException
- Throws:
IOException
-
test
public void test(IColorMap chart, String testImage) throws IOException
Perform a chart comparison to image and output multiple diagnostic images in case of failure- Expected image
- Actual image
- Diff image
- Zoom image
- Parameters:
chart
-testImage
-- Throws:
IOException
-
highlightSize
protected void highlightSize(BufferedImage diffImage, String m)
-
copy
protected BufferedImage copy(BufferedImage source)
-
highlightPixel
protected void highlightPixel(BufferedImage expected, List<IntegerCoord2d> diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates.
-
doHighlightPixels
protected void doHighlightPixels(BufferedImage expected, IntegerCoord2d diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
Invert the pixel color identified by the input coordinates (IntegerCoord2d
)
-
getErroneousArea
protected BufferedImage getErroneousArea(BufferedImage expected, List<IntegerCoord2d> diffs)
-
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.
-
compare
public void compare(AWTColorbarImageGenerator colorbar, String filename) throws IOException, ChartTestFailed
Compare a colorbar image with a reference 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.
-
compare
public void compare(IColorMap colormap, String filename) throws IOException, ChartTestFailed
- Throws:
IOException
ChartTestFailed
-
getImageGenerator
protected AWTColorbarImageGenerator getImageGenerator(IColorMap colormap) throws IOException
- Throws:
IOException
-
getBufferedImage
protected BufferedImage getBufferedImage(AWTColorbarImageGenerator colorbar) throws IOException
- Throws:
IOException
-
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)
-
isTextInvisible
public boolean isTextInvisible()
-
setTextInvisible
public void setTextInvisible(boolean textInvisible)
-
-