/hg/gfx-test: Added four new tests to the test suite

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Oct 8 02:30:04 PDT 2012


changeset 40480b1689fa in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=40480b1689fa
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Oct 08 11:32:50 2012 +0200

	Added four new tests to the test suite
	src/org/gfxtest/testsuites/PrintTestQuadraticCurves.java.


diffstat:

 ChangeLog                                                |    5 +
 src/org/gfxtest/testsuites/PrintTestQuadraticCurves.java |  143 +++++++++++++++
 2 files changed, 148 insertions(+), 0 deletions(-)

diffs (181 lines):

diff -r 12b8706751c4 -r 40480b1689fa ChangeLog
--- a/ChangeLog	Fri Oct 05 11:43:17 2012 +0200
+++ b/ChangeLog	Mon Oct 08 11:32:50 2012 +0200
@@ -1,3 +1,8 @@
+2012-10-08  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/testsuites/PrintTestQuadraticCurves.java:
+	Added four new tests to this test suite.
+
 2012-10-05  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/PrintTestBitBlt.java:
diff -r 12b8706751c4 -r 40480b1689fa src/org/gfxtest/testsuites/PrintTestQuadraticCurves.java
--- a/src/org/gfxtest/testsuites/PrintTestQuadraticCurves.java	Fri Oct 05 11:43:17 2012 +0200
+++ b/src/org/gfxtest/testsuites/PrintTestQuadraticCurves.java	Mon Oct 08 11:32:50 2012 +0200
@@ -37,8 +37,10 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version.
 */
+
 package org.gfxtest.testsuites;
 
+import java.awt.BasicStroke;
 import java.awt.Graphics2D;
 import java.awt.Shape;
 import java.awt.geom.QuadCurve2D;
@@ -46,6 +48,9 @@
 
 
 import org.gfxtest.callbacks.QuadraticCurveDrawCallbacks;
+import org.gfxtest.framework.ColorPalette;
+import org.gfxtest.framework.GrayscalePalette;
+import org.gfxtest.framework.HSBPalette;
 import org.gfxtest.framework.PrintTest;
 import org.gfxtest.framework.TestImage;
 import org.gfxtest.framework.TestResult;
@@ -183,6 +188,144 @@
     }
 
     /**
+     * Test basic behavior of method Graphics.draw(Shape).
+     * Quadratic curves are rendered with default width and default end caps.
+     * Color of all rendered curves are selected from a palette.
+     * All rendered quadratic curves are represented by a Shape object.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawQuadraticCurvesColorPalette(TestImage image, Graphics2D graphics)
+    {
+        drawQuadraticCurve(image, graphics, QUADRATIC_CURVE_STEP, new QuadraticCurveDrawCallbacks()
+        {
+            /**
+             * Callback function called before each quadratic curve is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int index)
+            {
+                // set curve color
+                this.graphics.setColor(ColorPalette.getColor(index));
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.draw(Shape).
+     * Quadratic curves are rendered with default width and default end caps.
+     * Color of all rendered curves are selected from a grayscale palette.
+     * All rendered quadratic curves are represented by a Shape object.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawQuadraticCurvesGrayScale(TestImage image, Graphics2D graphics)
+    {
+        drawQuadraticCurve(image, graphics, QUADRATIC_CURVE_STEP, new QuadraticCurveDrawCallbacks()
+        {
+            /**
+             * Callback function called before each quadratic curve is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int index)
+            {
+                // compute grayscale value
+                float gray = y1 * 1.0f / this.image.getHeight();
+                // set curve color
+                this.graphics.setColor(GrayscalePalette.createGrayscaleColor(gray));
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.draw(Shape).
+     * Quadratic curves are rendered with default width and default end caps.
+     * All rendered quadratic curves are represented by a Shape object.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawQuadraticCurvesColorScale(TestImage image, Graphics2D graphics)
+    {
+        drawQuadraticCurve(image, graphics, QUADRATIC_CURVE_STEP, new QuadraticCurveDrawCallbacks()
+        {
+            /**
+             * Callback function called before each quadratic curve is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int index)
+            {
+                // compute hue value
+                float hue = y1 * 1.0f / this.image.getHeight();
+                // set curve color
+                this.graphics.setColor(HSBPalette.createHsbColor(hue));
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.draw(Shape).
+     * Quadratic curves are rendered with various width and default end caps.
+     * Color of all rendered curves are selected from a grayscale palette.
+     * All rendered quadratic curves are represented by a Shape object.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawQuadraticCurvesChangeWidth(TestImage image, Graphics2D graphics)
+    {
+        drawQuadraticCurve(image, graphics, QUADRATIC_CURVE_STEP, new QuadraticCurveDrawCallbacks()
+        {
+            /**
+             * Stroke width.
+             */
+            float strokeWidth = 0.0f;
+
+            /**
+             * Callback function called before each quadratic curve is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int index)
+            {
+                // set stroke width
+                this.graphics.setStroke(new BasicStroke(this.strokeWidth));
+                // set new stroke width
+                this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA : this.strokeWidth;
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
      * Entry point to the test suite.
      * 
      * @param args



More information about the distro-pkg-dev mailing list