/hg/gfx-test: Create new test cases.

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Tue Aug 2 04:45:48 PDT 2011


changeset 8ef45900ab71 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=8ef45900ab71
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Aug 02 13:47:28 2011 +0200

	Create new test cases.


diffstat:

 ChangeLog                                      |    4 +
 src/org/gfxtest/testsuites/PathsFromLines.java |  521 ++++++++++++++++++++++++-
 2 files changed, 519 insertions(+), 6 deletions(-)

diffs (truncated from 585 to 500 lines):

diff -r a7c8d2ce958c -r 8ef45900ab71 ChangeLog
--- a/ChangeLog	Mon Aug 01 12:06:10 2011 +0200
+++ b/ChangeLog	Tue Aug 02 13:47:28 2011 +0200
@@ -1,3 +1,7 @@
+2011-08-02  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/testsuites/PathsFromLines.java: created new test
+	cases.
+
 2011-08-01  Pavel Tisnovsky  <ptisnovs at redhat.com> 
 	* src/org/gfxtest/harness/ExternalCommands.java:
 	* src/org/gfxtest/framework/GfxTestConfiguration.java:
diff -r a7c8d2ce958c -r 8ef45900ab71 src/org/gfxtest/testsuites/PathsFromLines.java
--- a/src/org/gfxtest/testsuites/PathsFromLines.java	Mon Aug 01 12:06:10 2011 +0200
+++ b/src/org/gfxtest/testsuites/PathsFromLines.java	Tue Aug 02 13:47:28 2011 +0200
@@ -51,7 +51,8 @@
 
 
 /**
- * These tests renders various shapes using Path2D class.
+ * These tests renders various shapes using Path2D class. Shapes are constructed
+ * only from line segments.
  * 
  * @author Pavel Tisnovsky
  */
@@ -121,6 +122,52 @@
     {
         return createLinePath(x, BORDER_WIDTH, x, height - BORDER_WIDTH);
     }
+    
+    /**
+     * This method creates Path2D consisting of two line segments, using right
+     * angle between these segments.
+     * 
+     * @param width
+     *            image width (not including borders)
+     * @param height
+     *            image height (not including borders)
+     * @return created Path2D object
+     */
+    private static Path2D createPathContainingRightAngleLShape(int width, int height)
+    {
+        Path2D path = new Path2D.Float();
+        path.moveTo(BORDER_WIDTH, BORDER_WIDTH);
+        path.lineTo(BORDER_WIDTH, height - BORDER_WIDTH);
+        path.lineTo(width - BORDER_WIDTH, height - BORDER_WIDTH);
+        return path;
+    }
+
+    /**
+     * This method creates Path2D consisting of two line segments, using right
+     * angle between these segments.
+     * 
+     * @param width
+     *            image width (not including borders)
+     * @param height
+     *            image height (not including borders)
+     * @return created Path2D object
+     */
+    private static Path2D createPathContainingRightAngleVShape(int width, int height)
+    {
+        // calculate horizontal and vertical length of line segments
+        int length = width > height ? height : width;
+        length >>= 1;
+
+        // calculate center point
+        int xCenter = width >> 1;
+
+        // create path2D
+        Path2D path = new Path2D.Float();
+        path.moveTo(xCenter - length, BORDER_WIDTH);
+        path.lineTo(xCenter, BORDER_WIDTH + length);
+        path.lineTo(xCenter + length, BORDER_WIDTH);
+        return path;
+    }
 
     /**
      * Computes color for line drawn by different angle
@@ -129,7 +176,7 @@
      *            counter
      * @return color computed for a given index
      */
-    private Color computeColorForSlopedLine(int index)
+    private static Color computeColorForSlopedLine(int index)
     {
         return new Color(Color.HSBtoRGB((float) index / ANGLES, 1.0f, 1.0f));
     }
@@ -145,7 +192,7 @@
      *            counter
      * @return new sloped line represented by an instance of Path2D
      */
-    private Path2D createSlopedLine(int xc, int yc, int index)
+    private static Path2D createSlopedLine(int xc, int yc, int index)
     {
         int majorRadius = (xc > yc ? yc : xc) - 20;
         double angle = 2.0 * index / ANGLES * Math.PI;
@@ -163,6 +210,54 @@
     }
 
     /**
+     * Draw path consisting of two line segments using right angle between two
+     * segments. The final path is similar to L-shape.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     */
+    private static TestResult drawPathWithRightAngleLShape(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // create path
+        Path2D path = createPathContainingRightAngleLShape(image.getWidth(), image.getHeight());
+
+        // draw path
+        graphics.draw(path);
+
+        // return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Draw path consisting of two line segments using right angle between two
+     * segments. The final path is similar to V-shape.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     */
+    private static TestResult drawPathWithRightAngleVShape(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // create path
+        Path2D path = createPathContainingRightAngleVShape(image.getWidth(), image.getHeight());
+
+        // draw path
+        graphics.draw(path);
+
+        // return value
+        return TestResult.PASSED;
+    }
+
+    /**
      * Draw color wheel using 'ANGLES' lines
      * 
      * @param image
@@ -170,7 +265,7 @@
      * @param graphics2d
      *            graphics canvas
      */
-    private void drawColorWheel(TestImage image, Graphics2D graphics)
+    private static void drawColorWheel(TestImage image, Graphics2D graphics)
     {
         // compute center of the image
         int xc = image.getCenterX();
@@ -657,9 +752,423 @@
     }
 
     /**
+     * Draw L-shaped shape consisting of two line segments.
+     *
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShape(TestImage image, Graphics2D graphics)
+    {
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and default caps & join.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapDefJoinDef(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10));
+
+        // draw the path
+        drawPathWithRightAngleLShape(image, graphics);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_BUTT, JOIN_BEVEL.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapButtJoinBevel(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_SQUARE, JOIN_BEVEL.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapSquareJoinBevel(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_ROUND, JOIN_BEVEL.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapRoundJoinBevel(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_BUTT, JOIN_MITER.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapButtJoinMiter(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_SQUARE, JOIN_MITER.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapSquareJoinMiter(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_ROUND, JOIN_MITER.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapRoundJoinMiter(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_BUTT, JOIN_ROUND.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapButtJoinRound(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_SQUARE, JOIN_ROUND.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapSquareJoinRound(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw L-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_ROUND, JOIN_ROUND.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleLShapeCapRoundJoinRound(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleLShape(image, graphics);
+    }
+
+    /**
+     * Draw V-shaped shape consisting of two line segments.
+     *
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleVShape(TestImage image, Graphics2D graphics)
+    {
+        // draw the path and return test result
+        return drawPathWithRightAngleVShape(image, graphics);
+    }
+
+    /**
+     * Draw V-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and default caps & join.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleVShapeCapDefJoinDef(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleVShape(image, graphics);
+    }
+
+    /**
+     * Draw V-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_BUTT, JOIN_BEVEL.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleVShapeCapButtJoinBevel(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+
+        // draw the path and return test result
+        return drawPathWithRightAngleVShape(image, graphics);
+    }
+
+    /**
+     * Draw V-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_BUTT, JOIN_MITER.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleVShapeCapButtJoinMiter(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
+        
+        // draw the path and return test result
+        return drawPathWithRightAngleVShape(image, graphics);
+    }
+    
+    /**
+     * Draw V-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_BUTT, JOIN_ROUND.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleVShapeCapButtJoinRound(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
+        
+        // draw the path and return test result
+        return drawPathWithRightAngleVShape(image, graphics);
+    }
+    
+    /**
+     * Draw V-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_ROUND, JOIN_BEVEL.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleVShapeCapRoundJoinBevel(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+        
+        // draw the path and return test result
+        return drawPathWithRightAngleVShape(image, graphics);
+    }
+    
+    /**
+     * Draw V-shaped shape consisting of two line segments using 10 pixels wide
+     * stroke and CAP_ROUND, JOIN_MITER .
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRightAngleVShapeCapRoundJoinMiter(TestImage image, Graphics2D graphics)
+    {
+        // set stroke to 10 pixel width
+        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));
+        
+        // draw the path and return test result
+        return drawPathWithRightAngleVShape(image, graphics);
+    }
+    
+    /**



More information about the distro-pkg-dev mailing list