/hg/gfx-test: Added new tests to a test suite PrintTestRectangles

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Tue Jun 26 03:24:37 PDT 2012


changeset 3a93ddd621d9 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=3a93ddd621d9
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Jun 26 12:27:14 2012 +0200

	Added new tests to a test suite PrintTestRectangles
	* src/org/gfxtest/testsuites/PrintTestRectangles.java:
	Added five new tests to this test suite.


diffstat:

 ChangeLog                                           |    5 +
 src/org/gfxtest/testsuites/PrintTestRectangles.java |  191 +++++++++++++++++++-
 2 files changed, 194 insertions(+), 2 deletions(-)

diffs (233 lines):

diff -r bfdafdcfe4b2 -r 3a93ddd621d9 ChangeLog
--- a/ChangeLog	Fri Jun 22 12:23:29 2012 +0200
+++ b/ChangeLog	Tue Jun 26 12:27:14 2012 +0200
@@ -1,3 +1,8 @@
+2012-06-26  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/testsuites/PrintTestRectangles.java:
+	Added five new tests to this test suite.
+
 2012-06-22  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/PrintTestArcs.java:
diff -r bfdafdcfe4b2 -r 3a93ddd621d9 src/org/gfxtest/testsuites/PrintTestRectangles.java
--- a/src/org/gfxtest/testsuites/PrintTestRectangles.java	Fri Jun 22 12:23:29 2012 +0200
+++ b/src/org/gfxtest/testsuites/PrintTestRectangles.java	Tue Jun 26 12:27:14 2012 +0200
@@ -42,11 +42,14 @@
 
 
 
+import java.awt.BasicStroke;
 import java.awt.Graphics2D;
 
 
 
 import org.gfxtest.callbacks.RectangleDrawCallbacks;
+import org.gfxtest.framework.ColorPalette;
+import org.gfxtest.framework.GrayscalePalette;
 import org.gfxtest.framework.PrintTest;
 import org.gfxtest.framework.TestImage;
 import org.gfxtest.framework.TestResult;
@@ -138,9 +141,9 @@
      *            graphics canvas
      * @return test result status - PASSED, FAILED or ERROR
      */
-    public TestResult testDrawRectanglesBasicStyle(TestImage image, Graphics2D graphics)
+    public TestResult testDrawRectanglesBasicStyle(TestImage image, Graphics2D graphics2d)
     {
-        drawRectangles(image, graphics, RECTANGLE_STEP, new RectangleDrawCallbacks()
+        drawRectangles(image, graphics2d, RECTANGLE_STEP, new RectangleDrawCallbacks()
         {
             /**
              * Callback function called before each rectangle is rendered.
@@ -157,6 +160,190 @@
     }
 
     /**
+     * Test basic behavior of method Graphics.drawRect(). Rectangles are
+     * rendered with default width and default end caps. Color of all rendered
+     * rectangles are selected from a palette.
+     *
+     * @param image
+     *            image to which circles are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRectanglesColorPalette(TestImage image, Graphics2D graphics2d)
+    {
+        drawRectangles(image, graphics2d, RECTANGLE_STEP, new RectangleDrawCallbacks()
+        {
+            /**
+             * Callback function called before each rectangle is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int index)
+            {
+                // set new circle color to index
+                this.graphics.setColor(ColorPalette.getColor(index));
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawRect(). Rectangles are
+     * rendered with default width and default end caps. Color of all rendered
+     * rectangles are selected from a palette.
+     *
+     * @param image
+     *            image to which circles are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRectanglesColorPaletteInv(TestImage image, Graphics2D graphics2d)
+    {
+        drawRectangles(image, graphics2d, RECTANGLE_STEP, new RectangleDrawCallbacks()
+        {
+            /**
+             * Callback function called before each rectangle is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int index)
+            {
+                // set new circle color according to index
+                this.graphics.setColor(ColorPalette.getColor(MAX_COLOR_INDEX - index));
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawRect(). Rectangles are
+     * rendered with default width and default end caps. Color of all rendered
+     * rectangles are selected from a grascale palette.
+     *
+     * @param image
+     *            image to which circles are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRectanglesGrayScale(TestImage image, Graphics2D graphics2d)
+    {
+        drawRectangles(image, graphics2d, RECTANGLE_STEP, new RectangleDrawCallbacks()
+        {
+            /**
+             * Callback function called before each rectangle is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int index)
+            {
+                // compute grayscale value
+                float gray = (x2 - x1) * 1.0f / (this.image.getWidth());
+                // clamp the grayscale value
+                if (gray > 1.0f)
+                {
+                    gray = 1.0f;
+                }
+                // set circle color
+                this.graphics.setColor(GrayscalePalette.createGrayscaleColor(gray));
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawRect(). Rectangles are
+     * rendered with default width and default end caps. Color of all rendered
+     * rectangles are selected from a grascale palette.
+     *
+     * @param image
+     *            image to which circles are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRectanglesGrayScaleInv(TestImage image, Graphics2D graphics2d)
+    {
+        drawRectangles(image, graphics2d, RECTANGLE_STEP, new RectangleDrawCallbacks()
+        {
+            /**
+             * Callback function called before each rectangle is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int index)
+            {
+                // compute grayscale value
+                float gray = 1.0f - (x2 - x1) * 1.0f / (this.image.getWidth());
+                // clamp the grayscale value
+                if (gray < 0.0f)
+                {
+                    gray = 0.0f;
+                }
+                // set circle color
+                this.graphics.setColor(GrayscalePalette.createGrayscaleColor(gray));
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawRect(). Rectangles are
+     * rendered with various width and default end caps. Color of all rendered
+     * rectangles are set to black.
+     *
+     * @param image
+     *            image to which circles are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawRectanglesChangeWidth(TestImage image, Graphics2D graphics2d)
+    {
+        drawRectangles(image, graphics2d, RECTANGLE_STEP * 3 / 2, new RectangleDrawCallbacks()
+        {
+            /**
+             * Stroke width which is changed in each iteration.
+             */
+            private float strokeWidth = MIN_STROKE_WIDTH;
+
+            /**
+             * Callback function called before each rectangle is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int index)
+            {
+                // set stroke width
+                this.graphics.setStroke(new BasicStroke(this.strokeWidth));
+                // and change it for the next iteration
+                changeStrokeWidth();
+                return;
+            }
+
+            /**
+             * Changes stroke width.
+             */
+            private void changeStrokeWidth()
+            {
+                this.strokeWidth  = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA : this.strokeWidth;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
      * Entry point to the test suite.
      *
      * @param args not used in this case



More information about the distro-pkg-dev mailing list