You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/07/31 16:08:55 UTC

svn commit: r427121 [27/29] - in /incubator/harmony/enhanced/classlib/trunk/modules/swing: make/ src/main/java/common/javax/swing/ src/main/java/common/javax/swing/text/ src/main/java/common/javax/swing/text/html/ src/main/java/common/javax/swing/text/...

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_RulesTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_RulesTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_RulesTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_RulesTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,337 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.awt.Color;
+import java.util.Enumeration;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyleContext;
+import javax.swing.text.html.CSS.Attribute;
+
+public class StyleSheet_RulesTest extends BasicSwingTestCase {
+    private StyleSheet ss;
+    private Enumeration rules;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+    }
+
+    /**
+     * Several rules (selector - property list pairs) in one string.
+     */
+    public void testAddRule01() throws Exception {
+        ss.addRule("p { text-align: right; }\nem {color: red}");
+        Style pStyle = null;
+        Style emStyle = null;
+        Style defStyle = null;
+        rules = ss.getStyleNames();
+        while (rules.hasMoreElements()) {
+            String name = (String)rules.nextElement();
+            Style style = ss.getStyle(name);
+            if ("p".equals(name)) {
+                pStyle = style;
+            } else if ("em".equals(name)) {
+                emStyle = style;
+            } else if (StyleContext.DEFAULT_STYLE.equals(name)) {
+                defStyle = style;
+            } else {
+                fail("Unexpected style: " + style);
+            }
+        }
+
+        assertEquals(2, pStyle.getAttributeCount());
+        assertEquals("right",
+                     pStyle.getAttribute(Attribute.TEXT_ALIGN).toString());
+        assertNotNull(pStyle.getAttribute(AttributeSet.NameAttribute));
+        assertEquals(StyleConstants.ALIGN_RIGHT,
+                     ((Integer)pStyle.getAttribute(StyleConstants.Alignment))
+                     .intValue());
+
+        assertEquals(2, emStyle.getAttributeCount());
+        assertEquals("red",
+                     emStyle.getAttribute(Attribute.COLOR).toString());
+        assertNotNull(emStyle.getAttribute(AttributeSet.NameAttribute));
+        assertEquals(Color.RED,
+                     emStyle.getAttribute(StyleConstants.Foreground));
+
+        assertEquals(1, defStyle.getAttributeCount());
+        assertNotNull(defStyle.getAttribute(AttributeSet.NameAttribute));
+    }
+
+    /**
+     * Several properties defined for one selector.
+     */
+    public void testAddRule02() throws Exception {
+        ss.addRule("p { text-align: justify; background-color: black; " +
+                   "color: white }");
+        Style pStyle = null;
+        rules = ss.getStyleNames();
+        while (rules.hasMoreElements()) {
+            String name = (String)rules.nextElement();
+            Style style = ss.getStyle(name);
+            if ("p".equals(name)) {
+                pStyle = style;
+            } else if (!StyleContext.DEFAULT_STYLE.equals(name)) {
+                fail("Unexpected style: " + style);
+            }
+        }
+
+        assertEquals(4, pStyle.getAttributeCount());
+        assertEquals("justify",
+                     pStyle.getAttribute(Attribute.TEXT_ALIGN).toString());
+        assertEquals(StyleConstants.ALIGN_JUSTIFIED,
+                     ((Integer)pStyle.getAttribute(StyleConstants.Alignment))
+                     .intValue());
+
+        assertEquals("white",
+                     pStyle.getAttribute(Attribute.COLOR).toString());
+        assertEquals(Color.WHITE,
+                     pStyle.getAttribute(StyleConstants.Foreground));
+
+        assertEquals("black",
+                     pStyle.getAttribute(Attribute.BACKGROUND_COLOR).toString());
+        assertEquals(Color.BLACK,
+                     pStyle.getAttribute(StyleConstants.Background));
+        assertNotNull(pStyle.getAttribute(AttributeSet.NameAttribute));
+    }
+
+    /**
+     * Tests that <code>addRule</code> uses <code>addCSSAttribute</code>
+     * to fill the attribute set.
+     */
+    public void testAddRule03() throws Exception {
+        final Marker marker = new Marker();
+        ss = new StyleSheet() {
+            public void addCSSAttribute(final MutableAttributeSet attr,
+                                        final Attribute key,
+                                        final String value) {
+                marker.setOccurred();
+//                assertFalse(attr instanceof Style);
+                assertSame(Attribute.FONT_SIZE, key);
+                assertEquals("21pt", value);
+                super.addCSSAttribute(attr, key, value);
+            }
+        };
+        ss.addRule("   p    {  font-size   :   21pt   }    ");
+
+        assertTrue(marker.isOccurred());
+    }
+
+    /**
+     * Tests that <code>addRule</code> calls <code>addStyle</code> to actually
+     * add the rule.
+     */
+    public void testAddRule04() throws Exception {
+        final Marker marker = new Marker();
+        ss = new StyleSheet() {
+            public Style addStyle(String name, Style parent) {
+                marker.setOccurred();
+                if (marker.getAuxiliary() != null) {
+                    assertEquals("p", name);
+                    assertNull(parent);
+                } else {
+                    assertEquals("default", name);
+                    marker.setAuxiliary(name);
+                }
+                return super.addStyle(name, parent);
+            }
+        };
+        assertTrue(marker.isOccurred());
+        marker.setOccurred(false);
+
+        ss.addRule("   p    {  font-size   :   21pt   }    ");
+        assertTrue(marker.isOccurred());
+    }
+
+    /**
+     * Tests that <code>addRule</code> stores rule as Style.
+     */
+    public void testAddRule05() throws Exception {
+        ss.addRule("em { text-decoration: underline }");
+        Style emStyle = ss.getStyle("em");
+
+        assertEquals(2, emStyle.getAttributeCount());
+        assertEquals("underline",
+                     emStyle.getAttribute(CSS.Attribute.TEXT_DECORATION)
+                     .toString());
+        assertEquals("em", emStyle.getAttribute(AttributeSet.NameAttribute));
+    }
+
+    /**
+     * Adding Style IS/IS NOT equivalent to adding a rule.
+     */
+    public void testAddRule06() throws Exception {
+        Style emStyle = ss.getStyle("em");
+        assertNull(emStyle);
+
+        emStyle = ss.addStyle("em", null);
+        ss.addCSSAttribute(emStyle, CSS.Attribute.TEXT_DECORATION, "underline");
+
+        Style emRule = ss.getRule("em");
+        assertNotNull(emRule);
+        assertEquals(isHarmony() ? 2 : 0, emRule.getAttributeCount());
+    }
+
+    /**
+     * Adding a property with several selectors.
+     */
+    public void testAddRule07() throws Exception {
+        assertNull(ss.getStyle("ol"));
+        assertNull(ss.getStyle("ul"));
+
+        ss.addRule("ol, ul { margin-left: 3pt }");
+
+        Style ol = ss.getStyle("ol");
+        assertNotNull(ol.getAttribute(Attribute.MARGIN_LEFT));
+
+        Style ul = ss.getStyle("ul");
+        assertNotNull(ul.getAttribute(Attribute.MARGIN_LEFT));
+    }
+
+    /**
+     * Tags are not case-sensitive in HTML.
+     */
+    public void testAddRule08() throws Exception {
+        assertNull(ss.getStyle("h1"));
+        assertNull(ss.getStyle("H1"));
+        ss.addRule("H1 { color: blue }");
+        assertNotNull(ss.getStyle("h1"));
+        assertNull(ss.getStyle("H1"));
+
+
+        Style h1 = ss.getRule("h1");
+        assertEquals(2, h1.getAttributeCount());
+        assertEquals("blue", h1.getAttribute(CSS.Attribute.COLOR).toString());
+
+        Style H1 = ss.getRule("H1");
+        if (isHarmony()) {
+            assertEquals(2, H1.getAttributeCount());
+            assertEquals("blue", H1.getAttribute(CSS.Attribute.COLOR).toString());
+            assertSame(h1, H1);
+        } else {
+            assertEquals(0, H1.getAttributeCount());
+            assertNull(H1.getAttribute(CSS.Attribute.COLOR));
+            assertNotSame(h1, H1);
+        }
+    }
+
+    /**
+     * Classes are case-sensitive.
+     */
+    public void testAddRule09() throws Exception {
+        assertNull(ss.getStyle(".header"));
+        assertNull(ss.getStyle(".HEADER"));
+        ss.addRule(".HEADER { color: blue }");
+        Style headerStyle = ss.getStyle(".header");
+        Style HEADERstyle = ss.getStyle(".HEADER");
+        Style headerRule = ss.getRule(".header");
+        Style HEADERrule = ss.getRule(".HEADER");
+        if (isHarmony()) {
+            assertNull(headerStyle);
+            assertNotNull(HEADERstyle);
+
+            assertEquals(0, headerRule.getAttributeCount());
+            assertEquals(2, HEADERrule.getAttributeCount());
+        } else {
+            assertNotNull(headerStyle);
+            assertNull(HEADERstyle);
+
+            assertEquals(2, headerRule.getAttributeCount());
+            assertEquals(0, HEADERrule.getAttributeCount());
+        }
+        assertNotSame(headerRule, HEADERrule);
+    }
+
+    /**
+     * ids are case-sensitive.
+     */
+    public void testAddRule10() throws Exception {
+        assertNull(ss.getStyle(".id"));
+        assertNull(ss.getStyle(".ID"));
+        ss.addRule("#ID { color: blue }");
+        Style idStyle = ss.getStyle("#id");
+        Style IDstyle = ss.getStyle("#ID");
+        Style idRule = ss.getRule("#id");
+        Style IDrule = ss.getRule("#ID");
+        if (isHarmony()) {
+            assertNull(idStyle);
+            assertNotNull(IDstyle);
+
+            assertEquals(0, idRule.getAttributeCount());
+            assertEquals(2, IDrule.getAttributeCount());
+        } else {
+            assertNotNull(idStyle);
+            assertNull(IDstyle);
+
+            assertEquals(2, idRule.getAttributeCount());
+            assertEquals(0, IDrule.getAttributeCount());
+        }
+        assertNotSame(idRule, IDrule);
+    }
+
+    /**
+     * Parses one property using <code>addCSSAttribute</code> to add
+     * the attribute to the set.
+     */
+    public void testGetDeclaration01() throws Exception {
+        final Marker marker = new Marker();
+        ss = new StyleSheet() {
+            public void addCSSAttribute(final MutableAttributeSet attr,
+                                        final Attribute key,
+                                        final String value) {
+                marker.setOccurred();
+                assertSame(Attribute.FONT_SIZE, key);
+                assertEquals("13pt", value);
+                super.addCSSAttribute(attr, key, value);
+            }
+        };
+        AttributeSet attr = ss.getDeclaration("font-size: 13pt");
+        assertTrue(marker.isOccurred());
+        assertEquals("13pt", attr.getAttribute(Attribute.FONT_SIZE).toString());
+//        assertEquals(13, ((Integer)attr.getAttribute(StyleConstants.FontSize))
+//                         .intValue());
+        assertNull(attr.getAttribute(StyleConstants.FontSize));
+
+        assertSame(SimpleAttributeSet.class, attr.getClass());
+    }
+
+    /**
+     * Parses several properties at once.
+     */
+    public void testGetDeclaration02() throws Exception {
+        AttributeSet attr = ss.getDeclaration("font-family: monospace; " +
+                                              "color: rgb(11, 33, 99); " +
+                                              "text-align: center");
+        assertEquals(3, attr.getAttributeCount());
+        assertEquals("monospace",
+                     attr.getAttribute(Attribute.FONT_FAMILY).toString());
+        assertEquals("rgb(11, 33, 99)",
+                     attr.getAttribute(Attribute.COLOR).toString());
+        assertEquals("center",
+                     attr.getAttribute(Attribute.TEXT_ALIGN).toString());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_Small_Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_Small_Test.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_Small_Test.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_Small_Test.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,166 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.util.Enumeration;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.CSS.Attribute;
+
+/**
+ * Tests <code>SmallAttributeSet</code> returned by
+ * <code>StyleSheet.addAttribute</code> method. The returned attribute set
+ * contains <code>CSS.Attribute</code>. It converts the value to
+ * <code>StyleConstants</code> when a <code>StyleConstants</code> attribute
+ * is requested.
+ * <p>
+ * The attribute used for testing is <code>StyleConstants.Bold</code>.
+ * It corresponds to <code>Attribute.FONT_WEIGHT</code>.
+ *
+ * @see StyleSheet
+ * @see StyleSheet#addAttribute(Object, Object)
+ * @see StyleSheet#createSmallAttributeSet(AttributeSet)
+ * @see CSS.Attribute
+ * @see javax.swing.text.StyleContext.SmallAttributeSet
+ */
+public class StyleSheet_Small_Test extends BasicSwingTestCase {
+    private static final Object scAttribute  = StyleConstants.Bold;
+    private static final Object scValue      = Boolean.TRUE;
+    private static final Object cssAttribute = Attribute.FONT_WEIGHT;
+
+    private StyleSheet ss;
+    private AttributeSet empty;
+    private AttributeSet attr;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        empty = ss.getEmptySet();
+
+        attr = ss.addAttribute(empty, scAttribute, scValue);
+    }
+
+    public void testGetAttribute() throws Exception {
+        Object value = attr.getAttribute(cssAttribute);
+        assertNotSame(Boolean.class, value.getClass());
+        assertNotSame(String.class, value.getClass());
+        assertEquals("bold", value.toString());
+
+        value = attr.getAttribute(scAttribute);
+        assertSame(Boolean.class, value.getClass());
+        assertTrue(((Boolean)value).booleanValue());
+        assertSame(scValue, value);
+    }
+
+    public void testIsDefined() throws Exception {
+        assertTrue(attr.isDefined(scAttribute));
+        assertTrue(attr.isDefined(cssAttribute));
+    }
+
+    public void testGetNames() throws Exception {
+        final Enumeration keys = attr.getAttributeNames();
+        final Object key = keys.nextElement();
+        assertSame(cssAttribute, key);
+        assertFalse(keys.hasMoreElements());
+    }
+
+    public void testGetAttributeCount() throws Exception {
+        assertEquals(1, attr.getAttributeCount());
+    }
+
+    public void testIsEqualSame() throws Exception {
+        assertTrue(attr.isEqual(attr));
+
+        final MutableAttributeSet simple = new SimpleAttributeSet(attr);
+        assertTrue(attr.isEqual(simple));
+        assertTrue(simple.isEqual(attr));
+    }
+
+    public void testIsEqualMutable() throws Exception {
+        final MutableAttributeSet simple = new SimpleAttributeSet();
+        simple.addAttribute(scAttribute, scValue);
+
+        assertTrue(attr.isEqual(simple));
+        if (isHarmony()) {
+            assertTrue(simple.isEqual(attr));
+        } else {
+            assertFalse(simple.isEqual(attr));
+        }
+    }
+
+    public void testCopyAttributes() throws Exception {
+        assertSame(attr, attr.copyAttributes());
+    }
+
+    public void testContainsAttribute() throws Exception {
+        assertTrue(attr.containsAttribute(cssAttribute,
+                                          attr.getAttribute(cssAttribute)));
+        assertTrue(attr.containsAttribute(scAttribute, scValue));
+    }
+
+    public void testContainsAttributeAnother() throws Exception {
+        final AttributeSet another = ss.addAttribute(empty,
+                                                     scAttribute, scValue);
+
+        assertEquals(attr.getAttribute(cssAttribute).toString(),
+                     another.getAttribute(cssAttribute).toString());
+        if (isHarmony()) {
+            assertTrue(attr.containsAttribute(cssAttribute,
+                                              another.getAttribute(cssAttribute)));
+        } else {
+            assertFalse(attr.containsAttribute(cssAttribute,
+                                               another.getAttribute(cssAttribute)));
+        }
+    }
+
+    public void testContainsAttributesSame() throws Exception {
+        assertTrue(attr.containsAttributes(attr));
+
+        final MutableAttributeSet simple = new SimpleAttributeSet(attr);
+
+        assertTrue(attr.containsAttributes(simple));
+        assertTrue(simple.containsAttributes(attr));
+    }
+
+    public void testContainsAttributesMutable() throws Exception {
+        final MutableAttributeSet simple = new SimpleAttributeSet();
+        simple.addAttribute(scAttribute, scValue);
+
+        assertTrue(attr.containsAttributes(simple));
+        assertFalse(simple.containsAttributes(attr));
+    }
+
+    public void testContainsAttributesSmall() throws Exception {
+        final AttributeSet another = ss.addAttribute(empty,
+                                                     scAttribute, scValue);
+
+        if (isHarmony()) {
+            assertTrue(attr.containsAttributes(another));
+            assertTrue(another.containsAttributes(attr));
+        } else {
+            assertFalse(attr.containsAttributes(another));
+            assertFalse(another.containsAttributes(attr));
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_StyleSheetsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_StyleSheetsTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_StyleSheetsTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_StyleSheetsTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,135 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import javax.swing.text.Style;
+import javax.swing.text.html.CSS.Attribute;
+
+import junit.framework.TestCase;
+
+public class StyleSheet_StyleSheetsTest extends TestCase {
+    private StyleSheet ss;
+    private StyleSheet second;
+    private StyleSheet third;
+    private StyleSheet[] sheets;
+    private Style rule;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+    }
+
+    public void testGetStyleSheets() {
+        sheets = ss.getStyleSheets();
+        assertNull(sheets);
+
+        second = new StyleSheet();
+        ss.addStyleSheet(second);
+        sheets = ss.getStyleSheets();
+        assertEquals(1, sheets.length);
+        assertSame(second, sheets[0]);
+    }
+
+    public void testAddStyleSheet() {
+        second = new StyleSheet();
+        third = new StyleSheet();
+        ss.addStyleSheet(second);
+        ss.addStyleSheet(third);
+
+        sheets = ss.getStyleSheets();
+        assertEquals(2, sheets.length);
+        assertSame(third, sheets[0]);
+        assertSame(second, sheets[1]);
+    }
+
+    public void testAddStyleSheetDuplicate() {
+        second = new StyleSheet();
+        ss.addStyleSheet(second);
+        assertEquals(1, ss.getStyleSheets().length);
+        ss.addStyleSheet(second);
+        assertEquals(1, ss.getStyleSheets().length);
+    }
+
+    public void testAddStyleSheetUpdateRule() {
+        rule = ss.getRule("p");
+        second = new StyleSheet();
+        second.addRule("p { color: red }");
+        ss.addStyleSheet(second);
+
+        assertEquals(2, rule.getAttributeCount());
+        assertEquals("red", rule.getAttribute(Attribute.COLOR).toString());
+
+        third = new StyleSheet();
+        third.addRule("p { color: blue }");
+        ss.addStyleSheet(third);
+
+        assertEquals(4, rule.getAttributeCount());
+        assertEquals("blue", rule.getAttribute(Attribute.COLOR).toString());
+    }
+
+    public void testAddStyleSheetOverrideRule() {
+        ss.addRule("p { color: black }");
+        rule = ss.getRule("p");
+        assertEquals("black", rule.getAttribute(Attribute.COLOR).toString());
+
+        second = new StyleSheet();
+        second.addRule("p { color: red }");
+        ss.addStyleSheet(second);
+        assertEquals("black", rule.getAttribute(Attribute.COLOR).toString());
+    }
+
+    public void testRemoveStyleSheet() {
+        second = new StyleSheet();
+        third  = new StyleSheet();
+        ss.addStyleSheet(second);
+        ss.addStyleSheet(third);
+
+        assertEquals(2, ss.getStyleSheets().length);
+
+        ss.removeStyleSheet(second);
+        assertEquals(1, ss.getStyleSheets().length);
+        assertEquals(third, ss.getStyleSheets()[0]);
+
+        ss.removeStyleSheet(second);
+        assertEquals(1, ss.getStyleSheets().length);
+
+        ss.removeStyleSheet(third);
+        assertNull(ss.getStyleSheets());
+    }
+
+    public void testRemoveStyleSheetRuleChange() {
+        rule = ss.getRule("p");
+        second = new StyleSheet();
+        second.addRule("p { color: red }");
+        ss.addStyleSheet(second);
+
+        third = new StyleSheet();
+        third.addRule("p { color: blue }");
+        ss.addStyleSheet(third);
+        assertEquals("blue", rule.getAttribute(Attribute.COLOR).toString());
+
+        ss.removeStyleSheet(third);
+        assertEquals("red", rule.getAttribute(Attribute.COLOR).toString());
+
+        ss.removeStyleSheet(second);
+        assertEquals(0, rule.getAttributeCount());
+        assertNull(rule.getAttribute(Attribute.COLOR));
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_TranslateHTMLToCSS.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_TranslateHTMLToCSS.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_TranslateHTMLToCSS.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_TranslateHTMLToCSS.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,473 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.awt.Rectangle;
+import java.io.StringReader;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyledDocument;
+import javax.swing.text.View;
+import javax.swing.text.AbstractDocument.AbstractElement;
+import javax.swing.text.AbstractDocument.BranchElement;
+import javax.swing.text.StyleContext.NamedStyle;
+import javax.swing.text.html.HTMLDocument.BlockElement;
+import javax.swing.text.html.HTMLDocument.RunElement;
+
+public class StyleSheet_TranslateHTMLToCSS extends BasicSwingTestCase {
+    private static class TestDocument extends HTMLDocument {
+        public TestDocument() {
+            super();
+        }
+
+        public TestDocument(final StyleSheet ss) {
+            super(ss);
+        }
+
+        public void lockWrite() {
+            writeLock();
+        }
+
+        public void unlockWrite() {
+            writeUnlock();
+        }
+    }
+
+    private TestDocument doc;
+    private StyleSheet ss;
+    private AttributeSet attr;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        setIgnoreNotImplemented(true);
+        doc = new TestDocument();
+        doc.insertString(0, "normal test text", null);
+        ss = new StyleSheet();
+
+        doc.lockWrite();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        doc.unlockWrite();
+    }
+
+    public void testTranslateHTMLToCSSBody() throws Exception {
+        AbstractElement body =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", body.getName());
+        assertTrue(body instanceof BlockElement);
+
+        body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
+        body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
+        body.addAttribute(HTML.Attribute.TEXT, "black");
+        body.addAttribute(HTML.Attribute.LINK, "blue");
+        body.addAttribute(HTML.Attribute.ALINK, "red");
+        body.addAttribute(HTML.Attribute.VLINK, "purple");
+        attr = ss.translateHTMLToCSS(body);
+        assertSame(NamedStyle.class, attr.getClass());
+        assertNull(((NamedStyle)attr).getName());
+        assertEquals(3, attr.getAttributeCount());
+        assertEquals(isHarmony() ? "url(bg.jpg)" : "bg.jpg",
+                     attr.getAttribute(CSS.Attribute.BACKGROUND_IMAGE)
+                     .toString());
+        assertEquals("#ffffff",
+                     attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
+                     .toString());
+        assertEquals("black",
+                     attr.getAttribute(CSS.Attribute.COLOR).toString());
+    }
+
+    public void testTranslateHTMLToCSSP() throws Exception {
+        AbstractElement p =
+            (AbstractElement)doc.getDefaultRootElement()
+                             .getElement(0).getElement(0);
+        assertEquals("p", p.getName());
+        assertTrue(p instanceof BlockElement);
+
+        p.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
+        p.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
+        p.addAttribute(HTML.Attribute.TEXT, "black");
+        p.addAttribute(HTML.Attribute.LINK, "blue");
+        p.addAttribute(HTML.Attribute.ALINK, "red");
+        p.addAttribute(HTML.Attribute.VLINK, "purple");
+
+        attr = ss.translateHTMLToCSS(p);
+        assertSame(NamedStyle.class, attr.getClass());
+        assertNull(((NamedStyle)attr).getName());
+
+        assertEquals(4, attr.getAttributeCount());
+        assertEquals(isHarmony() ? "url(bg.jpg)" : "bg.jpg",
+                     attr.getAttribute(CSS.Attribute.BACKGROUND_IMAGE)
+                     .toString());
+        assertEquals("#ffffff",
+                     attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
+                     .toString());
+        assertEquals("black",
+                     attr.getAttribute(CSS.Attribute.COLOR).toString());
+
+        assertEquals("0",
+                     attr.getAttribute(CSS.Attribute.MARGIN_TOP).toString());
+    }
+
+    public void testTranslateHTMLToCSSPContent() throws Exception {
+        AbstractElement content =
+            (AbstractElement)doc.getDefaultRootElement()
+                             .getElement(0).getElement(0).getElement(0);
+        assertEquals("content", content.getName());
+        assertTrue(content instanceof RunElement);
+
+        content.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
+        content.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
+        content.addAttribute(HTML.Attribute.TEXT, "black");
+        content.addAttribute(HTML.Attribute.LINK, "blue");
+        content.addAttribute(HTML.Attribute.ALINK, "red");
+        content.addAttribute(HTML.Attribute.VLINK, "purple");
+
+        attr = ss.translateHTMLToCSS(content);
+        assertSame(NamedStyle.class, attr.getClass());
+        assertNull(((NamedStyle)attr).getName());
+        if (isHarmony()) {
+            assertEquals("url(bg.jpg)",
+                         attr.getAttribute(CSS.Attribute.BACKGROUND_IMAGE)
+                         .toString());
+            assertEquals("#ffffff",
+                         attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
+                         .toString());
+            assertEquals("black",
+                         attr.getAttribute(CSS.Attribute.COLOR).toString());
+        } else {
+            assertEquals(0, attr.getAttributeCount());
+        }
+    }
+
+    public void testTranslateHTMLToCSSStyledDocument() throws Exception {
+        StyledDocument doc = new DefaultStyledDocument();
+        doc.insertString(0, "line1\nline2", null);
+
+        MutableAttributeSet mas = new SimpleAttributeSet();
+        mas.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
+        mas.addAttribute(HTML.Attribute.TEXT, "black");
+        doc.setParagraphAttributes(0, 1, mas, false);
+
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("paragraph", branch.getName());
+        assertTrue(branch instanceof BranchElement);
+        assertSame(BranchElement.class, branch.getClass());
+
+
+        attr = ss.translateHTMLToCSS(branch);
+        assertSame(NamedStyle.class, attr.getClass());
+        assertNull(((NamedStyle)attr).getName());
+
+        assertEquals(2, attr.getAttributeCount());
+        assertEquals("#ffffff",
+                     attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
+                     .toString());
+        assertEquals("black",
+                     attr.getAttribute(CSS.Attribute.COLOR).toString());
+    }
+
+    public void testTranslateHTMLToCSSA() throws Exception {
+        doc.remove(0, doc.getLength());
+        HTMLEditorKit kit = new HTMLEditorKit();
+        kit.read(new StringReader("<a href=\"http://go\">link</a>"), doc, 0);
+
+        AbstractElement body =
+            (AbstractElement)doc.getDefaultRootElement().getElement(1);
+        assertEquals("body", body.getName());
+
+        body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
+        body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
+        body.addAttribute(HTML.Attribute.TEXT, "black");
+        body.addAttribute(HTML.Attribute.LINK, "blue");
+        body.addAttribute(HTML.Attribute.ALINK, "red");
+        body.addAttribute(HTML.Attribute.VLINK, "purple");
+
+        AbstractElement a = (AbstractElement)doc.getCharacterElement(2);
+        assertNotNull(a.getAttribute(HTML.Tag.A));
+        attr = ss.translateHTMLToCSS(a);
+        assertNull(((NamedStyle)attr).getName());
+        assertEquals(0, attr.getAttributeCount());
+    }
+
+    public void testTranslateHTMLToCSSAlignLeft() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.ALIGN, "left");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("left",
+                     attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSAlignCenter() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.ALIGN, "center");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("center",
+                     attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSAlignRight() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.ALIGN, "right");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("right",
+                     attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSAlignJustify() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.ALIGN, "justify");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("justify",
+                     attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSAlignTop() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.ALIGN, "top");
+        attr = ss.translateHTMLToCSS(branch);
+        if (isHarmony()) {
+            assertEquals(0, attr.getAttributeCount());
+            assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
+        } else {
+            assertEquals(1, attr.getAttributeCount());
+            assertEquals("top",
+                         attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
+        }
+    }
+
+    public void testTranslateHTMLToCSSAlignBottom() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.ALIGN, "bottom");
+        attr = ss.translateHTMLToCSS(branch);
+        if (isHarmony()) {
+            assertEquals(0, attr.getAttributeCount());
+            assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
+        } else {
+            assertEquals(1, attr.getAttributeCount());
+            assertEquals("bottom",
+                         attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
+        }
+    }
+
+    public void testTranslateHTMLToCSSAlignChar() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.ALIGN, "char");
+        attr = ss.translateHTMLToCSS(branch);
+        if (isHarmony()) {
+            assertEquals(0, attr.getAttributeCount());
+            assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
+        } else {
+            assertEquals(1, attr.getAttributeCount());
+            assertEquals("char",
+                         attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
+        }
+    }
+
+    public void testTranslateHTMLToCSSVAlignTop() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.VALIGN, "top");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("top",
+                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSVAlignMiddle() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.VALIGN, "middle");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("middle",
+                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSVAlignBottom() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.VALIGN, "bottom");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("bottom",
+                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSVAlignBaseline() throws Exception {
+        AbstractElement branch =
+            (AbstractElement)doc.getDefaultRootElement().getElement(0);
+        assertEquals("body", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.VALIGN, "baseline");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(1, attr.getAttributeCount());
+        assertEquals("baseline",
+                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
+    }
+
+    public void testTranslateHTMLToCSSWidth() throws Exception {
+        AbstractElement branch = (AbstractElement)doc.getParagraphElement(0);
+        assertEquals("p", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.WIDTH, "50%");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(2, attr.getAttributeCount());
+        assertEquals("50%",
+                     attr.getAttribute(CSS.Attribute.WIDTH).toString());
+        assertEquals("0",
+                     attr.getAttribute(CSS.Attribute.MARGIN_TOP).toString());
+    }
+
+    public void testTranslateHTMLToCSSHeight() throws Exception {
+        AbstractElement branch = (AbstractElement)doc.getParagraphElement(0);
+        assertEquals("p", branch.getName());
+
+        branch.addAttribute(HTML.Attribute.HEIGHT, "331");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(2, attr.getAttributeCount());
+        assertEquals("331" + (isHarmony() ? "pt" : ""),
+                     attr.getAttribute(CSS.Attribute.HEIGHT).toString());
+        assertEquals("0",
+                     attr.getAttribute(CSS.Attribute.MARGIN_TOP).toString());
+    }
+
+    public void testTranslateHTMLToCSSStyle() throws Exception {
+        AbstractElement branch = (AbstractElement)doc.getParagraphElement(0);
+        assertEquals("p", branch.getName());
+
+        branch.addAttribute(CSS.Attribute.BORDER_BOTTOM_WIDTH, "1pt");
+        attr = ss.translateHTMLToCSS(branch);
+        assertEquals(2, attr.getAttributeCount());
+        assertEquals("1pt", attr.getAttribute(CSS.Attribute.BORDER_BOTTOM_WIDTH)
+                            .toString());
+        assertEquals("0",
+                     attr.getAttribute(CSS.Attribute.MARGIN_TOP).toString());
+    }
+
+    public void testTranslateHTMLToCSSViewAttributes() throws Exception {
+        final Marker gva = new Marker(true);
+        final Marker th2c = new Marker(true);
+        ss = new StyleSheet() {
+            public AttributeSet getViewAttributes(View v) {
+                gva.setOccurred();
+                return super.getViewAttributes(v);
+            }
+            public AttributeSet translateHTMLToCSS(AttributeSet htmlAttrSet) {
+                th2c.setOccurred();
+                return super.translateHTMLToCSS(htmlAttrSet);
+            }
+        };
+        doc = new TestDocument(ss);
+        doc.lockWrite();
+        final AbstractElement branch =
+            (AbstractElement)doc.getParagraphElement(0);
+        assertEquals("p", branch.getName());
+
+        assertFalse(gva.isOccurred());
+        assertFalse(th2c.isOccurred());
+        final View view = new InlineView(branch);
+        assertTrue(gva.isOccurred());
+        assertTrue(th2c.isOccurred());
+
+        final AttributeSet va = view.getAttributes();
+        assertFalse(gva.isOccurred());
+        assertFalse(th2c.isOccurred());
+
+        assertSame(va, view.getAttributes());
+        assertEquals(1, va.getAttributeCount());
+        assertEquals("0",
+                     va.getAttribute(CSS.Attribute.MARGIN_TOP).toString());
+
+        branch.addAttribute(HTML.Attribute.WIDTH, "200");
+
+        assertFalse(gva.isOccurred());
+        assertFalse(th2c.isOccurred());
+
+        view.changedUpdate(new DocumentEvent() {
+            public int getOffset() {
+                return branch.getStartOffset();
+            }
+            public int getLength() {
+                return branch.getEndOffset() - branch.getStartOffset();
+            }
+            public Document getDocument() {
+                return doc;
+            }
+            public EventType getType() {
+                return EventType.CHANGE;
+            }
+            public ElementChange getChange(final Element elem) {
+                return null;
+            }
+        }, new Rectangle(), null);
+        assertTrue(gva.isOccurred());
+        assertTrue(th2c.isOccurred());
+
+        final AttributeSet mva = view.getAttributes();
+        assertFalse(gva.isOccurred());
+        assertFalse(th2c.isOccurred());
+
+        assertNotSame(va, mva);
+        assertSame(mva, view.getAttributes());
+        assertEquals(2, mva.getAttributeCount());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ViewAttributesTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ViewAttributesTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ViewAttributesTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ViewAttributesTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,181 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.io.StringReader;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.Element;
+import javax.swing.text.Style;
+import javax.swing.text.View;
+import javax.swing.text.html.HTML.Tag;
+
+public class StyleSheet_ViewAttributesTest extends BasicSwingTestCase {
+    private HTMLDocument doc;
+    private StyleSheet ss;
+    private View view;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        setIgnoreNotImplemented(true);
+        ss = new StyleSheet();
+        doc = new HTMLDocument(ss);
+    }
+
+    public void testViewGetAttributes() throws Exception {
+        final Marker marker = new Marker();
+        ss = new StyleSheet() {
+            public AttributeSet getViewAttributes(final View v) {
+                marker.setOccurred();
+                marker.setAuxiliary(v);
+                return super.getViewAttributes(v);
+            };
+        };
+        doc = new HTMLDocument(ss);
+        view = new InlineView(doc.getCharacterElement(0));
+        assertTrue(marker.isOccurred());
+        assertSame(view, marker.getAuxiliary());
+    }
+
+    public void testGetViewAttributesGetRuleInline() throws Exception {
+        final Marker tag = new Marker();
+        final Marker sel = new Marker();
+        ss = new StyleSheet() {
+            public Style getRule(Tag t, Element elem) {
+                tag.setOccurred();
+                return super.getRule(t, elem);
+            }
+
+            public Style getRule(String selector) {
+                sel.setOccurred();
+                return super.getRule(selector);
+            }
+        };
+        view = new InlineView(doc.getCharacterElement(0));
+        ss.getViewAttributes(view);
+        assertFalse(tag.isOccurred());
+        assertFalse(sel.isOccurred());
+    }
+
+    public void testGetViewAttributesGetRuleBlock() throws Exception {
+        final Marker tag = new Marker();
+        final Marker sel = new Marker();
+        ss = new StyleSheet() {
+            public Style getRule(Tag t, Element elem) {
+                tag.setOccurred();
+                assertSame(HTML.Tag.P, t);
+                assertSame(view.getElement(), elem);
+                return super.getRule(t, elem);
+            }
+
+            public Style getRule(String selector) {
+                sel.setOccurred();
+                return super.getRule(selector);
+            }
+        };
+        view = new BlockView(doc.getParagraphElement(0), View.Y_AXIS);
+        ss.getViewAttributes(view);
+        assertTrue(tag.isOccurred());
+        assertFalse(sel.isOccurred());
+    }
+
+    public void testGetViewAttributesGetRuleInlineEm() throws Exception {
+        final Marker tag = new Marker();
+        final Marker sel = new Marker();
+        ss = new StyleSheet() {
+            public Style getRule(Tag t, Element elem) {
+                if (view != null) {
+                    tag.setOccurred();
+                    assertSame(HTML.Tag.EM, t);
+                    assertSame(view.getElement(), elem);
+                }
+                return super.getRule(t, elem);
+            }
+
+            public Style getRule(String selector) {
+                sel.setOccurred();
+                return super.getRule(selector);
+            }
+        };
+        doc = new HTMLDocument(ss);
+        HTMLEditorKit kit = new HTMLEditorKit();
+        kit.read(new StringReader("<em>emphasized</em>"), doc, 0);
+        Element inline = doc.getCharacterElement(1);
+        assertNotNull(inline.getAttributes()
+                      .getAttribute(AttributeSet.NameAttribute));
+        view = new InlineView(inline);
+        ss.getViewAttributes(view);
+        assertTrue(tag.isOccurred());
+        assertFalse(sel.isOccurred());
+    }
+
+    public void testGetViewAttributesTranslate() throws Exception {
+        final Marker marker = new Marker();
+        final Element block = doc.getParagraphElement(0);
+        ss = new StyleSheet() {
+            public AttributeSet translateHTMLToCSS(final AttributeSet attrs) {
+                marker.setOccurred();
+                assertSame(block, attrs);
+                return super.translateHTMLToCSS(attrs);
+            }
+        };
+        view = new BlockView(block, View.Y_AXIS);
+        assertFalse(marker.isOccurred());
+        ss.getViewAttributes(view);
+        assertTrue(marker.isOccurred());
+    }
+
+    public void testGetViewAttributesResolverNull() throws Exception {
+        final Element block = doc.getParagraphElement(0);
+        view = new BlockView(block, View.Y_AXIS);
+        AttributeSet va = ss.getViewAttributes(view);
+        assertNull(view.getParent());
+        assertNull(va.getResolveParent());
+    }
+
+    public void testGetViewAttributesResolver() throws Exception {
+        final Element block = doc.getParagraphElement(0);
+        final Element inline = block.getElement(0);
+
+        view = new InlineView(inline);
+        View bv = new BlockView(block, View.Y_AXIS);
+        view.setParent(bv);
+
+        AttributeSet va = ss.getViewAttributes(view);
+        assertSame(bv, view.getParent());
+        assertSame(bv.getAttributes(), va.getResolveParent());
+    }
+
+    public void testGetViewAttributesResolverChange() throws Exception {
+        final Element block = doc.getParagraphElement(0);
+        final Element inline = block.getElement(0);
+
+        view = new InlineView(inline);
+        View bv = new BlockView(block, View.Y_AXIS);
+
+        AttributeSet va = ss.getViewAttributes(view);
+        assertNull(view.getParent());
+        assertNull(va.getResolveParent());
+
+        view.setParent(bv);
+        assertSame(bv.getAttributes(), va.getResolveParent());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/AttributeListTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/AttributeListTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/AttributeListTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/AttributeListTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,145 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import java.util.Vector;
+import junit.framework.TestCase;
+
+public class AttributeListTest extends TestCase {
+       AttributeList attrList;
+       String name = "first";
+       int type = 26;
+       int modifier = 16;
+       String value = "value";
+       Vector values = new Vector();
+       AttributeList next = new AttributeList("second");
+
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        attrList = new AttributeList(name, type, modifier, value, values, next);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+
+    public void testAttributeListConstr1() {
+        Utils.checkAttributeList(attrList, modifier, type,
+                                 name, next, values, value, true);
+    }
+
+
+    public void testAttributeListConstr2() {
+        assertEquals(0, next.modifier);
+        assertEquals("second", next.name);
+        assertEquals(null, next.next);
+        assertEquals(0, next.type);
+        assertEquals(null, next.value);
+        assertEquals(null, next.values);
+
+        AttributeList attributeList = new AttributeList(null);
+        assertEquals(null, attributeList.name);
+
+        attributeList = new AttributeList("AAA");
+        assertEquals("AAA", attributeList.name);
+    }
+
+    public void testGetNext() {
+        assertEquals(next, attrList.getNext());
+    }
+
+
+    public void testGetValue() {
+        assertEquals(value, attrList.getValue());
+    }
+
+
+    public void testGetValues() {
+        assertEquals(values.elements().getClass(),
+                     attrList.getValues().getClass());
+    }
+
+
+    public void testGetModifier() {
+        assertEquals(modifier, attrList.getModifier());
+    }
+
+
+    public void testGetType() {
+        assertEquals(type, attrList.getType());
+    }
+
+
+    public void testGetName() {
+        assertEquals(name, attrList.getName());
+    }
+
+    String[] names = new String[] {null,
+                                   "CDATA",
+                                   "ENTITY",
+                                   "ENTITIES",
+                                   "ID",
+                                   "IDREF",
+                                   "IDREFS",
+                                   "NAME",
+                                   "NAMES",
+                                   "NMTOKEN",
+                                   "NMTOKENS",
+                                   "NOTATION",
+                                   "NUMBER",
+                                   "NUMBERS",
+                                   "NUTOKEN",
+                                   "NUTOKENS"};
+
+    public void testType2name() {
+        for (int i = 0; i < 300; i++) {
+            assertEquals(i < 16 ? names[i] : null, AttributeList.type2name(i));
+        }
+    }
+
+
+    public void testName2type() {
+        for (int i = 0; i < 300; i++) {
+            if (i > 0 && i < 16) {
+                assertEquals(1, AttributeList.name2type(names[i]
+                                                              .toLowerCase()));
+                assertEquals(i, AttributeList.name2type(names[i]));
+            } else {
+                try {
+                    assertEquals(1, AttributeList.name2type(null));
+                    assertFalse("NPE not thrown", true);
+                } catch (NullPointerException e) {
+                }
+            }
+        }
+        assertEquals(1, AttributeList.name2type("test"));
+    }
+
+    public void testSerialization() {
+        AttributeList attributeList = (AttributeList)Utils
+            .doSerialization(attrList);
+        Utils.checkAttributeList(attributeList,
+                                 modifier, type, name,
+                                 next, values, value, false);
+    }
+}

Added: 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?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ContentModelTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,548 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import java.awt.Rectangle;
+import java.util.Vector;
+
+import javax.swing.SwingTestCase;
+
+public class ContentModelTest extends SwingTestCase {
+    ContentModel contentModel;
+    Element[] elements;
+    char[] types;
+    Vector elemVec;
+    ContentModel contentModel1;
+    ContentModel contentModel2;
+    ContentModel contentModel3;
+    ContentModel contentModel4;
+    ContentModel contentModel5;
+    ContentModel contentModel6;
+    ContentModel contentModel7;
+    ContentModel contentModel8;
+    ContentModel contentModel9;
+    ContentModel contentModel10;
+    ContentModel contentModel11;
+    ContentModel contentModel12;
+    ContentModel contentModel13;
+    ContentModel contentModel14;
+
+
+    protected void setUp() throws Exception {
+        init();
+        resetElemVec();
+        super.setUp();
+    }
+
+    private void resetElemVec() {
+        if (elemVec == null) {
+            elemVec = new Vector();
+        } else {
+            elemVec.removeAllElements();
+        }
+    }
+
+    private void init() {
+        if (elements == null) {
+            elements = new Element[7];
+            for (int i = 0; i < 7; i++) {
+                elements[i] = new Element();
+                elements[i].name = Integer.toString(i);
+            }
+        }
+        if (types == null) {
+            types = new char[] {'*', '?', '+', ',', '|', '&'};
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testContentModelElement() {
+        contentModel = new ContentModel(elements[0]);
+        Utils.checkContentModel(contentModel, elements[0], 0, null);
+
+        contentModel = new ContentModel(null);
+        Utils.checkContentModel(contentModel, null, 0, null);
+    }
+
+    public void testContentModel() {
+        contentModel = new ContentModel();
+        Utils.checkContentModel(contentModel, null, 0, null);
+    }
+
+    public void testContentModelIntContentModel() {
+        contentModel1 = new ContentModel(elements[0]);
+
+        contentModel = new ContentModel('*', contentModel1);
+        Utils.checkContentModel(contentModel, contentModel1, '*', null);
+
+        contentModel = new ContentModel('?', contentModel1);
+        Utils.checkContentModel(contentModel, contentModel1, '?', null);
+
+        contentModel = new ContentModel('+', contentModel1);
+        Utils.checkContentModel(contentModel, contentModel1, '+', null);
+    }
+
+    public void testContentModelIntObjectContentModel() {
+        contentModel1 = new ContentModel(elements[0]);
+        contentModel = new ContentModel(',', elements[1], contentModel1);
+        Utils.checkContentModel(contentModel, elements[1], ',',
+                                contentModel1);
+
+        contentModel = new ContentModel('|', elements[1], contentModel1);
+        Utils.checkContentModel(contentModel, elements[1], '|',
+                                contentModel1);
+
+        contentModel = new ContentModel('&', elements[1], contentModel1);
+        Utils.checkContentModel(contentModel, elements[1], '&',
+                                contentModel1);
+
+        contentModel2 = new ContentModel(elements[1]);
+        contentModel = new ContentModel(',', contentModel2, contentModel1);
+        Utils.checkContentModel(contentModel, contentModel2, ',',
+                                contentModel1);
+
+        contentModel = new ContentModel('|', contentModel2, contentModel1);
+        Utils.checkContentModel(contentModel, contentModel2, '|',
+                                contentModel1);
+
+
+        contentModel = new ContentModel('&', contentModel2, contentModel1);
+        Utils.checkContentModel(contentModel, contentModel2, '&',
+                                contentModel1);
+    }
+
+    public void testIllegalArgumentException_Object() {
+        if (SwingTestCase.isHarmony()) {
+            contentModel1 = new ContentModel(elements[0]);
+            try {
+                contentModel = new ContentModel(',', new Rectangle(),
+                                            contentModel1);
+                throwException("1");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel(',', null,
+                                            contentModel1);
+                throwException("2");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('|', null,
+                                            contentModel1);
+                throwException("3");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('&', null,
+                                            contentModel1);
+                throwException("4");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel(',', elements[2],
+                                            null);
+                throwException("5");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('|', elements[2],
+                                            null);
+                throwException("6");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('&', elements[2],
+                                            null);
+                throwException("7");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('+', null);
+                throwException("8");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('*', null);
+                throwException("9");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('?', null);
+                throwException("10");
+            } catch (IllegalArgumentException e) {
+            }
+        }
+    }
+
+    public void testIllegalArgumentException_Type() {
+        if (SwingTestCase.isHarmony()) {
+            contentModel1 = new ContentModel(elements[0]);
+            try {
+                contentModel = new ContentModel(',', contentModel1);
+                throwException("0");
+            } catch (IllegalArgumentException e) {
+            }
+            try {
+                contentModel = new ContentModel('&', contentModel1);
+                throwException("1");
+            } catch (IllegalArgumentException e) {
+            }
+            try {
+                contentModel = new ContentModel('|', contentModel1);
+                throwException("2");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('a', contentModel1);
+                throwException("3");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('+', elements[0],
+                                                contentModel1);
+                throwException("4");
+            } catch (IllegalArgumentException e) {
+            }
+            try {
+                contentModel = new ContentModel('*', elements[0],
+                                                contentModel1);
+                throwException("5");
+            } catch (IllegalArgumentException e) {
+            }
+            try {
+                contentModel = new ContentModel('?', elements[0],
+                                                contentModel1);
+                throwException("6");
+            } catch (IllegalArgumentException e) {
+            }
+
+            try {
+                contentModel = new ContentModel('a', elements[0],
+                                                contentModel1);
+                throwException("7");
+            } catch (IllegalArgumentException e) {
+            }
+        }
+    }
+
+    private void throwException(final String s) {
+        assertFalse("IllegalArgumentException wasn't thrown:" + s, true);
+    }
+
+
+    public void testFirst() {
+        if (!SwingTestCase.isHarmony()) {
+            return;
+        }
+        initContentModels();
+        assertNull(contentModel1.first());
+        assertNull(contentModel2.first());
+        assertNull(contentModel3.first());
+        assertNull(contentModel4.first());
+        assertNull(contentModel5.first());
+        assertEquals(elements[3], contentModel6.first());
+        assertEquals(elements[2], contentModel7.first());
+        assertEquals(elements[1], contentModel8.first());
+        assertNull(contentModel9.first());
+    }
+
+
+    public void testToString() {
+        if (!SwingTestCase.isHarmony()) {
+            return;
+        }
+        initContentModels();
+        assertEquals("1", contentModel1.toString());
+        assertEquals("2", contentModel2.toString());
+        assertEquals("3", contentModel3.toString());
+        assertEquals("1+", contentModel4.toString());
+        assertEquals("2*", contentModel5.toString());
+        assertEquals("4|3", contentModel6.toString());
+        assertEquals("1+,2*", contentModel7.toString());
+        assertEquals("(4|3)&(1+,2*)", contentModel8.toString());
+        assertEquals("null", contentModel9.toString());
+        assertEquals("1?", contentModel10.toString());
+        assertEquals("1?,3*", contentModel11.toString());
+        assertEquals("(1?,3*)|(1?,3*)", contentModel12.toString());
+        assertEquals("(4|3),((1?,3*)|(1?,3*))", contentModel13.toString());
+        assertEquals("2*&null", contentModel14.toString());
+    }
+
+    private void initContentModels() {
+        contentModel1 = new ContentModel(elements[1]);
+        contentModel2 = new ContentModel(elements[2]);
+        contentModel3 = new ContentModel(elements[3]);
+        contentModel4 = new ContentModel('+', contentModel1);
+        contentModel5 = new ContentModel('*', contentModel2);
+        contentModel6 = new ContentModel('|', elements[4], contentModel3);
+        contentModel7 = new ContentModel(',', contentModel4, contentModel5);
+        contentModel8 = new ContentModel('&', contentModel6, contentModel7);
+        contentModel9 = new ContentModel();
+        contentModel10 = new ContentModel('?', contentModel1);
+        contentModel11 = new ContentModel(',',
+                                          new ContentModel('?', contentModel1),
+                                          new ContentModel('*', contentModel3));
+        contentModel12 = new ContentModel('|', contentModel11, contentModel11);
+        contentModel13 = new ContentModel(',', contentModel6, contentModel12);
+        contentModel14 = new ContentModel('&', contentModel5, contentModel9);
+    }
+
+    public void testFirstObject() {
+        if (!SwingTestCase.isHarmony()) {
+            return;
+        }
+        initContentModels();
+        Object rect = new Rectangle();
+        assertTrue(contentModel1.first(elements[1]));
+        assertTrue(contentModel1.first(null));
+        assertFalse(contentModel1.first(rect));
+        assertFalse(contentModel1.first(contentModel9));
+        assertTrue(contentModel1.first(contentModel1));
+        assertFalse(contentModel1.first(elements[2]));
+
+        assertTrue(contentModel4.first(elements[1]));
+        assertTrue(contentModel4.first(null));
+        assertFalse(contentModel4.first(contentModel9));
+        assertTrue(contentModel4.first(contentModel1));
+        assertFalse(contentModel4.first(elements[2]));
+
+        assertFalse(contentModel5.first(elements[1]));
+        assertTrue(contentModel5.first(null));
+        assertFalse(contentModel5.first(rect));
+        assertFalse(contentModel5.first(contentModel9));
+        assertFalse(contentModel5.first(contentModel1));
+        assertTrue(contentModel5.first(contentModel2));
+        assertTrue(contentModel5.first(elements[2]));
+
+        assertFalse(contentModel6.first(elements[1]));
+        assertTrue(contentModel6.first(null));
+        assertFalse(contentModel6.first(rect));
+        assertFalse(contentModel6.first(contentModel9));
+        assertFalse(contentModel6.first(contentModel1));
+        assertFalse(contentModel6.first(contentModel2));
+        assertFalse(contentModel6.first(elements[2]));
+        assertTrue(contentModel6.first(elements[4]));
+        assertTrue(contentModel6.first(elements[3]));
+        assertTrue(contentModel6.first(contentModel3));
+        assertTrue(contentModel6.first(contentModel6));
+
+
+        assertTrue(contentModel7.first(elements[1]));
+        assertTrue(contentModel7.first(null));
+        assertFalse(contentModel7.first(rect));
+        assertFalse(contentModel7.first(contentModel5));
+        assertTrue(contentModel7.first(contentModel1));
+        assertFalse(contentModel7.first(contentModel2));
+        assertFalse(contentModel7.first(elements[2]));
+        assertFalse(contentModel7.first(elements[4]));
+        assertFalse(contentModel7.first(elements[3]));
+        assertFalse(contentModel7.first(elements[5]));
+        assertFalse(contentModel7.first(contentModel3));
+
+        assertTrue(contentModel8.first(elements[1]));
+        assertTrue(contentModel8.first(null));
+        assertFalse(contentModel8.first(rect));
+        assertFalse(contentModel8.first(contentModel5));
+        assertTrue(contentModel8.first(contentModel6));
+        assertTrue(contentModel8.first(contentModel6));
+        assertFalse(contentModel8.first(contentModel2));
+        assertFalse(contentModel8.first(elements[2]));
+        assertTrue(contentModel8.first(elements[4]));
+        assertTrue(contentModel8.first(elements[3]));
+        assertFalse(contentModel8.first(elements[5]));
+
+        assertFalse(contentModel9.first(elements[1]));
+        assertTrue(contentModel9.first(null));
+        assertFalse(contentModel9.first(rect));
+        assertFalse(contentModel9.first(contentModel5));
+        assertFalse(contentModel9.first(contentModel6));
+
+        assertTrue(contentModel10.first(elements[1]));
+        assertTrue(contentModel10.first(null));
+        assertFalse(contentModel10.first(rect));
+        assertFalse(contentModel10.first(contentModel5));
+        assertTrue(contentModel10.first(contentModel1));
+        assertFalse(contentModel10.first(contentModel2));
+        assertFalse(contentModel10.first(elements[2]));
+
+        assertTrue(contentModel11.first(elements[1]));
+        assertTrue(contentModel11.first(null));
+        assertFalse(contentModel11.first(rect));
+        assertFalse(contentModel11.first(contentModel5));
+        assertTrue(contentModel11.first(contentModel1));
+        assertFalse(contentModel11.first(contentModel2));
+        assertTrue(contentModel11.first(contentModel3));
+        assertFalse(contentModel11.first(elements[2]));
+        assertFalse(contentModel11.first(elements[4]));
+        assertTrue(contentModel11.first(elements[3]));
+        assertFalse(contentModel11.first(elements[5]));
+        assertFalse(contentModel11.first(contentModel7));
+
+        assertTrue(contentModel12.first(elements[1]));
+        assertTrue(contentModel12.first(null));
+        assertFalse(contentModel12.first(rect));
+        assertFalse(contentModel12.first(contentModel5));
+        assertTrue(contentModel12.first(contentModel1));
+        assertFalse(contentModel12.first(contentModel2));
+        assertTrue(contentModel12.first(contentModel3));
+        assertFalse(contentModel12.first(elements[2]));
+        assertFalse(contentModel12.first(elements[4]));
+        assertTrue(contentModel12.first(elements[3]));
+        assertFalse(contentModel12.first(elements[5]));
+        assertFalse(contentModel12.first(contentModel7));
+        assertTrue(contentModel12.first(contentModel11));
+        assertTrue(contentModel12.first(contentModel12));
+
+        assertTrue(contentModel13.first(contentModel6));
+        assertTrue(contentModel13.first(elements[4]));
+        assertTrue(contentModel13.first(elements[3]));
+        assertTrue(contentModel13.first(null));
+        assertTrue(contentModel13.first(contentModel3));
+        assertFalse(contentModel13.first(elements[1]));
+        assertFalse(contentModel13.first(rect));
+        assertFalse(contentModel13.first(contentModel5));
+        assertFalse(contentModel13.first(contentModel1));
+        assertFalse(contentModel13.first(elements[2]));
+        assertFalse(contentModel13.first(elements[5]));
+        assertFalse(contentModel13.first(contentModel7));
+        assertFalse(contentModel13.first(contentModel11));
+        assertFalse(contentModel13.first(contentModel12));
+
+        assertTrue(contentModel14.first(contentModel5));
+        assertTrue(contentModel14.first(null));
+        assertTrue(contentModel14.first(contentModel9));
+        assertTrue(contentModel14.first(elements[2]));
+        assertFalse(contentModel14.first(elements[1]));
+        assertFalse(contentModel14.first(rect));
+        assertFalse(contentModel14.first(contentModel1));
+        assertFalse(contentModel14.first(contentModel6));
+        assertFalse(contentModel14.first(contentModel3));
+        assertFalse(contentModel14.first(elements[4]));
+        assertFalse(contentModel14.first(elements[3]));
+        assertFalse(contentModel14.first(elements[5]));
+        assertFalse(contentModel14.first(contentModel11));
+    }
+
+    private void checkElemVec(final Vector v) {
+        assertEquals(v.size(), elemVec.size());
+        for (int i = 0; i < v.size(); i++) {
+            assertEquals(v.get(i), elemVec.get(i));
+        }
+    }
+
+    public void testGetElements() {
+        resetElemVec();
+        Vector v = new Vector();
+        initContentModels();
+
+        contentModel1.getElements(elemVec);
+        v.add(elements[1]);
+        checkElemVec(v);
+
+        contentModel2.getElements(elemVec);
+        v.add(elements[2]);
+        checkElemVec(v);
+
+        contentModel3.getElements(elemVec);
+        v.add(elements[3]);
+        checkElemVec(v);
+
+        contentModel4.getElements(elemVec);
+        v.add(elements[1]);
+        checkElemVec(v);
+
+        contentModel5.getElements(elemVec);
+        v.add(elements[2]);
+        checkElemVec(v);
+
+        if (!SwingTestCase.isHarmony()) {
+            return;
+        }
+
+        contentModel6.getElements(elemVec);
+        v.add(elements[4]);
+        v.add(elements[3]);
+        checkElemVec(v);
+
+        contentModel7.getElements(elemVec);
+        v.add(elements[1]);
+        v.add(elements[2]);
+        checkElemVec(v);
+
+        contentModel8.getElements(elemVec);
+        v.add(elements[4]);
+        v.add(elements[3]);
+        v.add(elements[1]);
+        v.add(elements[2]);
+        checkElemVec(v);
+
+        contentModel9.getElements(elemVec);
+        checkElemVec(v);
+    }
+
+    public void testEmpty() {
+        //ClassCastException on RI
+        if (!SwingTestCase.isHarmony()) {
+            return;
+        }
+        initContentModels();
+        assertFalse(contentModel1.empty());
+        assertFalse(contentModel2.empty());
+        assertFalse(contentModel3.empty());
+        assertFalse(contentModel4.empty());
+        assertTrue(contentModel5.empty());
+        assertFalse(contentModel6.empty());
+        assertFalse(contentModel7.empty());
+        assertFalse(contentModel8.empty());
+        assertTrue(contentModel9.empty());
+        assertTrue(contentModel10.empty());
+        assertTrue(contentModel11.empty());
+        assertTrue(contentModel12.empty());
+        assertFalse(contentModel13.empty());
+        assertTrue(contentModel14.empty());
+    }
+
+    public void testSerialization() {
+        contentModel1 = new ContentModel(elements[0]);
+        contentModel = new ContentModel('|', elements[1], contentModel1);
+        contentModel2 = (ContentModel)Utils.doSerialization(contentModel);
+        assertEquals('|', contentModel2.type);
+        assertTrue(contentModel2.content instanceof Element);
+        assertEquals(elements[1].name, ((Element)contentModel2.content).name);
+        contentModel3 = contentModel2.next;
+        assertEquals(0, contentModel3.type);
+        assertEquals("0", ((Element)contentModel3.content).name);
+        assertNull(contentModel3.next);
+    }
+}