/hg/gfx-test: Added new tests for lines rendering.

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu Jul 28 07:42:17 PDT 2011


changeset f09f02f3af4f in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=f09f02f3af4f
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jul 28 16:43:52 2011 +0200

	Added new tests for lines rendering.


diffstat:

 ChangeLog                                   |    3 +
 src/org/gfxtest/testsuites/NormalLines.java |  348 ++++++++++++++++++++++++++++
 2 files changed, 351 insertions(+), 0 deletions(-)

diffs (388 lines):

diff -r 623e7a4847bf -r f09f02f3af4f ChangeLog
--- a/ChangeLog	Wed Jul 27 17:18:56 2011 +0200
+++ b/ChangeLog	Thu Jul 28 16:43:52 2011 +0200
@@ -1,3 +1,6 @@
+2011-07-28  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/testsuites/NormalLines.java: added new tests
+
 2011-07-27  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* Makefile:
 	Added new build targets - doc and clean-doc
diff -r 623e7a4847bf -r f09f02f3af4f src/org/gfxtest/testsuites/NormalLines.java
--- a/src/org/gfxtest/testsuites/NormalLines.java	Wed Jul 27 17:18:56 2011 +0200
+++ b/src/org/gfxtest/testsuites/NormalLines.java	Thu Jul 28 16:43:52 2011 +0200
@@ -58,10 +58,346 @@
 public class NormalLines extends GfxTest
 {
 
+    /**
+     * Width of border where lines are not drawn
+     */
+    private static final int BORDER_WIDTH = 30;
+
+    /**
+     * Step used for drawing sequence of horizontal and/or vertical lines
+     */
+    private static final int STEP = 20;
+
+    /**
+     * Test basic behavior of method Graphics.drawLine().
+     *
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLine(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+
+        // draw two diagonals along the whole test image
+        graphics.drawLine(BORDER_WIDTH, BORDER_WIDTH, image.getWidth() - BORDER_WIDTH, image.getHeight() - BORDER_WIDTH);
+        graphics.drawLine(BORDER_WIDTH, image.getHeight() - BORDER_WIDTH, image.getWidth() - BORDER_WIDTH, BORDER_WIDTH);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here vertical lines
+     * are drawn using various colors.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineVert1(TestImage image, Graphics2D graphics)
+    {
+        int colorIndex = 0;
+        for (int x = BORDER_WIDTH; x < image.getWidth() - BORDER_WIDTH; x += STEP)
+        {
+            // set drawing color
+            graphics.setColor(ColorPalette.getColor(colorIndex++));
+            // draw vertical line
+            graphics.drawLine(x, BORDER_WIDTH, x, image.getHeight() - BORDER_WIDTH);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here vertical lines
+     * are drawn using one color but with various stroke width using default caps.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineVert2(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int x = BORDER_WIDTH; x < image.getWidth() - BORDER_WIDTH; x += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw vertical line
+            graphics.drawLine(x, BORDER_WIDTH, x, image.getHeight() - BORDER_WIDTH);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here vertical lines
+     * are drawn using one color but with various stroke width using CAP_BUTT
+     * to render both line end points.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineVert3(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int x = BORDER_WIDTH; x < image.getWidth() - BORDER_WIDTH; x += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw vertical line
+            graphics.drawLine(x, BORDER_WIDTH, x, image.getHeight() - BORDER_WIDTH);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here vertical lines
+     * are drawn using one color but with various stroke width using CAP_ROUND
+     * to render both line end points.
+     *
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineVert4(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int x = BORDER_WIDTH; x < image.getWidth() - BORDER_WIDTH; x += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw vertical line
+            graphics.drawLine(x, BORDER_WIDTH, x, image.getHeight() - BORDER_WIDTH);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here vertical lines
+     * are drawn using one color but with various stroke width using CAP_SQUARE
+     * to render both line end points.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineVert5(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int x = BORDER_WIDTH; x < image.getWidth() - BORDER_WIDTH; x += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw vertical line
+            graphics.drawLine(x, BORDER_WIDTH, x, image.getHeight() - BORDER_WIDTH);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here horizontal lines
+     * are drawn using various colors.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineHors1(TestImage image, Graphics2D graphics)
+    {
+        int colorIndex = 0;
+        for (int y = BORDER_WIDTH; y < image.getWidth() - BORDER_WIDTH; y += STEP)
+        {
+            // set drawing color
+            graphics.setColor(ColorPalette.getColor(colorIndex++));
+            // draw horizontal line
+            graphics.drawLine(BORDER_WIDTH, y, image.getWidth() - BORDER_WIDTH, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here horizontal lines
+     * are drawn using one color but with various stroke width using default caps.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineHors2(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int y = BORDER_WIDTH; y < image.getWidth() - BORDER_WIDTH; y += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw horizontal line
+            graphics.drawLine(BORDER_WIDTH, y, image.getWidth() - BORDER_WIDTH, y);        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here horizontal lines
+     * are drawn using one color but with various stroke width using CAP_BUTT
+     * to render both line end points.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineHors3(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int y = BORDER_WIDTH; y < image.getWidth() - BORDER_WIDTH; y += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw horizontal line
+            graphics.drawLine(BORDER_WIDTH, y, image.getWidth() - BORDER_WIDTH, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here horizontal lines
+     * are drawn using one color but with various stroke width using CAP_ROUND
+     * to render both line end points.
+     *
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineHors4(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int y = BORDER_WIDTH; y < image.getWidth() - BORDER_WIDTH; y += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw horizontal line
+            graphics.drawLine(BORDER_WIDTH, y, image.getWidth() - BORDER_WIDTH, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+    
+    
+    /**
+     * Test basic behavior of method Graphics.drawLine(). Here horizontal lines
+     * are drawn using one color but with various stroke width using CAP_SQUARE
+     * to render both line end points.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawLineHors5(TestImage image, Graphics2D graphics)
+    {
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+        float strokeWidth = 0;
+        for (int y = BORDER_WIDTH; y < image.getWidth() - BORDER_WIDTH; y += STEP)
+        {
+            // set stroke width
+            graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+            // increase stroke width
+            strokeWidth += 0.5;
+            // draw horizontal line
+            graphics.drawLine(BORDER_WIDTH, y, image.getWidth() - BORDER_WIDTH, y);
+        }
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Draw line entity using various rendering styles. This method is
+     * automatically called by test harness.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @param testNumber
+     *            test number set by test harness
+     * @param entityRenderingStyle
+     *            entity rendering style set by test harness
+     */
     @Override
     protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
     {
+        // set entity rendering style
         graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
+        // calculate center of the image
         int xc = image.getCenterX();
         int yc = image.getCenterY();
         for (int i = 0; i < ANGLES; i++)
@@ -78,15 +414,27 @@
             int y2 = yc + (int)(majorRadius*sin);
             graphics.drawLine(x1, y1, x2, y2);
         }
+        // draw cross to mark center of the test image
         drawCross(graphics, xc, yc, CROSS_SIZE);
     }
 
+    /**
+     * Method which is automatically called by test harness.
+     * 
+     * @param configuration
+     *            current graphics test configuration
+     */
     @Override
     protected void runOtherTests(GfxTestConfiguration configuration)
     {
         drawEntityWithVariousStyles(configuration, true, false, true, false, false);
     }
 
+    /**
+     * Entry point to the test suite.
+     *
+     * @param args not used in this case
+     */
     public static void main(String[] args)
     {
         new NormalLines().runTestSuite(args);



More information about the distro-pkg-dev mailing list