/hg/gfx-test: Added support for zoomed images rendering, first v...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Mon Sep 6 07:56:16 PDT 2010
changeset 8ab660713623 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=8ab660713623
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Sep 06 16:56:33 2010 +0200
Added support for zoomed images rendering, first version of test
reporter.
diffstat:
31 files changed, 434 insertions(+), 12 deletions(-)
Makefile | 16 +-
src/org/gfxtest/framework/GfxTest.java | 62 +++++++-
src/org/gfxtest/framework/TestImage.java | 25 ++-
src/org/gfxtest/framework/annotations/Zoom.java | 53 +++++++
src/org/gfxtest/reporter/Reporter.java | 128 +++++++++++++++++
src/org/gfxtest/reporter/ReporterConfiguration.java | 98 +++++++++++++
src/org/gfxtest/reporter/TestResult.java | 38 +++++
src/org/gfxtest/testsuites/BlankImage.java | 1
src/org/gfxtest/testsuites/DashedCircles.java | 1
src/org/gfxtest/testsuites/DashedEllipses.java | 1
src/org/gfxtest/testsuites/DashedLines.java | 1
src/org/gfxtest/testsuites/DashedPolylines.java | 1
src/org/gfxtest/testsuites/DashedRectangles.java | 1
src/org/gfxtest/testsuites/FilledArcs.java | 1
src/org/gfxtest/testsuites/FilledCircles.java | 1
src/org/gfxtest/testsuites/FilledEllipses.java | 1
src/org/gfxtest/testsuites/FilledPolygons.java | 1
src/org/gfxtest/testsuites/FilledRectangles.java | 1
src/org/gfxtest/testsuites/FilledRoundRectangles.java | 1
src/org/gfxtest/testsuites/Normal3DRectangles.java | 3
src/org/gfxtest/testsuites/NormalArcs.java | 1
src/org/gfxtest/testsuites/NormalCircles.java | 1
src/org/gfxtest/testsuites/NormalEllipses.java | 1
src/org/gfxtest/testsuites/NormalLines.java | 1
src/org/gfxtest/testsuites/NormalPolygons.java | 1
src/org/gfxtest/testsuites/NormalPolylines.java | 1
src/org/gfxtest/testsuites/NormalRectangles.java | 1
src/org/gfxtest/testsuites/NormalRoundRectangles.java | 1
src/org/gfxtest/testsuites/ScaledLines.java | 1
src/org/gfxtest/testsuites/ScaledPolylines.java | 1
src/org/gfxtest/testsuites/ScaledRectangles.java | 1
diffs (truncated from 834 to 500 lines):
diff -r 6a72cc4964cc -r 8ab660713623 Makefile
--- a/Makefile Tue Aug 10 13:59:14 2010 +0200
+++ b/Makefile Mon Sep 06 16:56:33 2010 +0200
@@ -41,9 +41,12 @@ OUTPUT=output
OUTPUT=output
SAMPLES=samples
RESULTS=results
+
COMMON_DIR=org/gfxtest/common
FRAMEWORK_DIR=org/gfxtest/framework
TESTSUITE_DIR=org/gfxtest/testsuites
+REPORTER_DIR=org/gfxtest/reporter
+
TEST_PACKAGE=org.gfxtest.testsuites
RUN_OPTIONS=-w=640 -h=480 -t=rgb
TESTED_JAVA=/usr/java/default/bin/java
@@ -54,6 +57,9 @@ FRAMEWORK_CLASSES = \
$(CLASSES)/$(COMMON_DIR)/InvalidParameterValueException.class \
$(CLASSES)/$(COMMON_DIR)/ConfigurationException.class \
$(CLASSES)/$(COMMON_DIR)/Configuration.class \
+ $(CLASSES)/$(REPORTER_DIR)/TestResult.class \
+ $(CLASSES)/$(REPORTER_DIR)/ReporterConfiguration.class \
+ $(CLASSES)/$(REPORTER_DIR)/Reporter.class \
$(CLASSES)/$(FRAMEWORK_DIR)/annotations/GraphicsPrimitives.class \
$(CLASSES)/$(FRAMEWORK_DIR)/annotations/GraphicsPrimitive.class \
$(CLASSES)/$(FRAMEWORK_DIR)/annotations/RenderStyles.class \
@@ -62,6 +68,7 @@ FRAMEWORK_CLASSES = \
$(CLASSES)/$(FRAMEWORK_DIR)/annotations/TestType.class \
$(CLASSES)/$(FRAMEWORK_DIR)/annotations/Transformations.class \
$(CLASSES)/$(FRAMEWORK_DIR)/annotations/Transformation.class \
+ $(CLASSES)/$(FRAMEWORK_DIR)/annotations/Zoom.class \
$(CLASSES)/$(FRAMEWORK_DIR)/EntityRenderingStyle.class \
$(CLASSES)/$(FRAMEWORK_DIR)/TestResult.class \
$(CLASSES)/$(FRAMEWORK_DIR)/ParameterNotFoundException.class \
@@ -127,7 +134,7 @@ TESTSUITES = $(shell ls -1 src/org/gfxte
SAMPLE_IMAGES = $(shell ls -1 src/org/gfxtest/testsuites | sed -n -e 's/\([A-Za-z0-9]*\)\.java/samples\/\1/p')
-all: build sample_images runtests compareresults
+all: build sample_images runtests compareresults report
build: $(CLASSES)/stamp $(OUTPUT)/stamp gfxtest.jar
@@ -156,6 +163,9 @@ test_suites: $(TESTSUITE_CLASSES)
$(CLASSES)/$(TESTSUITE_DIR)/%.class: $(SOURCEPATH)/$(TESTSUITE_DIR)/%.java
$(JAVAC) -d $(CLASSES) -sourcepath src/ $<
+$(CLASSES)/$(REPORTER_DIR)/%.class: $(SOURCEPATH)/$(REPORTER_DIR)/%.java
+ $(JAVAC) -d $(CLASSES) -sourcepath src/ $<
+
gfxtest.jar: $(FRAMEWORK_CLASSES) $(TESTSUITE_CLASSES)
jar cvf gfxtest.jar -C $(CLASSES) .
@@ -172,7 +182,7 @@ runtests: gfxtest.jar $(TESTSUITES)
mkdir -p $@
$(REFERENCE_JAVA) -cp gfxtest.jar $(TEST_PACKAGE).$(subst samples/,,$@) $(RUN_OPTIONS) -o=$@
-# for output/NormalLines the internal macros are set:
+# for output/NormalLines the internal macros are set to following:
# $@ - results/NormalLines
# $< - output/NormalLines
# $* - NormalLines
@@ -186,6 +196,8 @@ compareresults: $(COMPARE_RESULTS)
cp results.html $(RESULTS)
mkdir -p masks
+report: gfxtest.jar
+ java -cp gfxtest.jar org.gfxtest.reporter.Reporter -i=$(RESULTS) -o=$(RESULTS)
cleanall: clean clean-output clean-results clean-samples
clean-all: cleanall
diff -r 6a72cc4964cc -r 8ab660713623 src/org/gfxtest/framework/GfxTest.java
--- a/src/org/gfxtest/framework/GfxTest.java Tue Aug 10 13:59:14 2010 +0200
+++ b/src/org/gfxtest/framework/GfxTest.java Mon Sep 06 16:56:33 2010 +0200
@@ -48,6 +48,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Method;
import org.gfxtest.common.ConfigurationException;
+import org.gfxtest.framework.annotations.Zoom;
public abstract class GfxTest
{
@@ -354,14 +355,15 @@ public abstract class GfxTest
{
String testName = "test" + testNumber; //$NON-NLS-1$
this.log.logBegin(testName);
- TestImage image = new TestImage(configuration);
+ int zoom = getZoom();
+ TestImage image = new TestImage(configuration, zoom);
Graphics2D graphics = image.getGraphics();
logCurrentRenderingStyle(entityRenderingStyle);
drawEntity(image, graphics, testNumber, entityRenderingStyle);
graphics.dispose();
try
{
- image.writeImage(configuration, this.suiteName, testName);
+ writeZoomedImage(configuration, image, testName, zoom);
}
catch (IOException e)
{
@@ -389,7 +391,8 @@ public abstract class GfxTest
if (method.getName().startsWith("test")) //$NON-NLS-1$
{
this.log.logBegin(methodName);
- TestImage image = new TestImage(configuration);
+ int zoom = getZoom();
+ TestImage image = new TestImage(configuration, zoom);
Graphics2D gc = image.getGraphics();
TestResult result = null;
try
@@ -407,7 +410,7 @@ public abstract class GfxTest
logTestResult(result);
try
{
- image.writeImage(configuration, this.suiteName, methodName);
+ writeZoomedImage(configuration, image, methodName, zoom);
}
catch (IOException e)
{
@@ -416,6 +419,57 @@ public abstract class GfxTest
this.log.logEnd(methodName);
}
}
+ }
+
+ private void writeZoomedImage(GfxTestConfiguration configuration, TestImage sourceImage, String methodName, int zoom) throws IOException
+ {
+ if (zoom == 1)
+ {
+ sourceImage.writeImage(configuration, this.suiteName, methodName);
+ }
+ else
+ {
+ TestImage destinationImage = new TestImage(configuration, 1);
+ zoomImage(sourceImage, zoom, destinationImage);
+ drawGrid(destinationImage, zoom);
+ destinationImage.writeImage(configuration, this.suiteName, methodName);
+ }
+ }
+
+ private void zoomImage(TestImage sourceImage, int zoom, TestImage destinationImage)
+ {
+ for (int y = 0; y < destinationImage.getHeight(); y++)
+ {
+ for (int x = 0; x < destinationImage.getWidth(); x++)
+ {
+ destinationImage.setRGB(x, y, sourceImage.getRGB(x / zoom, y / zoom));
+ }
+ }
+ }
+
+ private void drawGrid(TestImage image, int zoom)
+ {
+ Graphics2D g = image.getGraphics();
+ g.setColor(Color.GRAY);
+ for (int x = 0; x < image.getWidth(); x += zoom)
+ {
+ g.drawLine(x, 0, x, image.getHeight() - 1);
+ }
+ for (int y = 0; y < image.getWidth(); y += zoom)
+ {
+ g.drawLine(0, y, image.getWidth() - 1, y);
+ }
+ }
+
+ /**
+ * Returns zoom set by annotation.
+ *
+ * @return actual zoom value
+ */
+ private int getZoom()
+ {
+ Zoom zoom = this.getClass().getAnnotation(Zoom.class);
+ return zoom == null ? 1 : zoom.value();
}
/**
diff -r 6a72cc4964cc -r 8ab660713623 src/org/gfxtest/framework/TestImage.java
--- a/src/org/gfxtest/framework/TestImage.java Tue Aug 10 13:59:14 2010 +0200
+++ b/src/org/gfxtest/framework/TestImage.java Mon Sep 06 16:56:33 2010 +0200
@@ -54,22 +54,27 @@ public class TestImage
private static final int GRID_SIZE = 20;
private BufferedImage image = null;
- public TestImage(GfxTestConfiguration configuration)
+ public TestImage(GfxTestConfiguration configuration, int zoom)
{
this.log = new Log(this.getClass().getName(), true);
- this.createImage(configuration);
+ this.createImage(configuration, zoom);
}
/**
* Create new buffered image with given width, height and image type.
* @param configuration configuration of current test suite
+ * @param zoom zoom factor
* @return
*/
- public void createImage(GfxTestConfiguration configuration)
+ public void createImage(GfxTestConfiguration configuration, int zoom)
{
- this.image = new BufferedImage(configuration.getImageWidth(), configuration.getImageHeight(), configuration.getImageType());
+ this.image = new BufferedImage(configuration.getImageWidth() / zoom, configuration.getImageHeight() / zoom,
+ configuration.getImageType());
this.clearImage();
- this.drawGrid();
+ if (zoom == 1)
+ {
+ this.drawGrid();
+ }
}
protected void clearImage()
@@ -157,4 +162,14 @@ public class TestImage
{
return this.getHeight() >> 1;
}
+
+ public int getRGB(int x, int y)
+ {
+ return this.image.getRGB(x, y);
+ }
+
+ public void setRGB(int x, int y, int rgb)
+ {
+ this.image.setRGB(x, y, rgb);
+ }
}
diff -r 6a72cc4964cc -r 8ab660713623 src/org/gfxtest/framework/annotations/Zoom.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/framework/annotations/Zoom.java Mon Sep 06 16:56:33 2010 +0200
@@ -0,0 +1,53 @@
+/*
+ Java gfx-test framework
+
+ Copyright (C) 2010 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.framework.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.TYPE)
+public @interface Zoom
+{
+ int value();
+}
diff -r 6a72cc4964cc -r 8ab660713623 src/org/gfxtest/reporter/Reporter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/reporter/Reporter.java Mon Sep 06 16:56:33 2010 +0200
@@ -0,0 +1,128 @@
+/*
+ Java gfx-test framework
+
+ Copyright (C) 2010 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.reporter;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gfxtest.common.ConfigurationException;
+import org.gfxtest.framework.Log;
+
+/**
+ * Test reporter main class.
+ *
+ * @author Pavel Tisnovsky
+ */
+public class Reporter
+{
+ private Log log = null;
+
+ private ReporterConfiguration configuration = null;
+
+ @SuppressWarnings("nls")
+ private final String[] SPECTESTS = new String[] {"BlankImage"};
+
+ @SuppressWarnings("nls")
+ private final String[] ENTITIES = new String[] {"Line", "Polyline", "Polygon", "Rectangle", "Circle", "Ellipse", "Arc"};
+
+ @SuppressWarnings("nls")
+ private final String[] STYLES = new String[] {"Normal", "Filled", "Dashed", "Scaled"};
+
+ /**
+ * Write report writer duration to the log file.
+ *
+ * @param t1 time when the test suite has been started
+ * @param t2 time when the test suite was completed
+ */
+ private void printDuration(long t1, long t2)
+ {
+ this.log.logSet("duration", Long.valueOf(t2-t1)); //$NON-NLS-1$
+ }
+
+ private void doReport(String[] args)
+ {
+ long t1 = System.currentTimeMillis();
+ this.log = new Log(this.getClass().getName(), true);
+ this.log.logBegin("report"); //$NON-NLS-1$
+ try
+ {
+ this.configuration = new ReporterConfiguration(args, this.log);
+ Map<String, TestResult> testResults = readAllTestResults();
+ }
+ catch (ConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ long t2 = System.currentTimeMillis();
+ this.log.logEnd("report"); //$NON-NLS-1$
+ printDuration(t1, t2);
+ }
+ }
+
+ private Map<String, TestResult> readAllTestResults()
+ {
+ Map<String, TestResult> results = new HashMap<String, TestResult>();
+ File inputDir = this.configuration.getInputPath();
+
+ if (inputDir == null || !inputDir.isDirectory())
+ {
+ return results;
+ }
+ for (String resultDir : inputDir.list())
+ {
+ System.out.println("***" + resultDir);
+ }
+ return results;
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ new Reporter().doReport(args);
+ }
+
+
+}
diff -r 6a72cc4964cc -r 8ab660713623 src/org/gfxtest/reporter/ReporterConfiguration.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/reporter/ReporterConfiguration.java Mon Sep 06 16:56:33 2010 +0200
@@ -0,0 +1,98 @@
+/*
+ Java gfx-test framework
+
+ Copyright (C) 2010 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.reporter;
+
+import java.io.File;
+import java.util.Map;
+
+import org.gfxtest.common.Configuration;
+import org.gfxtest.common.ConfigurationException;
+import org.gfxtest.framework.Log;
+
+/**
+ * Configuration for graphics tests reporter.
+ *
+ * @author Pavel Tisnovsky
+ */
+public class ReporterConfiguration extends Configuration
+{
+ /**
+ * Path to reports generated by Lupic.jar.
+ */
+ private File inputPath;
+
+ /**
+ * Path to generated output files.
+ */
+ private File outputPath;
+
+ public ReporterConfiguration(String[] args, Log log) throws ConfigurationException
+ {
+ super(args, log);
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ protected void printParameters()
+ {
+ this.log.logSet("input path", this.inputPath);
+ this.log.logSet("output path", this.outputPath);
+ }
+
More information about the distro-pkg-dev
mailing list