/hg/gfx-test: Refactored, added new test cases (rendering using ...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Aug 12 07:03:59 PDT 2011


changeset fd3ba8985b59 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=fd3ba8985b59
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Aug 12 16:05:39 2011 +0200

	Refactored, added new test cases (rendering using transparency etc.)


diffstat:

 ChangeLog                                                    |    9 +-
 src/org/gfxtest/testsuites/NormalCubicCurves.java            |  275 ++++++-
 src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java     |  374 ++++++++--
 src/org/gfxtest/testsuites/NormalQuadraticCurves.java        |  266 ++++++-
 src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java |  370 ++++++++--
 5 files changed, 1049 insertions(+), 245 deletions(-)

diffs (truncated from 1959 to 500 lines):

diff -r 554e6adab4f4 -r fd3ba8985b59 ChangeLog
--- a/ChangeLog	Thu Aug 11 13:19:50 2011 +0200
+++ b/ChangeLog	Fri Aug 12 16:05:39 2011 +0200
@@ -1,3 +1,10 @@
+2011-08-12  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/testsuites/NormalQuadraticCurves.java:
+	* src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java:
+	* src/org/gfxtest/testsuites/NormalCubicCurves.java:
+	* src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java:
+	Refactored, added new test cases (rendering using transparency etc.)
+
 2011-08-11  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* Makefile: added new classes to compile
 	* src/org/gfxtest/framework/CommonRenderingStyles.java:
@@ -16,7 +23,7 @@
 2011-08-08  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java:
 	Fixed minor issues in two tests.
-	* src/org/gfxtest/testsuites/NormalCubisCurvesAsPaths.java:
+	* src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java:
 	Created new test suite containing 12 gfx.tests.
 
 2011-08-05  Pavel Tisnovsky  <ptisnovs at redhat.com>
diff -r 554e6adab4f4 -r fd3ba8985b59 src/org/gfxtest/testsuites/NormalCubicCurves.java
--- a/src/org/gfxtest/testsuites/NormalCubicCurves.java	Thu Aug 11 13:19:50 2011 +0200
+++ b/src/org/gfxtest/testsuites/NormalCubicCurves.java	Fri Aug 12 16:05:39 2011 +0200
@@ -63,17 +63,6 @@
 @Zoom(1)
 public class NormalCubicCurves extends GfxTest
 {
-
-    /**
-     * Stroke width used for drawing "thick" curves.
-     */
-    private static final int STROKE_WIDTH_THICK = 10;
-
-    /**
-     * Stroke width used for drawing extra "thick" curves.
-     */
-    private static final int STROKE_WIDTH_EXTRA_THICK = 30;
-
     /**
      * Default Y offset of curve end points.
      */
@@ -104,7 +93,7 @@
     {
         for (int i = 0; i < 4; i++)
         {
-            this.drawCross(graphics, x[pointIndexes[i]-1], y[pointIndexes[i]-1]);
+            drawCross(graphics, x[pointIndexes[i]-1], y[pointIndexes[i]-1]);
         }
     }
 
@@ -205,7 +194,7 @@
     private TestResult drawThickCubicCurve(TestImage image, Graphics2D graphics, CubicCurve2D cubicCurve, int[] pointIndexes)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeThickWidth(graphics);
 
         return drawCubicCurve(image, graphics, cubicCurve, Color.BLACK, pointIndexes);
     }
@@ -218,9 +207,6 @@
      *            image to which two dimensional shape is to be rendered
      * @param graphics
      *            graphics canvas
-     * 
-     * @param image
-     * @param graphics
      */
     private void drawCurveWithVariousColors(TestImage image, Graphics2D graphics)
     {
@@ -258,6 +244,47 @@
     }
 
     /**
+     * Draw set of cubic curves onto canvas specified by Graphics2D class.
+     * Curves are drawn using various transparency.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics canvas
+     */
+    private void drawCurveWithVariousTransparency(TestImage image, Graphics2D graphics)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
+
+        // offset counter
+        int offset = -DEFAULT_Y_OFFSET >> 1;
+
+        // Draw each curve with transparency
+        for (int transparency = 0; transparency < 16; transparency++)
+        {
+            // create new CubicCurve2D.Float
+            CubicCurve2D cubicCurve = new CubicCurve2D.Float();
+
+            // fill in arrays containing coordinates for all cubic curve control points
+            int[] x = pointSet.getXPointArray();
+            int[] y = pointSet.getYPointArray();
+
+            // construct CubicCurve2D.Float with set coordinates
+            cubicCurve.setCurve(x[0], y[0] + offset, x[1], y[1] + offset, x[2], y[2] + offset, x[3], y[3] + offset);
+
+            // set the specified color
+            graphics.setColor(new Color(0f, 0f, 0f, transparency / 16f));
+
+            // draw CubicCurve2D
+            graphics.draw(cubicCurve);
+
+            // move next curve down
+            offset += OFFSET_STEP;
+        }
+    }
+
+    /**
      * Test if cubic curve created by CubicCurve2D.Float() is rendered
      * correctly.
      * 
@@ -297,6 +324,29 @@
 
     /**
      * Test if cubic curve created by CubicCurve2D.Float() is rendered
+     * correctly. Curve is to be drawn with zero pixels wide
+     * stroke and default caps.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testZeroStroke(TestImage image, Graphics2D graphics)
+    {
+        // set zero pixels wide stroke
+        CommonRenderingStyles.setStrokeZeroThick(graphics);
+
+        // create new CubicCurve2D.Float
+        CubicCurve2D cubicCurve = new CubicCurve2D.Float();
+
+        // draw cubic curve
+        return drawCubicCurve(image, graphics, cubicCurve);
+    }
+
+    /**
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered
      * correctly. Curve is to be drawn with 10 pixels wide
      * stroke and default caps.
      * 
@@ -309,7 +359,7 @@
     public TestResult testThickStroke(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK));
+        CommonRenderingStyles.setStrokeThickWidth(graphics);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -332,7 +382,7 @@
     public TestResult testThickStrokeCapsButt(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeThickWidth(graphics, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -355,7 +405,7 @@
     public TestResult testThickStrokeCapsRound(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeThickWidth(graphics, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -378,7 +428,7 @@
     public TestResult testThickStrokeCapsSquare(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeThickWidth(graphics, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -400,8 +450,8 @@
      */
     public TestResult testExtraThickStroke(TestImage image, Graphics2D graphics)
     {
-        // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_EXTRA_THICK));
+        // set 30 pixels wide stroke
+        CommonRenderingStyles.setStrokeExtraThickWidth(graphics);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -424,7 +474,7 @@
     public TestResult testExtraThickStrokeCapsButt(TestImage image, Graphics2D graphics)
     {
         // set 30 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_EXTRA_THICK, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeExtraThickWidth(graphics, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -447,7 +497,7 @@
     public TestResult testExtraThickStrokeCapsRound(TestImage image, Graphics2D graphics)
     {
         // set 30 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_EXTRA_THICK, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeExtraThickWidth(graphics, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -470,7 +520,7 @@
     public TestResult testExtraThickStrokeCapsSquare(TestImage image, Graphics2D graphics)
     {
         // set 30 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_EXTRA_THICK, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeExtraThickWidth(graphics, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL);
 
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
@@ -499,7 +549,7 @@
     }
 
     /**
-     * Test if cubic curve created by QuadCurve2D.Float() is rendered
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered
      * correctly. Curve is drawn using different colors and using 10 pixel wide
      * stroke.
      * 
@@ -512,7 +562,7 @@
     public TestResult testColorsStrokeWidth(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK));
+        CommonRenderingStyles.setStrokeThickWidth(graphics); 
 
         // draw set of curves using test color palette
         drawCurveWithVariousColors(image, graphics);
@@ -522,7 +572,29 @@
     }
 
     /**
-     * Test if cubic curve created by QuadCurve2D.Float() is rendered
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered correctly.
+     * Curve is drawn using different colors and using zero pixel wide stroke.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testColorsZeroStrokeWidth(TestImage image, Graphics2D graphics)
+    {
+        // set zero pixels wide stroke
+        CommonRenderingStyles.setStrokeZeroThick(graphics); 
+
+        // draw set of curves using test color palette
+        drawCurveWithVariousColors(image, graphics);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered
      * correctly. Curve is drawn using different colors and using 10 pixel wide
      * stroke using CAP_BUTT.
      * 
@@ -535,7 +607,7 @@
     public TestResult testColorsCapsButt(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeThickWidth(graphics, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
 
         // draw set of curves using test color palette
         drawCurveWithVariousColors(image, graphics);
@@ -545,7 +617,7 @@
     }
 
     /**
-     * Test if cubic curve created by QuadCurve2D.Float() is rendered
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered
      * correctly. Curve is drawn using different colors and using 10 pixel wide
      * stroke using CAP_ROUND.
      * 
@@ -558,7 +630,7 @@
     public TestResult testColorsCapsRound(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeThickWidth(graphics, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
 
         // draw set of curves using test color palette
         drawCurveWithVariousColors(image, graphics);
@@ -568,7 +640,7 @@
     }
 
     /**
-     * Test if cubic curve created by QuadCurve2D.Float() is rendered
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered
      * correctly. Curve is drawn using different colors and using 10 pixel wide
      * stroke using CAP_SQUARE.
      * 
@@ -581,7 +653,7 @@
     public TestResult testColorsCapsSquare(TestImage image, Graphics2D graphics)
     {
         // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+        CommonRenderingStyles.setStrokeThickWidth(graphics, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL);
 
         // draw set of curves using test color palette
         drawCurveWithVariousColors(image, graphics);
@@ -591,6 +663,95 @@
     }
 
     /**
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered correctly.
+     * Curve is drawn using different transparency and using 1 pixel wide
+     * stroke.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testTransparencyBasicStroke(TestImage image, Graphics2D graphics)
+    {
+        // draw set of curves using different transparency
+        drawCurveWithVariousTransparency(image, graphics);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered correctly.
+     * Curve is drawn using different transparency and using 10 pixel wide
+     * stroke.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testTransparencyThickStroke(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke
+        CommonRenderingStyles.setStrokeThickWidth(graphics);
+
+        // draw set of curves using different transparency
+        drawCurveWithVariousTransparency(image, graphics);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered correctly.
+     * Curve is drawn using different transparency and using 30 pixel wide
+     * stroke.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testTransparencyExtraThickStroke(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke
+        CommonRenderingStyles.setStrokeExtraThickWidth(graphics);
+
+        // draw set of curves using different transparency
+        drawCurveWithVariousTransparency(image, graphics);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if cubic curve created by CubicCurve2D.Float() is rendered correctly.
+     * Curve is drawn using different transparency and using 30 pixel wide
+     * stroke.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testTransparencyZeroThickStroke(TestImage image, Graphics2D graphics)
+    {
+        // set zero pixels wide stroke
+        CommonRenderingStyles.setStrokeZeroThick(graphics);
+
+        // draw set of curves using different transparency
+        drawCurveWithVariousTransparency(image, graphics);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
      * Test drawing cubic curve with no identical points.
      * To be precise: first point and fourth point are curve end points and
      * second point and third point are control points which defines the curvature.
@@ -606,10 +767,10 @@
         // control point indexes
         int[] controlPointIndexes = new int[]
         { 1, 2, 3, 4 };
-        
+
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
-        
+
         // draw cubic curve and return test result
         return drawCubicCurve(image, graphics, cubicCurve, controlPointIndexes);
     }
@@ -630,10 +791,10 @@
         // control point indexes
         int[] controlPointIndexes = new int[]
         { 1, 1, 3, 4 };
-        
+
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
-        
+
         // draw cubic curve and return test result
         return drawThickCubicCurve(image, graphics, cubicCurve, controlPointIndexes);
     }
@@ -654,10 +815,10 @@
         // control point indexes
         int[] controlPointIndexes = new int[]
         { 1, 2, 1, 4 };
-        
+
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
-        
+
         // draw cubic curve and return test result
         return drawThickCubicCurve(image, graphics, cubicCurve, controlPointIndexes);
     }
@@ -678,10 +839,10 @@
         // control point indexes
         int[] controlPointIndexes = new int[]
         { 1, 2, 3, 1 };
-        
+
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
-        
+
         // draw cubic curve and return test result
         return drawThickCubicCurve(image, graphics, cubicCurve, controlPointIndexes);
     }
@@ -702,10 +863,10 @@
         // control point indexes
         int[] controlPointIndexes = new int[]
         { 1, 2, 2, 4 };
-        
+
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
-        
+
         // draw cubic curve and return test result
         return drawThickCubicCurve(image, graphics, cubicCurve, controlPointIndexes);
     }
@@ -726,10 +887,10 @@
         // control point indexes
         int[] controlPointIndexes = new int[]
         { 1, 2, 3, 2 };
-        
+
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();
-        
+
         // draw cubic curve and return test result
         return drawThickCubicCurve(image, graphics, cubicCurve, controlPointIndexes);
     }
@@ -750,10 +911,10 @@
         // control point indexes
         int[] controlPointIndexes = new int[]
         { 1, 2, 3, 3 };
-        
+
         // create new CubicCurve2D.Float
         CubicCurve2D cubicCurve = new CubicCurve2D.Float();



More information about the distro-pkg-dev mailing list