/hg/gfx-test: * src/org/gfxtest/reporter/Reporter.java:
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue Apr 17 05:34:28 PDT 2012
changeset 2bd442a17073 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=2bd442a17073
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Apr 17 14:37:07 2012 +0200
* src/org/gfxtest/reporter/Reporter.java:
* src/org/gfxtest/reporter/ReporterConfiguration.java:
* src/org/gfxtest/reporter/TestResult.java:
Code and JavaDoc improvements.
diffstat:
ChangeLog | 7 +
src/org/gfxtest/reporter/Reporter.java | 124 +++++++++++++++++--
src/org/gfxtest/reporter/ReporterConfiguration.java | 33 ++++-
src/org/gfxtest/reporter/TestResult.java | 78 ++++++++++++-
4 files changed, 223 insertions(+), 19 deletions(-)
diffs (481 lines):
diff -r 31509443dff8 -r 2bd442a17073 ChangeLog
--- a/ChangeLog Mon Apr 16 11:27:52 2012 +0200
+++ b/ChangeLog Tue Apr 17 14:37:07 2012 +0200
@@ -1,3 +1,10 @@
+2012-04-17 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/reporter/Reporter.java:
+ * src/org/gfxtest/reporter/ReporterConfiguration.java:
+ * src/org/gfxtest/reporter/TestResult.java:
+ Code and JavaDoc improvements.
+
2012-04-16 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/PrintTestBasic.java:
diff -r 31509443dff8 -r 2bd442a17073 src/org/gfxtest/reporter/Reporter.java
--- a/src/org/gfxtest/reporter/Reporter.java Mon Apr 16 11:27:52 2012 +0200
+++ b/src/org/gfxtest/reporter/Reporter.java Tue Apr 17 14:37:07 2012 +0200
@@ -65,18 +65,39 @@
*/
private static final String DEFAULT_ENCODING = "UTF-8";
+ /**
+ * Instance of logger class.
+ */
private Log log = null;
+ /**
+ * Configuration of test reporter.
+ */
private ReporterConfiguration configuration = null;
+ /**
+ * Directory where HTML templates are stored.
+ */
private static final String TEMPLATE_DIR = "templates";
+ /**
+ * Name of the main HTML template.
+ */
private static final String INPUT_FILE_NAME = "template_test_result.html";
+ /**
+ * Name of generated HTML file.
+ */
private static final String OUTPUT_FILE_NAME = "index.html";
+ /**
+ * Names of special tests.
+ */
private static final String[] SPECTESTS = new String[] {"BlankImage", "SpecialCases"};
+ /**
+ * Names of tested entities.
+ */
private static final String[] ENTITIES = new String[] {
"Lines",
"Polylines",
@@ -89,6 +110,9 @@
"Arcs"
};
+ /**
+ * Names of rendering styles.
+ */
private static final String[] STYLES = new String[] {
"Normal",
"Filled",
@@ -99,15 +123,22 @@
/**
* 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
+ *
+ * @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$
}
+ /**
+ * Do the report.
+ *
+ * @param args command line arguments
+ */
private void doReport(String[] args)
{
BufferedReader input = null;
@@ -127,9 +158,11 @@
output = new BufferedWriter(writer);
writeHtmlHeader(input, output);
writeHeaderForCommonTests(output);
+ // loop over all entity types
for (String entity : ENTITIES)
{
writeEntityHeader(output, entity);
+ // loop over all graphics styles
for (String style : STYLES)
{
String testSuiteName = style + entity;
@@ -140,6 +173,7 @@
output.write("</tr>\n");
}
output.write("<tr><td colspan='5'> </td>\n");
+ // special tests has to be done separately
for (String entity : SPECTESTS)
{
writeEntityHeader(output, entity);
@@ -161,23 +195,40 @@
}
finally
{
- try
- {
- if (output != null)
- {
- output.close();
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
+ closeOutputWriter(output);
long t2 = System.currentTimeMillis();
this.log.logEnd("report"); //$NON-NLS-1$
printDuration(t1, t2);
}
}
+ /**
+ * Try to close output buffered writer.
+ *
+ * @param output
+ */
+ private void closeOutputWriter(BufferedWriter output)
+ {
+ try
+ {
+ // close output file
+ if (output != null)
+ {
+ output.close();
+ }
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Write header for each test to a HTML file.
+ *
+ * @param output
+ * @throws IOException
+ */
private void writeHeaderForCommonTests(BufferedWriter output) throws IOException
{
output.write("<tr><td class='value'>Entity</td>");
@@ -188,11 +239,26 @@
output.write("</tr>\n");
}
+ /**
+ * Write header for given graphics entity.
+ *
+ * @param output
+ * @param entity
+ * @throws IOException
+ */
private void writeEntityHeader(BufferedWriter output, String entity) throws IOException
{
output.write("<tr><td class='key'>" + entity +"</td>");
}
+ /**
+ * Write result for one test suite or an 'x' character when the test did not run.
+ *
+ * @param output
+ * @param testResult
+ * @param testSuiteName
+ * @throws IOException
+ */
private void writeTestResult(BufferedWriter output, TestResult testResult, String testSuiteName) throws IOException
{
if (testResult == null)
@@ -205,6 +271,13 @@
}
}
+ /**
+ * Write HTML header which is read from a HTML template.
+ *
+ * @param input
+ * @param output
+ * @throws IOException
+ */
private void writeHtmlHeader(BufferedReader input, BufferedWriter output) throws IOException
{
String line;
@@ -215,6 +288,13 @@
}
}
+ /**
+ * Write HTML footer which is read from a HTML template.
+ *
+ * @param input
+ * @param output
+ * @throws IOException
+ */
private void writeHtmlFooter(BufferedReader input, BufferedWriter output) throws IOException
{
String line;
@@ -225,6 +305,11 @@
}
}
+ /**
+ * Read all test results a and store them into a map.
+ *
+ * @return
+ */
private Map<String, TestResult> readAllTestResults()
{
Map<String, TestResult> results = new HashMap<String, TestResult>();
@@ -248,6 +333,14 @@
return results;
}
+ /**
+ * Read and process test result from the file "results.xml".
+ *
+ * @param resultDirectory
+ * directory containing test result(s)
+ *
+ * @return results of one test run
+ */
@SuppressWarnings({ "boxing" })
private TestResult readTestResult(File resultDirectory)
{
@@ -261,6 +354,7 @@
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse(resultFile);
NodeList nodes = document.getElementsByTagName("test");
+ // read all nodes under node "test"
for (int i = 0; i < nodes.getLength(); i++)
{
Element testNode = (Element) nodes.item(i);
@@ -308,6 +402,8 @@
}
/**
+ * Entry to this application.
+ *
* @param args
*/
public static void main(String[] args)
diff -r 31509443dff8 -r 2bd442a17073 src/org/gfxtest/reporter/ReporterConfiguration.java
--- a/src/org/gfxtest/reporter/ReporterConfiguration.java Mon Apr 16 11:27:52 2012 +0200
+++ b/src/org/gfxtest/reporter/ReporterConfiguration.java Tue Apr 17 14:37:07 2012 +0200
@@ -1,7 +1,7 @@
/*
Java gfx-test framework
- Copyright (C) 2010, 2011 Red Hat
+ Copyright (C) 2010, 2011, 2012 Red Hat
This file is part of IcedTea.
@@ -47,9 +47,11 @@
import org.gfxtest.common.ConfigurationException;
import org.gfxtest.framework.Log;
+
+
/**
- * Configuration for graphics tests reporter.
- *
+ * Instance of this class contain configuration for graphics tests reporter.
+ *
* @author Pavel Tisnovsky
*/
public class ReporterConfiguration extends Configuration
@@ -64,11 +66,23 @@
*/
private File outputPath;
+ /**
+ * Constructor for this class.
+ *
+ * @param args
+ * command line parameters
+ * @param log
+ * @throws ConfigurationException
+ * this exception is thrown in case of any configuration problem
+ */
public ReporterConfiguration(String[] args, Log log) throws ConfigurationException
{
super(args, log);
}
+ /**
+ * Prints all configuration parameters.
+ */
@SuppressWarnings("nls")
@Override
protected void printParameters()
@@ -77,6 +91,9 @@
this.log.logSet("output path", this.outputPath);
}
+ /**
+ * Read all command line parameters from std. args.
+ */
@Override
protected void readCommandLineParameters(String[] args) throws ConfigurationException
{
@@ -85,11 +102,21 @@
this.outputPath = new File(getStringParameter(options, "o")); //$NON-NLS-1$
}
+ /**
+ * Returns input path.
+ *
+ * @return input path
+ */
public File getInputPath()
{
return this.inputPath;
}
+ /**
+ * Returns output path.
+ *
+ * @return output path
+ */
public File getOutputPath()
{
return this.outputPath;
diff -r 31509443dff8 -r 2bd442a17073 src/org/gfxtest/reporter/TestResult.java
--- a/src/org/gfxtest/reporter/TestResult.java Mon Apr 16 11:27:52 2012 +0200
+++ b/src/org/gfxtest/reporter/TestResult.java Tue Apr 17 14:37:07 2012 +0200
@@ -1,7 +1,7 @@
/*
Java gfx-test framework
- Copyright (C) 2010, 2011 Red Hat
+ Copyright (C) 2010, 2011, 2012 Red Hat
This file is part of IcedTea.
@@ -40,47 +40,121 @@
package org.gfxtest.reporter;
+/**
+ * Instances of this class contain results of one test run.
+ *
+ * @author Pavel Tisnovsky
+ */
public class TestResult
{
+ /**
+ * Total test run.
+ */
private int totalTests;
+
+ /**
+ * Number of images which are the same after comparison.
+ */
private int sameImages;
+
+ /**
+ * Number of images which are different after comparison.
+ */
private int differentImages;
+ /**
+ * Empty constructor
+ */
public TestResult()
{
- // empty
+ // empty as expected
}
+ /**
+ * Constructor.
+ *
+ * @param totalTests
+ * total test run
+ * @param sameImages
+ * number of images which are the same after comparison
+ * @param differentImages
+ * number of images which are different after comparison
+ */
+ public TestResult(int totalTests, int sameImages, int differentImages)
+ {
+ super();
+ // set all attributes
+ setTotalTests(totalTests);
+ setSameImages(sameImages);
+ setDifferentImages(differentImages);
+ }
+
+ /**
+ * Getter for an attribute totalTests.
+ *
+ * @return value of an attribute totalTests
+ */
public int getTotalTests()
{
return this.totalTests;
}
+ /**
+ * Setter for an attribute totalTests.
+ *
+ * @param totalTests
+ * new value of an attribute totalTests
+ */
public void setTotalTests(int totalTests)
{
this.totalTests = totalTests;
}
+ /**
+ * Getter for an attribute sameImages.
+ *
+ * @return value of an attribute sameImages
+ */
public int getSameImages()
{
return this.sameImages;
}
+ /**
+ * Setter for an attribute sameImages.
+ *
+ * @param sameImages
+ * new value of an attribute sameImages
+ */
public void setSameImages(int sameImages)
{
this.sameImages = sameImages;
}
+ /**
+ * Getter for an attribute differentImages.
+ *
+ * @return value of an attribute differentImages
+ */
public int getDifferentImages()
{
return this.differentImages;
}
+ /**
+ * Setter for an attribute differentImages.
+ *
+ * @param differentImages
+ * new value of an attribute differentImages
+ */
public void setDifferentImages(int differentImages)
{
this.differentImages = differentImages;
}
+ /**
+ * Returns string containing test results.
+ */
@SuppressWarnings({ "boxing", "nls" })
@Override
public String toString()
More information about the distro-pkg-dev
mailing list