/hg/gfx-test: * src/org/gfxtest/testsuites/PrintTestCircles.java:

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri May 11 00:58:51 PDT 2012


changeset b8c873675075 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=b8c873675075
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri May 11 10:01:32 2012 +0200

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


diffstat:

 ChangeLog                                        |    5 +
 src/org/gfxtest/testsuites/PrintTestCircles.java |  245 +++++++++++++++++++++++
 2 files changed, 250 insertions(+), 0 deletions(-)

diffs (267 lines):

diff -r bb8cea44ceaf -r b8c873675075 ChangeLog
--- a/ChangeLog	Thu May 10 12:08:40 2012 +0200
+++ b/ChangeLog	Fri May 11 10:01:32 2012 +0200
@@ -1,3 +1,8 @@
+2012-05-11  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/testsuites/PrintTestCircles.java:
+	Added new tests to this test suite.
+
 2012-05-10  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/framework/GfxTest.java:
diff -r bb8cea44ceaf -r b8c873675075 src/org/gfxtest/testsuites/PrintTestCircles.java
--- a/src/org/gfxtest/testsuites/PrintTestCircles.java	Thu May 10 12:08:40 2012 +0200
+++ b/src/org/gfxtest/testsuites/PrintTestCircles.java	Fri May 11 10:01:32 2012 +0200
@@ -77,6 +77,251 @@
 {
 
     /**
+     * Test basic behavior of method Graphics.drawOval().
+     * Color of all rendered circles 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 testDrawCircleBasicStyle(TestImage image, Graphics2D graphics2d)
+    {
+        // set drawing color
+        graphics2d.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int xc = width >> 1;
+        final int yc = height >> 1;
+
+        // max. radius
+        final int maxRadius = Math.min(width, height) - BORDER;
+
+        // draw all circles onto a paper
+        for (int r = 10; r < maxRadius; r += CIRCLE_RADIUS_STEP)
+        {
+            // render the circle
+            graphics2d.drawOval(xc - r, yc - r, r << 1, r << 1);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawOval().
+     * Circles color 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 testDrawCircleColorPalette(TestImage image, Graphics2D graphics2d)
+    {
+        // set drawing color
+        graphics2d.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int xc = width >> 1;
+        final int yc = height >> 1;
+
+        // max. radius
+        final int maxRadius = Math.min(width, height) - BORDER;
+
+        // index to color palette
+        int colorIndex = 0;
+
+        // draw all circles onto a paper
+        for (int r = 10; r < maxRadius; r += CIRCLE_RADIUS_STEP)
+        {
+            // set circle color
+            graphics2d.setColor(ColorPalette.getColor(colorIndex++));
+            // render the circle
+            graphics2d.drawOval(xc - r, yc - r, r << 1, r << 1);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawOval().
+     * Circles color are selected from a grayscale 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 testDrawCircleGrayScale(TestImage image, Graphics2D graphics2d)
+    {
+        // set drawing color
+        graphics2d.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int xc = width >> 1;
+        final int yc = height >> 1;
+
+        // max. radius
+        final int maxRadius = Math.min(width, height) - BORDER;
+
+        // draw all circles onto a paper
+        for (int r = 10; r < maxRadius; r += CIRCLE_RADIUS_STEP)
+        {
+            float gray = r * 1.0f / maxRadius;
+            // set circle color
+            graphics2d.setColor(GrayscalePalette.createGrayscaleColor(gray));
+            // render the circle
+            graphics2d.drawOval(xc - r, yc - r, r << 1, r << 1);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawOval().
+     * Circles color are selected from a grayscale 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 testDrawCircleGrayScaleInv(TestImage image, Graphics2D graphics2d)
+    {
+        // set drawing color
+        graphics2d.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int xc = width >> 1;
+        final int yc = height >> 1;
+
+        // max. radius
+        final int maxRadius = Math.min(width, height) - BORDER;
+
+        // draw all circles onto a paper
+        for (int r = 10; r < maxRadius; r += CIRCLE_RADIUS_STEP)
+        {
+            float gray = 1.0f - r * 1.0f / maxRadius;
+            // set circle color
+            graphics2d.setColor(GrayscalePalette.createGrayscaleColor(gray));
+            // render the circle
+            graphics2d.drawOval(xc - r, yc - r, r << 1, r << 1);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawOval().
+     * Circles are rendered with various width and default end caps.
+     * Color of all rendered circles 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 testDrawCircleChangeWidth(TestImage image, Graphics2D graphics2d)
+    {
+        // set drawing color
+        graphics2d.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int xc = width >> 1;
+        final int yc = height >> 1;
+
+        // stroke width
+        float strokeWidth = 0.0f; 
+
+        // max. radius
+        final int maxRadius = Math.min(width, height) - BORDER;
+
+        // draw all circles onto a paper
+        for (int r = 10; r < maxRadius; r += CIRCLE_RADIUS_STEP * 2)
+        {
+            graphics2d.setStroke(new BasicStroke(strokeWidth));
+            strokeWidth = strokeWidth < MAX_STROKE_WIDTH ? strokeWidth + 0.5f : strokeWidth;
+            // render the circle
+            graphics2d.drawOval(xc - r, yc - r, r << 1, r << 1);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawOval().
+     * Circles are rendered with various width and default end caps.
+     * Color of all rendered circles 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 testDrawCircleChangeWidthInv(TestImage image, Graphics2D graphics2d)
+    {
+        // set drawing color
+        graphics2d.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int xc = width >> 1;
+        final int yc = height >> 1;
+
+        // stroke width
+        float strokeWidth = 0.0f; 
+
+        // max. radius
+        final int maxRadius = Math.min(width, height) - BORDER;
+
+        // draw all circles onto a paper
+        for (int r = maxRadius; r > 10; r -= CIRCLE_RADIUS_STEP * 2)
+        {
+            graphics2d.setStroke(new BasicStroke(strokeWidth));
+            strokeWidth = strokeWidth < MAX_STROKE_WIDTH ? strokeWidth + 0.5f : strokeWidth;
+            // render the circle
+            graphics2d.drawOval(xc - r, yc - r, r << 1, r << 1);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
      * Entry point to the test suite.
      * 
      * @param args



More information about the distro-pkg-dev mailing list