mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-02 11:05:29 -04:00
More tests.
This commit is contained in:
parent
ed441a7d6a
commit
cda19ece0d
@ -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 {
|
||||
|
@ -63,7 +63,7 @@ import java.util.List;
|
||||
* @see <a href="http://en.wikipedia.org/wiki/ICO_(icon_image_file_format)">ICO file format (Wikipedia)</a>
|
||||
*/
|
||||
// SEE http://en.wikipedia.org/wiki/ICO_(icon_image_file_format)
|
||||
// TODO: Decide wether DirectoryEntry or DIBHeader should be primary source for color count/bit count
|
||||
// TODO: Decide whether DirectoryEntry or DIBHeader should be primary source for color count/bit count
|
||||
// TODO: Support loading icons from DLLs, see
|
||||
// <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_icons.asp">MSDN</a>
|
||||
// Known issue: 256x256 PNG encoded icons does not have IndexColorModel even if stated in DirectoryEntry (seem impossible as the PNGs are all true color)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.twelvemonkeys.imageio.plugins.ico;
|
||||
|
||||
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.ImageReadParam;
|
||||
@ -110,4 +111,11 @@ public class CURImageReaderTestCase extends ImageReaderAbstractTestCase<CURImage
|
||||
}
|
||||
|
||||
// TODO: Test cursor is transparent
|
||||
|
||||
@Test
|
||||
@Ignore("Known issue")
|
||||
@Override
|
||||
public void testNotBadCaching() throws IOException {
|
||||
super.testNotBadCaching();
|
||||
}
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package com.twelvemonkeys.imageio.plugins.ico;
|
||||
|
||||
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.spi.ImageReaderSpi;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -63,4 +66,11 @@ public class ICOImageReaderTestCase extends ImageReaderAbstractTestCase<ICOImage
|
||||
protected List<String> getMIMETypes() {
|
||||
return Arrays.asList("image/vnd.microsoft.icon", "image/ico", "image/x-icon");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Known issue")
|
||||
@Override
|
||||
public void testNotBadCaching() throws IOException {
|
||||
super.testNotBadCaching();
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import com.sun.imageio.plugins.jpeg.JPEGImageReader;
|
||||
import com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi;
|
||||
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
|
||||
import com.twelvemonkeys.lang.SystemUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.IIOException;
|
||||
@ -93,13 +94,16 @@ public class JPEGImageReaderTestCase extends ImageReaderAbstractTestCase<JPEGIma
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Known issue")
|
||||
@Override
|
||||
public void testReadAsRenderedImageIndexOutOfBounds() throws IIOException {
|
||||
try {
|
||||
super.testReadAsRenderedImageIndexOutOfBounds();
|
||||
}
|
||||
catch (IIOException expected) {
|
||||
// Known bug
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("No test data with JFIF thumbnail")
|
||||
@Override
|
||||
public void testNotBadCachingThumbnails() throws IOException {
|
||||
super.testNotBadCachingThumbnails();
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
|
||||
import com.twelvemonkeys.io.ole2.CompoundDocument;
|
||||
import com.twelvemonkeys.io.ole2.Entry;
|
||||
import com.twelvemonkeys.lang.SystemUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.spi.ImageReaderSpi;
|
||||
@ -140,4 +141,11 @@ public class ThumbsDBImageReaderTestCase extends ImageReaderAbstractTestCase<Thu
|
||||
System.err.println("WARNING: Test skipped due to known bug in Java 1.5, please test again with Java 6 or later");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Known issue")
|
||||
@Override
|
||||
public void testNotBadCaching() throws IOException {
|
||||
super.testNotBadCaching();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user