/hg/gfx-test: Added new test suite and class containing callback...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Jul 23 01:45:52 PDT 2012


changeset bcddbf10b1c3 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=bcddbf10b1c3
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Jul 23 10:48:30 2012 +0200

	Added new test suite and class containing callback methods
	used by this suite.


diffstat:

 ChangeLog                                           |   10 +
 Makefile                                            |    5 +-
 src/org/gfxtest/callbacks/PolygonDrawCallbacks.java |  111 +++++++++++++
 src/org/gfxtest/framework/PrintTest.java            |    5 +
 src/org/gfxtest/testsuites/PrintTestPolygons.java   |  170 ++++++++++++++++++++
 5 files changed, 300 insertions(+), 1 deletions(-)

diffs (356 lines):

diff -r 20899e14d776 -r bcddbf10b1c3 ChangeLog
--- a/ChangeLog	Mon Jul 23 10:39:34 2012 +0200
+++ b/ChangeLog	Mon Jul 23 10:48:30 2012 +0200
@@ -1,3 +1,13 @@
+2012-07-23  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/PrintTest.java:
+	New constant used by print tests.
+	* src/org/gfxtest/testsuites/PrintTestPolygons.java:
+	* src/org/gfxtest/callbacks/PolygonDrawCallbacks.java:
+	Added new test suite and class containing callback methods
+	used by this suite.
+	* Makefile: Updated - added new classes to compile and new test to run.
+
 2012-07-23  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/callbacks/PolylineDrawCallbacks.java:
diff -r 20899e14d776 -r bcddbf10b1c3 Makefile
--- a/Makefile	Mon Jul 23 10:39:34 2012 +0200
+++ b/Makefile	Mon Jul 23 10:48:30 2012 +0200
@@ -1,6 +1,6 @@
 # Java gfx-test framework
 #
-#    Copyright (C) 2010, 2011  Red Hat
+#    Copyright (C) 2010, 2011, 2012  Red Hat
 #
 # This file is part of IcedTea.
 #
@@ -104,6 +104,7 @@
 	$(CLASSES)/$(CALLBACKS_DIR)/DiagonalLineDrawCallbacks.class \
 	$(CLASSES)/$(CALLBACKS_DIR)/RectangleDrawCallbacks.class \
 	$(CLASSES)/$(CALLBACKS_DIR)/PolylineDrawCallbacks.class \
+	$(CLASSES)/$(CALLBACKS_DIR)/PolygonDrawCallbacks.class \
 	$(CLASSES)/$(IMAGE_DIFFER_DIR)/ComparisonResult.class \
 	$(CLASSES)/$(IMAGE_DIFFER_DIR)/Configuration.class \
 	$(CLASSES)/$(IMAGE_DIFFER_DIR)/ImageComparator.class \
@@ -194,6 +195,7 @@
 	$(CLASSES)/$(TESTSUITE_DIR)/PrintTestRoundRectangles.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/PrintTestPaths.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/PrintTestPolylines.class \
+	$(CLASSES)/$(TESTSUITE_DIR)/PrintTestPolygons.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/PrintTestQuadraticCurves.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/PrintTestBitBlt.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/PrintTestCircles.class \
@@ -282,6 +284,7 @@
 	$(RESULTS)/PrintTestRoundRectangles \
 	$(RESULTS)/PrintTestPaths \
 	$(RESULTS)/PrintTestPolylines \
+	$(RESULTS)/PrintTestPolygons \
 	$(RESULTS)/PrintTestQuadraticCurves \
 	$(RESULTS)/PrintTestArcs \
 	$(RESULTS)/PrintTestBitBlt \
diff -r 20899e14d776 -r bcddbf10b1c3 src/org/gfxtest/callbacks/PolygonDrawCallbacks.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/callbacks/PolygonDrawCallbacks.java	Mon Jul 23 10:48:30 2012 +0200
@@ -0,0 +1,111 @@
+/*
+  Java gfx-test framework
+
+   Copyright (C) 2012  Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+package org.gfxtest.callbacks;
+
+
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+
+
+import org.gfxtest.framework.TestImage;
+
+
+
+/**
+ * Class representing set of callback methods called for each rendered
+ * polygon.
+ * 
+ * @author Pavel Tisnovsky
+ */
+public abstract class PolygonDrawCallbacks
+{
+    /**
+     * Image to which polylines are to be drawn.
+     */
+    protected TestImage image;
+
+    /**
+     * Graphics canvas.
+     */
+    protected Graphics2D graphics;
+
+    /**
+     * Setup phase.
+     * 
+     * @param image
+     *            image to which polygons are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     */
+    public void setup(TestImage image, Graphics2D graphics)
+    {
+        this.image = image;
+        this.graphics = graphics;
+        // set drawing color
+        graphics.setColor(Color.BLACK);
+    }
+
+    /**
+     * Cleanup phase.
+     */
+    public void cleanup()
+    {
+        return;
+    }
+
+    /**
+     * Called for each rendered polygon.
+     * 
+     * @param x1
+     *            x-coordinate of the upper left vertex
+     * @param y1
+     *            y-coordinate of the upper left vertex
+     * @param x2
+     *            x-coordinate of the lower right vertex
+     * @param y2
+     *            y-coordinate of the lower right vertex
+     * @param index
+     *            polygon index
+     */
+    public abstract void iterationCallBack(int x1, int y1, int x2, int y2, int i);
+}
diff -r 20899e14d776 -r bcddbf10b1c3 src/org/gfxtest/framework/PrintTest.java
--- a/src/org/gfxtest/framework/PrintTest.java	Mon Jul 23 10:39:34 2012 +0200
+++ b/src/org/gfxtest/framework/PrintTest.java	Mon Jul 23 10:48:30 2012 +0200
@@ -122,6 +122,11 @@
     protected static final int POLYLINE_STEP = 10;
 
     /**
+     * Horizontal and also vertical distance between polygons in each test iteration.
+     */
+    protected static final int POLYGON_STEP = 10;
+
+    /**
      * Maximum color index.
      * (used only in tests which uses color palette)
      */
diff -r 20899e14d776 -r bcddbf10b1c3 src/org/gfxtest/testsuites/PrintTestPolygons.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/PrintTestPolygons.java	Mon Jul 23 10:48:30 2012 +0200
@@ -0,0 +1,170 @@
+/*
+  Java gfx-test framework
+
+   Copyright (C) 2012  Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+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 org.gfxtest.callbacks.PolygonDrawCallbacks;
+import org.gfxtest.framework.PrintTest;
+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;
+import org.gfxtest.framework.annotations.RenderStyles;
+import org.gfxtest.framework.annotations.TestType;
+import org.gfxtest.framework.annotations.TestTypes;
+import org.gfxtest.framework.annotations.Transformation;
+import org.gfxtest.framework.annotations.Transformations;
+import org.gfxtest.framework.annotations.Zoom;
+
+
+
+/**
+ * This test suite checks rendering of various polygons.
+ * 
+ * @author Pavel Tisnovsky
+ */
+ at TestType(TestTypes.PRINT_TEST)
+ at GraphicsPrimitive(GraphicsPrimitives.POLYGON)
+ at RenderStyle(RenderStyles.NORMAL)
+ at Transformation(Transformations.NONE)
+ at Zoom(1)
+public class PrintTestPolygons extends PrintTest
+{
+    /**
+     * Method which renders set of polygons using various colors and stroke
+     * styles. For each polygon, the callback function/method is called to
+     * perform all required setup.
+     * 
+     * @param image
+     *            image to which polygons are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @param step
+     *            between two near polygons
+     * @param polygonDrawCallbacks
+     *            class containing set of callback methods
+     */
+    private static void drawPolygons(TestImage image, Graphics2D graphics, int step, PolygonDrawCallbacks polygonDrawCallbacks)
+    {
+        // setup rendering
+        polygonDrawCallbacks.setup(image, graphics);
+
+        // image width and height
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+
+        // horizontal coordinates of polygon endpoints
+        int x1 = BORDER;
+        int x2 = width - BORDER;
+
+        // vertical coordinates of polygon endpoints
+        int y1 = BORDER;
+        int y2 = height - BORDER;
+
+        // index to color palette
+        int colorIndex = 0;
+
+        // draw all polygons onto a paper
+        while (x1 < x2 - BORDER && y1 < y2 - BORDER)
+        {
+            // setup can be made for each polygon
+            polygonDrawCallbacks.iterationCallBack(x1, y1, x2, y2, colorIndex++);
+            // render the polygon
+            int xpoints[] = {x1, x2, x2, x1};
+            int ypoints[] = {y1, y1, y2, y2};
+            graphics.drawPolygon(xpoints, ypoints, 4);
+            // setup coordinates for the next polygon
+            x1 += step;
+            y1 += step;
+            x2 -= step;
+            y2 -= step;
+        }
+
+        // cleanup rendering
+        polygonDrawCallbacks.cleanup();
+    }
+
+    /**
+     * Test basic behavior of method Graphics.drawPolygon(). Polygons are
+     * rendered with default width and default end caps. Color of all rendered
+     * polygons are set to black.
+     * 
+     * @param image
+     *            image to which polygons are to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testDrawPolygonsBasicStyle(TestImage image, Graphics2D graphics2d)
+    {
+        drawPolygons(image, graphics2d, POLYGON_STEP, new PolygonDrawCallbacks()
+        {
+            /**
+             * Callback function called before each polygon is rendered.
+             */
+            @Override
+            public void iterationCallBack(int x1, int y1, int x2, int y2, int index)
+            {
+                return;
+            }
+        });
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Entry point to the test suite.
+     * 
+     * @param args
+     *            not used in this case
+     */
+    public static void main(String[] args)
+    {
+        new PrintTestPolygons().runTestSuite(args);
+    }
+
+}



More information about the distro-pkg-dev mailing list