harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r953429 - in /harmony/enhanced/java/trunk/classlib/modules/imageio/src: main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java test/java/javax/imageio/ImageIOTest.java
Date Thu, 10 Jun 2010 19:49:39 GMT
Author: aaf
Date: Thu Jun 10 19:49:38 2010
New Revision: 953429

URL: http://svn.apache.org/viewvc?rev=953429&view=rev
Log:
Committed Lang's patch for HARMONY-6484: tests for ImageIO methods.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java?rev=953429&r1=953428&r2=953429&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageWriter.java
Thu Jun 10 19:49:38 2010
@@ -70,7 +70,7 @@ public class PNGImageWriter extends Imag
     private native int encode(byte[] input, int bytesInBuffer, int bytePixelSize, Object
ios, int imageWidth,
             int imageHeight, int bitDepth, int colorType, int[] palette, int i, boolean b);
 
-    protected PNGImageWriter(ImageWriterSpi iwSpi) {
+    public PNGImageWriter(ImageWriterSpi iwSpi) {
         super(iwSpi);
     }
 

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java?rev=953429&r1=953428&r2=953429&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
Thu Jun 10 19:49:38 2010
@@ -18,8 +18,13 @@
 package javax.imageio;
 
 import java.net.URL;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
@@ -45,4 +50,80 @@ public class ImageIOTest extends TestCas
 
         return img;
     }
+
+    private void testFormat(String format) {
+        ImageReader reader = ImageIO.getImageReadersByFormatName(format).next();
+        ImageWriter writer = ImageIO.getImageWritersByFormatName(format).next();
+
+        assertEquals("getImageReader() returns an incorrect reader for " + format,
+            ImageIO.getImageReader(writer).getClass(), reader.getClass());
+        assertEquals("getImageWriter() returns an incorrect writer for " + format,
+            ImageIO.getImageWriter(reader).getClass(), writer.getClass());
+    }
+    
+    // assume we have exactly one reader/writer pair
+    public void testGetJpegReaderWriter() throws Exception {
+        testFormat("jpeg");
+    }
+
+    // assume we have exactly one reader/writer pair
+    public void testGetPngReaderWriter() throws Exception {
+        testFormat("png");
+    }
+ 	
+    // GIF has no writer
+    // public void testGetGifReaderWriter() throws Exception {
+    //     testFormat("gif");
+    // }
+
+    public void testGetNullReaderWriter() throws Exception {
+    	try {
+            ImageIO.getImageWriter(null);
+            fail("Expected IllegalArgumentException");
+        }
+        catch (IllegalArgumentException expected) {
+            // Ok
+        }
+
+        try {
+            ImageIO.getImageReader(null);
+            fail("Expected IllegalArgumentException");
+        }
+        catch (IllegalArgumentException expected) {
+            // Ok
+        }
+    }
+        
+    public void testGetReaderMIMETypes() {
+        Set<String> expectedMIMETypes = new HashSet<String>(Arrays.asList(new
String[] {
+            "image/gif", "image/x-png", "image/png", "image/jpeg" } ));
+        
+        Set<String> actualMIMETypes = new HashSet<String>(Arrays.asList(ImageIO.getReaderMIMETypes()));
+        assertTrue(actualMIMETypes.containsAll(expectedMIMETypes));
+    }
+    
+    public void testGetWriterMIMETypes() {
+        Set<String> expectedMIMETypes = new HashSet<String>(Arrays.asList(new
String[] {
+            "image/x-png", "image/png", "image/jpeg" } ));
+        
+        Set<String> actualMIMETypes = new HashSet<String>(Arrays.asList(ImageIO.getWriterMIMETypes()));
+        assertTrue(actualMIMETypes.containsAll(expectedMIMETypes));
+    }
+    
+    public void testGetReaderFormatNames() {
+        Set<String> expectedFormatNames = new HashSet<String>(Arrays.asList(new
String[] {
+            "JPG", "jpg", "GIF", "gif", "JPEG", "jpeg", "PNG", "png" } ));
+        
+        Set<String> actualFormatNames = new HashSet<String>(Arrays.asList(ImageIO.getReaderFormatNames()));
+        assertTrue(actualFormatNames.containsAll(expectedFormatNames));
+    }
+    
+    public void testGetWriterFormatNames() {
+        Set<String> expectedFormatNames = new HashSet<String>(Arrays.asList(new
String[] {
+            "JPG", "jpg", "JPEG", "jpeg", "PNG", "png" } ));
+        
+        Set<String> actualFormatNames = new HashSet<String>(Arrays.asList(ImageIO.getWriterFormatNames()));
+        assertTrue(actualFormatNames.containsAll(expectedFormatNames));
+    }
+
 }



Mime
View raw message