Class 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 Detail

      • TEST_IMG_SIZE

        public static int TEST_IMG_SIZE
      • testCaseOutputFolder

        protected String testCaseOutputFolder
      • testCaseInputFolder

        protected String testCaseInputFolder
      • WIDTH

        protected int WIDTH
      • HEIGHT

        protected int HEIGHT
    • Constructor Detail

      • ChartTester

        public ChartTester()
    • Method Detail

      • 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(...)
      • clean

        public void clean​(String testImage)
      • cleanFile

        public boolean cleanFile​(String file)
      • 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
      • 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.
      • 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)