/hg/gfx-test: Added six new tests to the test suite PrintTestCub...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Fri Aug 10 05:58:43 PDT 2012
changeset 7d969e53aa12 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=7d969e53aa12
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Aug 10 15:01:19 2012 +0200
Added six new tests to the test suite PrintTestCubicCurvesAsPaths.
diffstat:
ChangeLog | 5 +
src/org/gfxtest/testsuites/PrintTestCubicCurvesAsPaths.java | 228 ++++++++++++
2 files changed, 233 insertions(+), 0 deletions(-)
diffs (263 lines):
diff -r e255b4abb8c4 -r 7d969e53aa12 ChangeLog
--- a/ChangeLog Thu Aug 09 11:45:40 2012 +0200
+++ b/ChangeLog Fri Aug 10 15:01:19 2012 +0200
@@ -1,3 +1,8 @@
+2012-08-10 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/testsuites/PrintTestCubicCurvesAsPaths.java:
+ Added six new tests to the test suite PrintTestCubicCurvesAsPaths.
+
2012-08-09 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/PrintTestQuadraticCurvesAsPaths.java:
diff -r e255b4abb8c4 -r 7d969e53aa12 src/org/gfxtest/testsuites/PrintTestCubicCurvesAsPaths.java
--- a/src/org/gfxtest/testsuites/PrintTestCubicCurvesAsPaths.java Thu Aug 09 11:45:40 2012 +0200
+++ b/src/org/gfxtest/testsuites/PrintTestCubicCurvesAsPaths.java Fri Aug 10 15:01:19 2012 +0200
@@ -40,12 +40,15 @@
package org.gfxtest.testsuites;
+import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;
import org.gfxtest.callbacks.CubicCurveDrawCallbacks;
+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;
@@ -189,6 +192,231 @@
}
/**
+ * Test basic behavior of method Graphics.draw(Path).
+ * Quadratic curves are rendered with default width and default end caps.
+ * Color of all rendered curves are selected from a palette.
+ * All rendered cubic curves are represented by a Path object.
+ *
+ * @param image
+ * image to which lines are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawCubicCurvesColorPalette(TestImage image, Graphics2D graphics)
+ {
+ drawCubicCurve(image, graphics, CUBIC_CURVE_STEP, new CubicCurveDrawCallbacks()
+ {
+ /**
+ * Callback function called before each cubic curve is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int index)
+ {
+ // set curve color
+ this.graphics.setColor(ColorPalette.getColor(index));
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.draw(Path).
+ * Quadratic curves are rendered with default width and default end caps.
+ * Color of all rendered curves are selected from a grayscale palette.
+ * All rendered cubic curves are represented by a Path object.
+ *
+ * @param image
+ * image to which lines are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawCubicCurvesGrayScale(TestImage image, Graphics2D graphics)
+ {
+ drawCubicCurve(image, graphics, CUBIC_CURVE_STEP, new CubicCurveDrawCallbacks()
+ {
+ /**
+ * Callback function called before each cubic curve is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int index)
+ {
+ // compute grayscale value
+ float gray = y1 * 1.0f / this.image.getHeight();
+ // set curve color
+ this.graphics.setColor(GrayscalePalette.createGrayscaleColor(gray));
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.draw(Path).
+ * Quadratic curves are rendered with various width and default end caps.
+ * Color of all rendered curves are selected from a grayscale palette.
+ * All rendered cubic curves are represented by a Path object.
+ *
+ * @param image
+ * image to which lines are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawCubicCurvesChangeWidth(TestImage image, Graphics2D graphics)
+ {
+ drawCubicCurve(image, graphics, CUBIC_CURVE_STEP, new CubicCurveDrawCallbacks()
+ {
+ /**
+ * Stroke width.
+ */
+ float strokeWidth = 0.0f;
+
+ /**
+ * Callback function called before each cubic curve is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int index)
+ {
+ // set stroke width
+ this.graphics.setStroke(new BasicStroke(this.strokeWidth));
+ // set new stroke width
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA : this.strokeWidth;
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.draw(Path).
+ * Quadratic curves are rendered with various width and end caps set to CAP_BUTT.
+ * Join style is set to bevel style.
+ * Color of all rendered curves are selected from a grayscale palette.
+ * All rendered cubic curves are represented by a Path object.
+ *
+ * @param image
+ * image to which lines are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawCubicCurvesChangeWidthCapButtJoinBevel(TestImage image, Graphics2D graphics)
+ {
+ drawCubicCurve(image, graphics, CUBIC_CURVE_STEP, new CubicCurveDrawCallbacks()
+ {
+ /**
+ * Stroke width.
+ */
+ float strokeWidth = 0.0f;
+
+ /**
+ * Callback function called before each cubic curve is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int index)
+ {
+ // set stroke width
+ this.graphics.setStroke(new BasicStroke(this.strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+ // set new stroke width
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA : this.strokeWidth;
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.draw(Path).
+ * Quadratic curves are rendered with various width and end caps set to CAP_ROUND.
+ * Join style is set to bevel style.
+ * Color of all rendered curves are selected from a grayscale palette.
+ * All rendered cubic curves are represented by a Path object.
+ *
+ * @param image
+ * image to which lines are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawCubicCurvesChangeWidthCapRoundJoinBevel(TestImage image, Graphics2D graphics)
+ {
+ drawCubicCurve(image, graphics, CUBIC_CURVE_STEP, new CubicCurveDrawCallbacks()
+ {
+ /**
+ * Stroke width.
+ */
+ float strokeWidth = 0.0f;
+
+ /**
+ * Callback function called before each cubic curve is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int index)
+ {
+ // set stroke width
+ this.graphics.setStroke(new BasicStroke(this.strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+ // set new stroke width
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA : this.strokeWidth;
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.draw(Path).
+ * Quadratic curves are rendered with various width and end caps set to CAP_SQUARE.
+ * Join style is set to bevel style.
+ * Color of all rendered curves are selected from a grayscale palette.
+ * All rendered cubic curves are represented by a Path object.
+ *
+ * @param image
+ * image to which lines are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawCubicCurvesChangeWidthCapSquareJoinBevel(TestImage image, Graphics2D graphics)
+ {
+ drawCubicCurve(image, graphics, CUBIC_CURVE_STEP, new CubicCurveDrawCallbacks()
+ {
+ /**
+ * Stroke width.
+ */
+ float strokeWidth = 0.0f;
+
+ /**
+ * Callback function called before each cubic curve is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int index)
+ {
+ // set stroke width
+ this.graphics.setStroke(new BasicStroke(this.strokeWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+ // set new stroke width
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA : this.strokeWidth;
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
* Entry point to the test suite.
*
* @param args
More information about the distro-pkg-dev
mailing list