/hg/gfx-test: Added basic functionality of the PrintTestPolyline...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue Jul 3 02:35:32 PDT 2012
changeset a6b8cf027b8d in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=a6b8cf027b8d
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Jul 03 11:38:08 2012 +0200
Added basic functionality of the PrintTestPolylines test suite + new test.
* src/org/gfxtest/callbacks/PolylineDrawCallbacks.java:
Added class containing callback methods used during rendering
sloped lines.
* src/org/gfxtest/testsuites/PrintTestPolylines.java:
Added basic functionality of this test suite + new test.
* src/org/gfxtest/testsuites/PrintTestRectangles.java:
Added new constant.
* Makefile: Updated according to previous changes.
diffstat:
ChangeLog | 11 +
Makefile | 1 +
src/org/gfxtest/callbacks/PolylineDrawCallbacks.java | 111 +++++++++++++++++++
src/org/gfxtest/framework/PrintTest.java | 5 +
src/org/gfxtest/testsuites/PrintTestPolylines.java | 93 +++++++++++++++-
5 files changed, 219 insertions(+), 2 deletions(-)
diffs (275 lines):
diff -r 6f8deba4ae11 -r a6b8cf027b8d ChangeLog
--- a/ChangeLog Mon Jul 02 11:19:23 2012 +0200
+++ b/ChangeLog Tue Jul 03 11:38:08 2012 +0200
@@ -1,3 +1,14 @@
+2012-07-03 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/callbacks/PolylineDrawCallbacks.java:
+ Added class containing callback methods used during rendering
+ sloped lines.
+ * src/org/gfxtest/testsuites/PrintTestPolylines.java:
+ Added basic functionality of this test suite + new test.
+ * src/org/gfxtest/testsuites/PrintTestRectangles.java:
+ Added new constant.
+ * Makefile: Updated according to previous changes.
+
2012-07-02 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/PrintTestRoundRectangles.java:
diff -r 6f8deba4ae11 -r a6b8cf027b8d Makefile
--- a/Makefile Mon Jul 02 11:19:23 2012 +0200
+++ b/Makefile Tue Jul 03 11:38:08 2012 +0200
@@ -102,6 +102,7 @@
$(CLASSES)/$(CALLBACKS_DIR)/VerticalLineDrawCallbacks.class \
$(CLASSES)/$(CALLBACKS_DIR)/DiagonalLineDrawCallbacks.class \
$(CLASSES)/$(CALLBACKS_DIR)/RectangleDrawCallbacks.class \
+ $(CLASSES)/$(CALLBACKS_DIR)/PolylineDrawCallbacks.class \
$(CLASSES)/$(IMAGE_DIFFER_DIR)/ComparisonResult.class \
$(CLASSES)/$(IMAGE_DIFFER_DIR)/Configuration.class \
$(CLASSES)/$(IMAGE_DIFFER_DIR)/ImageComparator.class \
diff -r 6f8deba4ae11 -r a6b8cf027b8d src/org/gfxtest/callbacks/PolylineDrawCallbacks.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/callbacks/PolylineDrawCallbacks.java Tue Jul 03 11:38:08 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
+ * polyline.
+ *
+ * @author Pavel Tisnovsky
+ */
+public abstract class PolylineDrawCallbacks
+{
+ /**
+ * Image to which polylines 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 polyline.
+ *
+ * @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 6f8deba4ae11 -r a6b8cf027b8d src/org/gfxtest/framework/PrintTest.java
--- a/src/org/gfxtest/framework/PrintTest.java Mon Jul 02 11:19:23 2012 +0200
+++ b/src/org/gfxtest/framework/PrintTest.java Tue Jul 03 11:38:08 2012 +0200
@@ -112,6 +112,11 @@
protected static final int RECTANGLE_STEP = 10;
/**
+ * Horizontal and also vertical distance between polylines in each test iteration.
+ */
+ protected static final int POLYLINE_STEP = 10;
+
+ /**
* Maximum color index.
* (used only in tests which uses color palette)
*/
diff -r 6f8deba4ae11 -r a6b8cf027b8d src/org/gfxtest/testsuites/PrintTestPolylines.java
--- a/src/org/gfxtest/testsuites/PrintTestPolylines.java Mon Jul 02 11:19:23 2012 +0200
+++ b/src/org/gfxtest/testsuites/PrintTestPolylines.java Tue Jul 03 11:38:08 2012 +0200
@@ -40,7 +40,14 @@
package org.gfxtest.testsuites;
+import java.awt.Graphics2D;
+
+
+
+import org.gfxtest.callbacks.PolylineDrawCallbacks;
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;
@@ -65,7 +72,89 @@
@Zoom(1)
public class PrintTestPolylines extends PrintTest
{
-
+ /**
+ * Method which renders set of polylines 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 polylineDrawCallbacks
+ * class containing set of callback methods
+ */
+ private static void drawPolylines(TestImage image, Graphics2D graphics, int step, PolylineDrawCallbacks polylineDrawCallbacks)
+ {
+ // setup rendering
+ polylineDrawCallbacks.setup(image, graphics);
+
+ // image width and height
+ final int width = image.getWidth();
+ final int height = image.getHeight();
+
+ // horizontal coordinates of polyline endpoints
+ int x1 = BORDER;
+ int x2 = width - BORDER;
+
+ // vertical coordinates of polyline 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
+ polylineDrawCallbacks.iterationCallBack(x1, y1, x2, y2, colorIndex++);
+ // render the rectangle
+ int xpoints[] = {x1, x2, x2, x1};
+ int ypoints[] = {y1, y1, y2, y2};
+ graphics.drawPolyline(xpoints, ypoints, 4);
+ // setup coordinates for the next rectangle
+ x1 += step;
+ y1 += step;
+ x2 -= step;
+ y2 -= step;
+ }
+
+ // cleanup rendering
+ polylineDrawCallbacks.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 testDrawPolylinesBasicStyle(TestImage image, Graphics2D graphics2d)
+ {
+ drawPolylines(image, graphics2d, POLYLINE_STEP, new PolylineDrawCallbacks()
+ {
+ /**
+ * Callback function called before each polyline 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.
*
@@ -76,5 +165,5 @@
{
new PrintTestPolylines().runTestSuite(args);
}
-
+
}
More information about the distro-pkg-dev
mailing list