harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r496771 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/text/StyleConstants.java test/api/java/common/javax/swing/text/ComponentViewTest.java
Date Tue, 16 Jan 2007 17:10:22 GMT
Author: hindessm
Date: Tue Jan 16 09:10:21 2007
New Revision: 496771

URL: http://svn.apache.org/viewvc?view=rev&rev=496771
Log:
Applying patches from "[#HARMONY-1767]
[classlib][swing]javax.swing.text.html.ComponentView(Element) throws
unexpected NullPointerException on user's implementation".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyleConstants.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ComponentViewTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyleConstants.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyleConstants.java?view=diff&rev=496771&r1=496770&r2=496771
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyleConstants.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyleConstants.java
Tue Jan 16 09:10:21 2007
@@ -200,7 +200,7 @@
     }
 
     public static Component getComponent(final AttributeSet a) {
-        return (Component)a.getAttribute(ComponentAttribute);
+        return (a == null ? null : (Component) a.getAttribute(ComponentAttribute));
     }
 
     public static void setForeground(final MutableAttributeSet a,

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ComponentViewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ComponentViewTest.java?view=diff&rev=496771&r1=496770&r2=496771
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ComponentViewTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ComponentViewTest.java
Tue Jan 16 09:10:21 2007
@@ -33,6 +33,10 @@
 import javax.swing.JTextArea;
 import javax.swing.JTextPane;
 import javax.swing.SwingTestCase;
+import javax.swing.text.Element;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.ListView;
+
 
 public class ComponentViewTest extends SwingTestCase {
     StyledDocument document;
@@ -646,6 +650,47 @@
             assertNotSame(textPane, view.getComponent().getParent());
             assertFalse(textPane.equals(view.getComponent().getParent()));
             assertSame(textPane, view.getComponent().getParent().getParent());
+        }
+    }
+
+    public void testSetParent_View() {
+        // Regression test for HARMONY-1767 
+        HTMLDocument doc = new HTMLDocument();
+        Element e = doc.getDefaultRootElement();
+        ComponentView obj = new ComponentView(new TestElement());
+        obj.setParent(new ListView(e));        
+    }  
+
+    private class TestElement implements Element {
+        public boolean isLeaf() {
+            return false;
+        }
+        public Element getElement(int index) {
+            return null;
+        }
+        public int getElementCount() {
+            return 0;
+        }
+        public int getElementIndex(int offset) {
+            return 0;
+        }
+        public int getEndOffset() {
+            return 0;
+        }       
+        public int getStartOffset() {
+            return 0;
+        }       
+        public AttributeSet getAttributes() {
+            return null;
+        }
+        public String getName() {
+            return "AA";
+        }
+        public Element getParentElement() {
+            return null;
+        }
+        public Document getDocument() {
+            return null;
         }
     }
 



Mime
View raw message