Class ChartTester

java.lang.Object
org.jzy3d.junit.ChartTester

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 Details

    • FILE_LABEL_ACTUAL

      public static final String FILE_LABEL_ACTUAL
      See Also:
    • FILE_LABEL_EXPECT

      public static final String FILE_LABEL_EXPECT
      See Also:
    • FILE_LABEL_DIFF

      public static final String FILE_LABEL_DIFF
      See Also:
    • FILE_LABEL_ZOOM

      public static final String FILE_LABEL_ZOOM
      See Also:
    • TEST_IMG_SIZE

      public static int TEST_IMG_SIZE
    • textInvisible

      protected boolean textInvisible
    • testCaseOutputFolder

      protected String testCaseOutputFolder
    • testCaseInputFolder

      protected String testCaseInputFolder
    • MAVEN_TEST_RESOURCES_PATH

      public static final String MAVEN_TEST_RESOURCES_PATH
      See Also:
    • MAVEN_TARGET_PATH

      public static final String MAVEN_TARGET_PATH
      See Also:
    • colorbarDimension

      protected org.jzy3d.maths.Dimension colorbarDimension
    • WIDTH

      protected int WIDTH
    • HEIGHT

      protected int HEIGHT
  • Constructor Details

    • ChartTester

      public ChartTester()
  • Method Details

    • assertSimilar

      public void assertSimilar(Chart chart, String testImage)
    • 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 image data/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 call fail(...)
    • 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
    • assertSimilar

      public void assertSimilar(org.jzy3d.colors.colormaps.IColorMap colormap, String testImage)
    • execute

      public void execute(org.jzy3d.colors.colormaps.IColorMap colormap, String testImage) throws IOException
      Throws:
      IOException
    • execute

      public void execute(org.jzy3d.colors.colormaps.IColorMap chart) throws IOException
      Throws:
      IOException
    • build

      public void build(org.jzy3d.colors.colormaps.IColorMap colormap, String testImage) throws IOException
      Throws:
      IOException
    • test

      public void test(org.jzy3d.colors.colormaps.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<org.jzy3d.maths.IntegerCoord2d> diffs, org.jzy3d.junit.ChartTester.Highlight highlight)
      Invert the pixel color identified by the input coordinates.
    • doHighlightPixels

      protected void doHighlightPixels(BufferedImage expected, org.jzy3d.maths.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<org.jzy3d.maths.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:
      filename -
      chart -
      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(org.jzy3d.colors.colormaps.IColorMap colormap, String filename) throws IOException, ChartTestFailed
      Throws:
      IOException
      ChartTestFailed
    • getImageGenerator

      protected AWTColorbarImageGenerator getImageGenerator(org.jzy3d.colors.colormaps.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 two BufferedImage.
      Parameters:
      actual -
      expected -
      Throws:
      ChartTestFailed - is thrown if at least one pixel differ. The exception holds all pixel coordinates where a difference exists.
    • path

      public String path(Object obj)
    • path

      public String path(Class<?> clazz)
    • path

      public String path(String filename)
    • getTestCaseFile

      public File getTestCaseFile()
    • getTestCaseFileName

      public String getTestCaseFileName()
    • getTestCaseFileName

      public String getTestCaseFileName(String testName)
    • 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)