You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2012/12/04 16:16:15 UTC
svn commit: r1416984 [2/2] - in
/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging: ./
common/bytesource/ examples/ formats/bmp/ formats/dcx/ formats/gif/
formats/icns/ formats/ico/ formats/jpeg/ formats/jpeg/exif/
formats/jpeg/iptc...
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java?rev=1416984&r1=1416983&r2=1416984&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java Tue Dec 4 15:16:02 2012
@@ -33,14 +33,16 @@ public class XmpUpdateTest extends Imagi
public void test() throws Exception {
List<File> images = getTestImages();
for (int i = 0; i < images.size(); i++) {
- if (i % 10 == 0)
+ if (i % 10 == 0) {
Debug.purgeMemory();
+ }
File imageFile = images.get(i);
if (imageFile.getName().toLowerCase().endsWith(".png")
- && isInvalidPNGTestFile(imageFile))
+ && isInvalidPNGTestFile(imageFile)) {
continue;
+ }
Debug.debug("imageFile", imageFile);
Debug.debug();
@@ -49,10 +51,12 @@ public class XmpUpdateTest extends Imagi
String xmpXml = Imaging.getXmpXml(imageFile);
if (null == xmpXml
- && imageFormat.equals(ImageFormat.IMAGE_FORMAT_GIF))
+ && imageFormat.equals(ImageFormat.IMAGE_FORMAT_GIF)) {
xmpXml = "temporary test until I can locate a GIF with XMP in the wild.";
- if (null == xmpXml)
+ }
+ if (null == xmpXml) {
continue;
+ }
assertNotNull(xmpXml);
@@ -68,8 +72,9 @@ public class XmpUpdateTest extends Imagi
* do
* nothing
*/
- } else
+ } else {
continue;
+ }
File tempFile = this.createTempFile(imageFile.getName() + ".", "."
+ imageFormat.getExtension());
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xpm/XpmReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xpm/XpmReadTest.java?rev=1416984&r1=1416983&r2=1416984&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xpm/XpmReadTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xpm/XpmReadTest.java Tue Dec 4 15:16:02 2012
@@ -33,8 +33,9 @@ public class XpmReadTest extends XpmBase
List<File> images = getXpmImages();
for (int i = 0; i < images.size(); i++) {
- if (i % 10 == 0)
+ if (i % 10 == 0) {
Debug.purgeMemory();
+ }
File imageFile = images.get(i);
Debug.debug("imageFile", imageFile);
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java?rev=1416984&r1=1416983&r2=1416984&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java Tue Dec 4 15:16:02 2012
@@ -105,33 +105,35 @@ public class RoundtripTest extends Imagi
private BufferedImage createArgbBitmapImage(int width, int height) {
BufferedImage result = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
// alternating black and white.
int modulator = y + 2; // make sure lines vary.
int argb = (x + y) % modulator == 0 ? 0xff000000 : 0xffffffff;
result.setRGB(x, y, argb);
}
+ }
return result;
}
private BufferedImage createBitmapBitmapImage(int width, int height) {
BufferedImage result = new BufferedImage(width, height,
BufferedImage.TYPE_BYTE_BINARY);
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
// alternating black and white.
int modulator = y + 2; // make sure lines vary.
int argb = (x + y) % modulator == 0 ? 0xff000000 : 0xffffffff;
result.setRGB(x, y, argb);
}
+ }
return result;
}
private BufferedImage createArgbGrayscaleImage(int width, int height) {
BufferedImage result = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int value = (256 * (x + y)) / (width + height);
int argb = (0xff << 24) | (value << 16) | (value << 8)
@@ -139,13 +141,14 @@ public class RoundtripTest extends Imagi
result.setRGB(x, y, argb);
}
+ }
return result;
}
private BufferedImage createGrayscaleGrayscaleImage(int width, int height) {
BufferedImage result = new BufferedImage(width, height,
BufferedImage.TYPE_BYTE_GRAY);
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int value = (256 * (x + y)) / (width + height);
int argb = (0xff << 24) | (value << 16) | (value << 8)
@@ -153,6 +156,7 @@ public class RoundtripTest extends Imagi
result.setRGB(x, y, argb);
}
+ }
return result;
}
@@ -162,18 +166,19 @@ public class RoundtripTest extends Imagi
BufferedImage result = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int argb = colors[(x + y) % colors.length];
result.setRGB(x, y, argb);
}
+ }
return result;
}
private BufferedImage createFullColorImage(int width, int height) {
BufferedImage result = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int red = (x * 255) / width;
int green = (y * 255) / height;
@@ -182,6 +187,7 @@ public class RoundtripTest extends Imagi
| (blue << 0);
result.setRGB(x, y, argb);
}
+ }
return result;
}
@@ -198,13 +204,15 @@ public class RoundtripTest extends Imagi
assertEquals(a.getWidth(), b.getWidth());
assertEquals(a.getHeight(), b.getHeight());
- for (int x = 0; x < a.getWidth(); x++)
+ for (int x = 0; x < a.getWidth(); x++) {
for (int y = 0; y < a.getHeight(); y++) {
int a_argb = a.getRGB(x, y);
int b_argb = b.getRGB(x, y);
if (a_argb != b_argb) {
if (calculateARGBDistance(a_argb, b_argb) <= tolerance)
+ {
continue; // ignore.
+ }
}
if (a_argb != b_argb) {
Debug.debug("width", a.getWidth());
@@ -220,6 +228,7 @@ public class RoundtripTest extends Imagi
}
assertEquals(a_argb, b_argb);
}
+ }
}
private int calculateARGBDistance(int a, int b) {
@@ -279,8 +288,9 @@ public class RoundtripTest extends Imagi
for (BufferedImage testImage : testImages) {
for (FormatInfo element : FORMAT_INFOS) {
FormatInfo formatInfo = element;
- if ((!formatInfo.canRead) || (!formatInfo.canWrite))
+ if ((!formatInfo.canRead) || (!formatInfo.canWrite)) {
continue;
+ }
Debug.debug("bitmap test: " + formatInfo.format.getName());
@@ -306,14 +316,16 @@ public class RoundtripTest extends Imagi
for (BufferedImage testImage : testImages) {
for (FormatInfo element : FORMAT_INFOS) {
FormatInfo formatInfo = element;
- if ((!formatInfo.canRead) || (!formatInfo.canWrite))
+ if ((!formatInfo.canRead) || (!formatInfo.canWrite)) {
continue;
+ }
Debug.debug("grayscale test: " + formatInfo.format.getName());
boolean imageExact = true;
- if (formatInfo.colorSupport == COLOR_BITMAP)
+ if (formatInfo.colorSupport == COLOR_BITMAP) {
imageExact = false;
+ }
roundtrip(formatInfo, testImage, "gray", imageExact);
}
@@ -332,16 +344,19 @@ public class RoundtripTest extends Imagi
for (BufferedImage testImage : testImages) {
for (FormatInfo element : FORMAT_INFOS) {
FormatInfo formatInfo = element;
- if ((!formatInfo.canRead) || (!formatInfo.canWrite))
+ if ((!formatInfo.canRead) || (!formatInfo.canWrite)) {
continue;
+ }
Debug.debug("indexable test: " + formatInfo.format.getName());
boolean imageExact = true;
- if (formatInfo.colorSupport == COLOR_BITMAP)
+ if (formatInfo.colorSupport == COLOR_BITMAP) {
imageExact = false;
- if (formatInfo.colorSupport == COLOR_GRAYSCALE)
+ }
+ if (formatInfo.colorSupport == COLOR_GRAYSCALE) {
imageExact = false;
+ }
roundtrip(formatInfo, testImage, "indexable", imageExact);
}
@@ -360,18 +375,22 @@ public class RoundtripTest extends Imagi
for (BufferedImage testImage : testImages) {
for (FormatInfo element : FORMAT_INFOS) {
FormatInfo formatInfo = element;
- if ((!formatInfo.canRead) || (!formatInfo.canWrite))
+ if ((!formatInfo.canRead) || (!formatInfo.canWrite)) {
continue;
+ }
Debug.debug("fullColor test: " + formatInfo.format.getName());
boolean imageExact = true;
- if (formatInfo.colorSupport == COLOR_BITMAP)
+ if (formatInfo.colorSupport == COLOR_BITMAP) {
imageExact = false;
- if (formatInfo.colorSupport == COLOR_GRAYSCALE)
+ }
+ if (formatInfo.colorSupport == COLOR_GRAYSCALE) {
imageExact = false;
- if (formatInfo.colorSupport == COLOR_LIMITED_INDEX)
+ }
+ if (formatInfo.colorSupport == COLOR_LIMITED_INDEX) {
imageExact = false;
+ }
roundtrip(formatInfo, testImage, "fullColor", imageExact);
}
@@ -382,8 +401,9 @@ public class RoundtripTest extends Imagi
ImageReadException, ImageWriteException {
BufferedImage testImage = createFullColorImage(2, 2);
for (FormatInfo formatInfo : FORMAT_INFOS) {
- if (!formatInfo.canRead || !formatInfo.canWrite || !formatInfo.preservesResolution)
+ if (!formatInfo.canRead || !formatInfo.canWrite || !formatInfo.preservesResolution) {
continue;
+ }
Debug.debug("pixel density test: " + formatInfo.format.getName());
@@ -396,8 +416,9 @@ public class RoundtripTest extends Imagi
Imaging.writeImage(testImage, temp1, formatInfo.format, params);
ImageInfo imageInfo = Imaging.getImageInfo(temp1);
- if (imageInfo == null)
+ if (imageInfo == null) {
continue;
+ }
int xReadDPI = imageInfo.getPhysicalWidthDpi();
int yReadDPI = imageInfo.getPhysicalHeightDpi();
// allow a 5% margin of error in storage and conversion
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/test/util/FileSystemTraversal.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/test/util/FileSystemTraversal.java?rev=1416984&r1=1416983&r2=1416984&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/test/util/FileSystemTraversal.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/test/util/FileSystemTraversal.java Tue Dec 4 15:16:02 2012
@@ -57,8 +57,9 @@ public class FileSystemTraversal {
if (file.isFile()) {
if ((mode == MODE_FILES) || (mode == MODE_FILES_AND_FOLDERS)
|| (mode == MODE_ALL)) {
- if (!visitor.visit(file, estimate))
+ if (!visitor.visit(file, estimate)) {
return false;
+ }
}
} else if (file.isDirectory()) {
File files[] = file.listFiles();
@@ -78,20 +79,23 @@ public class FileSystemTraversal {
if (!traverse(child, mode, visitor, estimate
+ estimateIncrement * i / files.length,
- estimateIncrement / files.length))
+ estimateIncrement / files.length)) {
return false;
+ }
}
}
if ((mode == MODE_FOLDERS) || (mode == MODE_FILES_AND_FOLDERS)
|| (mode == MODE_ALL)) {
- if (!visitor.visit(file, estimate))
+ if (!visitor.visit(file, estimate)) {
return false;
+ }
}
} else {
if (mode == MODE_ALL) {
- if (!visitor.visit(file, estimate))
+ if (!visitor.visit(file, estimate)) {
return false;
+ }
}
}
@@ -136,21 +140,25 @@ public class FileSystemTraversal {
if (ON_MAC_OS_X) {
File Volumes = new File("/Volumes/");
roots = Volumes.listFiles();
- } else
+ } else {
roots = File.listRoots();
+ }
- if (roots == null)
+ if (roots == null) {
return false;
+ }
for (int i = 0; i < roots.length; i++) {
File root = roots[i];
- if (root == null || !root.exists())
+ if (root == null || !root.exists()) {
continue;
+ }
if (!traverse(roots[i], mode, visitor, estimate + estimateIncrement
- * i / roots.length, estimateIncrement / roots.length))
+ * i / roots.length, estimateIncrement / roots.length)) {
return false;
+ }
}
return true;