/hg/gfx-test: Added support for displaying differences between t...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Oct 7 09:24:28 PDT 2010
changeset 9e7e2cc488e3 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=9e7e2cc488e3
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Oct 07 18:24:55 2010 +0200
Added support for displaying differences between test and sample
images in gfx. test harness GUI.
diffstat:
3 files changed, 71 insertions(+), 34 deletions(-)
Makefile | 2
src/org/gfxtest/ImageDiffer/Configuration.java | 5 +
src/org/gfxtest/harness/MainWindow.java | 98 +++++++++++++++---------
diffs (153 lines):
diff -r faa962e7e25b -r 9e7e2cc488e3 Makefile
--- a/Makefile Thu Oct 07 17:25:10 2010 +0200
+++ b/Makefile Thu Oct 07 18:24:55 2010 +0200
@@ -41,6 +41,7 @@ OUTPUT=output
OUTPUT=output
SAMPLES=samples
RESULTS=results
+TEST_BUILD=test-build
COMMON_DIR=org/gfxtest/common
FRAMEWORK_DIR=org/gfxtest/framework
@@ -245,6 +246,7 @@ clean-output:
rm -rf $(OUTPUT)
clean-test-build:
+ rm -rf $(TEST_BUILD)
clean-results:
rm -rf $(RESULTS)
diff -r faa962e7e25b -r 9e7e2cc488e3 src/org/gfxtest/ImageDiffer/Configuration.java
--- a/src/org/gfxtest/ImageDiffer/Configuration.java Thu Oct 07 17:25:10 2010 +0200
+++ b/src/org/gfxtest/ImageDiffer/Configuration.java Thu Oct 07 18:24:55 2010 +0200
@@ -71,6 +71,11 @@ public class Configuration
private boolean writeStructDiffImages = false;
private Log log = null;
+
+ public Configuration()
+ {
+ this.log = new Log(this.getClass().getName(), true);
+ }
public Configuration(String args[])
{
diff -r faa962e7e25b -r 9e7e2cc488e3 src/org/gfxtest/harness/MainWindow.java
--- a/src/org/gfxtest/harness/MainWindow.java Thu Oct 07 17:25:10 2010 +0200
+++ b/src/org/gfxtest/harness/MainWindow.java Thu Oct 07 18:24:55 2010 +0200
@@ -54,6 +54,9 @@ import javax.swing.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableModel;
+
+import org.gfxtest.ImageDiffer.ComparisonResult;
+import org.gfxtest.ImageDiffer.ImageComparator;
/**
* Main window code and basic application logic for graphic test harness.
@@ -449,44 +452,71 @@ public class MainWindow
+ ".png";
String sampleFileName = FileSystemTools.constructTestDirectoryName(this.configuration.getOutputDirectory(), this.selectedTestSuite);
String testFileName = FileSystemTools.constructTestDirectoryName(this.configuration.getOutputDirectory(), this.selectedTestSuite);
-
- File sampleImageFile = new File(sampleFileName, testName);
- if (sampleImageFile.exists() && sampleImageFile.isFile())
- {
- BufferedImage sampleImage;
- try
- {
- sampleImage = ImageIO.read(new File(sampleFileName, testName));
- this.topRightLabel.setIcon(new ImageIcon(sampleImage));
- this.topRightLabel.setText("");
- }
- catch (IOException e)
- {
- e.printStackTrace();
- this.topRightLabel.setText(e.getMessage());
- }
- }
-
- File testImageFile = new File(testFileName, testName);
- if (testImageFile.exists() && testImageFile.isFile())
- {
- BufferedImage testImage;
- try
- {
- testImage = ImageIO.read(new File(testFileName, testName));
- this.bottomRightLabel.setIcon(new ImageIcon(testImage));
- this.bottomRightLabel.setText("");
- }
- catch (IOException e)
- {
- e.printStackTrace();
- this.bottomRightLabel.setText(e.getMessage());
- }
- }
+ BufferedImage sampleImage = loadAndShowSampleImage(testName, sampleFileName);
+ BufferedImage testImage = loadAndShowTestImage(testName, testFileName);
+ computeAndShowImagesDifference(testName, sampleImage, testImage);
/*
* JOptionPane.showMessageDialog(this.mainWindow, "Selected test: "
* + testName, WINDOW_TITLE, JOptionPane.INFORMATION_MESSAGE);
*/
+ }
+ }
+
+ private BufferedImage loadAndShowTestImage(String testName, String testFileName)
+ {
+ BufferedImage testImage = null;
+ File testImageFile = new File(testFileName, testName);
+ if (testImageFile.exists() && testImageFile.isFile())
+ {
+ try
+ {
+ testImage = ImageIO.read(new File(testFileName, testName));
+ this.bottomRightLabel.setIcon(new ImageIcon(testImage));
+ this.bottomRightLabel.setText("");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ this.bottomRightLabel.setText(e.getMessage());
+ }
+ }
+ return testImage;
+ }
+
+ private BufferedImage loadAndShowSampleImage(String testName, String sampleFileName)
+ {
+ BufferedImage sampleImage = null;
+ File sampleImageFile = new File(sampleFileName, testName);
+ if (sampleImageFile.exists() && sampleImageFile.isFile())
+ {
+ try
+ {
+ sampleImage = ImageIO.read(new File(sampleFileName, testName));
+ this.topRightLabel.setIcon(new ImageIcon(sampleImage));
+ this.topRightLabel.setText("");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ this.topRightLabel.setText(e.getMessage());
+ }
+ }
+ return sampleImage;
+ }
+
+ private void computeAndShowImagesDifference(String testName, BufferedImage sampleImage, BufferedImage testImage)
+ {
+ if (testImage != null && sampleImage != null)
+ {
+ ImageComparator comparator = new ImageComparator();
+ org.gfxtest.ImageDiffer.Configuration cfg = new org.gfxtest.ImageDiffer.Configuration();
+ ComparisonResult result = comparator.diffImages(testName, new BufferedImage[] { testImage, sampleImage }, cfg);
+ this.bottomLeftLabel.setIcon(new ImageIcon(result.getDiffImage()));
+ this.bottomLeftLabel.setText("");
+ }
+ else
+ {
+ this.bottomLeftLabel.setText("difference");
}
}
More information about the distro-pkg-dev
mailing list