This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: Image op tests
- From: Francis Kung <fkung at redhat dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Wed, 02 Aug 2006 14:30:10 -0400
- Subject: FYI: Image op tests
This patch (committed) adds a number of tests to
java.awt.AffineTransformOp and BandCombineOp
Francis
2006-08-02 Francis Kung <fkung@redhat.com>
* gnu/testlet/java/awt/image/AffineTransformOp/constructors.java,
*
gnu/testlet/java/awt/image/AffineTransformOp/createCompatibleDestImage.java,
* gnu/testlet/java/awt/image/AffineTransformOp/filterImage.java,
* gnu/testlet/java/awt/image/AffineTransformOp/filterRaster.java,
* gnu/testlet/java/awt/image/AffineTransformOp/getBounds2D.java,
* gnu/testlet/java/awt/image/AffineTransformOp/getPoint2D.java,
* gnu/testlet/java/awt/image/BandCombineOp/constructors.java,
*
gnu/testlet/java/awt/image/BandCombineOp/createCompatibleDestRaster.java,
* gnu/testlet/java/awt/image/BandCombineOp/filter.java,
* gnu/testlet/java/awt/image/BandComgineOp/getBounds2D.java,
* gnu/testlet/java/awt/image/BandCombineOp/getPoint2D.java,
### Eclipse Workspace Patch 1.0
#P mauve
Index: gnu/testlet/java/awt/image/BandCombineOp/constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/image/BandCombineOp/constructors.java
diff -N gnu/testlet/java/awt/image/BandCombineOp/constructors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/BandCombineOp/constructors.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,88 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.BandCombineOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.BandCombineOp;
+import java.awt.image.ImagingOpException;
+import java.util.Arrays;
+
+/**
+ * Some checks for the constructors in the {@link BandCombineOp} class.
+ */
+public class constructors implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("(constructor)");
+
+ float[][] matrix = new float[][] {new float[]{1, 2, 3},
+ new float[]{4, 5, 6},
+ new float[]{7, 8, 9}};
+
+ BandCombineOp op = new BandCombineOp(matrix, null);
+
+ float[][] resultMatrix = op.getMatrix();
+ float[][] expectedMatrix = new float[][] {new float[]{1, 2, 3, 0},
+ new float[]{4, 5, 6, 0},
+ new float[]{7, 8, 9, 0}};
+ // The ref impl seems to add a column of zeros, so we test against that
+ // for compatibility
+
+ if (expectedMatrix.length != resultMatrix.length)
+ harness.check(false);
+ else
+ for (int i = 0; i < expectedMatrix.length; i++)
+ harness.check(Arrays.equals(expectedMatrix[i], resultMatrix[i]));
+
+ // Try creating with an empty matrix - this should be allowed
+ matrix = new float[][] {new float[]{},
+ new float[]{}};
+
+ try
+ {
+ new BandCombineOp(matrix, null);
+ harness.check(true);
+ }
+ catch (ImagingOpException e)
+ {
+ harness.check(false);
+ }
+
+ op = new BandCombineOp(matrix, null);
+ resultMatrix = op.getMatrix();
+ expectedMatrix = new float[][] {new float[]{0},
+ new float[]{0}};
+
+ if (expectedMatrix.length != resultMatrix.length)
+ harness.check(false);
+ else
+ for (int i = 0; i < expectedMatrix.length; i++)
+ harness.check(Arrays.equals(expectedMatrix[i], resultMatrix[i]));
+ }
+}
Index: gnu/testlet/java/awt/image/BandCombineOp/createCompatibleDestRaster.java
===================================================================
RCS file: gnu/testlet/java/awt/image/BandCombineOp/createCompatibleDestRaster.java
diff -N gnu/testlet/java/awt/image/BandCombineOp/createCompatibleDestRaster.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/BandCombineOp/createCompatibleDestRaster.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,103 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.BandCombineOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Point;
+import java.awt.image.BandCombineOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+
+/**
+ * Checks for the createCompatibleDestRaster method in the
+ * {@link BandCombineOp} class.
+ */
+public class createCompatibleDestRaster implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("createCompatibleDestRaster");
+
+ // Simple test
+ float[][] matrix = new float[][] {new float[] {1, 2, 3},
+ new float[] {4, 5, 6},
+ new float[] {7, 8, 9}};
+
+ Raster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, 3, new Point(5, 5));
+ BandCombineOp op = new BandCombineOp(matrix, null);
+
+ try
+ {
+ Raster dst = op.createCompatibleDestRaster(src);
+ harness.check(dst.getNumBands(), 3);
+ harness.check(dst.getHeight(), src.getHeight());
+ harness.check(dst.getWidth(), src.getWidth());
+ harness.check(dst.getDataBuffer().getDataType(), src.getDataBuffer().getDataType());
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(false);
+ }
+
+ src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, 3, new Point(5, 5));
+ try
+ {
+ Raster dst = op.createCompatibleDestRaster(src);
+ harness.check(dst.getNumBands(), 3);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(false);
+ }
+
+ // The source (4 bands) is incompatible with the matrix (2 or 3 bands)
+ src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, 4, new Point(5, 5));
+ try
+ {
+ op.createCompatibleDestRaster(src);
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+
+ // The source (1 band) is incompatible with the matrix (2 or 3 bands)
+ src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, 1, new Point(5, 5));
+ try
+ {
+ op.createCompatibleDestRaster(src);
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+ }
+}
+
Index: gnu/testlet/java/awt/image/AffineTransformOp/createCompatibleDestImage.java
===================================================================
RCS file: gnu/testlet/java/awt/image/AffineTransformOp/createCompatibleDestImage.java
diff -N gnu/testlet/java/awt/image/AffineTransformOp/createCompatibleDestImage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/AffineTransformOp/createCompatibleDestImage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,90 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.AffineTransformOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import java.awt.image.DirectColorModel;
+
+/**
+ * Checks for the createCompatibleDestImage method in the
+ * {@link AffineTransformOp} class.
+ */
+public class createCompatibleDestImage implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("createCompatibleDestImage");
+
+ // Simple test
+ AffineTransform xform = new AffineTransform();
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+
+ BufferedImage img = new BufferedImage(25, 40, BufferedImage.TYPE_INT_RGB);
+
+ BufferedImage dest = op.createCompatibleDestImage(img, img.getColorModel());
+
+ harness.check(dest.getHeight(), 40);
+ harness.check(dest.getWidth(), 25);
+ harness.check(dest.getColorModel(), img.getColorModel());
+
+ // Try a different colour model
+ img = new BufferedImage(25, 40, BufferedImage.TYPE_INT_RGB);
+ DirectColorModel cm = new DirectColorModel(16, 0x0f00, 0x00f0, 0x000f);
+ dest = op.createCompatibleDestImage(img, cm);
+
+ harness.check(dest.getHeight(), 40);
+ harness.check(dest.getWidth(), 25);
+ harness.check(dest.getColorModel(), cm);
+
+ // And the default color model
+ dest = op.createCompatibleDestImage(img, null);
+ harness.check(dest.getColorModel(), new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000));
+ //harness.check(dest.getColorModel(), img.getColorModel()) makes more sense,
+ // but that fails on the reference implementation...
+
+ /*
+ // Throw the right exceptions
+ img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
+ xform.scale(0.00000000000000001, 0.00000000000000001);
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ try
+ {
+ op.createCompatibleDestImage(img, null);
+ harness.check(false);
+ }
+ catch (RasterFormatException e)
+ {
+ harness.check(true);
+ }
+ */
+ }
+}
+
Index: gnu/testlet/java/awt/image/BandCombineOp/filter.java
===================================================================
RCS file: gnu/testlet/java/awt/image/BandCombineOp/filter.java
diff -N gnu/testlet/java/awt/image/BandCombineOp/filter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/BandCombineOp/filter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,177 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.BandCombineOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Point;
+import java.awt.image.BandCombineOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.util.Arrays;
+
+/**
+ * Checks the filter method in the {@link BandCombineOp} class.
+ */
+public class filter implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("filter");
+
+ float[][] matrix = new float[][] {{2, 7},
+ {5, 6}};
+
+ WritableRaster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 5, 5, 2, new Point(0,0));
+
+ /* Setting up:
+ [0] [1] [2] [3] [4]
+ [0] . . x . .
+ [1] . . . . .
+ [2] . . . . .
+ [3] . . . . .
+ [4] . . . . x
+ with two bands
+ */
+ src.setSample(2, 1, 0, 150);
+ src.setSample(4, 4, 0, 85);
+ src.setSample(2, 1, 1, 25);
+ src.setSample(4, 4, 1, 110);
+
+
+ // Basic checks on output
+ BandCombineOp op = new BandCombineOp(matrix, null);
+ WritableRaster dst2 = op.createCompatibleDestRaster(src);
+ WritableRaster dst = op.filter(src, dst2);
+ harness.check(dst, dst2);
+ harness.check(dst.getNumBands(), 2);
+
+ // A null dst2 should also work
+ dst2 = null;
+ dst = op.filter(src, dst2);
+ harness.check(dst instanceof WritableRaster);
+ harness.check(dst2, null);
+
+ // Check first band
+ int[] pixels = dst.getSamples(0, 0, 5, 5, 0, (int[])null);
+
+ int[] expected = new int[25];
+ Arrays.fill(expected, 0);
+ expected[7] = 475;
+ expected[24] = 940;
+ harness.check(Arrays.equals(expected, pixels));
+
+ // Check second band
+ pixels = dst.getSamples(0, 0, 5, 5, 1, pixels);
+ expected[7] = 900;
+ expected[24] = 1085;
+ harness.check(Arrays.equals(expected, pixels));
+
+ // Check the implied 1 at the end of the band samples, which happens if
+ // there is one more column in the matrix than there are bands
+ // And throw in a check with negative numbers too... why not =)
+ matrix = new float[][] {{2, -7, 5},
+ {5, 6, -3}};
+ op = new BandCombineOp(matrix, null);
+ dst = op.filter(src, dst);
+
+ // First band
+ pixels = dst.getSamples(0, 0, 5, 5, 0, (int[])null);
+ Arrays.fill(expected, 5);
+ expected[7] = 130;
+ expected[24] = -595;
+ harness.check(Arrays.equals(expected, pixels));
+ // Second band
+ pixels = dst.getSamples(0, 0, 5, 5, 1, (int[])null);
+ Arrays.fill(expected, -3);
+ expected[7] = 897;
+ expected[24] = 1082;
+ harness.check(Arrays.equals(expected, pixels));
+
+ // Check for overflow (this should fail silently and not throw an exception)
+ matrix = new float[][] {{2000000000, 2000000000},
+ {2000000000, 2000000000}};
+ try
+ {
+ op = new BandCombineOp(matrix, null);
+ dst = op.filter(src, dst);
+ harness.check(true);
+ }
+ catch (Exception e)
+ {
+ harness.check(false);
+ }
+
+ // Check for exceptions
+ try
+ {
+ expected[25] = 100;
+ harness.check(false);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ harness.check(true);
+ }
+
+ // accessing invalid band number
+ try
+ {
+ pixels = dst.getSamples(0, 0, 5, 5, 2, pixels);
+ harness.check(false);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ harness.check(true);
+ }
+
+ // dst has wrong number of bands
+ dst = Raster.createBandedRaster(DataBuffer.TYPE_INT, 5, 5, 6, new Point(0,0));
+ try
+ {
+ dst = op.filter(src, dst);
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+
+ // dst has wrong data type
+ dst = Raster.createBandedRaster(DataBuffer.TYPE_BYTE, 5, 5, 1, new Point(0,0));
+ try
+ {
+ dst = op.filter(src, dst);
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+ }
+}
+
Index: gnu/testlet/java/awt/image/AffineTransformOp/filterRaster.java
===================================================================
RCS file: gnu/testlet/java/awt/image/AffineTransformOp/filterRaster.java
diff -N gnu/testlet/java/awt/image/AffineTransformOp/filterRaster.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/AffineTransformOp/filterRaster.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,197 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.AffineTransformOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.ImagingOpException;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.util.Arrays;
+
+/**
+ * Checks the filter(BufferedImage) method in the {@link AffineTransformOp} class.
+ */
+public class filterRaster implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ testDefaults(harness, AffineTransformOp.TYPE_BILINEAR);
+ testDefaults(harness, AffineTransformOp.TYPE_BICUBIC);
+ testDefaults(harness, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
+
+ // testTransform(harness); // I don't really like how this test works,
+ // but am leaving it in, in the hopes someone
+ // might be able to base a better test off it
+ }
+
+ private void testDefaults(TestHarness harness, int type)
+ {
+ // Create a raster to work on based on an image
+ BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+ Graphics2D g = (Graphics2D)img.getGraphics();
+ g.draw(new Line2D.Double(0, 0, 20, 20));
+
+ WritableRaster src = img.getRaster();
+ AffineTransform xform = new AffineTransform();
+ AffineTransformOp op = new AffineTransformOp(xform, type);
+
+ // Make sure it works in the first place
+ WritableRaster dest = src.createCompatibleWritableRaster();
+ try
+ {
+ op.filter(src, dest);
+ harness.check(true);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(false);
+ }
+
+ // Src and dst cannot be the same
+ try
+ {
+ op.filter(src, src);
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+
+ // Different type of raster (not allowed)
+ dest = Raster.createBandedRaster(DataBuffer.TYPE_USHORT, 20, 20, 1, new Point(0,0));
+ try
+ {
+ op.filter(src, dest);
+ harness.check(false);
+ }
+ catch (ImagingOpException e)
+ {
+ harness.check(true);
+ }
+
+ // Different size (allowed)
+ dest = src.createCompatibleWritableRaster(75, 87);
+ try
+ {
+ op.filter(src, dest);
+ harness.check(true);
+ }
+ catch (ImagingOpException e)
+ {
+ harness.check(false);
+ }
+
+ // Null destination (allowed - will create one for us)
+ WritableRaster dest2 = op.filter(src, null);
+ harness.check(dest2 != null);
+ }
+
+ private void testTransform(TestHarness harness)
+ {
+ // Create a raster to work on based on an image
+ BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+ Graphics2D g = (Graphics2D)img.getGraphics();
+ g.draw(new Line2D.Double(0, 0, 20, 20));
+
+ WritableRaster src = img.getRaster();
+ AffineTransform xform = AffineTransform.getRotateInstance(Math.PI / 2, 10, 10);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+
+ WritableRaster dst = op.filter(src, null);
+
+ // The following values were found by testing against the ref impl, ie
+ /*
+ int[] pixels = dst.getSamples(0, 0, 20, 20, 0, (int[])null);
+ for (int i = 0; i < pixels.length; i++)
+ {
+ if (pixels[i] != 0)
+ System.out.println(i + ": " + pixels[i]);
+ }
+ */
+ // Note that changing the interpolation type will result in different values.
+ //
+ // I'm not fully convinced this test is good, since pixel variations
+ // in our transformations are tolerable (and visually insignificant)...
+ // but i can't think of any other way to write a test for it.
+ // Trying to draw a Line2D.Double(20, 0, 0, 20) and testing against that
+ // fails on all implementations.
+
+ int[] pixels = dst.getSamples(0, 0, 20, 20, 0, (int[])null);
+
+ int[] pixels2 = new int[400];
+ Arrays.fill(pixels2, 0);
+
+ pixels2[19] = 65535;
+ pixels2[37] = 65535;
+ pixels2[38] = 65535;
+ pixels2[56] = 65535;
+ pixels2[57] = 65535;
+ pixels2[75] = 65535;
+ pixels2[76] = 65535;
+ pixels2[94] = 65535;
+ pixels2[95] = 65535;
+ pixels2[113] = 65535;
+ pixels2[114] = 65535;
+ pixels2[132] = 65535;
+ pixels2[133] = 65535;
+ pixels2[151] = 65535;
+ pixels2[152] = 65535;
+ pixels2[170] = 65535;
+ pixels2[171] = 65535;
+ pixels2[189] = 65535;
+ pixels2[190] = 65535;
+ pixels2[208] = 65535;
+ pixels2[209] = 65535;
+ pixels2[227] = 65535;
+ pixels2[228] = 65535;
+ pixels2[246] = 65535;
+ pixels2[247] = 65535;
+ pixels2[265] = 65535;
+ pixels2[266] = 65535;
+ pixels2[284] = 65535;
+ pixels2[285] = 65535;
+ pixels2[303] = 65535;
+ pixels2[304] = 65535;
+ pixels2[322] = 65535;
+ pixels2[323] = 65535;
+ pixels2[342] = 65535;
+ pixels2[361] = 65535;
+ pixels2[380] = 65534;
+
+ harness.check(Arrays.equals(pixels, pixels2));
+ }
+}
+
Index: gnu/testlet/java/awt/image/BandCombineOp/getPoint2D.java
===================================================================
RCS file: gnu/testlet/java/awt/image/BandCombineOp/getPoint2D.java
diff -N gnu/testlet/java/awt/image/BandCombineOp/getPoint2D.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/BandCombineOp/getPoint2D.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,54 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.BandCombineOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.geom.Point2D;
+import java.awt.image.BandCombineOp;
+
+/**
+ * Checks the getPoint2D method in the
+ * {@link BandCombineOp} class.
+ */
+public class getPoint2D implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("getPoint2D");
+
+ // This is a simple test; the BandCombineOp should not change the
+ // geometry of the raster
+
+ float[][] matrix = new float[][] {{2, 7}};
+ BandCombineOp op = new BandCombineOp(matrix, null);
+ Point2D dest = null;
+ dest = op.getPoint2D(new Point2D.Double(3, 3), dest);
+ harness.check(dest, new Point2D.Double(3, 3));
+ }
+}
+
Index: gnu/testlet/java/awt/image/AffineTransformOp/filterImage.java
===================================================================
RCS file: gnu/testlet/java/awt/image/AffineTransformOp/filterImage.java
diff -N gnu/testlet/java/awt/image/AffineTransformOp/filterImage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/AffineTransformOp/filterImage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,186 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.AffineTransformOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import java.util.Arrays;
+
+/**
+ * Checks the filter(BufferedImage) method in the {@link AffineTransformOp} class.
+ */
+public class filterImage implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ testDefaults(harness);
+ //testTransform(harness); // I don't really like how this test works,
+ // but am leaving it in, in the hopes someone
+ // might be able to base a better test off it
+ }
+
+ private void testDefaults(TestHarness harness)
+ {
+ // Create an image to work on
+ BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+ Graphics2D g = (Graphics2D)img.getGraphics();
+ g.draw(new Line2D.Double(0, 0, 20, 20));
+
+ AffineTransform xform = new AffineTransform();
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+
+ // Src and dst images cannot be the same
+ try
+ {
+ op.filter(img, img);
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+
+ // Src and dst are different sizes (allowed)
+ BufferedImage dst = new BufferedImage(30, 40, BufferedImage.TYPE_USHORT_GRAY);
+ try
+ {
+ op.filter(img, dst);
+ harness.check(true);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(false);
+ }
+
+ // Src and dst have different tpyes (allowed)
+ dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
+ try
+ {
+ op.filter(img, dst);
+ harness.check(true);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(false);
+ }
+
+ // Src and dst are different sizes AND different types (not allowed)
+ dst = new BufferedImage(30, 40, BufferedImage.TYPE_INT_ARGB);
+ try
+ {
+ op.filter(img, dst);
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+ }
+
+ private void testTransform(TestHarness harness)
+ {
+ // Create an image to work on
+ BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+ Graphics2D g = (Graphics2D)img.getGraphics();
+ g.draw(new Line2D.Double(0, 0, 20, 20));
+
+ AffineTransform xform = AffineTransform.getRotateInstance(Math.PI / 2, 10, 10);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+
+ BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
+ BufferedImage dst2 = op.filter(img, dst);
+
+ harness.check(dst, dst2);
+
+ // The following values were found by testing against the ref impl, ie
+ /*
+ int[] pixels = img.getData().getPixels(0, 0, 20, 20, (int[])null);
+ for (int i = 0; i < pixels.length; i++)
+ {
+ if (pixels[i] != 0)
+ System.out.println(i + ": " + pixels[i]);
+ }
+ */
+ // Note that changing the interpolation type will result in different values.
+ //
+ // I'm not fully convinced this test is good, since pixel variations
+ // in our transformations are tolerable (and visually insignificant)...
+ // but i can't think of any other way to write a test for it.
+ // Trying to draw a Line2D.Double(20, 0, 0, 20) and testing against that
+ // fails on all implementations.
+
+ int[] pixels = dst.getData().getPixels(0,0,20,20,(int[])null);
+
+ int[] pixels2 = new int[400];
+ Arrays.fill(pixels2, 0);
+
+ pixels2[19] = 65535;
+ pixels2[37] = 65535;
+ pixels2[38] = 65535;
+ pixels2[56] = 65535;
+ pixels2[57] = 65535;
+ pixels2[75] = 65535;
+ pixels2[76] = 65535;
+ pixels2[94] = 65535;
+ pixels2[95] = 65535;
+ pixels2[113] = 65535;
+ pixels2[114] = 65535;
+ pixels2[132] = 65535;
+ pixels2[133] = 65535;
+ pixels2[151] = 65535;
+ pixels2[152] = 65535;
+ pixels2[170] = 65535;
+ pixels2[171] = 65535;
+ pixels2[189] = 65535;
+ pixels2[190] = 65535;
+ pixels2[208] = 65535;
+ pixels2[209] = 65535;
+ pixels2[227] = 65535;
+ pixels2[228] = 65535;
+ pixels2[246] = 65535;
+ pixels2[247] = 65535;
+ pixels2[265] = 65535;
+ pixels2[266] = 65535;
+ pixels2[284] = 65535;
+ pixels2[285] = 65535;
+ pixels2[303] = 65535;
+ pixels2[304] = 65535;
+ pixels2[322] = 65535;
+ pixels2[323] = 65535;
+ pixels2[342] = 65535;
+ pixels2[361] = 65535;
+ pixels2[380] = 65534;
+
+ harness.check(Arrays.equals(pixels, pixels2));
+ }
+}
+
Index: gnu/testlet/java/awt/image/BandCombineOp/getBounds2D.java
===================================================================
RCS file: gnu/testlet/java/awt/image/BandCombineOp/getBounds2D.java
diff -N gnu/testlet/java/awt/image/BandCombineOp/getBounds2D.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/BandCombineOp/getBounds2D.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,72 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.BandCombineOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Point;
+import java.awt.image.BandCombineOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+/**
+ * Checks the getBounds2D method in the
+ * {@link BandCombineOp} class.
+ */
+public class getBounds2D implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("getBounds2D");
+
+ // This is a simple test; the BandCombineOp should not change the
+ // dimensions of the raster
+
+ float[][] matrix = new float[][] {{2, 7}};
+ WritableRaster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 5, 5, 1, new Point(0,0));
+ BandCombineOp op = new BandCombineOp(matrix, null);
+ harness.check(op.getBounds2D(src), src.getBounds());
+
+ // This should throw an exception, as the bands in the source do not
+ // match the rows in the matrix
+ /*
+ * The spec says it *MAY* throw an exception; the ref. impl does not do so...
+ src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 5, 5, 3, new Point(0,0));
+ try
+ {
+ harness.check(op.getBounds2D(src), src.getBounds());
+ harness.check(false);
+ }
+ catch (IllegalArgumentException e)
+ {
+ harness.check(true);
+ }
+ */
+ }
+}
+
Index: gnu/testlet/java/awt/image/AffineTransformOp/getPoint2D.java
===================================================================
RCS file: gnu/testlet/java/awt/image/AffineTransformOp/getPoint2D.java
diff -N gnu/testlet/java/awt/image/AffineTransformOp/getPoint2D.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/AffineTransformOp/getPoint2D.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,122 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.AffineTransformOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.image.AffineTransformOp;
+
+/**
+ * Checks the getPoint2D method in the
+ * {@link AffineTransformOp} class.
+ */
+public class getPoint2D implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ testIdentity(harness);
+ testRotation(harness);
+ testScale(harness);
+ testShear(harness);
+ testTranslation(harness);
+ }
+
+ private void testIdentity(TestHarness harness)
+ {
+ harness.checkPoint("testIdentity");
+
+ AffineTransform xform = new AffineTransform();
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(5,5));
+
+ Point2D pt = null;
+ op.getPoint2D(new Point2D.Double(10,-5), pt);
+ harness.check(pt, null); // this is what the ref impl does...
+
+ pt = new Point2D.Double(0,0);
+ op.getPoint2D(new Point2D.Double(10,-5), pt);
+ harness.check(pt, new Point2D.Double(10, -5));
+
+ pt = new Point2D.Float(0,0);
+ op.getPoint2D(new Point2D.Float(-10,-5), pt);
+ harness.check(pt, new Point2D.Float(-10, -5));
+ }
+
+ private void testRotation(TestHarness harness)
+ {
+ harness.checkPoint("testRotation");
+
+ AffineTransform xform = AffineTransform.getRotateInstance(Math.PI / 2);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(-5,5));
+
+ // Do it again, but result in a diamond (not another level rectangle)
+ xform.rotate(Math.PI / 3);
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(-6.830127018922193, -1.8301270189221923));
+
+ // Rotation about a point
+ xform.setToIdentity();
+ xform.rotate(Math.PI / 2, 10, 2);
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(7,-3));
+ }
+
+ private void testScale(TestHarness harness)
+ {
+ harness.checkPoint("testScale");
+
+ AffineTransform xform = AffineTransform.getScaleInstance(1.0, 1.0);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(5, 5));
+
+ xform.scale(2.5, 4.75);
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(12.5,23.75));
+ }
+
+ private void testShear(TestHarness harness)
+ {
+ harness.checkPoint("testHarness");
+
+ AffineTransform xform = AffineTransform.getShearInstance(1.5, 3.25);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(12.5,21.25));
+ }
+
+ private void testTranslation(TestHarness harness)
+ {
+ harness.checkPoint("testTranslation");
+
+ AffineTransform xform = AffineTransform.getTranslateInstance(75, 50);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(80,55));
+ }
+}
+
Index: gnu/testlet/java/awt/image/AffineTransformOp/getBounds2D.java
===================================================================
RCS file: gnu/testlet/java/awt/image/AffineTransformOp/getBounds2D.java
diff -N gnu/testlet/java/awt/image/AffineTransformOp/getBounds2D.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/AffineTransformOp/getBounds2D.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,119 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.AffineTransformOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+
+/**
+ * Checks the getBounds2D method in the
+ * {@link AffineTransformOp} class.
+ */
+public class getBounds2D implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ testIdentity(harness);
+ testRotation(harness);
+ testScale(harness);
+ testShear(harness);
+ testTranslation(harness);
+ }
+
+ private void testIdentity(TestHarness harness)
+ {
+ harness.checkPoint("testIdentity");
+
+ AffineTransform xform = new AffineTransform();
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 30, 40));
+ }
+
+ private void testRotation(TestHarness harness)
+ {
+ harness.checkPoint("testRotation");
+
+ AffineTransform xform = AffineTransform.getRotateInstance(Math.PI / 2);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(-40, 0, 40, 30));
+
+ // Do it again, but result in a diamond (not another level rectangle)
+ xform.rotate(Math.PI / 3);
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(-45.980762f,
+ -34.641018f,
+ 45.980762f,
+ 49.641018f));
+
+ // Rotation about a point
+ xform.setToIdentity();
+ xform.rotate(Math.PI / 2, 10, 15);
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(-15, 5, 40, 30));
+ }
+
+ private void testScale(TestHarness harness)
+ {
+ harness.checkPoint("testScale");
+
+ AffineTransform xform = AffineTransform.getScaleInstance(1.0, 1.0);
+ BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 30, 40));
+
+ xform.scale(2.5, 4.75);
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 75, 190));
+ }
+
+ private void testShear(TestHarness harness)
+ {
+ harness.checkPoint("testHarness");
+
+ AffineTransform xform = AffineTransform.getShearInstance(1.5, 3.25);
+ BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 90, 137.5f));
+ }
+
+ private void testTranslation(TestHarness harness)
+ {
+ harness.checkPoint("testTranslation");
+
+ AffineTransform xform = AffineTransform.getTranslateInstance(75, 50);
+ BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getBounds2D(img), new Rectangle2D.Float(75, 50, 30, 40));
+ }
+}
+
Index: gnu/testlet/java/awt/image/AffineTransformOp/constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/image/AffineTransformOp/constructors.java
diff -N gnu/testlet/java/awt/image/AffineTransformOp/constructors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/AffineTransformOp/constructors.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,116 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2006 Francis Kung <fkung@redhat.com>
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.awt.image.AffineTransformOp;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.ImagingOpException;
+
+/**
+ * Some checks for the constructors in the {@link AffineTransformOp} class.
+ */
+public class constructors implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ testConstructor1(harness);
+ testConstructor2(harness);
+ }
+
+ public void testConstructor1(TestHarness harness)
+ {
+ harness.checkPoint("(xform, interpolationType)");
+
+ // Simple test
+ AffineTransform xform = new AffineTransform();
+ AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+
+ harness.check(op.getTransform(), xform);
+
+ harness.check(op.getInterpolationType(), AffineTransformOp.TYPE_BICUBIC);
+ harness.check(op.getRenderingHints(), new RenderingHints(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BICUBIC));
+
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BILINEAR);
+ harness.check(op.getTransform(), xform);
+ harness.check(op.getInterpolationType(), AffineTransformOp.TYPE_BILINEAR);
+ harness.check(op.getRenderingHints(), new RenderingHints(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BILINEAR));
+
+ op = new AffineTransformOp(xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
+ harness.check(op.getTransform(), xform);
+ harness.check(op.getInterpolationType(), AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
+ harness.check(op.getRenderingHints(), new RenderingHints(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR));
+
+
+ // Try creating with invalid transofrm
+ xform = new AffineTransform(0, 0, 0, 0, 0, 0);
+
+ try
+ {
+ new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
+ harness.check(false);
+ }
+ catch (ImagingOpException e)
+ {
+ harness.check(true);
+ }
+
+ }
+
+ public void testConstructor2(TestHarness harness)
+ {
+ harness.checkPoint("(xform, hints)");
+
+ // Simple test
+ RenderingHints hints = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING,
+ RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ AffineTransform xform = new AffineTransform();
+ AffineTransformOp op = new AffineTransformOp(xform, hints);
+
+ harness.check(op.getTransform(), xform);
+ harness.check(op.getRenderingHints(), hints);
+
+ // Try creating with invalid transofrm
+ xform = new AffineTransform(0, 0, 0, 0, 0, 0);
+
+ try
+ {
+ new AffineTransformOp(xform, hints);
+ harness.check(false);
+ }
+ catch (ImagingOpException e)
+ {
+ harness.check(true);
+ }
+ }
+}
+