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

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu May 3 05:31:58 PDT 2012


changeset 1e9fa50239df in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=1e9fa50239df
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu May 03 14:34:35 2012 +0200

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


diffstat:

 ChangeLog                                      |    5 +
 src/org/gfxtest/testsuites/PrintTestLines.java |  292 +++++++++++++++++++++++++
 2 files changed, 297 insertions(+), 0 deletions(-)

diffs (322 lines):

diff -r 0e93a0e23fe3 -r 1e9fa50239df ChangeLog
--- a/ChangeLog	Wed May 02 15:21:33 2012 +0200
+++ b/ChangeLog	Thu May 03 14:34:35 2012 +0200
@@ -1,3 +1,8 @@
+2012-05-03  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/testsuites/PrintTestLines.java:
+	Added new tests to this test suite.
+
 2012-05-02  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/PrintTestArcs.java:
diff -r 0e93a0e23fe3 -r 1e9fa50239df src/org/gfxtest/testsuites/PrintTestLines.java
--- a/src/org/gfxtest/testsuites/PrintTestLines.java	Wed May 02 15:21:33 2012 +0200
+++ b/src/org/gfxtest/testsuites/PrintTestLines.java	Thu May 03 14:34:35 2012 +0200
@@ -40,7 +40,16 @@
 
 package org.gfxtest.testsuites;
 
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+
+
+import org.gfxtest.framework.ColorPalette;
 import org.gfxtest.framework.GfxTest;
+import org.gfxtest.framework.TestImage;
+import org.gfxtest.framework.TestResult;
 import org.gfxtest.framework.annotations.GraphicsPrimitive;
 import org.gfxtest.framework.annotations.GraphicsPrimitives;
 import org.gfxtest.framework.annotations.RenderStyle;
@@ -65,6 +74,289 @@
 @Zoom(1)
 public class PrintTestLines extends GfxTest
 {
+    /**
+     * Maximum width of line rendered onto a paper.
+     */
+    private static final float MAX_STROKE_WIDTH = 15.0f;
+
+    /**
+     * Border around the test picture.
+     */
+    private static final int BORDER = 10;
+
+    /**
+     * Horizontal distance between two lines.
+     */
+    private static final int HOR_STEP = 10;
+
+    /**
+     * Vertical distance between two lines.
+     */
+    private static final int VER_STEP = 10;
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     * Horizontal lines are rendered with default width and default end caps.
+     * Color of all rendered lines are set to black.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawHorizontalLinesBasicStyle(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int x1 = BORDER;
+        final int x2 = width - BORDER;
+
+        // draw all lines onto a paper
+        for (int y = 0; y < height; y += VER_STEP)
+        {
+            // render the line
+            graphics.drawLine(x1, y, x2, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     * Horizontal lines are rendered with default width and default end caps.
+     * Lines color are selected from a palette.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawHorizontalLinesColorPalette(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int x1 = BORDER;
+        final int x2 = width - BORDER;
+
+        // index to color palette
+        int colorIndex = 0;
+
+        // draw all lines onto a paper
+        for (int y = 0; y < height; y += VER_STEP)
+        {
+            // set line color
+            graphics.setColor(ColorPalette.getColor(colorIndex++));
+            // render the line
+            graphics.drawLine(x1, y, x2, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     * Horizontal lines are rendered with default width and default end caps.
+     * Lines color are selected from a grayscale palette.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawHorizontalLinesGrayScale(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int x1 = BORDER;
+        final int x2 = width - BORDER;
+
+        // draw all lines onto a paper
+        for (int y = 0; y < height; y += VER_STEP)
+        {
+            float gray = y * 1.0f / height;
+            graphics.setColor(new Color(gray, gray, gray));
+            // render the line
+            graphics.drawLine(x1, y, x2, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     * Horizontal lines are rendered with various width and default end caps.
+     * Color of all rendered lines are set to black.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawHorizontalLinesChangeWidth(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int x1 = BORDER;
+        final int x2 = width - BORDER;
+        float strokeWidth = 0.0f; 
+
+        // draw all lines onto a paper
+        for (int y = 0; y < height; y += VER_STEP * 2)
+        {
+            graphics.setStroke(new BasicStroke(strokeWidth));
+            strokeWidth = strokeWidth < MAX_STROKE_WIDTH ? strokeWidth + 0.5f : strokeWidth;
+            // render the line
+            graphics.drawLine(x1, y, x2, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     * Horizontal lines are rendered with various width and end caps set to CAP_BUTT.
+     * Color of all rendered lines are set to black.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawHorizontalLinesChangeWidthCapButt(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int x1 = BORDER;
+        final int x2 = width - BORDER;
+        float strokeWidth = 0.0f; 
+
+        // draw all lines onto a paper
+        for (int y = 0; y < height; y += VER_STEP * 2)
+        {
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+            strokeWidth = strokeWidth < MAX_STROKE_WIDTH ? strokeWidth + 0.5f : strokeWidth;
+            // render the line
+            graphics.drawLine(x1, y, x2, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     * Horizontal lines are rendered with various width and end caps set to CAP_ROUND.
+     * Color of all rendered lines are set to black.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawHorizontalLinesChangeWidthCapRound(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int x1 = BORDER;
+        final int x2 = width - BORDER;
+        float strokeWidth = 0.0f; 
+
+        // draw all lines onto a paper
+        for (int y = 0; y < height; y += VER_STEP * 2)
+        {
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+            strokeWidth = strokeWidth < MAX_STROKE_WIDTH ? strokeWidth + 0.5f : strokeWidth;
+            // render the line
+            graphics.drawLine(x1, y, x2, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     * Horizontal lines are rendered with various width and end caps set to CAP_SQUARE.
+     * Color of all rendered lines are set to black.
+     *
+     * @param image
+     *            image to which lines are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawHorizontalLinesChangeWidthCapSquare(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of line endpoints
+        final int x1 = BORDER;
+        final int x2 = width - BORDER;
+        float strokeWidth = 0.0f; 
+
+        // draw all lines onto a paper
+        for (int y = 0; y < height; y += VER_STEP * 2)
+        {
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+            strokeWidth = strokeWidth < MAX_STROKE_WIDTH ? strokeWidth + 0.5f : strokeWidth;
+            // render the line
+            graphics.drawLine(x1, y, x2, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
 
     /**
      * Entry point to the test suite.



More information about the distro-pkg-dev mailing list