harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r450673 - in /incubator/harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/text/html/parser/ContentModel.java test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java
Date Thu, 28 Sep 2006 02:51:34 GMT
Author: pyang
Date: Wed Sep 27 19:51:34 2006
New Revision: 450673

URL: http://svn.apache.org/viewvc?view=rev&rev=450673
Log:
Modify testFirst() to make it really pass on RI, apply patch for HARMONY-1350 ([classlib][html]
The method j.s.t.h.p.ContentModel.first() returns a value in cases in which it should return
null)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/ContentModel.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/ContentModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/ContentModel.java?view=diff&rev=450673&r1=450672&r2=450673
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/ContentModel.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/ContentModel.java
Wed Sep 27 19:51:34 2006
@@ -137,26 +137,24 @@
     private String getBracket(final String s, final boolean need) {
         return need ? s : "";
     }
-
+    
     /**
-     *
-     * @return first Element from 'next' contentModel. if type equals one of
-     * unary operations that'll be null.
+     * Gets the <code>Element</code> that must be the first one to occur
+     * in the <code>ContentModel</code>.
+     * @return The first element that must appear in the
+     * <code>ContentModel</code>. Null if zero or more than one
+     * <code>Element</code> occurrence is possible.
      */
     public Element first() {
-        return isExtUnaryType(type) || next == null ? null
-                : next.getFirstElement();
-    }
-
-    private Element getFirstElement() {
-
-        if (content == null) {
-            return null;
+        Element element = null;
+        if (type == DEFAULT_TYPE) {
+            element = (Element)content;
+        } else if (type == PLUS_TYPE || type == COMMA_TYPE) {
+            element = ((ContentModel)content).first();
         }
-        return content instanceof Element ? (Element)content
-                : ((ContentModel)content).getFirstElement();
+        return element;
     }
-
+    
 
     /**
      * @return

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java?view=diff&rev=450673&r1=450672&r2=450673
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java
Wed Sep 27 19:51:34 2006
@@ -261,20 +261,26 @@
     }
 
 
-    public void testFirst() {
-        if (!SwingTestCase.isHarmony()) {
-            return;
-        }
+    public void testFirst() throws Exception{
         initContentModels();
-        assertNull(contentModel1.first());
-        assertNull(contentModel2.first());
-        assertNull(contentModel3.first());
-        assertNull(contentModel4.first());
+        assertEquals(elements[1], contentModel1.first());
+        assertEquals(elements[2], contentModel2.first());
+        assertEquals(elements[3], contentModel3.first());
+        assertEquals(elements[1], contentModel4.first());
         assertNull(contentModel5.first());
-        assertEquals(elements[3], contentModel6.first());
-        assertEquals(elements[2], contentModel7.first());
-        assertEquals(elements[1], contentModel8.first());
+        assertNull(contentModel6.first());
+        assertEquals(elements[1], contentModel7.first());
+        assertNull(contentModel8.first());
         assertNull(contentModel9.first());
+    }
+    
+    public void testFirst2() throws Exception{
+        //regression for HARMONY-1350
+        DTD dtd = DTD.getDTD("tmp");
+        ContentModel model1 = new ContentModel (dtd.getElement(2));
+        ContentModel model2 = new ContentModel (dtd.getElement(3));
+        ContentModel model = new ContentModel ('&', model1, model2);
+        assertNull(model.first());
     }
 
 



Mime
View raw message