harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r427121 [19/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/...
Date Mon, 31 Jul 2006 14:08:55 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKitTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKitTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKitTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKitTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,506 @@
+/*
+ *  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 Vadim L. Bogdanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.awt.Cursor;
+import java.awt.event.ActionEvent;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Arrays;
+
+import javax.swing.Action;
+import javax.swing.JEditorPane;
+import javax.swing.SwingTestCase;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledEditorKit;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.html.HTMLEditorKit.InsertHTMLTextAction;
+
+public class HTMLEditorKitTest extends SwingTestCase {
+    private static final String HTML_TEXT = "<title>t</title>html <i>text</i>";
+    private static final String LOADED_HTML_TEXT = "  \nhtml text";
+    private HTMLEditorKit editorKit;
+    private HTMLDocument document;
+
+    public HTMLEditorKitTest(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        setIgnoreNotImplemented(true);
+
+        editorKit = new HTMLEditorKit();
+        document = (HTMLDocument)editorKit.createDefaultDocument();
+        document.setAsynchronousLoadPriority(-1);  // synchronous loading
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testHTMLEditorKit() {
+        editorKit = new HTMLEditorKit();
+
+        assertNotNull(editorKit.getActions());
+    }
+
+    public void testClone() {
+        // TODO: implement
+    }
+
+    public void testCreateDefaultDocument() {
+        Document doc = editorKit.createDefaultDocument();
+        assertTrue(doc instanceof HTMLDocument);
+
+        HTMLDocument htmlDoc = (HTMLDocument)doc;
+        assertSame(editorKit.getParser(), htmlDoc.getParser());
+        assertEquals(4, htmlDoc.getAsynchronousLoadPriority());
+        assertNotNull(htmlDoc.getStyleSheet());
+        assertFalse(editorKit.getStyleSheet().equals(htmlDoc.getStyleSheet()));
+
+        assertTrue(Arrays.asList(htmlDoc.getStyleSheet().getStyleSheets())
+                   .contains(editorKit.getStyleSheet()));
+    }
+
+    public void testDeinstallJEditorPane() {
+        JEditorPane pane = new JEditorPane();
+        int mouseListenersCount = pane.getMouseListeners().length;
+        int mouseMotionListenersCount = pane.getMouseMotionListeners().length;
+
+        editorKit.install(pane);
+        editorKit.deinstall(pane);
+
+        assertEquals(mouseListenersCount,
+                     pane.getMouseListeners().length);
+        assertEquals(mouseMotionListenersCount,
+                     pane.getMouseMotionListeners().length);
+    }
+
+    public void testGetAccessibleContext() {
+        // TODO: implement
+    }
+
+    public void testGetActions() throws Exception {
+        Action[] ancestorActions = new StyledEditorKit().getActions();
+        Action[] actions = editorKit.getActions();
+        assertEquals(12, actions.length - ancestorActions.length);
+
+        Action[] predefinedInsertHTMLTextActions = createPredefinedInsertHTMLTextActions();
+        for (int i = 0; i < predefinedInsertHTMLTextActions.length; i++) {
+            Action action = findActionWithName(actions,
+                predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
+            if (action != null) {
+                assertTrue("Action is not same" + action.getValue(Action.NAME),
+                           compareInsertHTMLTextActions(action,
+                                                        predefinedInsertHTMLTextActions[i]));
+            } else {
+                fail("Action not found: " + predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
+            }
+        }
+    }
+
+    public void testNextLinkAction() throws Exception {
+        Action action = findActionWithName(
+            editorKit.getActions(), "next-link-action");
+        assertNotNull(action);
+
+        JEditorPane pane = new JEditorPane();
+        pane.setEditable(false);
+        pane.setEditorKit(editorKit);
+        document = ((HTMLDocument)pane.getDocument());
+        document.setAsynchronousLoadPriority(-1);  // synchronous loading
+        pane.setText("<p><a href=http://a.com>a.com</a>text<a href=http://b.com>b.com</a></p>");
+        pane.setCaretPosition(0);
+
+        action.actionPerformed(new ActionEvent(pane, 0, null));
+        Element e = document.getCharacterElement(pane.getCaretPosition());
+        assertEquals("http://a.com", getURLString(e));
+        action.actionPerformed(new ActionEvent(pane, 0, null));
+        e = document.getCharacterElement(pane.getCaretPosition());
+        assertEquals("http://b.com", getURLString(e));
+    }
+
+    public void testPreviousLinkAction() throws Exception {
+        Action action = findActionWithName(
+            editorKit.getActions(), "previous-link-action");
+        assertNotNull(action);
+
+        JEditorPane pane = new JEditorPane();
+        pane.setEditable(false);
+        pane.setEditorKit(editorKit);
+        document = ((HTMLDocument)pane.getDocument());
+        document.setAsynchronousLoadPriority(-1);  // synchronous loading
+        pane.setText("<p><a href=http://a.com>a.com</a>text<a href=http://b.com>b.com</a></p>");
+        pane.setCaretPosition(document.getLength() - 1);
+
+        action.actionPerformed(new ActionEvent(pane, 0, null));
+        Element e = document.getCharacterElement(pane.getCaretPosition());
+        assertEquals("http://b.com", getURLString(e));
+        action.actionPerformed(new ActionEvent(pane, 0, null));
+        e = document.getCharacterElement(pane.getCaretPosition());
+        assertEquals("http://a.com", getURLString(e));
+    }
+
+    public void testActivateLinkAction() throws Exception {
+        Action action = findActionWithName(
+            editorKit.getActions(), "activate-link-action");
+        assertNotNull(action);
+
+        JEditorPane pane = new JEditorPane();
+        pane.setEditable(false);
+        pane.setEditorKit(editorKit);
+        document = ((HTMLDocument)pane.getDocument());
+        document.setAsynchronousLoadPriority(-1);  // synchronous loading
+        pane.setText("<p><a href=http://a.com>a.com</a>text<a href=http://b.com>b.com</a></p>");
+        pane.setCaretPosition(1);
+
+        class TestHyperlinkListener implements HyperlinkListener {
+            public boolean occured;
+
+            public void hyperlinkUpdate(HyperlinkEvent event) {
+                occured = true;
+            }
+        }
+
+        TestHyperlinkListener listener = new TestHyperlinkListener();
+        pane.addHyperlinkListener(listener);
+
+        action.actionPerformed(new ActionEvent(pane, 0, null));
+        assertTrue(listener.occured);
+    }
+
+    public void testInsertHRAction() throws Exception {
+        InsertHTMLTextAction action = (InsertHTMLTextAction)findActionWithName(
+            editorKit.getActions(), "InsertHR");
+        assertNotNull(action);
+
+        JEditorPane pane = new JEditorPane();
+        pane.setEditorKit(editorKit);
+        document = ((HTMLDocument)pane.getDocument());
+        document.setAsynchronousLoadPriority(-1);  // synchronous loading
+        pane.setText("<p>test</p>");
+        final int pos = document.getLength() - 1;
+        pane.setCaretPosition(pos);
+
+        action.actionPerformed(new ActionEvent(pane, 0, null));
+        Element e = document.getCharacterElement(pos + 1);
+        assertEquals(HTML.Tag.HR, getHTMLTagByElement(e));
+        assertNotNull(e);
+        HTML.Tag parentTag = getHTMLTagByElement(e.getParentElement());
+        assertTrue(HTML.Tag.P.equals(parentTag) || HTML.Tag.IMPLIED.equals(parentTag));
+    }
+
+    public void testGetContentType() {
+        assertEquals("text/html", editorKit.getContentType());
+    }
+
+    public void testGetInputAttributes() throws Exception {
+        JEditorPane pane = new JEditorPane();
+        editorKit.install(pane);
+        editorKit.read(new StringReader("normal<i>italic</i>"),
+                       pane.getDocument(), 0);
+
+        pane.setCaretPosition(pane.getDocument().getLength() - 1);
+        assertNotNull(editorKit.getInputAttributes());
+    }
+
+    public void testGetViewFactory() {
+        ViewFactory factory = editorKit.getViewFactory();
+        assertTrue(factory instanceof HTMLEditorKit.HTMLFactory);
+        assertSame(factory, editorKit.getViewFactory());
+        assertSame(factory, new HTMLEditorKit().getViewFactory());
+    }
+
+    public void testInsertHTML() throws Exception {
+        final String HTML_TEXT2 = "<i>_another text_</i>";
+        final String HTML_TEXT3 = ("");
+        final String INSERTION_RESULT = "  \nhtml_another text_ text";
+
+        editorKit.read(new StringReader(HTML_TEXT), document, 0);
+        String s = document.getText(0, document.getLength());
+        assertEquals(LOADED_HTML_TEXT, s);
+
+        editorKit.insertHTML(document, 7, HTML_TEXT2, 0, 0, HTML.Tag.I);
+        assertEquals(INSERTION_RESULT, document.getText(0, document.getLength()));
+
+        // test pos > document's length
+        testExceptionalCase(new ExceptionalCase() {
+            public Class expectedExceptionClass() {
+                return BadLocationException.class;
+            }
+            public void exceptionalAction() throws Exception {
+                editorKit.insertHTML(document, document.getLength() + 1,
+                                     HTML_TEXT3, 0, 0, HTML.Tag.P);
+            }
+        });
+
+        // test pos < 0
+        testExceptionalCase(new ExceptionalCase() {
+            public Class expectedExceptionClass() {
+                return BadLocationException.class;
+            }
+            public void exceptionalAction() throws Exception {
+                editorKit.insertHTML(document, -1, HTML_TEXT2, 0, 0, HTML.Tag.I);
+            }
+        });
+
+        // empty insertion, no exception should be thrown
+        editorKit.insertHTML(document, -1, HTML_TEXT3, 0, 0, HTML.Tag.I);
+    }
+
+    public void testInstallJEditorPane() {
+        JEditorPane pane = new JEditorPane();
+        int mouseListenersCount = pane.getMouseListeners().length;
+        int mouseMotionListenersCount = pane.getMouseMotionListeners().length;
+
+        editorKit.install(pane);
+
+        assertEquals(mouseListenersCount + 1,
+                     pane.getMouseListeners().length);
+        assertEquals(mouseMotionListenersCount + 1,
+                     pane.getMouseMotionListeners().length);
+    }
+
+    public void testRead() throws Exception {
+        final StringReader in1 = new StringReader(HTML_TEXT);
+        final StringReader in2 = new StringReader("another text");
+        final StringReader in3 = new StringReader("");
+        final StringReader in4 = new StringReader("");
+        final StringReader in5 = new StringReader("");
+        final String text2 = "  \nhtml\nanother text\n text";
+
+        editorKit.read(in1, document, 0);
+        String s = document.getText(0, document.getLength());
+        assertEquals(LOADED_HTML_TEXT, s);
+        testExceptionalCase(new ExceptionalCase() {
+            public Class expectedExceptionClass() {
+                return IOException.class;
+            }
+            public void exceptionalAction() throws Exception {
+                in1.ready();
+            }
+        });
+
+        editorKit.read(in2, document, 7);
+        assertEquals(text2, document.getText(0, document.getLength()));
+
+        // test pos > document's length
+        testExceptionalCase(new ExceptionalCase() {
+            public Class expectedExceptionClass() {
+                return BadLocationException.class;
+            }
+            public void exceptionalAction() throws Exception {
+                editorKit.read(in3, document, document.getLength() + 1);
+            }
+        });
+
+        // test pos outside BODY
+        testExceptionalCase(new ExceptionalCase() {
+            public Class expectedExceptionClass() {
+                return RuntimeException.class;
+            }
+            public void exceptionalAction() throws Exception {
+                editorKit.read(in4, document, 0);
+            }
+        });
+
+        // test pos < 0
+        testExceptionalCase(new ExceptionalCase() {
+            public Class expectedExceptionClass() {
+                return RuntimeException.class;
+            }
+            public void exceptionalAction() throws Exception {
+                editorKit.read(in5, document, -1);
+            }
+        });
+    }
+
+    public void testSetIsAutoFormSubmission() {
+        assertTrue(editorKit.isAutoFormSubmission());
+
+        editorKit.setAutoFormSubmission(false);
+        assertFalse(editorKit.isAutoFormSubmission());
+    }
+
+    public void testSetGetDefaultCursor() {
+        assertSame(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR),
+                   editorKit.getDefaultCursor());
+
+        Cursor newCursor = new Cursor(Cursor.DEFAULT_CURSOR);
+        editorKit.setDefaultCursor(newCursor);
+        assertSame(newCursor, editorKit.getDefaultCursor());
+    }
+
+    public void testSetGetLinkCursor() {
+        assertSame(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
+                   editorKit.getLinkCursor());
+
+        Cursor newCursor = new Cursor(Cursor.DEFAULT_CURSOR);
+        editorKit.setLinkCursor(newCursor);
+        assertSame(newCursor, editorKit.getLinkCursor());
+    }
+
+    public void testSetStyleSheet() {
+        StyleSheet ss = new StyleSheet();
+        editorKit.setStyleSheet(ss);
+        assertSame(ss, editorKit.getStyleSheet());
+
+        editorKit = new HTMLEditorKit();
+        assertSame(ss, editorKit.getStyleSheet());
+    }
+
+    public void testGetStyleSheet() {
+        StyleSheet ss = editorKit.getStyleSheet();
+        assertNotNull(ss);
+        assertSame(ss, editorKit.getStyleSheet());
+
+        editorKit = new HTMLEditorKit();
+        assertSame(ss, editorKit.getStyleSheet());
+    }
+
+    public void testWrite() throws Exception {
+        StringWriter writer = new StringWriter();
+        final String content = "Hello, World!";
+        final int start = 1;
+        final int end = 4;
+        DefaultStyledDocument doc = new DefaultStyledDocument();
+        doc.insertString(0, content, null);
+
+        editorKit.write(writer, doc, start, end);
+        String output = writer.toString();
+        assertTrue(output.indexOf("<html>") != -1);
+        if (isHarmony()) {
+            assertFalse(output.indexOf(content) != -1);
+            assertTrue(output.indexOf(content.substring(start, end)) != -1);
+        }
+
+        writer = new StringWriter();
+        doc = (HTMLDocument)editorKit.createDefaultDocument();
+        doc.insertString(0, content, null);
+        editorKit.write(writer, doc, start, end);
+        output = writer.toString();
+        assertTrue(output.indexOf("<html>") != -1);
+        assertFalse(output.indexOf(content) != -1);
+        assertTrue(output.indexOf(content.substring(start, end)) != -1);
+    }
+
+    public void testGetParser() {
+        HTMLEditorKit.Parser parser = editorKit.getParser();
+        assertNotNull(parser);
+        assertSame(parser, editorKit.getParser());
+        assertSame(parser, new HTMLEditorKit().getParser());
+    }
+
+    public void testCreateInputAttributes() throws Exception {
+        document.insertAfterStart(document.getDefaultRootElement(), "<b>bold</b>");
+        Element e = document.getDefaultRootElement().getElement(0);
+        SimpleAttributeSet attrSet = new SimpleAttributeSet();
+        editorKit.createInputAttributes(e, attrSet);
+        assertTrue(attrSet.containsAttribute(StyleConstants.NameAttribute,
+                                             HTML.Tag.CONTENT));
+        assertEquals("bold", attrSet.getAttribute(CSS.Attribute.FONT_WEIGHT).toString());
+    }
+
+    public void testParserCallback() {
+        Object implied = HTMLEditorKit.ParserCallback.IMPLIED;
+        assertTrue(implied instanceof String);
+        assertFalse("".equals(implied));
+    }
+
+    private Action[] createPredefinedInsertHTMLTextActions() {
+        Action[] actions = {
+            new HTMLEditorKit.InsertHTMLTextAction("InsertOrderedList",
+                "<ol><li></li></ol>", HTML.Tag.BODY, HTML.Tag.OL),
+            new HTMLEditorKit.InsertHTMLTextAction("InsertOrderedListItem",
+                "<ol><li></li></ol>",
+                HTML.Tag.OL, HTML.Tag.LI, HTML.Tag.BODY, HTML.Tag.OL),
+            new HTMLEditorKit.InsertHTMLTextAction("InsertUnorderedList",
+                "<ul><li></li></ul>", HTML.Tag.BODY, HTML.Tag.UL),
+            new HTMLEditorKit.InsertHTMLTextAction("InsertUnorderedListItem",
+                "<ul><li></li></ul>",
+                HTML.Tag.UL, HTML.Tag.LI, HTML.Tag.BODY, HTML.Tag.UL),
+            new HTMLEditorKit.InsertHTMLTextAction("InsertTable",
+                "<table border=1><tr><td></td></tr></table>",
+                HTML.Tag.BODY, HTML.Tag.TABLE),
+            new HTMLEditorKit.InsertHTMLTextAction("InsertTableDataCell",
+                "<table border=1><tr><td></td></tr></table>",
+                HTML.Tag.TR, HTML.Tag.TD, HTML.Tag.BODY, HTML.Tag.TABLE),
+            new HTMLEditorKit.InsertHTMLTextAction("InsertTableRow",
+                "<table border=1><tr><td></td></tr></table>",
+                HTML.Tag.TABLE, HTML.Tag.TR, HTML.Tag.BODY, HTML.Tag.TABLE),
+            new HTMLEditorKit.InsertHTMLTextAction("InsertPre", "<pre></pre>",
+                HTML.Tag.BODY, HTML.Tag.PRE),
+        };
+
+        return actions;
+    }
+
+    private boolean compareInsertHTMLTextActions(final Action a1,
+                                                 final Action a2) {
+        if (!(a1 instanceof HTMLEditorKit.InsertHTMLTextAction)
+                || !(a2 instanceof HTMLEditorKit.InsertHTMLTextAction)) {
+            return false;
+        }
+        HTMLEditorKit.InsertHTMLTextAction htmlAction1 = (HTMLEditorKit.InsertHTMLTextAction)a1;
+        HTMLEditorKit.InsertHTMLTextAction htmlAction2 = (HTMLEditorKit.InsertHTMLTextAction)a2;
+        return compareActionFields(htmlAction1.addTag, htmlAction2.addTag)
+            && compareActionFields(htmlAction1.alternateAddTag, htmlAction2.alternateAddTag)
+            && compareActionFields(htmlAction1.alternateParentTag, htmlAction2.alternateParentTag)
+            && compareActionFields(htmlAction1.html, htmlAction2.html)
+            && compareActionFields(htmlAction1.parentTag, htmlAction2.parentTag);
+    }
+
+    private boolean compareActionFields(final Object f1, final Object f2) {
+        return f1 != null && f1.equals(f2) || f1 == f2;
+    }
+
+    private Action findActionWithName(final Action[] actions, final Object name) {
+        for (int i = 0; i < actions.length; i++) {
+            if (name.equals(actions[i].getValue(Action.NAME))) {
+                return actions[i];
+            }
+        }
+        return null;
+    }
+
+    private static HTML.Tag getHTMLTagByElement(final Element elem) {
+        final Object result = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
+        return (result instanceof HTML.Tag) ? (HTML.Tag)result : null;
+    }
+
+
+    private static String getURLString(final Element e) {
+        AttributeSet aSet = (AttributeSet)e.getAttributes()
+                .getAttribute(HTML.Tag.A);
+        return aSet == null
+                ? null
+                : (String)aSet.getAttribute(HTML.Attribute.HREF);
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLFactoryTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLFactoryTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLFactoryTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,231 @@
+/*
+ *  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 Vadim L. Bogdanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import javax.swing.SwingTestCase;
+import javax.swing.text.Element;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.View;
+
+public class HTMLEditorKit_HTMLFactoryTest extends SwingTestCase {
+    private static class TestHTMLDocument extends HTMLDocument {
+        public void callWriteLock() {
+            writeLock();
+        }
+    }
+
+    private TestHTMLDocument doc;
+    private HTMLEditorKit.HTMLFactory factory;
+
+    public HTMLEditorKit_HTMLFactoryTest(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        setIgnoreNotImplemented(true);
+
+        doc = new TestHTMLDocument();
+        factory = new HTMLEditorKit.HTMLFactory();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testCreateForCONTENT() {
+        implTestCreateForTag(HTML.Tag.CONTENT, "javax.swing.text.html.InlineView");
+    }
+
+    public void testCreateForIMPLIED() {
+        implTestCreateForTag(HTML.Tag.IMPLIED,
+                             "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForP() {
+        implTestCreateForTag(HTML.Tag.P, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForH1() {
+        implTestCreateForTag(HTML.Tag.H1, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForH2() {
+        implTestCreateForTag(HTML.Tag.H2, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForH3() {
+        implTestCreateForTag(HTML.Tag.H3, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForH4() {
+        implTestCreateForTag(HTML.Tag.H4, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForH5() {
+        implTestCreateForTag(HTML.Tag.H5, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForH6() {
+        implTestCreateForTag(HTML.Tag.H6, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForDT() {
+        implTestCreateForTag(HTML.Tag.DT, "javax.swing.text.html.ParagraphView");
+    }
+
+    public void testCreateForMENU() {
+        implTestCreateForTag(HTML.Tag.MENU, "javax.swing.text.html.ListView");
+    }
+
+    public void testCreateForDIR() {
+        implTestCreateForTag(HTML.Tag.DIR, "javax.swing.text.html.ListView");
+    }
+
+    public void testCreateForUL() {
+        implTestCreateForTag(HTML.Tag.UL, "javax.swing.text.html.ListView");
+    }
+
+    public void testCreateForOL() {
+        implTestCreateForTag(HTML.Tag.OL, "javax.swing.text.html.ListView");
+    }
+
+    public void testCreateForLI() {
+        View view = implTestCreateForTag(HTML.Tag.LI,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForDL() {
+        View view = implTestCreateForTag(HTML.Tag.DL,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForDD() {
+        View view = implTestCreateForTag(HTML.Tag.DD,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForBODY() {
+        doc.callWriteLock();
+        Element elem = doc.getDefaultRootElement();
+        setTag(elem, HTML.Tag.BODY);
+        View view = factory.create(elem);
+        assertTrue(view instanceof BlockView);
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForHTML() {
+        View view = implTestCreateForTag(HTML.Tag.HTML,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForCENTER() {
+        View view = implTestCreateForTag(HTML.Tag.CENTER,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForDIV() {
+        View view = implTestCreateForTag(HTML.Tag.DIV,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForBLOCKQUOTE() {
+        View view = implTestCreateForTag(HTML.Tag.BLOCKQUOTE,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForPRE() {
+        View view = implTestCreateForTag(HTML.Tag.PRE,
+                                         "javax.swing.text.html.BlockView");
+        assertEquals(View.Y_AXIS, ((BlockView)view).getAxis());
+    }
+
+    public void testCreateForIMG() {
+        implTestCreateForTag(HTML.Tag.IMG, "javax.swing.text.html.ImageView");
+    }
+
+    public void testCreateForHR() {
+        if (isHarmony()) {
+            implTestCreateForTag(HTML.Tag.HR, "javax.swing.text.html.HRuleTagView");
+        }
+    }
+
+    public void testCreateForBR() {
+        implTestCreateForTag(HTML.Tag.BR, "javax.swing.text.html.BRView");
+    }
+
+    public void testCreateForTABLE() {
+        if (isHarmony()) {
+            implTestCreateForTag(HTML.Tag.TABLE, "javax.swing.text.html.TableTagView");
+        }
+    }
+
+    public void testCreateForINPUT() {
+        implTestCreateForTag(HTML.Tag.INPUT, "javax.swing.text.html.FormView");
+    }
+
+    public void testCreateForSELECT() {
+        implTestCreateForTag(HTML.Tag.SELECT, "javax.swing.text.html.FormView");
+    }
+
+    public void testCreateForTEXTAREA() {
+        implTestCreateForTag(HTML.Tag.TEXTAREA, "javax.swing.text.html.FormView");
+    }
+
+    public void testCreateForOBJECT() {
+        implTestCreateForTag(HTML.Tag.OBJECT, "javax.swing.text.html.ObjectView");
+    }
+
+    public void testCreateForFRAMESET() {
+        if (isHarmony()) {
+            implTestCreateForTag(HTML.Tag.FRAMESET,
+                                 "javax.swing.text.html.FrameSetTagView");
+        }
+    }
+
+    public void testCreateForFRAME() {
+        if (isHarmony()) {
+            implTestCreateForTag(HTML.Tag.FRAME, "javax.swing.text.html.FrameTagView");
+        }
+    }
+
+    private View implTestCreateForTag(final HTML.Tag tag, final String expected) {
+        doc.callWriteLock();
+        Element elem = doc.getDefaultRootElement();
+        ((HTMLDocument.BlockElement)elem).addAttribute(HTML.Attribute.ROWS, "1");
+        setTag(elem, tag);
+        View result = factory.create(elem);
+        assertEquals(expected, result.getClass().getName());
+        return result;
+    }
+
+    private void setTag(final Element elem, final HTML.Tag tag) {
+        ((HTMLDocument.BlockElement)elem).addAttribute(
+                StyleConstants.NameAttribute, tag);
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLTextActionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLTextActionTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLTextActionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_HTMLTextActionTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,155 @@
+/*
+ *  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 Vadim L. Bogdanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.awt.event.ActionEvent;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Arrays;
+
+import javax.swing.AbstractAction;
+import javax.swing.JEditorPane;
+import javax.swing.SwingTestCase;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Element;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledEditorKit;
+
+public class HTMLEditorKit_HTMLTextActionTest extends SwingTestCase {
+    private static final String HTML_TEXT = "<i>Italic text</i>";
+
+    private static class TestHTMLTextAction extends HTMLEditorKit.HTMLTextAction {
+        public TestHTMLTextAction(final String name) {
+            super(name);
+        }
+
+        public void actionPerformed(final ActionEvent e) {
+        }
+    }
+
+    private JEditorPane editorPane;
+    private HTMLEditorKit editorKit;
+    private HTMLDocument document;
+    private HTMLEditorKit.HTMLTextAction action;
+
+    public HTMLEditorKit_HTMLTextActionTest(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        setIgnoreNotImplemented(true);
+
+        editorPane = new JEditorPane();
+        editorKit = new HTMLEditorKit();
+        editorPane.setEditorKit(editorKit);
+        document = (HTMLDocument)editorPane.getDocument();
+        action = new TestHTMLTextAction("name");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testHTMLTextAction() {
+        action = new TestHTMLTextAction("actionName");
+        assertEquals("actionName", action.getValue(AbstractAction.NAME));
+    }
+
+    public void testElementCountToTag() throws Exception {
+        loadHTML();
+        final int offset = editorPane.getDocument().getLength();
+
+        int bodyCount = action.elementCountToTag(document,
+                                                 offset,
+                                                 HTML.Tag.BODY);
+        assertEquals(1, bodyCount);
+
+        assertEquals(-1, action.elementCountToTag(document,
+                                                  offset,
+                                                  HTML.Tag.HEAD));
+    }
+
+    public void testFindElementMatchingTag() throws Exception {
+        loadHTML();
+        final int offset = editorPane.getDocument().getLength();
+        Element[] elems = action.getElementsAt(document, offset);
+
+        Element bodyElem = action.findElementMatchingTag(document, offset,
+                                                         HTML.Tag.BODY);
+        assertEquals(HTML.Tag.BODY, getHTMLTagByElement(bodyElem));
+        assertTrue(Arrays.asList(elems).contains(bodyElem));
+
+        assertNull(action.findElementMatchingTag(document, offset,
+                                                 HTML.Tag.HEAD));
+
+        assertNotNull(action.findElementMatchingTag(document,
+                                                    document.getLength() + 1,
+                                                    HTML.Tag.BODY));
+    }
+
+    public void testGetElementsAt() throws Exception {
+        loadHTML();
+        final int offset = editorPane.getDocument().getLength();
+
+        Element[] elems = action.getElementsAt(
+                action.getHTMLDocument(editorPane), offset);
+        assertEquals(editorPane.getDocument().getDefaultRootElement(), elems[0]);
+        assertEquals(0, elems[elems.length - 1].getElementCount());
+
+        for (int i = 0; i < elems.length; i++) {
+            assertTrue(elems[i].getStartOffset() <= offset
+                       && elems[i].getEndOffset() >= offset);
+        }
+
+        elems = action.getElementsAt(document, document.getLength());
+        assertEquals(editorPane.getDocument().getDefaultRootElement(), elems[0]);
+
+        elems = action.getElementsAt(document, document.getLength() + 1);
+        assertEquals(editorPane.getDocument().getDefaultRootElement(), elems[0]);
+    }
+
+    public void testGetHTMLDocument() {
+        assertSame(editorPane.getDocument(),
+                   action.getHTMLDocument(editorPane));
+    }
+
+    public void testGetHTMLEditorKit() {
+        assertSame(editorPane.getEditorKit(),
+                   action.getHTMLEditorKit(editorPane));
+
+        editorPane.setEditorKit(new StyledEditorKit());
+        testExceptionalCase(new IllegalArgumentCase() {
+            public void exceptionalAction() throws Exception {
+                action.getHTMLEditorKit(editorPane);
+            }
+        });
+    }
+
+    private void loadHTML() throws IOException, BadLocationException {
+        StringReader in = new StringReader(HTML_TEXT);
+        editorKit.read(in, editorPane.getDocument(), 0);
+    }
+
+    private static HTML.Tag getHTMLTagByElement(final Element elem) {
+        return (HTML.Tag)elem.getAttributes()
+                .getAttribute(StyleConstants.NameAttribute);
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_InsertHTMLTextActionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_InsertHTMLTextActionTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_InsertHTMLTextActionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLEditorKit_InsertHTMLTextActionTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,108 @@
+/*
+ *  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 Vadim L. Bogdanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import javax.swing.AbstractAction;
+import javax.swing.JEditorPane;
+import javax.swing.SwingTestCase;
+import javax.swing.text.BadLocationException;
+
+public class HTMLEditorKit_InsertHTMLTextActionTest extends SwingTestCase {
+    private final String name = "name";
+    private final HTML.Tag addTag = HTML.Tag.I;
+    private final HTML.Tag alternateAddTag = HTML.Tag.B;
+    private final HTML.Tag alternateParentTag = HTML.Tag.I;
+    private final String html = "<i><b>html text</b></i>";
+    private final HTML.Tag parentTag = HTML.Tag.B;
+
+    private HTMLEditorKit.InsertHTMLTextAction action;
+    private JEditorPane pane;
+    private HTMLDocument document;
+
+    public HTMLEditorKit_InsertHTMLTextActionTest(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        setIgnoreNotImplemented(true);
+
+        pane = new JEditorPane();
+        pane.setEditorKit(new HTMLEditorKit());
+        document = (HTMLDocument)pane.getDocument();
+
+        action = new HTMLEditorKit.InsertHTMLTextAction(name, html,
+                                                        parentTag, addTag,
+                                                        alternateParentTag,
+                                                        alternateAddTag);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testInsertHTMLTextActionStringStringTagTagTagTag() {
+        action = new HTMLEditorKit.InsertHTMLTextAction(name, html,
+                                                        parentTag, addTag,
+                                                        alternateParentTag,
+                                                        alternateAddTag);
+        assertSame(name, action.getValue(AbstractAction.NAME));
+        assertSame(html, action.html);
+        assertSame(parentTag, action.parentTag);
+        assertSame(addTag, action.addTag);
+        assertSame(alternateParentTag, action.alternateParentTag);
+        assertSame(alternateAddTag, action.alternateAddTag);
+    }
+
+    public void testInsertHTMLTextActionStringStringTagTag() {
+        action = new HTMLEditorKit.InsertHTMLTextAction(name, html,
+                                                        parentTag, addTag);
+        assertSame(name, action.getValue(AbstractAction.NAME));
+        assertSame(html, action.html);
+        assertSame(parentTag, action.parentTag);
+        assertSame(addTag, action.addTag);
+        assertNull(action.alternateParentTag);
+        assertNull(action.alternateAddTag);
+    }
+
+    public void testActionPerformed() {
+        action.actionPerformed(null);
+        // TODO: implement
+    }
+
+    public void testInsertHTML() throws BadLocationException {
+        action.insertHTML(pane, document, 0, html, 0, 0, addTag);
+        assertEquals("html text", document.getText(0, document.getLength()));
+
+        testExceptionalCase(new ExceptionalCase() {
+            public Class expectedExceptionClass() {
+                return RuntimeException.class;
+            }
+            public void exceptionalAction() throws Exception {
+                action.insertHTML(pane, document, document.getLength() + 1,
+                                  html, 0, 0, addTag);
+            }
+        });
+    }
+
+    public void testInsertAtBoundary() {
+        // TODO: implement
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLFrameHyperlinkEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLFrameHyperlinkEventTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLFrameHyperlinkEventTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLFrameHyperlinkEventTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,163 @@
+/*
+ *  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 Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package javax.swing.text.html;
+
+import java.net.URL;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.text.Element;
+
+public class HTMLFrameHyperlinkEventTest extends BasicSwingTestCase {
+
+    HTMLFrameHyperlinkEvent event;
+    
+    /*
+     * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, Element, String)'
+     */
+    public void testHTMLFrameHyperlinkEventObjectEventTypeURLElementString() throws Exception {
+        final Object source = new Object();
+        final EventType type = EventType.ENTERED;
+        final URL url = new URL("file:///");
+        final Element element = new HTMLDocument().getDefaultRootElement();
+        final String targetFrame = "targetFrame";
+
+        HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, element, targetFrame);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertSame(url, event.getURL());
+        assertSame(element, event.getSourceElement());
+        assertNull(event.getDescription());
+        assertSame(targetFrame, event.getTarget());
+        
+        event = new HTMLFrameHyperlinkEvent(source, type, null, (Element)null, null);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertNull(event.getURL());
+        assertNull(event.getSourceElement());
+        assertNull(event.getDescription());
+        assertNull(event.getTarget());
+        
+        new NullPointerCase() {
+            public void exceptionalAction() throws Exception {
+                new HTMLFrameHyperlinkEvent(null, type, null, (Element)null, null);
+            }
+        };
+    }
+
+    /*
+     * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, String)'
+     */
+    public void testHTMLFrameHyperlinkEventObjectEventTypeURLString() throws Exception {
+        final Object source = new Object();
+        final EventType type = EventType.ENTERED;
+        final URL url = new URL("file:///");
+        final String targetFrame = "targetFrame";
+
+        HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, targetFrame);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertSame(url, event.getURL());
+        assertNull(event.getSourceElement());
+        assertNull(event.getDescription());
+        assertSame(targetFrame, event.getTarget());
+        
+        event = new HTMLFrameHyperlinkEvent(source, type, null, null);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertNull(event.getURL());
+        assertNull(event.getSourceElement());
+        assertNull(event.getDescription());
+        assertNull(event.getTarget());
+        
+        new NullPointerCase() {
+            public void exceptionalAction() throws Exception {
+                new HTMLFrameHyperlinkEvent(null, type, null, null);
+            }
+        };
+    }
+
+    /*
+     * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, String, String)'
+     */
+    public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringString() throws Exception {
+        final Object source = new Object();
+        final EventType type = EventType.ENTERED;
+        final URL url = new URL("file:///");
+        final String targetFrame = "targetFrame";
+        final String descr = "description";
+
+        HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, descr, targetFrame);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertSame(url, event.getURL());
+        assertNull(event.getSourceElement());
+        assertSame(targetFrame, event.getTarget());
+        assertSame(descr, event.getDescription());
+        
+        event = new HTMLFrameHyperlinkEvent(source, type, null, (String)null, (String)null);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertNull(event.getURL());
+        assertNull(event.getSourceElement());
+        assertNull(event.getDescription());
+        assertNull(event.getTarget());
+        
+        new NullPointerCase() {
+            public void exceptionalAction() throws Exception {
+                new HTMLFrameHyperlinkEvent(null, type, null, (String)null, (String)null);
+            }
+        };
+    }
+
+    /*
+     * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, String, Element, String)'
+     */
+    public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringElementString() throws Exception {
+        final Object source = new Object();
+        final EventType type = EventType.ENTERED;
+        final URL url = new URL("file:///");
+        final Element element = new HTMLDocument().getDefaultRootElement();
+        final String targetFrame = "targetFrame";
+        final String descr = "description";
+
+        HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, descr, element, targetFrame);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertSame(url, event.getURL());
+        assertSame(element, event.getSourceElement());
+        assertSame(descr, event.getDescription());
+        assertSame(targetFrame, event.getTarget());
+        
+        event = new HTMLFrameHyperlinkEvent(source, type, null, null, (Element)null, null);
+        assertSame(source, event.getSource());
+        assertSame(type, event.getEventType());
+        assertNull(event.getURL());
+        assertNull(event.getSourceElement());
+        assertNull(event.getDescription());
+        assertNull(event.getTarget());
+        
+        new NullPointerCase() {
+            public void exceptionalAction() throws Exception {
+                new HTMLFrameHyperlinkEvent(null, type, null, null, (Element)null, null);
+            }
+        };
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,685 @@
+/*
+ *  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.BasicSwingTestCase;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleContext;
+import javax.swing.text.html.HTML.Attribute;
+import javax.swing.text.html.HTML.Tag;
+
+public class HTMLTest extends BasicSwingTestCase {
+
+//    public void testHTML() {
+//    }
+
+    public void testGetAllTags() {
+        final Tag[] expected = {
+            Tag.A,
+            Tag.ADDRESS,
+            Tag.APPLET,
+            Tag.AREA,
+            Tag.B,
+            Tag.BASE,
+            Tag.BASEFONT,
+            Tag.BIG,
+            Tag.BLOCKQUOTE,
+            Tag.BODY,
+            Tag.BR,
+            Tag.CAPTION,
+            Tag.CENTER,
+            Tag.CITE,
+            Tag.CODE,
+            //Tag.COMMENT,
+            //Tag.CONTENT,
+            Tag.DD,
+            Tag.DFN,
+            Tag.DIR,
+            Tag.DIV,
+            Tag.DL,
+            Tag.DT,
+            Tag.EM,
+            Tag.FONT,
+            Tag.FORM,
+            Tag.FRAME,
+            Tag.FRAMESET,
+            Tag.H1,
+            Tag.H2,
+            Tag.H3,
+            Tag.H4,
+            Tag.H5,
+            Tag.H6,
+            Tag.HEAD,
+            Tag.HR,
+            Tag.HTML,
+            Tag.I,
+            Tag.IMG,
+            //Tag.IMPLIED,
+            Tag.INPUT,
+            Tag.ISINDEX,
+            Tag.KBD,
+            Tag.LI,
+            Tag.LINK,
+            Tag.MAP,
+            Tag.MENU,
+            Tag.META,
+            Tag.NOFRAMES,
+            Tag.OBJECT,
+            Tag.OL,
+            Tag.OPTION,
+            Tag.P,
+            Tag.PARAM,
+            Tag.PRE,
+            Tag.S,
+            Tag.SAMP,
+            Tag.SCRIPT,
+            Tag.SELECT,
+            Tag.SMALL,
+            Tag.SPAN,
+            Tag.STRIKE,
+            Tag.STRONG,
+            Tag.STYLE,
+            Tag.SUB,
+            Tag.SUP,
+            Tag.TABLE,
+            Tag.TD,
+            Tag.TEXTAREA,
+            Tag.TH,
+            Tag.TITLE,
+            Tag.TR,
+            Tag.TT,
+            Tag.U,
+            Tag.UL,
+            Tag.VAR
+        };
+
+        Tag[] actual = HTML.getAllTags();
+        assertEquals(73, expected.length);
+        assertEquals(isHarmony() ? 91 : 74, actual.length);
+
+        final boolean[] found = new boolean[expected.length];
+        for (int i = 0; i < expected.length; i++) {
+            for (int j = 0; j < actual.length; j++) {
+                if (expected[i] == actual[j]) {
+                    found[i] = true;
+                    break;
+                }
+            }
+        }
+
+        for (int i = 0; i < found.length; i++) {
+            assertTrue("Tag " + expected[i] + " was not found, index " + i,
+                       found[i]);
+        }
+    }
+
+    public void testGetTag() {
+        assertNull(HTML.getTag("comment"));
+        assertNull(HTML.getTag(HTML.Tag.COMMENT.toString()));
+        assertNull(HTML.getTag("content"));
+        assertNull(HTML.getTag(HTML.Tag.CONTENT.toString()));
+        assertNull(HTML.getTag("p-implied"));
+        assertNull(HTML.getTag(HTML.Tag.IMPLIED.toString()));
+
+        if (!isHarmony()) {
+            assertNotNull("nobr");
+        }
+
+        assertSame(Tag.A,
+                   HTML.getTag("a"));
+        assertSame(Tag.ADDRESS,
+                   HTML.getTag("address"));
+        assertSame(Tag.APPLET,
+                   HTML.getTag("applet"));
+        assertSame(Tag.AREA,
+                   HTML.getTag("area"));
+        assertSame(Tag.B,
+                   HTML.getTag("b"));
+        assertSame(Tag.BASE,
+                   HTML.getTag("base"));
+        assertSame(Tag.BASEFONT,
+                   HTML.getTag("basefont"));
+        assertSame(Tag.BIG,
+                   HTML.getTag("big"));
+        assertSame(Tag.BLOCKQUOTE,
+                   HTML.getTag("blockquote"));
+        assertSame(Tag.BODY,
+                   HTML.getTag("body"));
+        assertSame(Tag.BR,
+                   HTML.getTag("br"));
+        assertSame(Tag.CAPTION,
+                   HTML.getTag("caption"));
+        assertSame(Tag.CENTER,
+                   HTML.getTag("center"));
+        assertSame(Tag.CITE,
+                   HTML.getTag("cite"));
+        assertSame(Tag.CODE,
+                   HTML.getTag("code"));
+        assertSame(Tag.DD,
+                   HTML.getTag("dd"));
+        assertSame(Tag.DFN,
+                   HTML.getTag("dfn"));
+        assertSame(Tag.DIR,
+                   HTML.getTag("dir"));
+        assertSame(Tag.DIV,
+                   HTML.getTag("div"));
+        assertSame(Tag.DL,
+                   HTML.getTag("dl"));
+        assertSame(Tag.DT,
+                   HTML.getTag("dt"));
+        assertSame(Tag.EM,
+                   HTML.getTag("em"));
+        assertSame(Tag.FONT,
+                   HTML.getTag("font"));
+        assertSame(Tag.FORM,
+                   HTML.getTag("form"));
+        assertSame(Tag.FRAME,
+                   HTML.getTag("frame"));
+        assertSame(Tag.FRAMESET,
+                   HTML.getTag("frameset"));
+        assertSame(Tag.H1,
+                   HTML.getTag("h1"));
+        assertSame(Tag.H2,
+                   HTML.getTag("h2"));
+        assertSame(Tag.H3,
+                   HTML.getTag("h3"));
+        assertSame(Tag.H4,
+                   HTML.getTag("h4"));
+        assertSame(Tag.H5,
+                   HTML.getTag("h5"));
+        assertSame(Tag.H6,
+                   HTML.getTag("h6"));
+        assertSame(Tag.HEAD,
+                   HTML.getTag("head"));
+        assertSame(Tag.HR,
+                   HTML.getTag("hr"));
+        assertSame(Tag.HTML,
+                   HTML.getTag("html"));
+        assertSame(Tag.I,
+                   HTML.getTag("i"));
+        assertSame(Tag.IMG,
+                   HTML.getTag("img"));
+        assertSame(Tag.INPUT,
+                   HTML.getTag("input"));
+        assertSame(Tag.ISINDEX,
+                   HTML.getTag("isindex"));
+        assertSame(Tag.KBD,
+                   HTML.getTag("kbd"));
+        assertSame(Tag.LI,
+                   HTML.getTag("li"));
+        assertSame(Tag.LINK,
+                   HTML.getTag("link"));
+        assertSame(Tag.MAP,
+                   HTML.getTag("map"));
+        assertSame(Tag.MENU,
+                   HTML.getTag("menu"));
+        assertSame(Tag.META,
+                   HTML.getTag("meta"));
+        assertSame(Tag.NOFRAMES,
+                   HTML.getTag("noframes"));
+        assertSame(Tag.OBJECT,
+                   HTML.getTag("object"));
+        assertSame(Tag.OL,
+                   HTML.getTag("ol"));
+        assertSame(Tag.OPTION,
+                   HTML.getTag("option"));
+        assertSame(Tag.P,
+                   HTML.getTag("p"));
+        assertSame(Tag.PARAM,
+                   HTML.getTag("param"));
+        assertSame(Tag.PRE,
+                   HTML.getTag("pre"));
+        assertSame(Tag.S,
+                   HTML.getTag("s"));
+        assertSame(Tag.SAMP,
+                   HTML.getTag("samp"));
+        assertSame(Tag.SCRIPT,
+                   HTML.getTag("script"));
+        assertSame(Tag.SELECT,
+                   HTML.getTag("select"));
+        assertSame(Tag.SMALL,
+                   HTML.getTag("small"));
+        assertSame(Tag.SPAN,
+                   HTML.getTag("span"));
+        assertSame(Tag.STRIKE,
+                   HTML.getTag("strike"));
+        assertSame(Tag.STRONG,
+                   HTML.getTag("strong"));
+        assertSame(Tag.STYLE,
+                   HTML.getTag("style"));
+        assertSame(Tag.SUB,
+                   HTML.getTag("sub"));
+        assertSame(Tag.SUP,
+                   HTML.getTag("sup"));
+        assertSame(Tag.TABLE,
+                   HTML.getTag("table"));
+        assertSame(Tag.TD,
+                   HTML.getTag("td"));
+        assertSame(Tag.TEXTAREA,
+                   HTML.getTag("textarea"));
+        assertSame(Tag.TH,
+                   HTML.getTag("th"));
+        assertSame(Tag.TITLE,
+                   HTML.getTag("title"));
+        assertSame(Tag.TR,
+                   HTML.getTag("tr"));
+        assertSame(Tag.TT,
+                   HTML.getTag("tt"));
+        assertSame(Tag.U,
+                   HTML.getTag("u"));
+        assertSame(Tag.UL,
+                   HTML.getTag("ul"));
+        assertSame(Tag.VAR,
+                   HTML.getTag("var"));
+
+
+        if (isHarmony()) {
+            assertSame(Tag.ABBR,
+                       HTML.getTag("abbr"));
+            assertSame(Tag.ACRONYM,
+                       HTML.getTag("acronym"));
+            assertSame(Tag.BDO,
+                       HTML.getTag("bdo"));
+            assertSame(Tag.BUTTON,
+                       HTML.getTag("button"));
+            assertSame(Tag.COL,
+                       HTML.getTag("col"));
+            assertSame(Tag.COLGROUP,
+                       HTML.getTag("colgroup"));
+            assertSame(Tag.DEL,
+                       HTML.getTag("del"));
+            assertSame(Tag.FIELDSET,
+                       HTML.getTag("fieldset"));
+            assertSame(Tag.IFRAME,
+                       HTML.getTag("iframe"));
+            assertSame(Tag.INS,
+                       HTML.getTag("ins"));
+            assertSame(Tag.LABEL,
+                       HTML.getTag("label"));
+            assertSame(Tag.LEGEND,
+                       HTML.getTag("legend"));
+            assertSame(Tag.NOSCRIPT,
+                       HTML.getTag("noscript"));
+            assertSame(Tag.OPTGROUP,
+                       HTML.getTag("optgroup"));
+            assertSame(Tag.Q,
+                       HTML.getTag("q"));
+            assertSame(Tag.TBODY,
+                       HTML.getTag("tbody"));
+            assertSame(Tag.TFOOT,
+                       HTML.getTag("tfoot"));
+            assertSame(Tag.THEAD,
+                       HTML.getTag("thead"));
+
+
+        } else {
+
+
+            assertNull(HTML.getTag("abbr"));
+            assertNull(HTML.getTag("acronym"));
+            assertNull(HTML.getTag("bdo"));
+            assertNull(HTML.getTag("button"));
+            assertNull(HTML.getTag("col"));
+            assertNull(HTML.getTag("colgroup"));
+            assertNull(HTML.getTag("del"));
+            assertNull(HTML.getTag("fieldset"));
+            assertNull(HTML.getTag("iframe"));
+            assertNull(HTML.getTag("ins"));
+            assertNull(HTML.getTag("label"));
+            assertNull(HTML.getTag("legend"));
+            assertNull(HTML.getTag("noscript"));
+            assertNull(HTML.getTag("optgroup"));
+            assertNull(HTML.getTag("q"));
+            assertNull(HTML.getTag("tbody"));
+            assertNull(HTML.getTag("tfoot"));
+            assertNull(HTML.getTag("thead"));
+        }
+    }
+
+    public void testGetAllAttributeKeys() {
+        final Attribute[] expected = {
+            Attribute.ACTION,
+            Attribute.ALIGN,
+            Attribute.ALINK,
+            Attribute.ALT,
+            Attribute.ARCHIVE,
+            Attribute.BACKGROUND,
+            Attribute.BGCOLOR,
+            Attribute.BORDER,
+            Attribute.CELLPADDING,
+            Attribute.CELLSPACING,
+            Attribute.CHECKED,
+            Attribute.CLASS,
+            Attribute.CLASSID,
+            Attribute.CLEAR,
+            Attribute.CODE,
+            Attribute.CODEBASE,
+            Attribute.CODETYPE,
+            Attribute.COLOR,
+            Attribute.COLS,
+            Attribute.COLSPAN,
+            Attribute.COMMENT,
+            Attribute.COMPACT,
+            Attribute.CONTENT,
+            Attribute.COORDS,
+            Attribute.DATA,
+            Attribute.DECLARE,
+            Attribute.DIR,
+            Attribute.DUMMY,
+            Attribute.ENCTYPE,
+            Attribute.ENDTAG,
+            Attribute.FACE,
+            Attribute.FRAMEBORDER,
+            Attribute.HALIGN,
+            Attribute.HEIGHT,
+            Attribute.HREF,
+            Attribute.HSPACE,
+            Attribute.HTTPEQUIV,
+            Attribute.ID,
+            Attribute.ISMAP,
+            Attribute.LANG,
+            Attribute.LANGUAGE,
+            Attribute.LINK,
+            Attribute.LOWSRC,
+            Attribute.MARGINHEIGHT,
+            Attribute.MARGINWIDTH,
+            Attribute.MAXLENGTH,
+            Attribute.METHOD,
+            Attribute.MULTIPLE,
+            Attribute.N,
+            Attribute.NAME,
+            Attribute.NOHREF,
+            Attribute.NORESIZE,
+            Attribute.NOSHADE,
+            Attribute.NOWRAP,
+            Attribute.PROMPT,
+            Attribute.REL,
+            Attribute.REV,
+            Attribute.ROWS,
+            Attribute.ROWSPAN,
+            Attribute.SCROLLING,
+            Attribute.SELECTED,
+            Attribute.SHAPE,
+            Attribute.SHAPES,
+            Attribute.SIZE,
+            Attribute.SRC,
+            Attribute.STANDBY,
+            Attribute.START,
+            Attribute.STYLE,
+            Attribute.TARGET,
+            Attribute.TEXT,
+            Attribute.TITLE,
+            Attribute.TYPE,
+            Attribute.USEMAP,
+            Attribute.VALIGN,
+            Attribute.VALUE,
+            Attribute.VALUETYPE,
+            Attribute.VERSION,
+            Attribute.VLINK,
+            Attribute.VSPACE,
+            Attribute.WIDTH,
+        };
+
+        Attribute[] actual = HTML.getAllAttributeKeys();
+        assertEquals(80, expected.length);
+        assertEquals(isHarmony() ? 84 : 81, actual.length);
+
+        final boolean[] found = new boolean[expected.length];
+        for (int i = 0; i < expected.length; i++) {
+            for (int j = 0; j < actual.length; j++) {
+                if (expected[i] == actual[j]) {
+                    found[i] = true;
+                    break;
+                }
+            }
+        }
+
+        for (int i = 0; i < found.length; i++) {
+            assertTrue("Attribute " + expected[i]
+                       + " was not found, index " + i,
+                       found[i]);
+        }
+    }
+
+    public void testGetAttributeKey() {
+        assertNull(HTML.getAttributeKey("httpequiv")); // without hyphen
+        assertNull(HTML.getAttributeKey("xmlns"));     // XML namespace
+
+        if (!isHarmony()) {
+            assertNotNull(HTML.getAttributeKey("media"));
+        }
+
+        assertSame(Attribute.ACTION,
+                   HTML.getAttributeKey("action"));
+        assertSame(Attribute.ALIGN,
+                   HTML.getAttributeKey("align"));
+        assertSame(Attribute.ALINK,
+                   HTML.getAttributeKey("alink"));
+        assertSame(Attribute.ALT,
+                   HTML.getAttributeKey("alt"));
+        assertSame(Attribute.ARCHIVE,
+                   HTML.getAttributeKey("archive"));
+        assertSame(Attribute.BACKGROUND,
+                   HTML.getAttributeKey("background"));
+        assertSame(Attribute.BGCOLOR,
+                   HTML.getAttributeKey("bgcolor"));
+        assertSame(Attribute.BORDER,
+                   HTML.getAttributeKey("border"));
+        assertSame(Attribute.CELLPADDING,
+                   HTML.getAttributeKey("cellpadding"));
+        assertSame(Attribute.CELLSPACING,
+                   HTML.getAttributeKey("cellspacing"));
+        assertSame(Attribute.CHECKED,
+                   HTML.getAttributeKey("checked"));
+        assertSame(Attribute.CLASS,
+                   HTML.getAttributeKey("class"));
+        assertSame(Attribute.CLASSID,
+                   HTML.getAttributeKey("classid"));
+        assertSame(Attribute.CLEAR,
+                   HTML.getAttributeKey("clear"));
+        assertSame(Attribute.CODE,
+                   HTML.getAttributeKey("code"));
+        assertSame(Attribute.CODEBASE,
+                   HTML.getAttributeKey("codebase"));
+        assertSame(Attribute.CODETYPE,
+                   HTML.getAttributeKey("codetype"));
+        assertSame(Attribute.COLOR,
+                   HTML.getAttributeKey("color"));
+        assertSame(Attribute.COLS,
+                   HTML.getAttributeKey("cols"));
+        assertSame(Attribute.COLSPAN,
+                   HTML.getAttributeKey("colspan"));
+        assertSame(Attribute.COMMENT,
+                   HTML.getAttributeKey("comment"));
+        assertSame(Attribute.COMPACT,
+                   HTML.getAttributeKey("compact"));
+        assertSame(Attribute.CONTENT,
+                   HTML.getAttributeKey("content"));
+        assertSame(Attribute.COORDS,
+                   HTML.getAttributeKey("coords"));
+        assertSame(Attribute.DATA,
+                   HTML.getAttributeKey("data"));
+        assertSame(Attribute.DECLARE,
+                   HTML.getAttributeKey("declare"));
+        assertSame(Attribute.DIR,
+                   HTML.getAttributeKey("dir"));
+        assertSame(Attribute.DUMMY,
+                   HTML.getAttributeKey("dummy"));
+        assertSame(Attribute.ENCTYPE,
+                   HTML.getAttributeKey("enctype"));
+        assertSame(Attribute.ENDTAG,
+                   HTML.getAttributeKey("endtag"));
+        assertSame(Attribute.FACE,
+                   HTML.getAttributeKey("face"));
+        assertSame(Attribute.FRAMEBORDER,
+                   HTML.getAttributeKey("frameborder"));
+        assertSame(Attribute.HALIGN,
+                   HTML.getAttributeKey("halign"));
+        assertSame(Attribute.HEIGHT,
+                   HTML.getAttributeKey("height"));
+        assertSame(Attribute.HREF,
+                   HTML.getAttributeKey("href"));
+        assertSame(Attribute.HSPACE,
+                   HTML.getAttributeKey("hspace"));
+        assertSame(Attribute.HTTPEQUIV,
+                   HTML.getAttributeKey("http-equiv"));
+        assertSame(Attribute.ID,
+                   HTML.getAttributeKey("id"));
+        assertSame(Attribute.ISMAP,
+                   HTML.getAttributeKey("ismap"));
+        assertSame(Attribute.LANG,
+                   HTML.getAttributeKey("lang"));
+        assertSame(Attribute.LANGUAGE,
+                   HTML.getAttributeKey("language"));
+        assertSame(Attribute.LINK,
+                   HTML.getAttributeKey("link"));
+        assertSame(Attribute.LOWSRC,
+                   HTML.getAttributeKey("lowsrc"));
+        assertSame(Attribute.MARGINHEIGHT,
+                   HTML.getAttributeKey("marginheight"));
+        assertSame(Attribute.MARGINWIDTH,
+                   HTML.getAttributeKey("marginwidth"));
+        assertSame(Attribute.MAXLENGTH,
+                   HTML.getAttributeKey("maxlength"));
+        assertSame(Attribute.METHOD,
+                   HTML.getAttributeKey("method"));
+        assertSame(Attribute.MULTIPLE,
+                   HTML.getAttributeKey("multiple"));
+        assertSame(Attribute.N,
+                   HTML.getAttributeKey("n"));
+        assertSame(Attribute.NAME,
+                   HTML.getAttributeKey("name"));
+        assertSame(Attribute.NOHREF,
+                   HTML.getAttributeKey("nohref"));
+        assertSame(Attribute.NORESIZE,
+                   HTML.getAttributeKey("noresize"));
+        assertSame(Attribute.NOSHADE,
+                   HTML.getAttributeKey("noshade"));
+        assertSame(Attribute.NOWRAP,
+                   HTML.getAttributeKey("nowrap"));
+        assertSame(Attribute.PROMPT,
+                   HTML.getAttributeKey("prompt"));
+        assertSame(Attribute.REL,
+                   HTML.getAttributeKey("rel"));
+        assertSame(Attribute.REV,
+                   HTML.getAttributeKey("rev"));
+        assertSame(Attribute.ROWS,
+                   HTML.getAttributeKey("rows"));
+        assertSame(Attribute.ROWSPAN,
+                   HTML.getAttributeKey("rowspan"));
+        assertSame(Attribute.SCROLLING,
+                   HTML.getAttributeKey("scrolling"));
+        assertSame(Attribute.SELECTED,
+                   HTML.getAttributeKey("selected"));
+        assertSame(Attribute.SHAPE,
+                   HTML.getAttributeKey("shape"));
+        assertSame(Attribute.SHAPES,
+                   HTML.getAttributeKey("shapes"));
+        assertSame(Attribute.SIZE,
+                   HTML.getAttributeKey("size"));
+        assertSame(Attribute.SRC,
+                   HTML.getAttributeKey("src"));
+        assertSame(Attribute.STANDBY,
+                   HTML.getAttributeKey("standby"));
+        assertSame(Attribute.START,
+                   HTML.getAttributeKey("start"));
+        assertSame(Attribute.STYLE,
+                   HTML.getAttributeKey("style"));
+        assertSame(Attribute.TARGET,
+                   HTML.getAttributeKey("target"));
+        assertSame(Attribute.TEXT,
+                   HTML.getAttributeKey("text"));
+        assertSame(Attribute.TITLE,
+                   HTML.getAttributeKey("title"));
+        assertSame(Attribute.TYPE,
+                   HTML.getAttributeKey("type"));
+        assertSame(Attribute.USEMAP,
+                   HTML.getAttributeKey("usemap"));
+        assertSame(Attribute.VALIGN,
+                   HTML.getAttributeKey("valign"));
+        assertSame(Attribute.VALUE,
+                   HTML.getAttributeKey("value"));
+        assertSame(Attribute.VALUETYPE,
+                   HTML.getAttributeKey("valuetype"));
+        assertSame(Attribute.VERSION,
+                   HTML.getAttributeKey("version"));
+        assertSame(Attribute.VLINK,
+                   HTML.getAttributeKey("vlink"));
+        assertSame(Attribute.VSPACE,
+                   HTML.getAttributeKey("vspace"));
+        assertSame(Attribute.WIDTH,
+                   HTML.getAttributeKey("width"));
+    }
+
+    public void testGetIntegerAttributeValue() {
+        MutableAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(Attribute.COLSPAN, new String("11"));
+        assertEquals(11,
+                     HTML.getIntegerAttributeValue(attrs,
+                                                   Attribute.COLSPAN, -1));
+
+        attrs = new SimpleAttributeSet();
+        attrs.addAttribute(Attribute.HREF, new String("10101"));
+        assertEquals(10101,
+                     HTML.getIntegerAttributeValue(attrs,
+                                                   Attribute.HREF, -1));
+
+        attrs = new SimpleAttributeSet();
+        attrs.addAttribute(Attribute.HREF, new String("not a number"));
+        assertEquals(-1,
+                     HTML.getIntegerAttributeValue(attrs,
+                                                   Attribute.HREF, -1));
+
+        attrs = new SimpleAttributeSet();
+        assertEquals(-1,
+                     HTML.getIntegerAttributeValue(attrs,
+                                                   Attribute.HREF, -1));
+
+        final MutableAttributeSet wrongValue = new SimpleAttributeSet();
+        wrongValue.addAttribute(Attribute.HREF, new Integer("10101"));
+        testExceptionalCase(new ClassCastCase() {
+            public void exceptionalAction() throws Exception {
+                HTML.getIntegerAttributeValue(wrongValue, Attribute.HREF, -1);
+            }
+        });
+    }
+
+    public void testStaticAttributeKeysOfAttributes() {
+        final Attribute[] attrs = HTML.getAllAttributeKeys();
+        for (int i = 0; i < attrs.length; i++) {
+            Object staticKey = StyleContext.getStaticAttributeKey(attrs[i]);
+            assertSame("Static attribute for Attribute" + attrs[i]
+                       + ", index " + i,
+                       attrs[i],
+                       StyleContext.getStaticAttribute(staticKey));
+        }
+    }
+
+    public void testStaticAttributeKeysOfTags() {
+        final Tag[] tags = HTML.getAllTags();
+        for (int i = 0; i < tags.length; i++) {
+            Object staticKey = StyleContext.getStaticAttributeKey(tags[i]);
+            assertSame("Static attribute for Tag " + tags[i] + ", index " + i,
+                       tags[i],
+                       StyleContext.getStaticAttribute(staticKey));
+        }
+    }
+}



Mime
View raw message