/hg/gfx-test: Quadratic curve tests: refactored and added new te...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Wed Aug 3 06:43:06 PDT 2011


changeset e7894806a147 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=e7894806a147
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Wed Aug 03 15:44:44 2011 +0200

	Quadratic curve tests: refactored and added new tests.


diffstat:

 ChangeLog                                             |    5 +
 src/org/gfxtest/framework/ColorPalette.java           |   12 +-
 src/org/gfxtest/testsuites/NormalQuadraticCurves.java |  503 +++++++++--------
 3 files changed, 291 insertions(+), 229 deletions(-)

diffs (truncated from 629 to 500 lines):

diff -r 8ef45900ab71 -r e7894806a147 ChangeLog
--- a/ChangeLog	Tue Aug 02 13:47:28 2011 +0200
+++ b/ChangeLog	Wed Aug 03 15:44:44 2011 +0200
@@ -1,3 +1,8 @@
+2011-08-03  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/testsuites/ColorPalette.java: added new method
+	* src/org/gfxtest/testsuites/NormalQuadraticCurves.java:
+	Refactoring, added new test cases.
+
 2011-08-02  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* src/org/gfxtest/testsuites/PathsFromLines.java: created new test
 	cases.
diff -r 8ef45900ab71 -r e7894806a147 src/org/gfxtest/framework/ColorPalette.java
--- a/src/org/gfxtest/framework/ColorPalette.java	Tue Aug 02 13:47:28 2011 +0200
+++ b/src/org/gfxtest/framework/ColorPalette.java	Wed Aug 03 15:44:44 2011 +0200
@@ -67,7 +67,7 @@
          Color.GRAY,
          Color.DARK_GRAY
     };
-    
+
     /**
      * Return color for the specified position in a color palette.
      * 
@@ -79,4 +79,14 @@
     {
         return ColorPalette.colors[color % colors.length];
     }
+
+    /**
+     * Returns 12-color palette.
+     *
+     * @return test 12-color palette
+     */
+    public static Color[] getColors()
+    {
+        return colors;
+    }
 }
diff -r 8ef45900ab71 -r e7894806a147 src/org/gfxtest/testsuites/NormalQuadraticCurves.java
--- a/src/org/gfxtest/testsuites/NormalQuadraticCurves.java	Tue Aug 02 13:47:28 2011 +0200
+++ b/src/org/gfxtest/testsuites/NormalQuadraticCurves.java	Wed Aug 03 15:44:44 2011 +0200
@@ -64,28 +64,41 @@
 @Zoom(1)
 public class NormalQuadraticCurves 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.
      */
-    private static final int DEFAULT_Y_OFFSET = 20;
+    private static final int DEFAULT_Y_OFFSET = 40;
 
     /**
      * Draw quadratic curve onto canvas specified by Graphics2D class.
      * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
      * @param graphics
      *            graphics canvas
-     * @param width
-     *            canvas width
-     * @param height
-     *            canvas height
      * @param quadCurve
      *            curve to be drawn
      * @param color
      *            curve color or null when Color.BLACK can be used.
      * @return test result status - PASSED, FAILED or ERROR
      */
-    private TestResult drawQuadraticCurve(Graphics2D graphics, int width, int height, QuadCurve2D quadCurve, Color color)
+    private TestResult drawQuadraticCurve(TestImage image, Graphics2D graphics, QuadCurve2D quadCurve, Color color)
     {
+        // calculate image dimensions
+        int width =  image.getWidth();
+        int height =  image.getHeight();
+
         // construct QuadCurve2D.Float with set coordinates
         quadCurve.setCurve(computeX1(width), computeY1(), computeX2(width), computeY2(height), computeX3(width), computeY3());
 
@@ -103,206 +116,39 @@
      * Draw quadratic curve onto canvas specified by Graphics2D class using
      * black color.
      * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
      * @param graphics
      *            graphics canvas
-     * @param width
-     *            canvas width
-     * @param height
-     *            canvas height
      * @param quadCurve
      *            curve to be drawn
      * @return test result status - PASSED, FAILED or ERROR
      */
-    private TestResult drawQuadraticCurve(Graphics2D graphics, int w, int h, QuadCurve2D quadCurve)
+    private TestResult drawQuadraticCurve(TestImage image, Graphics2D graphics, QuadCurve2D quadCurve)
     {
-        return drawQuadraticCurve(graphics, w, h, quadCurve, Color.BLACK);
+        return drawQuadraticCurve(image, graphics, quadCurve, Color.BLACK);
     }
     
     /**
-     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
-     * correctly.
+     * Draw set of quadratic curves onto canvas specified by Graphics2D class.
+     * Curves are drawn using various colors.
      * 
      * @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
+     *            graphics canvas
      */
-    public TestResult test0(TestImage image, Graphics2D graphics)
-    {
-        // calculate image dimensions
-        int width =  image.getWidth();
-        int height =  image.getHeight();
-
-        // create new QuadCurve2D.Float
-        QuadCurve2D quadCurve = new QuadCurve2D.Float();
-
-        // draw quadratic curve
-        return drawQuadraticCurve(graphics, width, height, quadCurve);
-    }
-    
-    /**
-     * Test if quadratic curve created by QuadCurve2D.Double() is rendered
-     * correctly.
-     * 
-     * @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 test1(TestImage image, Graphics2D graphics)
-    {
-        // calculate image dimensions
-        int width =  image.getWidth();
-        int height =  image.getHeight();
-
-        // create new QuadCurve2D.Float
-        QuadCurve2D quadCurve = new QuadCurve2D.Double();
-
-        // draw quadratic curve
-        return drawQuadraticCurve(graphics, width, height, quadCurve);
-    }
-    
-    /**
-     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
-     * correctly. Curve is to be drawn with 10 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 test2(TestImage image, Graphics2D graphics)
-    {
-        // calculate image dimensions
-        int width =  image.getWidth();
-        int height =  image.getHeight();
-
-        // set 10 pixels wide stroke
-        graphics.setStroke(new BasicStroke(10));
-
-        // create new QuadCurve2D.Float
-        QuadCurve2D quadCurve = new QuadCurve2D.Float();
-
-        // draw quadratic curve
-        return drawQuadraticCurve(graphics, width, height, quadCurve);
-    }
-
-    /**
-     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
-     * correctly. Curve is to be drawn with 10 pixels wide stroke and default
-     * CAP_BUTT.
-     * 
-     * @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 test3(TestImage image, Graphics2D graphics)
-    {
-        // calculate image dimensions
-        int width =  image.getWidth();
-        int height =  image.getHeight();
-
-        // set 10 pixels wide stroke and CAP_BUTT
-        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
-
-        // create new QuadCurve2D.Float
-        QuadCurve2D quadCurve = new QuadCurve2D.Float();
-
-        // draw quadratic curve
-        return drawQuadraticCurve(graphics, width, height, quadCurve);
-    }
-
-    /**
-     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
-     * correctly. Curve is to be drawn with 10 pixels wide stroke and default
-     * CAP_ROUND.
-     * 
-     * @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 test4(TestImage image, Graphics2D graphics)
-    {
-        // calculate image dimensions
-        int width =  image.getWidth();
-        int height =  image.getHeight();
-
-        // set 10 pixels wide stroke and CAP_ROUND
-        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
-
-        // create new QuadCurve2D.Float
-        QuadCurve2D quadCurve = new QuadCurve2D.Float();
-
-        // draw quadratic curve
-        return drawQuadraticCurve(graphics, width, height, quadCurve);
-    }
-
-    /**
-     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
-     * correctly. Curve is to be drawn with 10 pixels wide stroke and default
-     * CAP_SQUARE.
-     * 
-     * @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 test5(TestImage image, Graphics2D graphics)
-    {
-        // calculate image dimensions
-        int width =  image.getWidth();
-        int height =  image.getHeight();
-
-        // set 10 pixels wide stroke and CAP_SQUARE
-        graphics.setStroke(new BasicStroke(10, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
-
-        // create new QuadCurve2D.Float
-        QuadCurve2D quadCurve = new QuadCurve2D.Float();
-
-        // draw quadratic curve
-        return drawQuadraticCurve(graphics, width, height, quadCurve);
-    }
-
-    /**
-     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
-     * correctly. Curve is drawn using different colors.
-     * 
-     * @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 test6(TestImage image, Graphics2D graphics)
+    private void drawCurveWithVariousColors(TestImage image, Graphics2D graphics)
     {
         // calculate image dimensions
         int width =  image.getWidth();
         int height =  image.getHeight();
 
         // curve colors
-        Color[] colors = new Color[]
-        {
-             Color.BLACK,
-             Color.BLUE,
-             Color.CYAN,
-             Color.GREEN,
-             Color.ORANGE,
-             Color.RED,
-             Color.YELLOW,
-             Color.GRAY
-        };
+        Color[] colors = ColorPalette.getColors();
 
         // offset counter
-        int offset = 0;
+        int offset = DEFAULT_Y_OFFSET;
 
         // Draw each curve with different color.
         for (Color color : colors)
@@ -323,11 +169,180 @@
             // move next curve down
             offset += 20;
         }
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
+     * correctly.
+     * 
+     * @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 testBasicQuadCurveFloat(TestImage image, Graphics2D graphics)
+    {
+        // create new QuadCurve2D.Float
+        QuadCurve2D quadCurve = new QuadCurve2D.Float();
+
+        // draw quadratic curve
+        return drawQuadraticCurve(image, graphics, quadCurve);
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Double() is rendered
+     * correctly.
+     * 
+     * @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 testBasicQuadCurveDouble(TestImage image, Graphics2D graphics)
+    {
+        // create new QuadCurve2D.Float
+        QuadCurve2D quadCurve = new QuadCurve2D.Double();
+
+        // draw quadratic curve
+        return drawQuadraticCurve(image, graphics, quadCurve);
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
+     * correctly. Curve is to be drawn with 10 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 testThickStroke(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK));
+
+        // create new QuadCurve2D.Float
+        QuadCurve2D quadCurve = new QuadCurve2D.Float();
+
+        // draw quadratic curve
+        return drawQuadraticCurve(image, graphics, quadCurve);
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
+     * correctly. Curve is to be drawn with 10 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 testExtraThickStroke(TestImage image, Graphics2D graphics)
+    {
+        // set 30 pixels wide stroke
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_EXTRA_THICK));
+
+        // create new QuadCurve2D.Float
+        QuadCurve2D quadCurve = new QuadCurve2D.Float();
+
+        // draw quadratic curve
+        return drawQuadraticCurve(image, graphics, quadCurve);
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
+     * correctly. Curve is to be drawn with 10 pixels wide stroke and default
+     * CAP_BUTT.
+     * 
+     * @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 testThickStrokeCapsButt(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke and CAP_BUTT
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+
+        // create new QuadCurve2D.Float
+        QuadCurve2D quadCurve = new QuadCurve2D.Float();
+
+        // draw quadratic curve
+        return drawQuadraticCurve(image, graphics, quadCurve);
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
+     * correctly. Curve is to be drawn with 10 pixels wide stroke and default
+     * CAP_ROUND.
+     * 
+     * @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 testThickStrokeCapsRound(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke and CAP_ROUND
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+
+        // create new QuadCurve2D.Float
+        QuadCurve2D quadCurve = new QuadCurve2D.Float();
+
+        // draw quadratic curve
+        return drawQuadraticCurve(image, graphics, quadCurve);
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
+     * correctly. Curve is to be drawn with 10 pixels wide stroke and default
+     * CAP_SQUARE.
+     * 
+     * @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 testThickStrokeCapsSquare(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke and CAP_SQUARE
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+
+        // create new QuadCurve2D.Float
+        QuadCurve2D quadCurve = new QuadCurve2D.Float();
+
+        // draw quadratic curve
+        return drawQuadraticCurve(image, graphics, quadCurve);
+    }
+
+    /**
+     * Test if quadratic curve created by QuadCurve2D.Float() is rendered
+     * correctly. Curve is drawn using different colors.
+     * 
+     * @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 testColors(TestImage image, Graphics2D graphics)
+    {
+        // draw set of curves using test color palette
+        drawCurveWithVariousColors(image, graphics);
 
         // test return value
         return TestResult.PASSED;
     }
-    
+
     /**
      * Test if quadratic curve created by QuadCurve2D.Float() is rendered
      * correctly. Curve is drawn using different colors and using 10 pixel wide
@@ -339,55 +354,87 @@
      *            graphics context for image
      * @return test result status - PASSED, FAILED or ERROR
      */
-    public TestResult test7(TestImage image, Graphics2D graphics)
+    public TestResult testColorsStrokeWidth(TestImage image, Graphics2D graphics)
     {
-        // calculate image dimensions
-        int width =  image.getWidth();
-        int height =  image.getHeight();
+        // set 10 pixels wide stroke



More information about the distro-pkg-dev mailing list