harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r427121 [23/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/StyleSheet_ConvertAttr_BackgroundAttachmentTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundAttachmentTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundAttachmentTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundAttachmentTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,66 @@
+/*
+ *  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.html.CSS.Attribute;
+
+import junit.framework.TestCase;
+
+public class StyleSheet_ConvertAttr_BackgroundAttachmentTest extends TestCase {
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBackgroundAttachmentScroll() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_ATTACHMENT, "scroll");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_ATTACHMENT);
+        assertEquals("scroll", cssValue.toString());
+    }
+
+    public void testBackgroundAttachmentFixed() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_ATTACHMENT, "fixed");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_ATTACHMENT);
+        assertEquals("fixed", cssValue.toString());
+    }
+
+    public void testBackgroundAttachmentInvalid() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_ATTACHMENT, "invalid");
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals(0, simple.getAttributeCount());
+            assertNull(simple.getAttribute(Attribute.BACKGROUND_ATTACHMENT));
+        } else {
+            assertEquals(1, simple.getAttributeCount());
+            assertEquals("scroll", // default value
+                         simple.getAttribute(Attribute.BACKGROUND_ATTACHMENT)
+                         .toString());
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundImageTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundImageTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundImageTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundImageTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,79 @@
+/*
+ *  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.html.CSS.Attribute;
+
+import junit.framework.TestCase;
+
+public class StyleSheet_ConvertAttr_BackgroundImageTest extends TestCase {
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBackgroundImageNone() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_IMAGE, "none");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_IMAGE);
+        assertEquals("none", cssValue.toString());
+    }
+
+    public void testBackgroundImageURLNoQuotes() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_IMAGE, "url(bg.jpg)");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_IMAGE);
+        assertEquals("url(bg.jpg)", cssValue.toString());
+    }
+
+    public void testBackgroundImageURLQuotes() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_IMAGE,
+                           "url(\"bg.jpg\")");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_IMAGE);
+        assertEquals("url(\"bg.jpg\")", cssValue.toString());
+    }
+
+    public void testBackgroundImageURLApostrophes() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_IMAGE, "url('bg.jpg')");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_IMAGE);
+        assertEquals("url('bg.jpg')", cssValue.toString());
+    }
+
+    public void testBackgroundImageNoURL() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_IMAGE, "bg.jpg");
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_IMAGE);
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals(0, simple.getAttributeCount());
+            assertNull(cssValue);
+        } else {
+            assertEquals("bg.jpg", cssValue.toString());
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionAdvancedTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionAdvancedTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionAdvancedTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionAdvancedTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,142 @@
+/*
+ *  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.lang.reflect.Field;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.html.CSS.Attribute;
+
+public class StyleSheet_ConvertAttr_BackgroundPositionAdvancedTest
+    extends BasicSwingTestCase {
+
+    /**
+     * Expected values for validValues.
+     */
+    private static final String[] expectedVV = new String[] {
+        "0% 0%",      "0% 0%",
+        "50% 0%",     "50% 0%",    "50% 0%",
+        "100% 0%",    "100% 0%",
+        "0% 50%",     "0% 50%",    "0% 50%",
+        "50% 50%",    "50% 50%",
+        "100% 50%",   "100% 50%",  "100% 50%",
+        "0% 100%",    "0% 100%",
+        "50% 100%",   "50% 100%",  "50% 100%",
+        "100% 100%",  "100% 100%"
+    };
+
+    private static final String[] validValues =
+        StyleSheet_ConvertAttr_BackgroundPositionTest.validValues;
+    private static final String[] percentValues =
+        StyleSheet_ConvertAttr_BackgroundPositionTest.percentValues;
+    private static final String[] otherValues =
+        StyleSheet_ConvertAttr_BackgroundPositionTest.otherValues;
+
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Attribute cssKey;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = Attribute.BACKGROUND_POSITION;
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBackgroundPositionValidKeywords() throws Exception {
+        if (!isHarmony()) {
+            return;
+        }
+
+        assertEquals(validValues.length, expectedVV.length);
+        for (int i = 0; i < validValues.length; i++) {
+            simple.removeAttribute(cssKey);
+            ss.addCSSAttribute(simple, cssKey, validValues[i]);
+            cssValue = simple.getAttribute(cssKey);
+            assertEquals("@ " + i, expectedVV[i], getString());
+        }
+    }
+
+    public void testBackgroundPositionPercentage() throws Exception {
+        if (!isHarmony()) {
+            return;
+        }
+
+        for (int i = 0; i < percentValues.length; i++) {
+            simple.removeAttribute(cssKey);
+            ss.addCSSAttribute(simple, cssKey, percentValues[i]);
+            cssValue = simple.getAttribute(cssKey);
+            assertEquals("@ " + i,
+                         getExtendedValue(percentValues[i]), getString());
+        }
+    }
+
+    public void testBackgroundPositionOther() throws Exception {
+        if (!isHarmony()) {
+            return;
+        }
+
+        for (int i = 0; i < otherValues.length; i++) {
+            simple.removeAttribute(cssKey);
+            ss.addCSSAttribute(simple, cssKey, otherValues[i]);
+            cssValue = simple.getAttribute(cssKey);
+            assertEquals("@ " + i,
+                         getExtendedValue(otherValues[i]), getString());
+        }
+    }
+
+    private static String getExtendedValue(String value) {
+        return value.indexOf(' ') != -1 ? value
+                                        : value + " 50%";
+    }
+
+    private Object getHorz() {
+        try {
+            Field f = cssValue.getClass().getDeclaredField("horz");
+            f.setAccessible(true);
+            return f.get(cssValue);
+        } catch (IllegalAccessException e) {
+            fail(e.getMessage());
+        } catch (NoSuchFieldException e) {
+            fail(e.getMessage());
+        }
+        return null;
+    }
+
+    private Object getVert() {
+        try {
+            Field f = cssValue.getClass().getDeclaredField("vert");
+            f.setAccessible(true);
+            return f.get(cssValue);
+        } catch (IllegalAccessException e) {
+            fail(e.getMessage());
+        } catch (NoSuchFieldException e) {
+            fail(e.getMessage());
+        }
+        return null;
+    }
+
+    private String getString() {
+        return getHorz() + " " + getVert();
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundPositionTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,130 @@
+/*
+ *  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.html.CSS.Attribute;
+
+import junit.framework.TestCase;
+
+public class StyleSheet_ConvertAttr_BackgroundPositionTest extends TestCase {
+    static final String[] validValues = new String[] {
+        "top left", "left top",
+        "top", "top center", "center top",
+        "right top", "top right",
+        "left", "left center", "center left",
+        "center", "center center",
+        "right", "right center", "center right",
+        "bottom left", "left bottom",
+        "bottom", "bottom center", "center bottom",
+        "bottom right", "right bottom"
+    };
+
+    static final String[] percentValues = new String[] {
+        "0%", "0% 0%",
+        "10%", "10% 0%",
+        "50%", "50% 50%", "50% 100%", "100% 50%",
+        "100%", "100% 100%", "100% 85%",
+        "100%", "100% 100%", "100% 85%"
+    };
+
+    static final String[] otherValues = new String[] {
+        "1.11px", "1.11px 50%", "1.11px 1.11px",
+        "1.11pt", "1.11pt 50%", "1.11pt 1.11pt",
+        "1.11mm", "1.11mm 50%", "1.11mm 1.11mm",
+        "1.11cm", "1.11cm 50%", "1.11cm 1.11cm",
+        "1.11in", "1.11in 50%", "1.11in 1.11in",
+        "1.11pc", "1.11pc 50%", "1.11pc 1.11pc",
+        "1.11em", "1.11em 50%", "1.11em 1.11em",
+        "1.11ex", "1.11ex 50%", "1.11ex 1.11ex",
+
+        "-1.11px", "-1.11px 50%", "-1.11px 1.11px",
+        "-50%", "1.11pt -50%", "1.11px -1.11px",
+        "-1.11px -1.11px"
+    };
+
+    private static final String[] invalidValues = new String[] {
+        "top top",
+        "left left",
+        "right right",
+        "bottom bottom",
+
+        "top 50%",
+        "25% right",
+        "1pt center",
+        "bottom 1px",
+
+        "10px 10px 10px"
+    };
+
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Attribute cssKey;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = Attribute.BACKGROUND_POSITION;
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBackgroundPositionValidKeywords() throws Exception {
+        for (int i = 0; i < validValues.length; i++) {
+            simple.removeAttribute(cssKey);
+            ss.addCSSAttribute(simple, cssKey, validValues[i]);
+            cssValue = simple.getAttribute(cssKey);
+            assertEquals("@ " + i, validValues[i], cssValue.toString());
+        }
+    }
+
+    public void testBackgroundPositionInvalidKeywords() throws Exception {
+        for (int i = 0; i < invalidValues.length; i++) {
+            simple.removeAttribute(cssKey);
+            ss.addCSSAttribute(simple, cssKey, invalidValues[i]);
+            cssValue = simple.getAttribute(cssKey);
+            if (BasicSwingTestCase.isHarmony()) {
+                assertNull("@ " + i, cssValue);
+            } else {
+                assertEquals("@ " + i, invalidValues[i], cssValue.toString());
+            }
+        }
+    }
+
+    public void testBackgroundPositionPercentage() throws Exception {
+        for (int i = 0; i < percentValues.length; i++) {
+            simple.removeAttribute(cssKey);
+            ss.addCSSAttribute(simple, cssKey, percentValues[i]);
+            cssValue = simple.getAttribute(cssKey);
+            assertEquals("@ " + i, percentValues[i], cssValue.toString());
+        }
+    }
+
+    public void testBackgroundPositionOther() throws Exception {
+        for (int i = 0; i < otherValues.length; i++) {
+            simple.removeAttribute(cssKey);
+            ss.addCSSAttribute(simple, cssKey, otherValues[i]);
+            cssValue = simple.getAttribute(cssKey);
+            assertEquals("@ " + i, otherValues[i], cssValue.toString());
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundRepeatTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundRepeatTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundRepeatTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundRepeatTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,80 @@
+/*
+ *  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.html.CSS.Attribute;
+
+import junit.framework.TestCase;
+
+public class StyleSheet_ConvertAttr_BackgroundRepeatTest extends TestCase {
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBackgroundRepeatRepeat() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_REPEAT, "repeat");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_REPEAT);
+        assertEquals("repeat", cssValue.toString());
+    }
+
+    public void testBackgroundRepeatRepeatX() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_REPEAT, "repeat-x");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_REPEAT);
+        assertEquals("repeat-x", cssValue.toString());
+    }
+
+    public void testBackgroundRepeatRepeatY() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_REPEAT, "repeat-y");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_REPEAT);
+        assertEquals("repeat-y", cssValue.toString());
+    }
+
+    public void testBackgroundRepeatNoRepeat() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_REPEAT, "no-repeat");
+
+        cssValue = simple.getAttribute(Attribute.BACKGROUND_REPEAT);
+        assertEquals("no-repeat", cssValue.toString());
+    }
+
+    public void testBackgroundRepeatRepeatNo() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND_REPEAT, "repeat-no");
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals(0, simple.getAttributeCount());
+            assertNull(simple.getAttribute(Attribute.BACKGROUND_REPEAT));
+        } else {
+            assertEquals(1, simple.getAttributeCount());
+            assertEquals("repeat", // default value
+                         simple.getAttribute(Attribute.BACKGROUND_REPEAT)
+                         .toString());
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BackgroundTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,226 @@
+/*
+ *  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.html.CSS.Attribute;
+
+public class StyleSheet_ConvertAttr_BackgroundTest extends BasicSwingTestCase {
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBackground01() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND, "red no-repeat");
+
+        assertAttributes("red", isHarmony() ? "none" : null, "no-repeat",
+                         "scroll", isHarmony() ? "0% 0%" : null);
+    }
+
+    public void testBackground02() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND, "no-repeat red");
+
+        assertAttributes("red", isHarmony() ? "none" : null, "no-repeat",
+                         "scroll", isHarmony() ? "0% 0%" : null);
+    }
+
+    public void testBackground03() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "no-repeat red fixed url(bg.jpg)");
+
+        assertAttributes("red", "url(bg.jpg)", "no-repeat",
+                         "fixed", isHarmony() ? "0% 0%" : null);
+    }
+
+    public void testBackground04() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "no-repeat red fixed url('bg.jpg') top");
+
+        assertAttributes("red", "url('bg.jpg')", "no-repeat", "fixed", "top");
+    }
+
+    public void testBackground05() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "no-repeat red fixed url(\"bg.jpg\") top center");
+
+        assertAttributes("red", "url(\"bg.jpg\")", "no-repeat",
+                         "fixed", "top center");
+    }
+
+    public void testBackground06() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "no-repeat red fixed url(\"bg.jpg\") top top");
+        if (isHarmony()) {
+            assertEquals(0, simple.getAttributeCount());
+            return;
+        }
+
+        assertAttributes("red", "url(\"bg.jpg\")", "no-repeat",
+                         "fixed", "top top");
+    }
+
+    public void testBackground07() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "no-repeat red url(\"bg.jpg scroll");
+        if (isHarmony()) {
+            assertEquals(0, simple.getAttributeCount());
+            return;
+        }
+
+        assertAttributes("red", null, "no-repeat", "scroll", null);
+    }
+
+    public void testBackground08() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "repeat-x blue bg.jpg scroll");
+        if (isHarmony()) {
+            assertEquals(0, simple.getAttributeCount());
+            return;
+        }
+
+        assertAttributes("blue", null, "repeat-x", "scroll", null);
+    }
+
+    public void testBackground09() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "repeat-x #AABBCC fixed");
+
+        assertAttributes("#AABBCC", isHarmony() ? "none" : null,
+                         "repeat-x", "fixed", isHarmony() ? "0% 0%" : null);
+    }
+
+    public void testBackground10() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "repeat-y none rgb(50%, 100%, 25%) fixed center");
+
+        assertAttributes(isHarmony() ? "rgb(50%, 100%, 25%)" : "rgb(50%,",
+                         isHarmony() ? "none" : null,
+                         "repeat-y",
+                         "fixed",
+                         isHarmony() ? "center" : "100%, 25%)");
+    }
+
+    public void testBackground11() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "repeat-y none green fixed center repeat");
+        if (isHarmony()) {
+            assertEquals(0, simple.getAttributeCount());
+            return;
+        }
+
+        assertAttributes("green", null, "repeat-y", "fixed", "center");
+    }
+
+    public void testBackground12() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND, "none none");
+        if (!isHarmony()) {
+            return;
+        }
+        assertEquals(0, simple.getAttributeCount());
+    }
+
+    public void testBackground13() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND, "black white");
+        if (!isHarmony()) {
+            return;
+        }
+        assertEquals(0, simple.getAttributeCount());
+    }
+
+    public void testBackground14() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND, "fixed scroll");
+        if (!isHarmony()) {
+            return;
+        }
+        assertEquals(0, simple.getAttributeCount());
+    }
+
+    public void testBackground15() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "50% blue url(bg.jpg) top");
+        if (!isHarmony()) {
+            return;
+        }
+        assertEquals(0, simple.getAttributeCount());
+    }
+
+    public void testBackground16() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "50% fixed url(bg.jpg) 10px");
+        if (!isHarmony()) {
+            return;
+        }
+        assertAttributes("transparent", "url(bg.jpg)", "repeat",
+                         "fixed", "50% 10px");
+    }
+
+    public void testBackground17() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "url(bg.jpg) none");
+        if (!isHarmony()) {
+            return;
+        }
+        assertEquals(0, simple.getAttributeCount());
+    }
+
+    public void testBackground18() {
+        ss.addCSSAttribute(simple, Attribute.BACKGROUND,
+                           "fixed url(bg.jpg) left top transparent");
+        if (!isHarmony()) {
+            return;
+        }
+        assertAttributes("transparent", "url(bg.jpg)", "repeat",
+                         "fixed", "left top");
+    }
+
+    private void assertAttributes(final String color,
+                                  final String image,
+                                  final String repeat,
+                                  final String attachment,
+                                  final String position) {
+//        assertEquals("Attribute count",
+//                     isHarmony() ? 5 : 4, simple.getAttributeCount());
+
+        assertEquals("background-color",
+                     color, getCSSAttribute(Attribute.BACKGROUND_COLOR));
+        assertEquals("background-image",
+                     image, getCSSAttribute(Attribute.BACKGROUND_IMAGE));
+        assertEquals("background-repeat",
+                     repeat, getCSSAttribute(Attribute.BACKGROUND_REPEAT));
+        assertEquals("background-attachment",
+                     attachment,
+                     getCSSAttribute(Attribute.BACKGROUND_ATTACHMENT));
+        assertEquals("background-position",
+                     position, getCSSAttribute(Attribute.BACKGROUND_POSITION));
+    }
+
+    private String getCSSAttribute(final Attribute cssKey) {
+        final Object result = simple.getAttribute(cssKey);
+        return result != null ? result.toString() : null;
+    }
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BoldTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BoldTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BoldTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BoldTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,244 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.util.Enumeration;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.CSS.Attribute;
+
+public class StyleSheet_ConvertAttr_BoldTest extends BasicSwingTestCase {
+    private StyleSheet ss;
+    private AttributeSet empty;
+    private AttributeSet attr;
+    private MutableAttributeSet simple;
+    private Object cssValue;
+    private Object scValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        empty = ss.getEmptySet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBold() {
+        attr = ss.addAttribute(empty, StyleConstants.Bold, Boolean.TRUE);
+
+        Enumeration names = attr.getAttributeNames();
+        Object name = names.nextElement();
+        assertSame(Attribute.FONT_WEIGHT, name);
+        assertFalse(names.hasMoreElements());
+
+        cssValue = attr.getAttribute(Attribute.FONT_WEIGHT);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertSame(Boolean.class, scValue.getClass());
+        assertNotSame(Boolean.class, cssValue.getClass());
+        assertNotSame(String.class, cssValue.getClass());
+        assertEquals("bold", cssValue.toString());
+        assertEquals("true", scValue.toString());
+        assertTrue(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBoldFalse() {
+        attr = ss.addAttribute(empty, StyleConstants.Bold, Boolean.FALSE);
+
+        Enumeration names = attr.getAttributeNames();
+        Object name = names.nextElement();
+        assertSame(Attribute.FONT_WEIGHT, name);
+        assertFalse(names.hasMoreElements());
+
+        cssValue = attr.getAttribute(Attribute.FONT_WEIGHT);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertSame(Boolean.class, scValue.getClass());
+        assertNotSame(Boolean.class, cssValue.getClass());
+        assertNotSame(String.class, cssValue.getClass());
+        assertEquals("normal", cssValue.toString());
+        assertFalse(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBoldBold() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "bold");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("bold", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertTrue(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBoldNormal() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "normal");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("normal", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertFalse(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBoldBolder() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "bolder");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        if (isHarmony()) {
+            assertEquals("bolder", cssValue.toString());
+
+            attr = ss.createSmallAttributeSet(simple);
+            scValue = attr.getAttribute(StyleConstants.Bold);
+            assertNotNull(scValue);
+            assertTrue(((Boolean)scValue).booleanValue());
+        } else {
+            assertEquals("normal", cssValue.toString()); // default value
+        }
+    }
+
+    public void testBoldLighter() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "lighter");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        if (isHarmony()) {
+            assertEquals("lighter", cssValue.toString());
+
+            attr = ss.createSmallAttributeSet(simple);
+            scValue = attr.getAttribute(StyleConstants.Bold);
+            assertNotNull(scValue);
+            assertFalse(((Boolean)scValue).booleanValue());
+        } else {
+            assertEquals("normal", cssValue.toString()); // default value
+        }
+    }
+
+    public void testBold100() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "100");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("100", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertFalse(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold200() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "200");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("200", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertFalse(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold300() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "300");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("300", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertFalse(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold400() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "400");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("400", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertFalse(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold500() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "500");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("500", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertFalse(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold600() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "600");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("600", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertTrue(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold700() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "700");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("700", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertTrue(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold800() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "800");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("800", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertTrue(((Boolean)scValue).booleanValue());
+    }
+
+    public void testBold900() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.FONT_WEIGHT, "900");
+        assertEquals(1, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.FONT_WEIGHT);
+        assertEquals("900", cssValue.toString());
+
+        attr = ss.createSmallAttributeSet(simple);
+        scValue = attr.getAttribute(StyleConstants.Bold);
+        assertNotNull(scValue);
+        assertTrue(((Boolean)scValue).booleanValue());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,31 @@
+/*
+ *  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;
+
+public class StyleSheet_ConvertAttr_BorderBottomTest
+    extends StyleSheet_ConvertAttr_BorderPartTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = CSS.Attribute.BORDER_BOTTOM;
+        cssWidthKey = CSS.Attribute.BORDER_BOTTOM_WIDTH;
+        sideIndex = 2;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomWidthTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomWidthTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomWidthTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderBottomWidthTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,29 @@
+/*
+ *  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;
+
+public class StyleSheet_ConvertAttr_BorderBottomWidthTest
+    extends StyleSheet_ConvertAttr_BorderWidthTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = CSS.Attribute.BORDER_BOTTOM_WIDTH;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderColorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderColorTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderColorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderColorTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,117 @@
+/*
+ *  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.html.CSS.Attribute;
+
+public class StyleSheet_ConvertAttr_BorderColorTest extends BasicSwingTestCase {
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Attribute cssKey;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+        cssKey = CSS.Attribute.BORDER_COLOR;
+    }
+
+    public void testRed() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "red");
+        cssValue = simple.getAttribute(cssKey);
+        assertNotSame(String.class, cssValue.getClass());
+        assertEquals("red", cssValue.toString());
+    }
+
+    public void testRedGreen() throws Exception {
+        if (!isHarmony()) {
+            testExceptionalCase(new NullPointerCase() {
+                public void exceptionalAction() throws Exception {
+                    ss.addCSSAttribute(simple, cssKey, "red green");
+                }
+            });
+            return;
+        }
+
+        ss.addCSSAttribute(simple, cssKey, "red green");
+        cssValue = simple.getAttribute(cssKey);
+        assertEquals("red green", cssValue.toString());
+    }
+
+    public void testRedGreenFuchsia() throws Exception {
+        if (!isHarmony()) {
+            testExceptionalCase(new NullPointerCase() {
+                public void exceptionalAction() throws Exception {
+                    ss.addCSSAttribute(simple, cssKey, "red green fuchsia");
+                }
+            });
+            return;
+        }
+
+        ss.addCSSAttribute(simple, cssKey, "red green fuchsia");
+        cssValue = simple.getAttribute(cssKey);
+        assertEquals("red green fuchsia", cssValue.toString());
+    }
+
+    public void testRedGreenFuchsiaAqua() throws Exception {
+        if (!isHarmony()) {
+            testExceptionalCase(new NullPointerCase() {
+                public void exceptionalAction() throws Exception {
+                    ss.addCSSAttribute(simple, cssKey, "red green fuchsia aqua");
+                }
+            });
+            return;
+        }
+
+        ss.addCSSAttribute(simple, cssKey, "red green fuchsia aqua");
+        cssValue = simple.getAttribute(cssKey);
+        assertEquals("red green fuchsia aqua", cssValue.toString());
+    }
+
+    public void testHex() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "#FFEEDD");
+        cssValue = simple.getAttribute(cssKey);
+        assertEquals("#FFEEDD", cssValue.toString());
+    }
+
+    public void testHexHex() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "#FFEEDD #EEDDFF");
+        cssValue = simple.getAttribute(cssKey);
+        assertEquals("#FFEEDD #EEDDFF", cssValue.toString());
+    }
+
+    public void testRGB() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "rgb(127, 255, 75)");
+        cssValue = simple.getAttribute(cssKey);
+        assertEquals("rgb(127, 255, 75)", cssValue.toString());
+    }
+
+    public void testRGB_RGB() throws Exception {
+        ss.addCSSAttribute(simple, cssKey,
+                           "rgb(127, 255, 75) rgb(50%, 100%, 30%)");
+        cssValue = simple.getAttribute(cssKey);
+        assertEquals("rgb(127, 255, 75) rgb(50%, 100%, 30%)",
+                     cssValue.toString());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,31 @@
+/*
+ *  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;
+
+public class StyleSheet_ConvertAttr_BorderLeftTest
+    extends StyleSheet_ConvertAttr_BorderPartTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = CSS.Attribute.BORDER_LEFT;
+        cssWidthKey = CSS.Attribute.BORDER_LEFT_WIDTH;
+        sideIndex = 3;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftWidthTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftWidthTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftWidthTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderLeftWidthTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,29 @@
+/*
+ *  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;
+
+public class StyleSheet_ConvertAttr_BorderLeftWidthTest
+    extends StyleSheet_ConvertAttr_BorderWidthTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = CSS.Attribute.BORDER_LEFT_WIDTH;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderPartTestCase.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderPartTestCase.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderPartTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderPartTestCase.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,217 @@
+/*
+ *  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.html.CSS.Attribute;
+
+public abstract class StyleSheet_ConvertAttr_BorderPartTestCase extends BasicSwingTestCase {
+    protected StyleSheet ss;
+    protected MutableAttributeSet simple;
+    protected Attribute cssKey;
+    protected Object cssValue;
+    protected Attribute cssWidthKey;
+    protected int sideIndex;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+        sideIndex = -1;
+    }
+
+    public void testBlackSolidThin() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "black solid thin");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("black solid thin", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(3, simple.getAttributeCount());
+
+        assertEquals(getColorDeclaration("black"),
+                     simple.getAttribute(Attribute.BORDER_COLOR).toString());
+        assertEquals(getStyleDeclaration("solid"),
+                     simple.getAttribute(Attribute.BORDER_STYLE).toString());
+        assertEquals("thin",
+                     simple.getAttribute(cssWidthKey).toString());
+    }
+
+    public void testSolidThin() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "solid thin");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("solid thin", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(2, simple.getAttributeCount());
+
+        assertEquals(getStyleDeclaration("solid"),
+                     simple.getAttribute(Attribute.BORDER_STYLE).toString());
+        assertEquals("thin",
+                     simple.getAttribute(cssWidthKey).toString());
+    }
+
+    public void testBlackThin() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "black thin");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("black thin", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(2, simple.getAttributeCount());
+
+        assertEquals(getColorDeclaration("black"),
+                     simple.getAttribute(Attribute.BORDER_COLOR).toString());
+        assertEquals("thin",
+                     simple.getAttribute(cssWidthKey).toString());
+    }
+
+    public void testBlackSolid() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "black solid");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("black solid", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(2, simple.getAttributeCount());
+
+        assertEquals(getColorDeclaration("black"),
+                     simple.getAttribute(Attribute.BORDER_COLOR).toString());
+        assertEquals(getStyleDeclaration("solid"),
+                     simple.getAttribute(Attribute.BORDER_STYLE).toString());
+    }
+
+    public void testSolidBlackThin() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "solid black thin");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("solid black thin", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(3, simple.getAttributeCount());
+
+        assertEquals(getColorDeclaration("black"),
+                     simple.getAttribute(Attribute.BORDER_COLOR).toString());
+        assertEquals(getStyleDeclaration("solid"),
+                     simple.getAttribute(Attribute.BORDER_STYLE).toString());
+        assertEquals("thin",
+                     simple.getAttribute(cssWidthKey).toString());
+    }
+
+    public void testSolidFFEEDDThin() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "solid #FFEEDD thin");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("solid #FFEEDD thin", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(3, simple.getAttributeCount());
+
+        assertEquals(getColorDeclaration("#FFEEDD"),
+                     simple.getAttribute(Attribute.BORDER_COLOR).toString());
+        assertEquals(getStyleDeclaration("solid"),
+                     simple.getAttribute(Attribute.BORDER_STYLE).toString());
+        assertEquals("thin",
+                     simple.getAttribute(cssWidthKey).toString());
+    }
+
+    public void testSolidRGBMedium() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "solid rgb(127, 255, 75) medium");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("solid rgb(127, 255, 75) medium", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(3, simple.getAttributeCount());
+
+        assertEquals(getColorDeclaration("rgb(127, 255, 75)"),
+                     simple.getAttribute(Attribute.BORDER_COLOR).toString());
+        assertEquals(getStyleDeclaration("solid"),
+                     simple.getAttribute(Attribute.BORDER_STYLE).toString());
+        assertEquals("medium",
+                     simple.getAttribute(cssWidthKey).toString());
+    }
+
+    public void testInsetRGBLength() throws Exception {
+        ss.addCSSAttribute(simple, cssKey, "inset rgb(50%, 100%, 30%) 1px");
+        cssValue = simple.getAttribute(cssKey);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("inset rgb(50%, 100%, 30%) 1px", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(3, simple.getAttributeCount());
+
+        assertEquals(getColorDeclaration("rgb(50%, 100%, 30%)"),
+                     simple.getAttribute(Attribute.BORDER_COLOR).toString());
+        assertEquals(getStyleDeclaration("inset"),
+                     simple.getAttribute(Attribute.BORDER_STYLE).toString());
+        assertEquals("1px",
+                     simple.getAttribute(cssWidthKey).toString());
+    }
+
+    protected final String getStyleDeclaration(final String style) {
+        StringBuffer result = new StringBuffer();
+        for (int i = 0; i < 4; i++) {
+            if (i > 0) {
+                result.append(' ');
+            }
+            result.append(i == sideIndex ? style : "none");
+        }
+        return result.toString();
+    }
+
+    protected final String getColorDeclaration(final String color) {
+        StringBuffer result = new StringBuffer();
+        for (int i = 0; i < 4; i++) {
+            if (i > 0) {
+                result.append(' ');
+            }
+            result.append(i == sideIndex ? color : "white");
+        }
+        return result.toString();
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,31 @@
+/*
+ *  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;
+
+public class StyleSheet_ConvertAttr_BorderRightTest
+    extends StyleSheet_ConvertAttr_BorderPartTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = CSS.Attribute.BORDER_RIGHT;
+        cssWidthKey = CSS.Attribute.BORDER_RIGHT_WIDTH;
+        sideIndex = 1;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightWidthTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightWidthTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightWidthTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderRightWidthTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,30 @@
+/*
+ *  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;
+
+public class StyleSheet_ConvertAttr_BorderRightWidthTest
+    extends StyleSheet_ConvertAttr_BorderWidthTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = CSS.Attribute.BORDER_RIGHT_WIDTH;
+    }
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderStyleTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderStyleTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderStyleTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderStyleTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,153 @@
+/*
+ *  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.html.CSS.Attribute;
+
+import junit.framework.TestCase;
+
+public class StyleSheet_ConvertAttr_BorderStyleTest extends TestCase {
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBorderStyleNone() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "none");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals("none", cssValue.toString());
+        } else {
+            assertEquals(0, simple.getAttributeCount());
+            assertNull(cssValue);
+        }
+    }
+
+    public void testBorderStyleDotted() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "dotted");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("dotted", cssValue.toString());
+    }
+
+    public void testBorderStyleDashed() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "dashed");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("dashed", cssValue.toString());
+    }
+
+    public void testBorderStyleSolid() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "solid");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("solid", cssValue.toString());
+    }
+
+    public void testBorderStyleDouble() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "double");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("double", cssValue.toString());
+    }
+
+    public void testBorderStyleGroove() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "groove");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("groove", cssValue.toString());
+    }
+
+    public void testBorderStyleRidge() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "ridge");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("ridge", cssValue.toString());
+    }
+
+    public void testBorderStyleInset() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "inset");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("inset", cssValue.toString());
+    }
+
+    public void testBorderStyleOutset() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "outset");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals("outset", cssValue.toString());
+    }
+
+    public void testBorderStyleSunken() throws Exception {
+        // Invalid value
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "sunken");
+        assertEquals(0, simple.getAttributeCount());
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertNull(cssValue);
+    }
+
+
+    public void testBorderStyleInsetOutset() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "inset outset");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals(1, simple.getAttributeCount());
+            assertEquals("inset outset", cssValue.toString());
+        } else {
+            assertEquals(0, simple.getAttributeCount());
+            assertNull(cssValue);
+        }
+    }
+
+    public void testBorderStyleOutsetInsetSolid() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "outset inset solid");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals(1, simple.getAttributeCount());
+            assertEquals("outset inset solid", cssValue.toString());
+        } else {
+            assertEquals(0, simple.getAttributeCount());
+            assertNull(cssValue);
+        }
+    }
+
+    public void testBorderStyleInsetRidgeOutsetGroove() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE,
+                           "inset ridge outset groove");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        if (BasicSwingTestCase.isHarmony()) {
+            assertEquals(1, simple.getAttributeCount());
+            assertEquals("inset ridge outset groove", cssValue.toString());
+        } else {
+            assertEquals(0, simple.getAttributeCount());
+            assertNull(cssValue);
+        }
+    }
+
+
+    public void testBorderStyleInsetRidgeOutsetEtched() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER_STYLE,
+                           "inset ridge outset etched");
+        cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
+        assertEquals(0, simple.getAttributeCount());
+        assertNull(cssValue);
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,303 @@
+/*
+ *  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.html.CSS.Attribute;
+
+public class StyleSheet_ConvertAttr_BorderTest extends BasicSwingTestCase {
+    private StyleSheet ss;
+    private MutableAttributeSet simple;
+    private Object cssValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        ss = new StyleSheet();
+        simple = new SimpleAttributeSet();
+    }
+
+    public void testBorderThin() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "thin");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("thin", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(4, simple.getAttributeCount());
+
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                             .toString());
+    }
+
+    public void testBorderGreen() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "green");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("green", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(1, simple.getAttributeCount());
+
+        assertEquals("green", simple.getAttribute(Attribute.BORDER_COLOR)
+                              .toString());
+    }
+
+    public void testBorderSolid() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "solid");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("solid", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(1, simple.getAttributeCount());
+
+        assertEquals("solid", simple.getAttribute(Attribute.BORDER_STYLE)
+                              .toString());
+    }
+
+
+    public void testBorderThinYellow() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "thin yellow");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("thin yellow", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(5, simple.getAttributeCount());
+
+        assertEquals("yellow", simple.getAttribute(Attribute.BORDER_COLOR)
+                               .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                             .toString());
+    }
+
+    public void testBorderThinDotted() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "thin dotted");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("thin dotted", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(5, simple.getAttributeCount());
+
+        assertEquals("dotted", simple.getAttribute(Attribute.BORDER_STYLE)
+                               .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                             .toString());
+    }
+
+    public void testBorderGreenMedium() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "green medium");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("green medium", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(5, simple.getAttributeCount());
+
+        assertEquals("green", simple.getAttribute(Attribute.BORDER_COLOR)
+                              .toString());
+        assertEquals("medium", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                               .toString());
+        assertEquals("medium", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                               .toString());
+        assertEquals("medium", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                               .toString());
+        assertEquals("medium", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                               .toString());
+    }
+
+    public void testBorderGreenDashed() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "green dashed");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("green dashed", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(2, simple.getAttributeCount());
+
+        assertEquals("dashed", simple.getAttribute(Attribute.BORDER_STYLE)
+                               .toString());
+        assertEquals("green", simple.getAttribute(Attribute.BORDER_COLOR)
+                              .toString());
+    }
+
+    public void testBorderSolidRed() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "solid red");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("solid red", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(2, simple.getAttributeCount());
+
+        assertEquals("red", simple.getAttribute(Attribute.BORDER_COLOR)
+                            .toString());
+        assertEquals("solid", simple.getAttribute(Attribute.BORDER_STYLE)
+                              .toString());
+    }
+
+    public void testBorderSolidThin() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "solid thin");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("solid thin", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(5, simple.getAttributeCount());
+
+        assertEquals("solid", simple.getAttribute(Attribute.BORDER_STYLE)
+                              .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                             .toString());
+        assertEquals("thin", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                             .toString());
+    }
+
+
+    public void testBorderInsetThickAqua() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "inset thick aqua");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("inset thick aqua", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(6, simple.getAttributeCount());
+
+        assertEquals("inset", simple.getAttribute(Attribute.BORDER_STYLE)
+                              .toString());
+        assertEquals("aqua", simple.getAttribute(Attribute.BORDER_COLOR)
+                             .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                              .toString());
+    }
+
+    public void testBorderThickAquaInset() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "thick aqua inset");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("thick aqua inset", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(6, simple.getAttributeCount());
+
+        assertEquals("inset", simple.getAttribute(Attribute.BORDER_STYLE)
+                              .toString());
+        assertEquals("aqua", simple.getAttribute(Attribute.BORDER_COLOR)
+                             .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                              .toString());
+    }
+
+    public void testBorderAquaInsetThick() throws Exception {
+        ss.addCSSAttribute(simple, Attribute.BORDER, "aqua inset thick");
+        cssValue = simple.getAttribute(Attribute.BORDER);
+        if (!isHarmony()) {
+            assertSame(String.class, cssValue.getClass());
+            assertEquals("aqua inset thick", cssValue.toString());
+            return;
+        }
+
+        assertNull(cssValue);
+        assertEquals(6, simple.getAttributeCount());
+
+        assertEquals("inset", simple.getAttribute(Attribute.BORDER_STYLE)
+                              .toString());
+        assertEquals("aqua", simple.getAttribute(Attribute.BORDER_COLOR)
+                             .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_TOP_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_RIGHT_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_BOTTOM_WIDTH)
+                              .toString());
+        assertEquals("thick", simple.getAttribute(Attribute.BORDER_LEFT_WIDTH)
+                              .toString());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTopTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTopTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTopTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_BorderTopTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,31 @@
+/*
+ *  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;
+
+public class StyleSheet_ConvertAttr_BorderTopTest
+    extends StyleSheet_ConvertAttr_BorderPartTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        cssKey = CSS.Attribute.BORDER_TOP;
+        cssWidthKey = CSS.Attribute.BORDER_TOP_WIDTH;
+        sideIndex = 0;
+    }
+}



Mime
View raw message