harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r507018 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/ImageIcon.java test/api/java/common/javax/swing/ImageIconTest.java
Date Tue, 13 Feb 2007 14:25:43 GMT
Author: apetrenko
Date: Tue Feb 13 06:25:43 2007
New Revision: 507018

URL: http://svn.apache.org/viewvc?view=rev&rev=507018
Log:
javax.swing.ImageIcon.AccessibleImageIcon class implementations and unit test for it

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ImageIconTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java?view=diff&rev=507018&r1=507017&r2=507018
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java
Tue Feb 13 06:25:43 2007
@@ -48,24 +48,31 @@
 public class ImageIcon implements Icon, Serializable, Accessible {
     private static final long serialVersionUID = -6101950798829449111L;
 
-    // TODO: implement
     protected class AccessibleImageIcon extends AccessibleContext implements AccessibleIcon,
             Serializable {
         private static final long serialVersionUID = -860693743697825660L;
+        
+        protected AccessibleImageIcon() {
+        }
 
         @Override
-        public Accessible getAccessibleChild(int i) throws NotImplementedException {
-            throw new NotImplementedException();
+        public Accessible getAccessibleChild(int i) {
+            return null;
         }
 
         @Override
-        public int getAccessibleChildrenCount() throws NotImplementedException {
-            throw new NotImplementedException();
+        public int getAccessibleChildrenCount() {
+            return 0;
+        }
+        
+        @Override
+        public Accessible getAccessibleParent() {
+            return null;
         }
 
         @Override
-        public int getAccessibleIndexInParent() throws NotImplementedException {
-            throw new NotImplementedException();
+        public int getAccessibleIndexInParent() {
+            return -1;
         }
 
         @Override
@@ -74,31 +81,29 @@
         }
 
         @Override
-        public AccessibleStateSet getAccessibleStateSet() throws NotImplementedException
{
-            throw new NotImplementedException();
+        public AccessibleStateSet getAccessibleStateSet() {
+            return null;
         }
 
         @Override
-        public Locale getLocale() throws IllegalComponentStateException,
-                NotImplementedException {
-            throw new NotImplementedException();
+        public Locale getLocale() throws IllegalComponentStateException {
+            return null;
         }
 
-        public void setAccessibleIconDescription(String description)
-                throws NotImplementedException {
-            throw new NotImplementedException();
+        public void setAccessibleIconDescription(String description) {
+            setDescription(description);
         }
 
-        public String getAccessibleIconDescription() throws NotImplementedException {
-            throw new NotImplementedException();
+        public String getAccessibleIconDescription() {
+            return getDescription();
         }
 
-        public int getAccessibleIconWidth() throws NotImplementedException {
-            throw new NotImplementedException();
+        public int getAccessibleIconWidth() {
+            return getIconWidth();
         }
 
-        public int getAccessibleIconHeight() throws NotImplementedException {
-            throw new NotImplementedException();
+        public int getAccessibleIconHeight() {
+            return getIconHeight();
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ImageIconTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ImageIconTest.java?view=diff&rev=507018&r1=507017&r2=507018
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ImageIconTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ImageIconTest.java
Tue Feb 13 06:25:43 2007
@@ -31,6 +31,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleIcon;
 
 public class ImageIconTest extends SwingTestCase {
     private static final String FILE_NAME_1 = "images/Error.gif";
@@ -403,5 +404,28 @@
         MyImageIcon myIcon = new MyImageIcon();
         assertNotNull(myIcon.getTracker());
         assertNotNull(myIcon.getComponent());
+    }
+    
+    public void testAccessibleImageIcon() {
+        int width = 111;
+        int height = 235;
+        icon = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB));
+        
+        AccessibleContext ac = icon.getAccessibleContext();
+        AccessibleIcon ai = (AccessibleIcon)ac;
+
+        assertEquals(ac.getAccessibleChildrenCount(), 0);
+        assertNull(ac.getAccessibleChild(0));
+        assertNull(ac.getAccessibleChild(10));
+        assertNull(ac.getAccessibleChild(-1));
+
+        assertNull(ac.getAccessibleParent());
+        
+        ac.setAccessibleParent(new ImageIcon());
+        assertNull(ac.getAccessibleParent());
+        assertNull(ac.getAccessibleStateSet());
+
+        assertEquals("width", width, ai.getAccessibleIconWidth());
+        assertEquals("height", height, ai.getAccessibleIconHeight());
     }
 }



Mime
View raw message