mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-10-04 11:26:44 -04:00
More tests.
This commit is contained in:
@@ -354,6 +354,10 @@ public abstract class ImageReaderBase extends ImageReader {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
if (e.getCause() instanceof RuntimeException) {
|
||||
throw (RuntimeException) e.getCause();
|
||||
}
|
||||
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@@ -57,6 +57,9 @@ public final class IIOUtil {
|
||||
|
||||
/**
|
||||
* Creates an {@code OutputStream} adapter that writes to an underlying {@code ImageOutputStream}.
|
||||
* <p/>
|
||||
* Note: The adapter is buffered, and <em>MUST</em> be properly flushed/closed after use,
|
||||
* otherwise data may be lost.
|
||||
*
|
||||
* @param pStream the stream to write to.
|
||||
* @return an {@code OutputSteam} writing to {@code pStream}.
|
||||
|
@@ -1441,6 +1441,72 @@ public abstract class ImageReaderAbstractTestCase<T extends ImageReader> {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotBadCaching() throws IOException {
|
||||
T reader = createReader();
|
||||
TestData data = getTestData().get(0);
|
||||
reader.setInput(data.getInputStream());
|
||||
|
||||
BufferedImage one = reader.read(0);
|
||||
BufferedImage two = reader.read(0);
|
||||
|
||||
assertNotSame("Multiple reads return same (mutable) image", one, two);
|
||||
|
||||
Graphics2D g = one.createGraphics();
|
||||
try {
|
||||
g.setColor(Color.WHITE);
|
||||
g.setXORMode(Color.BLACK);
|
||||
g.fillRect(0, 0, one.getWidth(), one.getHeight());
|
||||
}
|
||||
finally {
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
assertTrue(one.getRGB(0, 0) != two.getRGB(0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotBadCachingThumbnails() throws IOException {
|
||||
T reader = createReader();
|
||||
|
||||
if (reader.readerSupportsThumbnails()) {
|
||||
for (TestData data : getTestData()) {
|
||||
reader.setInput(data.getInputStream());
|
||||
|
||||
int images = reader.getNumImages(true);
|
||||
for (int i = 0; i < images; i++) {
|
||||
int thumbnails = reader.getNumThumbnails(0);
|
||||
|
||||
for (int j = 0; j < thumbnails; j++) {
|
||||
BufferedImage one = reader.readThumbnail(i, j);
|
||||
BufferedImage two = reader.readThumbnail(i, j);
|
||||
|
||||
assertNotSame("Multiple reads return same (mutable) image", one, two);
|
||||
|
||||
Graphics2D g = one.createGraphics();
|
||||
try {
|
||||
g.setColor(Color.WHITE);
|
||||
g.setXORMode(Color.BLACK);
|
||||
g.fillRect(0, 0, one.getWidth(), one.getHeight());
|
||||
}
|
||||
finally {
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
assertTrue(one.getRGB(0, 0) != two.getRGB(0, 0));
|
||||
}
|
||||
|
||||
if (thumbnails > 0) {
|
||||
// We've tested thumbnails, let's get out of here
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fail("No thumbnails tested for reader that supports thumbnails.");
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("TODO: Implement")
|
||||
@Test
|
||||
public void testSetDestinationBands() throws IOException {
|
||||
|
Reference in New Issue
Block a user