/hg/gfx-test: * src/org/gfxtest/callbacks/RectangleDrawCallbacks...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue Jun 19 07:33:45 PDT 2012
changeset db07a99622d9 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=db07a99622d9
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Jun 19 16:36:24 2012 +0200
* src/org/gfxtest/callbacks/RectangleDrawCallbacks.java:
Added class containing callback methods used during rendering
rectangles.
* src/org/gfxtest/framework/PrintTest.java:
Added new constant.
* src/org/gfxtest/testsuites/PrintTestRectangles.java:
New test suite - printing rectangles on a printer.
* Makefile: Updated according to previous changes.
diffstat:
ChangeLog | 11 +
Makefile | 3 +
src/org/gfxtest/callbacks/RectangleDrawCallbacks.java | 111 +++++++++++
src/org/gfxtest/framework/PrintTest.java | 5 +
src/org/gfxtest/testsuites/PrintTestRectangles.java | 168 ++++++++++++++++++
5 files changed, 298 insertions(+), 0 deletions(-)
diffs (347 lines):
diff -r 91cef43793d3 -r db07a99622d9 ChangeLog
--- a/ChangeLog Mon Jun 18 15:28:39 2012 +0200
+++ b/ChangeLog Tue Jun 19 16:36:24 2012 +0200
@@ -1,3 +1,14 @@
+2012-06-19 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/callbacks/RectangleDrawCallbacks.java:
+ Added class containing callback methods used during rendering
+ rectangles.
+ * src/org/gfxtest/framework/PrintTest.java:
+ Added new constant.
+ * src/org/gfxtest/testsuites/PrintTestRectangles.java:
+ New test suite - printing rectangles on a printer.
+ * Makefile: Updated according to previous changes.
+
2012-06-18 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/PrintTestColorPaint.java:
diff -r 91cef43793d3 -r db07a99622d9 Makefile
--- a/Makefile Mon Jun 18 15:28:39 2012 +0200
+++ b/Makefile Tue Jun 19 16:36:24 2012 +0200
@@ -101,6 +101,7 @@
$(CLASSES)/$(CALLBACKS_DIR)/HorizontalLineDrawCallbacks.class \
$(CLASSES)/$(CALLBACKS_DIR)/VerticalLineDrawCallbacks.class \
$(CLASSES)/$(CALLBACKS_DIR)/DiagonalLineDrawCallbacks.class \
+ $(CLASSES)/$(CALLBACKS_DIR)/RectangleDrawCallbacks.class \
$(CLASSES)/$(IMAGE_DIFFER_DIR)/ComparisonResult.class \
$(CLASSES)/$(IMAGE_DIFFER_DIR)/Configuration.class \
$(CLASSES)/$(IMAGE_DIFFER_DIR)/ImageComparator.class \
@@ -186,6 +187,7 @@
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestArcs.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestCubicCurves.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestLines.class \
+ $(CLASSES)/$(TESTSUITE_DIR)/PrintTestRectangles.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestPaths.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestPolylines.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestQuadraticCurves.class \
@@ -270,6 +272,7 @@
$(RESULTS)/PrintTestArcs \
$(RESULTS)/PrintTestCubicCurves \
$(RESULTS)/PrintTestLines \
+ $(RESULTS)/PrintTestRectangles \
$(RESULTS)/PrintTestPaths \
$(RESULTS)/PrintTestPolylines \
$(RESULTS)/PrintTestQuadraticCurves \
diff -r 91cef43793d3 -r db07a99622d9 src/org/gfxtest/callbacks/RectangleDrawCallbacks.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/callbacks/RectangleDrawCallbacks.java Tue Jun 19 16:36:24 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
+ * rectangle.
+ *
+ * @author Pavel Tisnovsky
+ */
+public abstract class RectangleDrawCallbacks
+{
+ /**
+ * Image to which rectangles are to be drawn.
+ */
+ protected TestImage image;
+
+ /**
+ * Graphics canvas.
+ */
+ protected Graphics2D graphics;
+
+ /**
+ * Setup phase.
+ *
+ * @param image
+ * image to which rectangles 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 rectagle.
+ *
+ * @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
+ * rectangle index
+ */
+ public abstract void iterationCallBack(int x1, int y1, int x2, int y2, int index);
+}
diff -r 91cef43793d3 -r db07a99622d9 src/org/gfxtest/framework/PrintTest.java
--- a/src/org/gfxtest/framework/PrintTest.java Mon Jun 18 15:28:39 2012 +0200
+++ b/src/org/gfxtest/framework/PrintTest.java Tue Jun 19 16:36:24 2012 +0200
@@ -107,6 +107,11 @@
protected static final int DIAGONAL_STEP = 16;
/**
+ * Horizontal and also vertical distance between rectangles lines in each test iteration.
+ */
+ protected static final int RECTANGLE_STEP = 10;
+
+ /**
* Maximum color index.
* (used only in tests which uses color palette)
*/
diff -r 91cef43793d3 -r db07a99622d9 src/org/gfxtest/testsuites/PrintTestRectangles.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/PrintTestRectangles.java Tue Jun 19 16:36:24 2012 +0200
@@ -0,0 +1,168 @@
+/*
+ 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.Graphics2D;
+
+
+
+import org.gfxtest.callbacks.RectangleDrawCallbacks;
+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 rectangles.
+ *
+ * @author Pavel Tisnovsky
+ */
+ at TestType(TestTypes.PRINT_TEST)
+ at GraphicsPrimitive(GraphicsPrimitives.RECTANGLE)
+ at RenderStyle(RenderStyles.NORMAL)
+ at Transformation(Transformations.NONE)
+ at Zoom(1)
+public class PrintTestRectangles extends PrintTest
+{
+
+ /**
+ * Method which renders set of rectangles using various colors and stroke
+ * styles. For each rectangle, the callback function/method is called to
+ * perform all required setup.
+ *
+ * @param image
+ * image to which rectangles are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @param step
+ * between two near rectangles
+ * @param rectangleDrawCallbacks
+ * class containing set of callback methods
+ */
+ private static void drawRectangles(TestImage image, Graphics2D graphics, int step, RectangleDrawCallbacks rectangleDrawCallbacks)
+ {
+ // setup rendering
+ rectangleDrawCallbacks.setup(image, graphics);
+
+ // image width and height
+ final int width = image.getWidth();
+ final int height = image.getHeight();
+
+ // horizontal coordinates of rectangle endpoints
+ int x1 = BORDER;
+ int x2 = width - BORDER;
+
+ // vertical coordinates of rectangle endpoints
+ int y1 = BORDER;
+ int y2 = height - BORDER;
+
+ // index to color palette
+ int colorIndex = 0;
+
+ // draw all rectangles onto a paper
+ while (x1 < x2 - BORDER && y1 < y2 - BORDER)
+ {
+ // setup can be made for each rectangle
+ rectangleDrawCallbacks.iterationCallBack(x1, y1, x2, y2, colorIndex++);
+ // render the rectangle
+ graphics.drawRect(x1, y1, x2 - x1, y2 - y1);
+ // setup coordinates for the next rectangle
+ x1 += step;
+ y1 += step;
+ x2 -= step;
+ y2 -= step;
+ }
+
+ // cleanup rendering
+ rectangleDrawCallbacks.cleanup();
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawRect(). Rectangles are
+ * rendered with default width and default end caps. Color of all rendered
+ * rectangles are set to black.
+ *
+ * @param image
+ * image to which rectangles are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawRectanglesBasicStyle(TestImage image, Graphics2D graphics)
+ {
+ drawRectangles(image, graphics, 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)
+ {
+ 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 PrintTestRectangles().runTestSuite(args);
+ }
+}
More information about the distro-pkg-dev
mailing list