/hg/gfx-test: * src/org/gfxtest/framework/PrintTest.java:
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Wed Jun 13 03:05:31 PDT 2012
changeset aa4331288424 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=aa4331288424
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Wed Jun 13 12:08:08 2012 +0200
* src/org/gfxtest/framework/PrintTest.java:
Refactored and improved JavaDoc.
* src/org/gfxtest/testsuites/PrintTestArcs.java:
Added new tests to this test suite.
diffstat:
ChangeLog | 7 +
src/org/gfxtest/framework/PrintTest.java | 40 ++++++---
src/org/gfxtest/testsuites/PrintTestArcs.java | 102 ++++++++++++++++++++++++++
3 files changed, 135 insertions(+), 14 deletions(-)
diffs (226 lines):
diff -r 8820f1d37a0d -r aa4331288424 ChangeLog
--- a/ChangeLog Tue Jun 12 15:10:25 2012 +0200
+++ b/ChangeLog Wed Jun 13 12:08:08 2012 +0200
@@ -1,3 +1,10 @@
+2012-06-13 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/framework/PrintTest.java:
+ Refactored and improved JavaDoc.
+ * src/org/gfxtest/testsuites/PrintTestArcs.java:
+ Added new tests to this test suite.
+
2012-06-12 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/PrintTest.java:
diff -r 8820f1d37a0d -r aa4331288424 src/org/gfxtest/framework/PrintTest.java
--- a/src/org/gfxtest/framework/PrintTest.java Tue Jun 12 15:10:25 2012 +0200
+++ b/src/org/gfxtest/framework/PrintTest.java Wed Jun 13 12:08:08 2012 +0200
@@ -43,39 +43,46 @@
/**
- * Abstract class used by all print tests.
+ * Abstract class used by all print tests, ie all tests
+ * which renders all drawing into a PostScript file.
*
* @author Pavel Tisnovsky
*/
abstract public class PrintTest extends GfxTest
{
/**
- * Maximum width of line rendered onto a paper.
+ * Border around the test picture. It's better to not to draw into the
+ * border due to PostScript renderers differences.
+ */
+ protected static final int BORDER = 10;
+
+ /**
+ * Maximum width of line or other open shape rendered onto a paper.
*/
protected static final float MAX_STROKE_WIDTH = 15.0f;
/**
- * Change of stroke width.
+ * Minimum width of line or other open shape rendered onto a paper.
+ */
+ protected static final float MIN_STROKE_WIDTH = 0.0f;
+
+ /**
+ * Change of stroke width in each test iteration.
*/
protected static final float STROKE_WIDTH_DELTA = 0.5f;
/**
- * Change of stroke width for diagonal lines.
+ * Change of stroke width in each test iteration for diagonal lines.
*/
protected static final float STROKE_WIDTH_DIAGONAL_DELTA = 0.2f;
/**
- * Border around the test picture.
- */
- protected static final int BORDER = 10;
-
- /**
- * Offset between two circles.
+ * Offset between two circles in each test iteration.
*/
protected static final int CIRCLE_RADIUS_STEP = 10;
/**
- * Offset between two arcs.
+ * Offset between two arcs in each test iteration.
*/
protected static final int ARC_RADIUS_STEP = 10;
@@ -85,18 +92,23 @@
protected static final int MINIMUM_RADIUS = 10;
/**
- * Horizontal distance between two lines.
+ * Horizontal distance between two lines in each test iteration.
*/
protected static final int HORIZONTAL_STEP = 10;
/**
- * Vertical distance between two lines.
+ * Vertical distance between two lines in each test iteration.
*/
protected static final int VERTICAL_STEP = 10;
/**
- * Diagonal distance between two lines.
+ * Diagonal distance between two lines in each test iteration.
*/
protected static final int DIAGONAL_STEP = 16;
+ /**
+ * Maximum color index.
+ * (used only in tests which uses color palette)
+ */
+ protected static final int MAX_COLOR_INDEX = 1000;
}
diff -r 8820f1d37a0d -r aa4331288424 src/org/gfxtest/testsuites/PrintTestArcs.java
--- a/src/org/gfxtest/testsuites/PrintTestArcs.java Tue Jun 12 15:10:25 2012 +0200
+++ b/src/org/gfxtest/testsuites/PrintTestArcs.java Wed Jun 13 12:08:08 2012 +0200
@@ -40,11 +40,14 @@
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.GrayscalePalette;
import org.gfxtest.framework.PrintTest;
import org.gfxtest.framework.TestImage;
import org.gfxtest.framework.TestResult;
@@ -153,6 +156,105 @@
}
/**
+ * Test basic behavior of method Graphics.drawOval().
+ * Arcs are rendered with various width and default end caps.
+ * Color of all rendered arcs are set to black.
+ *
+ * @param image
+ * image to which arcs are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawArcChangeWidth(TestImage image, Graphics2D graphics2d)
+ {
+ drawArcs(image, graphics2d, ARC_RADIUS_STEP * 3 / 2, new CommonArcDrawCallbacks()
+ {
+ /**
+ * Stroke width which is changed in each iteration.
+ */
+ private float strokeWidth = MIN_STROKE_WIDTH;
+
+ /**
+ * Callback function called before each arc is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set new stroke width
+ this.graphics.setStroke(new BasicStroke(this.strokeWidth));
+ // change stroke width for the next iteration
+ changeStrokeWidth();
+ return;
+ }
+
+ /**
+ * Changes stroke width.
+ */
+ private void changeStrokeWidth()
+ {
+ // increase stroke width
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA : this.strokeWidth;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval().
+ * Arcs are rendered with various width and default end caps.
+ * Color of all rendered arcs are set to black.
+ *
+ * @param image
+ * image to which arcs are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawArcChangeWidthInv(TestImage image, Graphics2D graphics2d)
+ {
+ drawArcs(image, graphics2d, ARC_RADIUS_STEP * 3 / 2, new CommonArcDrawCallbacks()
+ {
+ /**
+ * Stroke width which is changed in each iteration.
+ */
+ private float strokeWidth = MAX_STROKE_WIDTH - 2;
+
+ /**
+ * Callback function called before each arc is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set new stroke width
+ this.graphics.setStroke(new BasicStroke(this.strokeWidth));
+ // change stroke width for the next iteration
+ changeStrokeWidth();
+ return;
+ }
+
+ /**
+ * Changes stroke width.
+ */
+ private void changeStrokeWidth()
+ {
+ // decrease stroke width
+ this.strokeWidth -= STROKE_WIDTH_DELTA;
+ // stroke width should not be less than zero
+ if (this.strokeWidth < MIN_STROKE_WIDTH)
+ {
+ this.strokeWidth = MIN_STROKE_WIDTH;
+ }
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
* Entry point to the test suite.
*
* @param args
More information about the distro-pkg-dev
mailing list