mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-04-30 00:00:01 -04:00
Mainly new code standard.
A few changes that should have been committed earlier.. :-/
This commit is contained in:
+3
-3
@@ -18,7 +18,7 @@ import java.util.Random;
|
||||
* @version $Id: BufferedImageInputStreamTestCase.java,v 1.0 Jun 30, 2008 3:07:42 PM haraldk Exp$
|
||||
*/
|
||||
public class BufferedImageInputStreamTestCase extends TestCase {
|
||||
protected final Random mRandom = new Random();
|
||||
protected final Random random = new Random();
|
||||
|
||||
public void testCreate() throws IOException {
|
||||
new BufferedImageInputStream(new ByteArrayImageInputStream(new byte[0]));
|
||||
@@ -58,7 +58,7 @@ public class BufferedImageInputStreamTestCase extends TestCase {
|
||||
|
||||
// Fill bytes
|
||||
byte[] bytes = new byte[size * 2];
|
||||
mRandom.nextBytes(bytes);
|
||||
random.nextBytes(bytes);
|
||||
|
||||
// Create wrapper stream
|
||||
BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes));
|
||||
@@ -79,7 +79,7 @@ public class BufferedImageInputStreamTestCase extends TestCase {
|
||||
public void testBufferPositionCorrect() throws IOException {
|
||||
// Fill bytes
|
||||
byte[] bytes = new byte[1024];
|
||||
mRandom.nextBytes(bytes);
|
||||
random.nextBytes(bytes);
|
||||
|
||||
ByteArrayImageInputStream input = new ByteArrayImageInputStream(bytes);
|
||||
|
||||
|
||||
+7
-6
@@ -1,11 +1,12 @@
|
||||
package com.twelvemonkeys.imageio.stream;
|
||||
|
||||
import static com.twelvemonkeys.imageio.stream.BufferedImageInputStreamTestCase.rangeEquals;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.twelvemonkeys.imageio.stream.BufferedImageInputStreamTestCase.rangeEquals;
|
||||
|
||||
/**
|
||||
* ByteArrayImageInputStreamTestCase
|
||||
*
|
||||
@@ -14,7 +15,7 @@ import java.util.Random;
|
||||
* @version $Id: ByteArrayImageInputStreamTestCase.java,v 1.0 Apr 21, 2009 10:58:48 AM haraldk Exp$
|
||||
*/
|
||||
public class ByteArrayImageInputStreamTestCase extends TestCase {
|
||||
protected final Random mRandom = new Random();
|
||||
protected final Random random = new Random();
|
||||
|
||||
public void testCreate() {
|
||||
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(new byte[0]);
|
||||
@@ -36,7 +37,7 @@ public class ByteArrayImageInputStreamTestCase extends TestCase {
|
||||
|
||||
public void testRead() throws IOException {
|
||||
byte[] data = new byte[1024 * 1024];
|
||||
mRandom.nextBytes(data);
|
||||
random.nextBytes(data);
|
||||
|
||||
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
|
||||
|
||||
@@ -49,7 +50,7 @@ public class ByteArrayImageInputStreamTestCase extends TestCase {
|
||||
|
||||
public void testReadArray() throws IOException {
|
||||
byte[] data = new byte[1024 * 1024];
|
||||
mRandom.nextBytes(data);
|
||||
random.nextBytes(data);
|
||||
|
||||
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
|
||||
|
||||
@@ -65,7 +66,7 @@ public class ByteArrayImageInputStreamTestCase extends TestCase {
|
||||
|
||||
public void testReadSkip() throws IOException {
|
||||
byte[] data = new byte[1024 * 14];
|
||||
mRandom.nextBytes(data);
|
||||
random.nextBytes(data);
|
||||
|
||||
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
|
||||
|
||||
@@ -82,7 +83,7 @@ public class ByteArrayImageInputStreamTestCase extends TestCase {
|
||||
|
||||
public void testReadSeek() throws IOException {
|
||||
byte[] data = new byte[1024 * 18];
|
||||
mRandom.nextBytes(data);
|
||||
random.nextBytes(data);
|
||||
|
||||
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
|
||||
|
||||
|
||||
+2
-2
@@ -19,12 +19,12 @@ import java.util.Random;
|
||||
*/
|
||||
public class SubImageInputStreamTestCase extends TestCase {
|
||||
// TODO: Extract super test case for all stream tests
|
||||
private final Random mRandom = new Random(837468l);
|
||||
private final Random random = new Random(837468l);
|
||||
|
||||
private ImageInputStream createStream(final int pSize) {
|
||||
byte[] bytes = new byte[pSize];
|
||||
|
||||
mRandom.nextBytes(bytes);
|
||||
random.nextBytes(bytes);
|
||||
|
||||
return new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes)) {
|
||||
@Override
|
||||
|
||||
+40
-26
@@ -116,6 +116,10 @@ public abstract class ImageReaderAbstractTestCase<T extends ImageReader> extends
|
||||
|
||||
protected abstract List<String> getMIMETypes();
|
||||
|
||||
protected boolean allowsNullRawImageType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void assertProviderInstalledForName(final String pFormat, final Class<? extends ImageReader> pReaderClass) {
|
||||
assertProviderInstalled0(pFormat.toUpperCase(), pReaderClass, ImageIO.getImageReadersByFormatName(pFormat.toUpperCase()));
|
||||
assertProviderInstalled0(pFormat.toLowerCase(), pReaderClass, ImageIO.getImageReadersByFormatName(pFormat.toLowerCase()));
|
||||
@@ -1111,30 +1115,34 @@ public abstract class ImageReaderAbstractTestCase<T extends ImageReader> extends
|
||||
|
||||
public void testGetTypeSpecifiers() throws IOException {
|
||||
final ImageReader reader = createReader();
|
||||
TestData data = getTestData().get(0);
|
||||
reader.setInput(data.getInputStream());
|
||||
for (TestData data : getTestData()) {
|
||||
reader.setInput(data.getInputStream());
|
||||
|
||||
ImageTypeSpecifier rawType = reader.getRawImageType(0);
|
||||
assertNotNull(rawType);
|
||||
|
||||
Iterator<ImageTypeSpecifier> types = reader.getImageTypes(0);
|
||||
|
||||
assertNotNull(types);
|
||||
assertTrue(types.hasNext());
|
||||
|
||||
// TODO: This might fail even though the specifiers are obviously equal, if the
|
||||
// color spaces they use are not the SAME instance, as ColorSpace uses identity equals
|
||||
// and Interleaved ImageTypeSpecifiers are only equal if color spaces are equal...
|
||||
boolean rawFound = false;
|
||||
while (types.hasNext()) {
|
||||
ImageTypeSpecifier type = types.next();
|
||||
if (type.equals(rawType)) {
|
||||
rawFound = true;
|
||||
break;
|
||||
ImageTypeSpecifier rawType = reader.getRawImageType(0);
|
||||
if (rawType == null && allowsNullRawImageType()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assertNotNull(rawType);
|
||||
|
||||
assertTrue("ImageTypeSepcifier from getRawImageType should be in the iterator from getImageTypes", rawFound);
|
||||
Iterator<ImageTypeSpecifier> types = reader.getImageTypes(0);
|
||||
|
||||
assertNotNull(types);
|
||||
assertTrue(types.hasNext());
|
||||
|
||||
// TODO: This might fail even though the specifiers are obviously equal, if the
|
||||
// color spaces they use are not the SAME instance, as ColorSpace uses identity equals
|
||||
// and Interleaved ImageTypeSpecifiers are only equal if color spaces are equal...
|
||||
boolean rawFound = false;
|
||||
while (types.hasNext()) {
|
||||
ImageTypeSpecifier type = types.next();
|
||||
if (type.equals(rawType)) {
|
||||
rawFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue("ImageTypeSepcifier from getRawImageType should be in the iterator from getImageTypes", rawFound);
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetDestination() throws IOException {
|
||||
@@ -1164,12 +1172,18 @@ public abstract class ImageReaderAbstractTestCase<T extends ImageReader> extends
|
||||
ImageReadParam param = reader.getDefaultReadParam();
|
||||
|
||||
ImageTypeSpecifier type = reader.getRawImageType(0);
|
||||
BufferedImage destination = type.createBufferedImage(reader.getWidth(0), reader.getHeight(0));
|
||||
param.setDestination(destination);
|
||||
|
||||
BufferedImage result = reader.read(0, param);
|
||||
if (type != null) {
|
||||
BufferedImage destination = type.createBufferedImage(reader.getWidth(0), reader.getHeight(0));
|
||||
param.setDestination(destination);
|
||||
|
||||
assertSame(destination, result);
|
||||
BufferedImage result = reader.read(0, param);
|
||||
|
||||
assertSame(destination, result);
|
||||
}
|
||||
else {
|
||||
System.err.println("WARNING: Test skipped due to reader.getRawImageType(0) returning null");
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetDestinationIllegal() throws IOException {
|
||||
@@ -1258,7 +1272,7 @@ public abstract class ImageReaderAbstractTestCase<T extends ImageReader> extends
|
||||
boolean removed = illegalTypes.remove(valid);
|
||||
|
||||
// TODO: 4BYTE_ABGR (6) and 4BYTE_ABGR_PRE (7) is essentially the same type...
|
||||
// !#$#§%$! ImageTypeSpecifier.equals is not well-defined
|
||||
// !#$#�%$! ImageTypeSpecifier.equals is not well-defined
|
||||
if (!removed) {
|
||||
for (Iterator<ImageTypeSpecifier> iterator = illegalTypes.iterator(); iterator.hasNext();) {
|
||||
ImageTypeSpecifier illegalType = iterator.next();
|
||||
|
||||
Reference in New Issue
Block a user