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 DimensioncolorbarDimensionstatic StringFILE_LABEL_ACTUALstatic StringFILE_LABEL_DIFFstatic StringFILE_LABEL_EXPECTstatic StringFILE_LABEL_ZOOMprotected intHEIGHTstatic StringMAVEN_TARGET_PATHstatic intTEST_IMG_SIZEprotected StringtestCaseInputFolderprotected StringtestCaseOutputFolderprotected booleantextInvisibleprotected intWIDTH
-
Constructor Summary
Constructors Constructor Description ChartTester()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertSimilar(Chart chart, String testImage)voidassertSimilar(IColorMap colormap, String testImage)voidbuild(Chart chart, String testImage)voidbuild(IColorMap colormap, String testImage)voidclean(String testImage)booleancleanFile(String file)voidcompare(BufferedImage actual, BufferedImage expected)Perform the comparison between twoBufferedImage.voidcompare(Chart chart, String filename)Compare the image displayed by the chart with an image given by filename.voidcompare(IColorMap colormap, String filename)voidcompare(AWTColorbarImageGenerator colorbar, String filename)Compare a colorbar image with a reference image given by filename.protected BufferedImagecopy(BufferedImage source)protected voiddoHighlightPixels(BufferedImage expected, IntegerCoord2d diffs, org.jzy3d.junit.ChartTester.Highlight highlight)Invert the pixel color identified by the input coordinates (IntegerCoord2d)voidexecute(Chart chart)voidexecute(Chart chart, String testImage)Run a chart and verify if its screenshot is pixelwise similar to the test case image.voidexecute(IColorMap chart)voidexecute(IColorMap colormap, String testImage)protected BufferedImagegetBufferedImage(Chart chart)protected BufferedImagegetBufferedImage(AWTColorbarImageGenerator colorbar)protected BufferedImagegetErroneousArea(BufferedImage expected, List<IntegerCoord2d> diffs)protected AWTColorbarImageGeneratorgetImageGenerator(IColorMap colormap)StringgetTestCanvasType()StringgetTestCaseFailedFileName()FilegetTestCaseFile()StringgetTestCaseFileName()StringgetTestCaseFileName(String testName)StringgetTestCaseInputFolder()StringgetTestCaseOutputFolder()StringgetTestName()protected voidhighlightPixel(BufferedImage expected, List<IntegerCoord2d> diffs, org.jzy3d.junit.ChartTester.Highlight highlight)Invert the pixel color identified by the input coordinates.protected voidhighlightSize(BufferedImage diffImage, String m)booleanisBuilt(String testImage)booleanisTextInvisible()protected BufferedImageloadBufferedImage(String filename)Stringpath(Class<?> clazz)Stringpath(Object obj)Stringpath(String filename)voidsetTestCaseInputFolder(String testCaseFolder)voidsetTestCaseOutputFolder(String testCaseOutputFolder)voidsetTextInvisible(boolean textInvisible)voidtest(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 imagevoidtest(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:
IOExceptionChartTestFailed- 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:
IOExceptionChartTestFailed- 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:
IOExceptionChartTestFailed
-
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)
-
-