harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r427121 [13/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/BlockViewTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/BlockViewTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/BlockViewTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/BlockViewTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,607 @@
+/*
+ *  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.Insets;
+import java.io.StringReader;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.SizeRequirements;
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.GlyphView;
+import javax.swing.text.PlainView;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.GlyphView.GlyphPainter;
+import javax.swing.text.ViewTestHelpers.ChildrenFactory;
+import javax.swing.text.html.InlineViewTest.FixedPainter;
+
+public class BlockViewTest extends BasicSwingTestCase {
+    private class Event implements DocumentEvent {
+        public int getOffset() {
+            return block.getStartOffset();
+        }
+
+        public int getLength() {
+            return block.getEndOffset() - block.getStartOffset();
+        }
+
+        public Document getDocument() {
+            return doc;
+        }
+
+        public EventType getType() {
+            return EventType.CHANGE;
+        }
+
+        public ElementChange getChange(Element elem) {
+            return null;
+        }
+    }
+
+    public static class InlineViewFactory implements ViewFactory {
+        public static final GlyphPainter painter = new FixedPainter();
+
+        public View create(Element element) {
+            GlyphView result = new InlineView(element);
+            result.setGlyphPainter(painter);
+            return result;
+        }
+    }
+
+    private class BlockViewImpl extends BlockView {
+        public BlockViewImpl(final Element element, final int axis) {
+            super(element, axis);
+            loadChildren();
+        }
+
+        public ViewFactory getViewFactory() {
+            return factory;
+        }
+
+        public void loadChildren() {
+            loadChildren(getViewFactory());
+        }
+
+        public void layoutMinorAxis(final int targetSpan, final int axis,
+                                    final int[] offsets, final int[] spans) {
+            super.layoutMinorAxis(targetSpan, axis, offsets, spans);
+        }
+    }
+
+    private static final int Y_AXIS = View.Y_AXIS;
+    private static final int X_AXIS = View.X_AXIS;
+
+    private HTMLEditorKit kit;
+    private HTMLDocument doc;
+    private Element block;
+    private BlockView view;
+    private ViewFactory factory;
+    private AttributeSet attrs;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        setIgnoreNotImplemented(true);
+        kit = new HTMLEditorKit();
+        doc = (HTMLDocument)kit.createDefaultDocument();
+        StringReader reader = new StringReader("<html><head></head>" +
+               "<body>" +
+               "<p>Normal <em>em inside</em> paragraph." +
+               "</body></html>");
+        kit.read(reader, doc, 0);
+
+        block = doc.getParagraphElement(10);
+        assertEquals(HTML.Tag.P.toString(), block.getName());
+
+        factory = new InlineViewFactory();
+        view = new BlockViewImpl(block, Y_AXIS);
+        attrs = view.getAttributes();
+        doc.getStyleSheet().getStyleSheets()[0].addRule("p { margin-top: 15pt }");
+    }
+
+    public void testBlockView() {
+        assertSame(block, view.getElement());
+        assertNotSame(block.getAttributes(), view.getAttributes());
+        assertEquals(block.getElementCount(), view.getViewCount());
+    }
+
+    public void testGetMinimumSpan() {
+        assertEquals(view.getPreferredSpan(X_AXIS),
+                     view.getMinimumSpan(X_AXIS), 0);
+        assertEquals(view.getPreferredSpan(Y_AXIS),
+                     view.getMinimumSpan(Y_AXIS), 0);
+    }
+
+    public void testGetPreferredSpan() {
+        assertEquals(getMaxChildSpan(X_AXIS), view.getPreferredSpan(X_AXIS), 0);
+        assertEquals(0, (int)view.getPreferredSpan(Y_AXIS));
+    }
+
+    public void testGetMaximumSpan() {
+        assertEquals(Integer.MAX_VALUE, view.getMaximumSpan(X_AXIS), 0);
+        assertEquals(0, (int)view.getMaximumSpan(Y_AXIS));
+    }
+
+    public void testGetAlignment() {
+        factory = new ChildrenFactory();
+        ((ChildrenFactory)factory).makeFlexible();
+
+        view = new BlockViewImpl(block, Y_AXIS);
+        assertEquals(0, view.getAlignment(X_AXIS), 0);
+        assertEquals(0, view.getAlignment(Y_AXIS), 0);
+    }
+
+    public void testGetAlignmentFlexible() {
+        factory = new ChildrenFactory();
+        ((ChildrenFactory)factory).makeFlexible();
+        view = new BlockViewImpl(block, Y_AXIS);
+
+        assertEquals(0, view.getAlignment(X_AXIS), 0);
+        assertEquals(0, view.getAlignment(Y_AXIS), 0);
+
+        SizeRequirements r = view.calculateMajorAxisRequirements(Y_AXIS, null);
+        assertEquals(0.5f, r.alignment, 0);
+
+        r = view.calculateMajorAxisRequirements(X_AXIS, r);
+        assertEquals(0.5f, r.alignment, 0);
+    }
+
+    public void testGetAttributes() {
+        assertEquals(2, attrs.getAttributeCount());
+        assertEquals("15pt",
+                     attrs.getAttribute(CSS.Attribute.MARGIN_TOP).toString());
+        assertEquals(HTML.Tag.P.toString(),
+                     attrs.getAttribute(AttributeSet.NameAttribute));
+
+        assertEquals(15, StyleConstants.getSpaceAbove(attrs), 0f);
+    }
+
+    public void testGetAttributesUpdate() {
+        assertEquals(2, attrs.getAttributeCount());
+        assertEquals("15pt",
+                     attrs.getAttribute(CSS.Attribute.MARGIN_TOP).toString());
+        assertEquals(HTML.Tag.P.toString(),
+                     attrs.getAttribute(AttributeSet.NameAttribute));
+        assertNull(attrs.getAttribute(CSS.Attribute.BACKGROUND_COLOR));
+
+        doc.getStyleSheet().addRule("p { background-color: red }");
+        assertEquals(4, attrs.getAttributeCount());
+        assertEquals("red", attrs.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
+                            .toString());
+    }
+
+    public void testGetAttributesStyleSheet() {
+        final Marker ssMarker = new Marker();
+        view = new BlockView(block, Y_AXIS) {
+            protected StyleSheet getStyleSheet() {
+                ssMarker.setOccurred();
+                return super.getStyleSheet();
+            };
+        };
+        assertFalse(ssMarker.isOccurred());
+        view.getAttributes();
+        assertTrue(ssMarker.isOccurred());
+    }
+
+    public void testGetAttributesSame() {
+        assertSame(attrs, view.getAttributes());
+    }
+
+    public void testGetResizeWeight() {
+        assertEquals(1, view.getResizeWeight(X_AXIS));
+        assertEquals(0, view.getResizeWeight(Y_AXIS));
+    }
+
+    public void testGetResizeWeightFlexible() {
+        factory = new ChildrenFactory();
+        ((ChildrenFactory)factory).makeFlexible();
+        view = new BlockViewImpl(block, Y_AXIS);
+
+        assertEquals(1, view.getResizeWeight(X_AXIS));
+        assertEquals(isHarmony() ? 1 : 0, view.getResizeWeight(Y_AXIS));
+
+        SizeRequirements r = view.calculateMajorAxisRequirements(Y_AXIS, null);
+        assertEquals(44, r.minimum);
+        assertEquals(400, r.maximum);
+        assertEquals(44, (int)view.getMinimumSpan(Y_AXIS));
+        assertEquals(400, (int)view.getMaximumSpan(Y_AXIS));
+    }
+
+    public void testChangedUpdate() {
+        final Marker propMarker = new Marker();
+        final Marker prefMarker = new Marker();
+        view = new BlockViewImpl(block, Y_AXIS) {
+            private int count;
+            private boolean flag;
+
+            protected void setPropertiesFromAttributes() {
+                propMarker.setOccurred();
+                super.setPropertiesFromAttributes();
+            }
+
+            public void preferenceChanged(View child,
+                                          boolean width, boolean height) {
+                prefMarker.setOccurred();
+                assertSame(getView(count), child);
+                if (isHarmony() || flag) {
+                    count++;
+                }
+                flag = !flag;
+                prefMarker.setAuxiliary(new Integer(count));
+
+                assertNotNull(child);
+                assertTrue(width);
+                assertTrue(height);
+                super.preferenceChanged(child, width, height);
+            }
+        };
+
+        assertFalse(propMarker.isOccurred());
+        assertFalse(prefMarker.isOccurred());
+
+        view.changedUpdate(new Event(), null, null);
+
+        assertTrue(propMarker.isOccurred());
+        assertTrue(prefMarker.isOccurred());
+        assertEquals(view.getViewCount(),
+                     ((Integer)prefMarker.getAuxiliary()).intValue());
+    }
+
+    public void testChangedUpdateAttributes() {
+        final Marker viewAttrMarker = new Marker(true);
+        final StyleSheet ss = new StyleSheet() {
+            public AttributeSet getViewAttributes(final View v) {
+                viewAttrMarker.setOccurred();
+                return super.getViewAttributes(v);
+            }
+        };
+        view = new BlockView(block, View.Y_AXIS) {
+            protected StyleSheet getStyleSheet() {
+                return ss;
+            }
+        };
+
+        attrs = view.getAttributes();
+        assertTrue(viewAttrMarker.isOccurred());
+        view.changedUpdate(new Event(), null, null);
+        assertTrue(viewAttrMarker.isOccurred());
+        assertNotSame(attrs, view.getAttributes());
+    }
+
+    public void testSetParent() {
+        final Marker propertiesMarker = new Marker(true);
+        view = new BlockView(block, Y_AXIS) {
+            protected void setPropertiesFromAttributes() {
+                propertiesMarker.setOccurred();
+                super.setPropertiesFromAttributes();
+            }
+        };
+        assertFalse(propertiesMarker.isOccurred());
+        view.setParent(null);
+        assertFalse(propertiesMarker.isOccurred());
+
+        view.setParent(new PlainView(doc.getDefaultRootElement()));
+        assertTrue(propertiesMarker.isOccurred());
+
+        view.setParent(null);
+        assertFalse(propertiesMarker.isOccurred());
+    }
+
+    public void testCalculateMajorAxisRequirements() {
+        SizeRequirements r = view.calculateMajorAxisRequirements(Y_AXIS, null);
+        assertEquals(r.preferred, r.minimum);
+        assertEquals(0, r.preferred);
+        assertEquals(0, r.maximum);
+
+        doc.getStyleSheet().addRule("p {width: 305pt}");
+        view.setPropertiesFromAttributes();
+        SizeRequirements sr = view.calculateMajorAxisRequirements(Y_AXIS, r);
+        assertSame(r, sr);
+        assertEquals(0, r.minimum);
+        assertEquals(0, r.preferred);
+        assertEquals(0, r.maximum);
+
+        doc.getStyleSheet().addRule("p {height: 40pt}");
+        view.setPropertiesFromAttributes();
+        view.calculateMajorAxisRequirements(Y_AXIS, r);
+        assertEquals(25, r.minimum);
+        assertEquals(25, r.preferred);
+        assertEquals(25, r.maximum);
+    }
+
+    public void testCalculateMajorAxisRequirementsFlexible() {
+        factory = new ChildrenFactory();
+        ((ChildrenFactory)factory).makeFlexible();
+
+        view = new BlockViewImpl(block, Y_AXIS);
+
+        int minSpan = 0;
+        for (int i = 0; i < view.getViewCount(); i++) {
+            minSpan += (int)view.getView(i).getMinimumSpan(Y_AXIS);
+        }
+        assertEquals(44, minSpan);
+
+        int prefSpan = 0;
+        for (int i = 0; i < view.getViewCount(); i++) {
+            prefSpan += (int)view.getView(i).getPreferredSpan(Y_AXIS);
+        }
+        assertEquals(112, prefSpan);
+
+        int maxSpan = 0;
+        for (int i = 0; i < view.getViewCount(); i++) {
+            maxSpan += (int)view.getView(i).getMaximumSpan(Y_AXIS);
+        }
+        assertEquals(400, maxSpan);
+
+
+        doc.getStyleSheet().addRule("p {height: 45pt}");
+        view.setPropertiesFromAttributes();
+        SizeRequirements r = view.calculateMajorAxisRequirements(Y_AXIS, null);
+        assertEquals(44, r.minimum); // 45 - 15 def. margin = 30 < 44
+        assertEquals(isHarmony() ? 112 : 44, r.preferred);
+        assertEquals(400, r.maximum);
+
+        doc.getStyleSheet().addRule("p {height: 60pt}");
+        view.setPropertiesFromAttributes();
+        view.calculateMajorAxisRequirements(Y_AXIS, r);
+        assertEquals(45, r.minimum); // 60 - 15 def. margin = 45 > 44
+        assertEquals(45, r.preferred);
+        assertEquals(45, r.maximum);
+    }
+
+    public void testCalculateMinorAxisRequirements() {
+        SizeRequirements r = view.calculateMinorAxisRequirements(X_AXIS, null);
+        assertEquals(r.preferred, r.minimum);
+        assertEquals((int)getMaxChildSpan(X_AXIS), r.preferred);
+        assertEquals(Integer.MAX_VALUE, r.maximum);
+
+        doc.getStyleSheet().addRule("p {height: 40pt}");
+        view.setPropertiesFromAttributes();
+        SizeRequirements sr = view.calculateMinorAxisRequirements(X_AXIS, r);
+        assertSame(r, sr);
+        assertEquals(r.preferred, r.minimum);
+        assertEquals((int)getMaxChildSpan(X_AXIS), r.preferred);
+        assertEquals(Integer.MAX_VALUE, r.maximum);
+
+        doc.getStyleSheet().addRule("p {width: 305pt}");
+        view.setPropertiesFromAttributes();
+        view.calculateMinorAxisRequirements(X_AXIS, r);
+        assertEquals(r.preferred, r.minimum);
+        assertEquals(305, r.preferred);
+        assertEquals(305, r.maximum);
+    }
+
+    public void testCalculateMinorAxisRequirementsFlexible() {
+        factory = new ChildrenFactory();
+        ((ChildrenFactory)factory).makeFlexible();
+
+        view = new BlockViewImpl(block, Y_AXIS);
+
+        int minSpan = 0;
+        for (int i = 0; i < view.getViewCount(); i++) {
+            minSpan = Math.max(minSpan,
+                               (int)view.getView(i).getMinimumSpan(X_AXIS));
+        }
+        assertEquals(50, minSpan);
+
+        int prefSpan = 0;
+        for (int i = 0; i < view.getViewCount(); i++) {
+            prefSpan = Math.max(prefSpan,
+                                (int)view.getView(i).getPreferredSpan(X_AXIS));
+        }
+        assertEquals(100, prefSpan);
+
+
+        doc.getStyleSheet().addRule("p {width: 46pt}");
+        view.setPropertiesFromAttributes();
+        SizeRequirements r = view.calculateMinorAxisRequirements(X_AXIS, null);
+        assertEquals(50, r.minimum);
+        assertEquals(isHarmony() ? 100 : 50, r.preferred);
+        assertEquals(Integer.MAX_VALUE, r.maximum);
+
+        doc.getStyleSheet().addRule("p {width: 146pt}");
+        view.setPropertiesFromAttributes();
+        view.calculateMinorAxisRequirements(X_AXIS, r);
+        assertEquals(146, r.minimum);
+        assertEquals(146, r.preferred);
+        assertEquals(146, r.maximum);
+    }
+
+    public void testCalculateMinorAxisRequirementsOrthogonal() {
+        view = new BlockViewImpl(block, X_AXIS);
+        SizeRequirements r = view.calculateMinorAxisRequirements(Y_AXIS, null);
+        assertEquals(r.preferred, r.minimum);
+        assertEquals(0, r.preferred);
+        assertEquals(Integer.MAX_VALUE, r.maximum);
+
+        doc.getStyleSheet().addRule("p {width: 305pt}");
+        view.setPropertiesFromAttributes();
+        SizeRequirements sr = view.calculateMinorAxisRequirements(Y_AXIS, r);
+        assertSame(r, sr);
+        assertEquals(r.preferred, r.minimum);
+        assertEquals(0, r.preferred);
+        assertEquals(Integer.MAX_VALUE, r.maximum);
+
+        doc.getStyleSheet().addRule("p {height: 40pt}");
+        view.setPropertiesFromAttributes();
+        view.calculateMinorAxisRequirements(Y_AXIS, r);
+        assertEquals(r.preferred, r.minimum);
+        assertEquals(25, r.preferred); // 40 - 15 (def. top margin) = 25
+        assertEquals(25, r.maximum);
+    }
+
+    public void testLayoutMinorAxis() {
+        final Marker marker = new Marker();
+        view = new BlockViewImpl(block, Y_AXIS) {
+            protected void baselineLayout(int targetSpan, int axis,
+                                          int[] offsets, int[] spans) {
+                marker.setOccurred();
+                super.baselineLayout(targetSpan, axis, offsets, spans);
+            }
+        };
+
+        final int[] offsets = new int[view.getViewCount()];
+        final int[] spans = new int[view.getViewCount()];
+        final int target = 305;
+        ((BlockViewImpl)view).layoutMinorAxis(target, X_AXIS, offsets, spans);
+        assertFalse(marker.isOccurred());
+        for (int i = 0; i < view.getViewCount(); i++) {
+            View child = view.getView(i);
+            assertEquals(0.0, view.getAlignment(X_AXIS), 0);
+            assertEquals((int)child.getPreferredSpan(X_AXIS), spans[i]);
+            assertEquals((target - spans[i]) / 2, offsets[i]);
+        }
+    }
+
+    public void testLayoutMinorAxisFlexible() {
+        factory = new ChildrenFactory();
+        ((ChildrenFactory)factory).makeFlexible();
+
+        view = new BlockViewImpl(block, Y_AXIS);
+
+        final int[] offsets = new int[view.getViewCount()];
+        final int[] spans = new int[view.getViewCount()];
+        final int target = 305;
+        ((BlockViewImpl)view).layoutMinorAxis(target, X_AXIS, offsets, spans);
+        for (int i = 0; i < view.getViewCount(); i++) {
+            View child = view.getView(i);
+            SizeRequirements sr =
+                new SizeRequirements((int)child.getMinimumSpan(X_AXIS),
+                                     (int)child.getPreferredSpan(X_AXIS),
+                                     (int)child.getMaximumSpan(X_AXIS),
+                                     child.getAlignment(X_AXIS));
+            assertEquals(getChildSpan(target, sr), spans[i]);
+            assertEquals(getChildOffset(target, spans[i], sr), offsets[i]);
+        }
+    }
+
+    public void testLayoutMinorAxisFlexibleWide() {
+        factory = new ChildrenFactory();
+        ((ChildrenFactory)factory).makeFlexible();
+
+        view = new BlockViewImpl(block, Y_AXIS);
+
+        final int[] offsets = new int[view.getViewCount()];
+        final int[] spans = new int[view.getViewCount()];
+        final int target = 451;
+        ((BlockViewImpl)view).layoutMinorAxis(target, X_AXIS, offsets, spans);
+        for (int i = 0; i < view.getViewCount(); i++) {
+            View child = view.getView(i);
+            SizeRequirements sr =
+                new SizeRequirements((int)child.getMinimumSpan(X_AXIS),
+                                     (int)child.getPreferredSpan(X_AXIS),
+                                     (int)child.getMaximumSpan(X_AXIS),
+                                     child.getAlignment(X_AXIS));
+            assertEquals(getChildSpan(target, sr), spans[i]);
+            assertEquals(getChildOffset(target, spans[i], sr), offsets[i]);
+        }
+    }
+
+    public void testGetStyleSheet() {
+        assertSame(doc.getStyleSheet(), view.getStyleSheet());
+    }
+
+    public void testSetPropertiesFromAttributes() {
+        final StyleSheet ss = doc.getStyleSheet();
+        final Style pStyle = ss.getRule("p");
+        assertEquals(2, pStyle.getAttributeCount());
+        assertEquals("15pt", pStyle.getAttribute(CSS.Attribute.MARGIN_TOP)
+                           .toString());
+
+        final Marker insetMarker = new Marker(true);
+        final Insets insets = new Insets(0, 0, 0, 0);
+        view = new BlockViewImpl(block, Y_AXIS) {
+            protected void setParagraphInsets(AttributeSet attrs) {
+                fail("Unexpected call setParagraphInsets(AttributeSet)");
+                super.setParagraphInsets(attrs);
+            }
+
+            protected void setInsets(short top, short left,
+                                     short bottom, short right) {
+                super.setInsets(top, left, bottom, right);
+                insetMarker.setOccurred();
+                insets.top = top;
+                insets.left = left;
+                insets.bottom = bottom;
+                insets.right = right;
+            }
+        };
+        view.setPropertiesFromAttributes();
+        assertTrue(insetMarker.isOccurred());
+        assertEquals(15, insets.top);
+        assertEquals(0, insets.left);
+        assertEquals(0, insets.bottom);
+        assertEquals(0, insets.right);
+
+        ss.addRule("p { padding-right: 31px; margin-bottom: 3pt }");
+        view.setPropertiesFromAttributes();
+        assertEquals(15, insets.top);
+        assertEquals(0, insets.left);
+        assertEquals(3, insets.bottom);
+        assertEquals(40, insets.right);
+    }
+
+    public void testSetPropertiesFromAttributesBoxPainter() {
+        final Marker boxMarker = new Marker();
+        final Marker listMarker = new Marker();
+        final StyleSheet ss = new StyleSheet() {
+            public BoxPainter getBoxPainter(final AttributeSet attr) {
+                boxMarker.setOccurred();
+                return super.getBoxPainter(attr);
+            }
+            public ListPainter getListPainter(final AttributeSet attr) {
+                listMarker.setOccurred();
+                return null;
+            }
+        };
+        view = new BlockView(block, Y_AXIS) {
+            protected StyleSheet getStyleSheet() {
+                return ss;
+            }
+        };
+        assertFalse(boxMarker.isOccurred());
+        assertFalse(listMarker.isOccurred());
+        view.setPropertiesFromAttributes();
+        assertTrue(boxMarker.isOccurred());
+        assertFalse(listMarker.isOccurred());
+    }
+
+    private int getChildSpan(final int targetSpan, final SizeRequirements sr) {
+        return Math.max(sr.minimum, Math.min(targetSpan, sr.maximum));
+    }
+
+    private int getChildOffset(final int targetSpan, final int childSpan,
+                               final SizeRequirements sr) {
+        return (int)((targetSpan - childSpan) * sr.alignment);
+    }
+
+    private float getMaxChildSpan(final int axis) {
+        float result = 0;
+        for (int i = 0; i < view.getViewCount(); i++) {
+            result = Math.max(result, view.getView(i).getPreferredSpan(axis));
+        }
+        return result;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSSTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSSTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSSTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSSTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,246 @@
+/*
+ *  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.IOException;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.StyleContext;
+import javax.swing.text.html.CSS.Attribute;
+
+public class CSSTest extends BasicSwingTestCase {
+    public void testGetAllAttributeKeys() {
+        Attribute[] keys = CSS.getAllAttributeKeys();
+        if (isHarmony()) {
+            // The array contains only the public attribute keys
+            assertEquals(53, keys.length);
+        } else {
+            // The array contains two more attributes than declared in the Spec
+            assertEquals(55, keys.length);
+        }
+        Attribute[] allAttributeKeys = {
+            Attribute.BACKGROUND,
+            Attribute.BACKGROUND_ATTACHMENT,
+            Attribute.BACKGROUND_COLOR,
+            Attribute.BACKGROUND_IMAGE,
+            Attribute.BACKGROUND_POSITION,
+            Attribute.BACKGROUND_REPEAT,
+            Attribute.BORDER,
+            Attribute.BORDER_BOTTOM,
+            Attribute.BORDER_BOTTOM_WIDTH,
+            Attribute.BORDER_COLOR,
+            Attribute.BORDER_LEFT,
+            Attribute.BORDER_LEFT_WIDTH,
+            Attribute.BORDER_RIGHT,
+            Attribute.BORDER_RIGHT_WIDTH,
+            Attribute.BORDER_STYLE,
+            Attribute.BORDER_TOP,
+            Attribute.BORDER_TOP_WIDTH,
+            Attribute.BORDER_WIDTH,
+            Attribute.CLEAR,
+            Attribute.COLOR,
+            Attribute.DISPLAY,
+            Attribute.FLOAT,
+            Attribute.FONT,
+            Attribute.FONT_FAMILY,
+            Attribute.FONT_SIZE,
+            Attribute.FONT_STYLE,
+            Attribute.FONT_VARIANT,
+            Attribute.FONT_WEIGHT,
+            Attribute.HEIGHT,
+            Attribute.LETTER_SPACING,
+            Attribute.LINE_HEIGHT,
+            Attribute.LIST_STYLE,
+            Attribute.LIST_STYLE_IMAGE,
+            Attribute.LIST_STYLE_POSITION,
+            Attribute.LIST_STYLE_TYPE,
+            Attribute.MARGIN,
+            Attribute.MARGIN_BOTTOM,
+            Attribute.MARGIN_LEFT,
+            Attribute.MARGIN_RIGHT,
+            Attribute.MARGIN_TOP,
+            Attribute.PADDING,
+            Attribute.PADDING_BOTTOM,
+            Attribute.PADDING_LEFT,
+            Attribute.PADDING_RIGHT,
+            Attribute.PADDING_TOP,
+            Attribute.TEXT_ALIGN,
+            Attribute.TEXT_DECORATION,
+            Attribute.TEXT_INDENT,
+            Attribute.TEXT_TRANSFORM,
+            Attribute.VERTICAL_ALIGN,
+            Attribute.WHITE_SPACE,
+            Attribute.WIDTH,
+            Attribute.WORD_SPACING
+        };
+        final boolean[] found = new boolean[allAttributeKeys.length];
+
+        for (int i = 0; i < allAttributeKeys.length; i++) {
+            for (int j = 0; j < allAttributeKeys.length; j++) {
+                if (allAttributeKeys[i] == keys[j]) {
+                    found[i] = true;
+                    break;
+                }
+            }
+        }
+
+        for (int i = 0; i < found.length; i++) {
+            assertTrue("Attribute " + allAttributeKeys[i] + " was not found",
+                       found[i]);
+        }
+    }
+
+    public void testGetAttribute() throws Exception {
+        // These properties are defined only in CSS Level 2
+        assertNull(CSS.getAttribute("position"));
+        assertNull(CSS.getAttribute("cursor"));
+        assertNull(CSS.getAttribute("border-collapse"));
+
+        if (!isHarmony()) {
+            // These properties are defined somewhere but they're not public
+            assertNotNull(CSS.getAttribute("border-spacing"));
+            assertNotNull(CSS.getAttribute("caption-side"));
+        }
+
+
+        // Standard properties defined in CSS Level 1
+        assertSame(Attribute.BACKGROUND,
+                   CSS.getAttribute("background"));
+        assertSame(Attribute.BACKGROUND_ATTACHMENT,
+                   CSS.getAttribute("background-attachment"));
+        assertSame(Attribute.BACKGROUND_COLOR,
+                   CSS.getAttribute("background-color"));
+        assertSame(Attribute.BACKGROUND_IMAGE,
+                   CSS.getAttribute("background-image"));
+        assertSame(Attribute.BACKGROUND_POSITION,
+                   CSS.getAttribute("background-position"));
+        assertSame(Attribute.BACKGROUND_REPEAT,
+                   CSS.getAttribute("background-repeat"));
+        assertSame(Attribute.BORDER,
+                   CSS.getAttribute("border"));
+        assertSame(Attribute.BORDER_BOTTOM,
+                   CSS.getAttribute("border-bottom"));
+        assertSame(Attribute.BORDER_BOTTOM_WIDTH,
+                   CSS.getAttribute("border-bottom-width"));
+        assertSame(Attribute.BORDER_COLOR,
+                   CSS.getAttribute("border-color"));
+        assertSame(Attribute.BORDER_LEFT,
+                   CSS.getAttribute("border-left"));
+        assertSame(Attribute.BORDER_LEFT_WIDTH,
+                   CSS.getAttribute("border-left-width"));
+        assertSame(Attribute.BORDER_RIGHT,
+                   CSS.getAttribute("border-right"));
+        assertSame(Attribute.BORDER_RIGHT_WIDTH,
+                   CSS.getAttribute("border-right-width"));
+        assertSame(Attribute.BORDER_STYLE,
+                   CSS.getAttribute("border-style"));
+        assertSame(Attribute.BORDER_TOP,
+                   CSS.getAttribute("border-top"));
+        assertSame(Attribute.BORDER_TOP_WIDTH,
+                   CSS.getAttribute("border-top-width"));
+        assertSame(Attribute.BORDER_WIDTH,
+                   CSS.getAttribute("border-width"));
+        assertSame(Attribute.CLEAR,
+                   CSS.getAttribute("clear"));
+        assertSame(Attribute.COLOR,
+                   CSS.getAttribute("color"));
+        assertSame(Attribute.DISPLAY,
+                   CSS.getAttribute("display"));
+        assertSame(Attribute.FLOAT,
+                   CSS.getAttribute("float"));
+        assertSame(Attribute.FONT,
+                   CSS.getAttribute("font"));
+        assertSame(Attribute.FONT_FAMILY,
+                   CSS.getAttribute("font-family"));
+        assertSame(Attribute.FONT_SIZE,
+                   CSS.getAttribute("font-size"));
+        assertSame(Attribute.FONT_STYLE,
+                   CSS.getAttribute("font-style"));
+        assertSame(Attribute.FONT_VARIANT,
+                   CSS.getAttribute("font-variant"));
+        assertSame(Attribute.FONT_WEIGHT,
+                   CSS.getAttribute("font-weight"));
+        assertSame(Attribute.HEIGHT,
+                   CSS.getAttribute("height"));
+        assertSame(Attribute.LETTER_SPACING,
+                   CSS.getAttribute("letter-spacing"));
+        assertSame(Attribute.LINE_HEIGHT,
+                   CSS.getAttribute("line-height"));
+        assertSame(Attribute.LIST_STYLE,
+                   CSS.getAttribute("list-style"));
+        assertSame(Attribute.LIST_STYLE_IMAGE,
+                   CSS.getAttribute("list-style-image"));
+        assertSame(Attribute.LIST_STYLE_POSITION,
+                   CSS.getAttribute("list-style-position"));
+        assertSame(Attribute.LIST_STYLE_TYPE,
+                   CSS.getAttribute("list-style-type"));
+        assertSame(Attribute.MARGIN,
+                   CSS.getAttribute("margin"));
+        assertSame(Attribute.MARGIN_BOTTOM,
+                   CSS.getAttribute("margin-bottom"));
+        assertSame(Attribute.MARGIN_LEFT,
+                   CSS.getAttribute("margin-left"));
+        assertSame(Attribute.MARGIN_RIGHT,
+                   CSS.getAttribute("margin-right"));
+        assertSame(Attribute.MARGIN_TOP,
+                   CSS.getAttribute("margin-top"));
+        assertSame(Attribute.PADDING,
+                   CSS.getAttribute("padding"));
+        assertSame(Attribute.PADDING_BOTTOM,
+                   CSS.getAttribute("padding-bottom"));
+        assertSame(Attribute.PADDING_LEFT,
+                   CSS.getAttribute("padding-left"));
+        assertSame(Attribute.PADDING_RIGHT,
+                   CSS.getAttribute("padding-right"));
+        assertSame(Attribute.PADDING_TOP,
+                   CSS.getAttribute("padding-top"));
+        assertSame(Attribute.TEXT_ALIGN,
+                   CSS.getAttribute("text-align"));
+        assertSame(Attribute.TEXT_DECORATION,
+                   CSS.getAttribute("text-decoration"));
+        assertSame(Attribute.TEXT_INDENT,
+                   CSS.getAttribute("text-indent"));
+        assertSame(Attribute.TEXT_TRANSFORM,
+                   CSS.getAttribute("text-transform"));
+        assertSame(Attribute.VERTICAL_ALIGN,
+                   CSS.getAttribute("vertical-align"));
+        assertSame(Attribute.WHITE_SPACE,
+                   CSS.getAttribute("white-space"));
+        assertSame(Attribute.WIDTH,
+                   CSS.getAttribute("width"));
+        assertSame(Attribute.WORD_SPACING,
+                   CSS.getAttribute("word-spacing"));
+    }
+
+    public void testStaticAttributeKeys() {
+        final Attribute[] attrs = CSS.getAllAttributeKeys();
+        for (int i = 0; i < attrs.length; i++) {
+            Object staticKey = StyleContext.getStaticAttributeKey(attrs[i]);
+            assertSame("Static attribute for " + attrs[i] + ", index " + i,
+                       attrs[i], StyleContext.getStaticAttribute(staticKey));
+        }
+    }
+
+    public void testSerializable() throws IOException, ClassNotFoundException {
+        CSS css = new CSS();
+        CSS read = (CSS)serializeObject(css);
+        assertNotNull(read);
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSS_AttributeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSS_AttributeTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSS_AttributeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/CSS_AttributeTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,404 @@
+/*
+ *  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.html.CSS.Attribute;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the values of fields of <code>CSS.Attribute</code> class, i.e.
+ * its name (<code>toString()</code>), default value and inheritance.
+ *
+ */
+public class CSS_AttributeTest extends TestCase {
+    private Attribute attr;
+
+    public void testBackground() {
+        attr = CSS.Attribute.BACKGROUND;
+        assertEquals("background", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBackgroundAttachment() {
+        attr = CSS.Attribute.BACKGROUND_ATTACHMENT;
+        assertEquals("background-attachment", attr.toString());
+        assertEquals("scroll", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBackgroundColor() {
+        attr = CSS.Attribute.BACKGROUND_COLOR;
+        assertEquals("background-color", attr.toString());
+        assertEquals("transparent", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBackgroundImage() {
+        attr = CSS.Attribute.BACKGROUND_IMAGE;
+        assertEquals("background-image", attr.toString());
+        assertEquals("none", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBackgroundPosition() {
+        attr = CSS.Attribute.BACKGROUND_POSITION;
+        assertEquals("background-position", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBackgroundRepeat() {
+        attr = CSS.Attribute.BACKGROUND_REPEAT;
+        assertEquals("background-repeat", attr.toString());
+        assertEquals("repeat", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorder() {
+        attr = CSS.Attribute.BORDER;
+        assertEquals("border", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderBottom() {
+        attr = CSS.Attribute.BORDER_BOTTOM;
+        assertEquals("border-bottom", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderBottomWidth() {
+        attr = CSS.Attribute.BORDER_BOTTOM_WIDTH;
+        assertEquals("border-bottom-width", attr.toString());
+        assertEquals("medium", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderColor() {
+        attr = CSS.Attribute.BORDER_COLOR;
+        assertEquals("border-color", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderLeft() {
+        attr = CSS.Attribute.BORDER_LEFT;
+        assertEquals("border-left", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderLeftWidth() {
+        attr = CSS.Attribute.BORDER_LEFT_WIDTH;
+        assertEquals("border-left-width", attr.toString());
+        assertEquals("medium", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderRight() {
+        attr = CSS.Attribute.BORDER_RIGHT;
+        assertEquals("border-right", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderRightWidth() {
+        attr = CSS.Attribute.BORDER_RIGHT_WIDTH;
+        assertEquals("border-right-width", attr.toString());
+        assertEquals("medium", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderStyle() {
+        attr = CSS.Attribute.BORDER_STYLE;
+        assertEquals("border-style", attr.toString());
+        assertEquals("none", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderTop() {
+        attr = CSS.Attribute.BORDER_TOP;
+        assertEquals("border-top", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderTopWidth() {
+        attr = CSS.Attribute.BORDER_TOP_WIDTH;
+        assertEquals("border-top-width", attr.toString());
+        assertEquals("medium", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testBorderWidth() {
+        attr = CSS.Attribute.BORDER_WIDTH;
+        assertEquals("border-width", attr.toString());
+        assertEquals("medium", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testClear() {
+        attr = CSS.Attribute.CLEAR;
+        assertEquals("clear", attr.toString());
+        assertEquals("none", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testColor() {
+        attr = CSS.Attribute.COLOR;
+        assertEquals("color", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testDisplay() {
+        attr = CSS.Attribute.DISPLAY;
+        assertEquals("display", attr.toString());
+        assertEquals("block", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testFloat() {
+        attr = CSS.Attribute.FLOAT;
+        assertEquals("float", attr.toString());
+        assertEquals("none", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testFont() {
+        attr = CSS.Attribute.FONT;
+        assertEquals("font", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testFontFamily() {
+        attr = CSS.Attribute.FONT_FAMILY;
+        assertEquals("font-family", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testFontSize() {
+        attr = CSS.Attribute.FONT_SIZE;
+        assertEquals("font-size", attr.toString());
+        assertEquals("medium", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testFontStyle() {
+        attr = CSS.Attribute.FONT_STYLE;
+        assertEquals("font-style", attr.toString());
+        assertEquals("normal", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testFontVariant() {
+        attr = CSS.Attribute.FONT_VARIANT;
+        assertEquals("font-variant", attr.toString());
+        assertEquals("normal", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testFontWeight() {
+        attr = CSS.Attribute.FONT_WEIGHT;
+        assertEquals("font-weight", attr.toString());
+        assertEquals("normal", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testHeight() {
+        attr = CSS.Attribute.HEIGHT;
+        assertEquals("height", attr.toString());
+        assertEquals("auto", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testLetterSpacing() {
+        attr = CSS.Attribute.LETTER_SPACING;
+        assertEquals("letter-spacing", attr.toString());
+        assertEquals("normal", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testLineHeight() {
+        attr = CSS.Attribute.LINE_HEIGHT;
+        assertEquals("line-height", attr.toString());
+        assertEquals("normal", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testListStyle() {
+        attr = CSS.Attribute.LIST_STYLE;
+        assertEquals("list-style", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testListStyleImage() {
+        attr = CSS.Attribute.LIST_STYLE_IMAGE;
+        assertEquals("list-style-image", attr.toString());
+        assertEquals("none", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testListStylePosition() {
+        attr = CSS.Attribute.LIST_STYLE_POSITION;
+        assertEquals("list-style-position", attr.toString());
+        assertEquals("outside", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testListStyleType() {
+        attr = CSS.Attribute.LIST_STYLE_TYPE;
+        assertEquals("list-style-type", attr.toString());
+        assertEquals("disc", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testMargin() {
+        attr = CSS.Attribute.MARGIN;
+        assertEquals("margin", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testMarginBottom() {
+        attr = CSS.Attribute.MARGIN_BOTTOM;
+        assertEquals("margin-bottom", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testMarginLeft() {
+        attr = CSS.Attribute.MARGIN_LEFT;
+        assertEquals("margin-left", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testMarginRight() {
+        attr = CSS.Attribute.MARGIN_RIGHT;
+        assertEquals("margin-right", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testMarginTop() {
+        attr = CSS.Attribute.MARGIN_TOP;
+        assertEquals("margin-top", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testPadding() {
+        attr = CSS.Attribute.PADDING;
+        assertEquals("padding", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testPaddingBottom() {
+        attr = CSS.Attribute.PADDING_BOTTOM;
+        assertEquals("padding-bottom", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testPaddingLeft() {
+        attr = CSS.Attribute.PADDING_LEFT;
+        assertEquals("padding-left", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testPaddingRight() {
+        attr = CSS.Attribute.PADDING_RIGHT;
+        assertEquals("padding-right", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testPaddingTop() {
+        attr = CSS.Attribute.PADDING_TOP;
+        assertEquals("padding-top", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testTextAlign() {
+        attr = CSS.Attribute.TEXT_ALIGN;
+        assertEquals("text-align", attr.toString());
+        assertEquals(null, attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testTextDecoration() {
+        attr = CSS.Attribute.TEXT_DECORATION;
+        assertEquals("text-decoration", attr.toString());
+        assertEquals("none", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testTextIndent() {
+        attr = CSS.Attribute.TEXT_INDENT;
+        assertEquals("text-indent", attr.toString());
+        assertEquals("0", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testTextTransform() {
+        attr = CSS.Attribute.TEXT_TRANSFORM;
+        assertEquals("text-transform", attr.toString());
+        assertEquals("none", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testVerticalAlign() {
+        attr = CSS.Attribute.VERTICAL_ALIGN;
+        assertEquals("vertical-align", attr.toString());
+        assertEquals("baseline", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testWhiteSpace() {
+        attr = CSS.Attribute.WHITE_SPACE;
+        assertEquals("white-space", attr.toString());
+        assertEquals("normal", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+
+    public void testWidth() {
+        attr = CSS.Attribute.WIDTH;
+        assertEquals("width", attr.toString());
+        assertEquals("auto", attr.getDefaultValue());
+        assertEquals(false, attr.isInherited());
+    }
+
+    public void testWordSpacing() {
+        attr = CSS.Attribute.WORD_SPACING;
+        assertEquals("word-spacing", attr.toString());
+        assertEquals("normal", attr.getDefaultValue());
+        assertEquals(true, attr.isInherited());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormSubmitEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormSubmitEventTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormSubmitEventTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormSubmitEventTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,88 @@
+/*
+ *  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.util.Arrays;
+
+import javax.swing.SwingTestCase;
+
+public class FormSubmitEventTest extends SwingTestCase {
+
+    public FormSubmitEventTest(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testGetData() {
+        if (!isHarmony()) {
+            return;
+        }
+
+        String data = "data";
+        FormSubmitEvent.MethodType method = FormSubmitEvent.MethodType.GET;
+        FormSubmitEvent event = new FormSubmitEvent(new Object(), null, null,
+                                                    null, null, null,
+                                                    method, data);
+
+        assertSame(data, event.getData());
+    }
+
+    public void testGetMethod() {
+        if (!isHarmony()) {
+            return;
+        }
+
+        String data = "data";
+        FormSubmitEvent.MethodType method = FormSubmitEvent.MethodType.GET;
+        FormSubmitEvent event = new FormSubmitEvent(new Object(), null, null,
+                                                    null, null, null,
+                                                    method, data);
+
+        assertSame(method, event.getMethod());
+    }
+
+    public void testMethodType() {
+        assertSame(FormSubmitEvent.MethodType.GET,
+                   FormSubmitEvent.MethodType.valueOf("GET"));
+        assertSame(FormSubmitEvent.MethodType.POST,
+                   FormSubmitEvent.MethodType.valueOf("POST"));
+        testExceptionalCase(new IllegalArgumentCase() {
+            public void exceptionalAction() throws Exception {
+                FormSubmitEvent.MethodType.valueOf("SOMETHING_ELSE");
+            }
+        });
+
+        FormSubmitEvent.MethodType[] values = FormSubmitEvent.MethodType.values();
+        assertEquals(2, values.length);
+        assertEquals(0,
+                     Arrays.asList(values).indexOf(FormSubmitEvent.MethodType.GET));
+        assertEquals(1,
+                     Arrays.asList(values).indexOf(FormSubmitEvent.MethodType.POST));
+    }
+}



Mime
View raw message