You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/07/31 16:08:55 UTC
svn commit: r427121 [25/29] - in
/incubator/harmony/enhanced/classlib/trunk/modules/swing: make/
src/main/java/common/javax/swing/ src/main/java/common/javax/swing/text/
src/main/java/common/javax/swing/text/html/
src/main/java/common/javax/swing/text/...
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ItalicTest.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_ItalicTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ItalicTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ItalicTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,137 @@
+/*
+ * 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;
+
+import junit.framework.TestCase;
+
+public class StyleSheet_ConvertAttr_ItalicTest extends TestCase {
+ 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 testItalic() {
+ attr = ss.addAttribute(empty, StyleConstants.Italic, Boolean.TRUE);
+
+ Enumeration names = attr.getAttributeNames();
+ Object name = names.nextElement();
+ assertSame(Attribute.FONT_STYLE, name);
+ assertFalse(names.hasMoreElements());
+
+ cssValue = attr.getAttribute(Attribute.FONT_STYLE);
+ scValue = attr.getAttribute(StyleConstants.Italic);
+ assertSame(Boolean.class, scValue.getClass());
+ assertNotSame(Boolean.class, cssValue.getClass());
+ assertNotSame(String.class, cssValue.getClass());
+ assertEquals("italic", cssValue.toString());
+ assertEquals("true", scValue.toString());
+ assertTrue(((Boolean)scValue).booleanValue());
+ }
+
+ public void testItalicFalse() {
+ attr = ss.addAttribute(empty, StyleConstants.Italic, Boolean.FALSE);
+
+ Enumeration names = attr.getAttributeNames();
+ Object name = names.nextElement();
+ assertSame(Attribute.FONT_STYLE, name);
+ assertFalse(names.hasMoreElements());
+
+ cssValue = attr.getAttribute(Attribute.FONT_STYLE);
+ scValue = attr.getAttribute(StyleConstants.Italic);
+ assertSame(Boolean.class, scValue.getClass());
+ assertNotSame(Boolean.class, cssValue.getClass());
+ assertNotSame(String.class, cssValue.getClass());
+ assertEquals(BasicSwingTestCase.isHarmony() ? "normal" : "",
+ cssValue.toString());
+ assertFalse(((Boolean)scValue).booleanValue());
+ }
+
+ public void testItalicItalic() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.FONT_STYLE, "italic");
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.FONT_STYLE);
+ assertEquals("italic", cssValue.toString());
+
+ attr = ss.createSmallAttributeSet(simple);
+ scValue = attr.getAttribute(StyleConstants.Italic);
+ assertNotNull(scValue);
+ assertTrue(((Boolean)scValue).booleanValue());
+ }
+
+ public void testItalicNormal() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.FONT_STYLE, "normal");
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.FONT_STYLE);
+ assertEquals("normal", cssValue.toString());
+
+ attr = ss.createSmallAttributeSet(simple);
+ scValue = attr.getAttribute(StyleConstants.Italic);
+ assertNotNull(scValue);
+ assertFalse(((Boolean)scValue).booleanValue());
+ }
+
+ public void testItalicOblique() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.FONT_STYLE, "oblique");
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.FONT_STYLE);
+ assertEquals("oblique", cssValue.toString());
+
+ attr = ss.createSmallAttributeSet(simple);
+ scValue = attr.getAttribute(StyleConstants.Italic);
+ assertNotNull(scValue);
+ assertFalse(((Boolean)scValue).booleanValue());
+ }
+
+ public void testItalicInvalidValue() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.FONT_STYLE, "invalid");
+ cssValue = simple.getAttribute(Attribute.FONT_STYLE);
+ if (BasicSwingTestCase.isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ return;
+ }
+
+ assertEquals(1, simple.getAttributeCount());
+ assertEquals("invalid", cssValue.toString());
+
+ attr = ss.createSmallAttributeSet(simple);
+ scValue = attr.getAttribute(StyleConstants.Italic);
+ assertNotNull(scValue);
+ assertFalse(((Boolean)scValue).booleanValue());
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LengthTestCase.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_LengthTestCase.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LengthTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LengthTestCase.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import 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 abstract class StyleSheet_ConvertAttr_LengthTestCase extends TestCase {
+ protected StyleSheet ss;
+ protected MutableAttributeSet simple;
+ protected Attribute cssKey;
+ protected Object cssValue;
+ protected boolean negativeValuesInvalid;
+ protected boolean percentageValuesInvalid;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ss = new StyleSheet();
+ simple = new SimpleAttributeSet();
+ negativeValuesInvalid = false;
+ percentageValuesInvalid = false;
+ }
+
+ public void testLength0_75em() {
+ ss.addCSSAttribute(simple, cssKey, "0.75em");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("0.75em", cssValue.toString());
+ }
+
+ public void testLength1_25ex() {
+ ss.addCSSAttribute(simple, cssKey, "1.25ex");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("1.25ex", cssValue.toString());
+ }
+
+ public void testLength0() {
+ ss.addCSSAttribute(simple, cssKey, "0");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("0", cssValue.toString());
+ }
+
+ public void testLength0px() {
+ ss.addCSSAttribute(simple, cssKey, "0px");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("0px", cssValue.toString());
+ }
+
+ public void testLength11_1() {
+ ss.addCSSAttribute(simple, cssKey, "11.1");
+ cssValue = simple.getAttribute(cssKey);
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ assertEquals("11.1", cssValue.toString());
+ return;
+ }
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ }
+
+ public void testLength11_1pt() {
+ ss.addCSSAttribute(simple, cssKey, "11.1pt");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("11.1pt", cssValue.toString());
+ }
+
+ public void testLength11_1px() {
+ ss.addCSSAttribute(simple, cssKey, "11.1px");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("11.1px", cssValue.toString());
+ }
+
+ public void testLength11_1mm() {
+ ss.addCSSAttribute(simple, cssKey, "11.1mm");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("11.1mm", cssValue.toString());
+ }
+
+ public void testLength11_1cm() {
+ ss.addCSSAttribute(simple, cssKey, "11.1cm");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("11.1cm", cssValue.toString());
+ }
+
+ public void testLength11_1pc() {
+ ss.addCSSAttribute(simple, cssKey, "11.1pc");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("11.1pc", cssValue.toString());
+ }
+
+ public void testLength11_1in() {
+ ss.addCSSAttribute(simple, cssKey, "11.1in");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("11.1in", cssValue.toString());
+ }
+
+ public void testLengthMinus11_1pt() {
+ ss.addCSSAttribute(simple, cssKey, "-11.1pt");
+ cssValue = simple.getAttribute(cssKey);
+ if (negativeValuesInvalid) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals("-11.1pt", cssValue.toString());
+ }
+ }
+
+ public void testLengthPlus11_1pt() {
+ ss.addCSSAttribute(simple, cssKey, "+11.1pt");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("+11.1pt", cssValue.toString());
+ }
+
+ public void testLength11_1Percent() {
+ ss.addCSSAttribute(simple, cssKey, "11.1%");
+ cssValue = simple.getAttribute(cssKey);
+ if (percentageValuesInvalid) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals("11.1%", cssValue.toString());
+ }
+ }
+
+ public void testLengthPlus11_1Percent() {
+ ss.addCSSAttribute(simple, cssKey, "+11.1%");
+ cssValue = simple.getAttribute(cssKey);
+ if (percentageValuesInvalid) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals("+11.1%", cssValue.toString());
+ }
+ }
+
+ public void testLengthMinus11_1Percent() {
+ ss.addCSSAttribute(simple, cssKey, "-11.1%");
+ cssValue = simple.getAttribute(cssKey);
+ if (percentageValuesInvalid || negativeValuesInvalid) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals("-11.1%", cssValue.toString());
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LetterSpacingTest.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_LetterSpacingTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LetterSpacingTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LetterSpacingTest.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_LetterSpacingTest extends
+ StyleSheet_ConvertAttr_SpacingTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cssKey = CSS.Attribute.LETTER_SPACING;
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LineHeightTest.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_LineHeightTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LineHeightTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_LineHeightTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,78 @@
+/*
+ * 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.AttributeSet;
+import javax.swing.text.StyleConstants;
+
+public class StyleSheet_ConvertAttr_LineHeightTest extends
+ StyleSheet_ConvertAttr_LengthTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cssKey = CSS.Attribute.LINE_HEIGHT;
+ negativeValuesInvalid = true;
+ }
+
+ public void testNormal() {
+ ss.addCSSAttribute(simple, cssKey, "normal");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("normal", cssValue.toString());
+ }
+
+ public void testMedium() {
+ ss.addCSSAttribute(simple, cssKey, "medium");
+ cssValue = simple.getAttribute(cssKey);
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ assertEquals("medium", cssValue.toString());
+ return;
+ }
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ }
+
+ public void testLength11_1() {
+ ss.addCSSAttribute(simple, cssKey, "11.1"); // Valid for 'line-height'
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals(1, simple.getAttributeCount());
+ assertEquals("11.1", cssValue.toString());
+ }
+
+ public void testLineSpacing() {
+ StyleSheet ss = new StyleSheet();
+ AttributeSet attr = ss.addAttribute(ss.getEmptySet(),
+ StyleConstants.LineSpacing,
+ new Float(1.1));
+ assertEquals(1, attr.getAttributeCount());
+ assertNull(attr.getAttribute(CSS.Attribute.LINE_HEIGHT));
+ }
+
+ public void testLengthMinus11_1pt() {
+ negativeValuesInvalid = BasicSwingTestCase.isHarmony();
+ super.testLengthMinus11_1pt();
+ }
+
+ public void testLengthMinus11_1Percent() {
+ negativeValuesInvalid = BasicSwingTestCase.isHarmony();
+ super.testLengthMinus11_1Percent();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleImageTest.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_ListStyleImageTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleImageTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleImageTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,78 @@
+/*
+ * 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_ListStyleImageTest extends TestCase {
+ private StyleSheet ss;
+ private MutableAttributeSet simple;
+ private Attribute cssKey;
+ private Object cssValue;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cssKey = Attribute.LIST_STYLE_IMAGE;
+ ss = new StyleSheet();
+ simple = new SimpleAttributeSet();
+ }
+
+ public void testListStyleImageNone() throws Exception {
+ ss.addCSSAttribute(simple, cssKey, "none");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyleImageURLNoQuotes() throws Exception {
+ ss.addCSSAttribute(simple, cssKey, "url(bullet.gif)");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("url(bullet.gif)", cssValue.toString());
+ }
+
+ public void testListStyleImageURLQuotes() throws Exception {
+ ss.addCSSAttribute(simple, cssKey,
+ "url(\"bullet.gif\")");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("url(\"bullet.gif\")", cssValue.toString());
+ }
+
+ public void testListStyleImageURLApostrophes() throws Exception {
+ ss.addCSSAttribute(simple, cssKey, "url('bullet.gif')");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("url('bullet.gif')", cssValue.toString());
+ }
+
+ public void testListStyleImageNoURL() throws Exception {
+ ss.addCSSAttribute(simple, cssKey, "bullet.gif");
+ cssValue = simple.getAttribute(cssKey);
+ if (BasicSwingTestCase.isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals("bullet.gif", cssValue.toString());
+ }
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStylePositionTest.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_ListStylePositionTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStylePositionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStylePositionTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,63 @@
+/*
+ * 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_ListStylePositionTest 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 testListStylePositionInside() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_POSITION, "inside");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("inside", cssValue.toString());
+ }
+
+ public void testListStylePositionOutside() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_POSITION, "outside");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ }
+
+ public void testListStylePositionCompact() throws Exception {
+ // Invalid value
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_POSITION, "compact");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ if (BasicSwingTestCase.isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals("compact", cssValue.toString());
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleTest.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_ListStyleTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,400 @@
+/*
+ * 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_ListStyleTest 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 testListStyle01() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "none");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("none", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("none", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle02() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "disc");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("disc", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("disc", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle03() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "decimal");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("decimal", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("decimal", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle04() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "outside");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("outside", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("disc", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle05() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "inside");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("inside", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("disc", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("inside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle06() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "url(bullet.gif)");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("url(bullet.gif)", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("disc", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("url(bullet.gif)", cssValue.toString());
+ }
+
+ public void testListStyle07() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "square inside");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("square inside", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("square", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("inside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle08() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "inside square");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("inside square", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("square", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("inside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle09() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "square url(buller.gif)");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("square url(buller.gif)", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("square", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("url(buller.gif)", cssValue.toString());
+ }
+
+ public void testListStyle10() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "url(buller.gif) inside square");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("url(buller.gif) inside square", cssValue.toString());
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("square", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("inside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("url(buller.gif)", cssValue.toString());
+ }
+
+ public void testListStyle11() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "disc square");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("disc square", cssValue.toString());
+ return;
+ }
+
+ assertEquals(0, simple.getAttributeCount());
+
+// cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+// assertEquals("square", cssValue.toString());
+// cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+// assertEquals("inside", cssValue.toString());
+// cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+// assertEquals("url(buller.gif)", cssValue.toString());
+ }
+
+ public void testListStyle12() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "inside outside");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("inside outside", cssValue.toString());
+ return;
+ }
+
+ assertEquals(0, simple.getAttributeCount());
+ }
+
+ public void testListStyle13() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "url(bullet.gif) url('square.gif')");
+ if (!BasicSwingTestCase.isHarmony()) {
+ assertEquals(1, simple.getAttributeCount());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE);
+ assertEquals("url(bullet.gif) url('square.gif')",
+ cssValue.toString());
+ return;
+ }
+
+ assertEquals(0, simple.getAttributeCount());
+ }
+
+ public void testListStyle14() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "none none");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("none", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle15() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "none disc");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("disc", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle16() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE, "disc none");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("disc", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyle17() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "none url(bullet.gif)");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("none", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("url(bullet.gif)", cssValue.toString());
+ }
+
+ public void testListStyle18() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "url(bullet.gif) none");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(3, simple.getAttributeCount());
+
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("none", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_POSITION);
+ assertEquals("outside", cssValue.toString());
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_IMAGE);
+ assertEquals("url(bullet.gif)", cssValue.toString());
+ }
+
+ public void testListStyle19() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "url(bullet.gif) none none");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(0, simple.getAttributeCount());
+ }
+
+ public void testListStyle20() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "url(bullet.gif) none disc");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(0, simple.getAttributeCount());
+ }
+
+ public void testListStyle21() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "url(bullet.gif) disc none");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(0, simple.getAttributeCount());
+ }
+
+ public void testListStyle22() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE,
+ "url(bullet.gif) disc inside none");
+ if (!BasicSwingTestCase.isHarmony()) {
+ return;
+ }
+
+ assertEquals(0, simple.getAttributeCount());
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleTypeTest.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_ListStyleTypeTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleTypeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_ListStyleTypeTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,106 @@
+/*
+ * 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_ListStyleTypeTest 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 testListStyleTypeDisc() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "disc");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("disc", cssValue.toString());
+ }
+
+ public void testListStyleTypeCircle() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "circle");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("circle", cssValue.toString());
+ }
+
+ public void testListStyleTypeSquare() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "square");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("square", cssValue.toString());
+ }
+
+ public void testListStyleTypeDecimal() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "decimal");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("decimal", cssValue.toString());
+ }
+
+ public void testListStyleTypeLowerRoman() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "lower-roman");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("lower-roman", cssValue.toString());
+ }
+
+ public void testListStyleTypeUpperRoman() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "upper-roman");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("upper-roman", cssValue.toString());
+ }
+
+ public void testListStyleTypeLowerAlpha() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "lower-alpha");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("lower-alpha", cssValue.toString());
+ }
+
+ public void testListStyleTypeUpperAlpha() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "upper-alpha");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("upper-alpha", cssValue.toString());
+ }
+
+ public void testListStyleTypeNone() throws Exception {
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "none");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ assertEquals("none", cssValue.toString());
+ }
+
+ public void testListStyleTypeDisk() throws Exception {
+ // Invalid value
+ ss.addCSSAttribute(simple, Attribute.LIST_STYLE_TYPE, "disk");
+ cssValue = simple.getAttribute(Attribute.LIST_STYLE_TYPE);
+ if (BasicSwingTestCase.isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals(1, simple.getAttributeCount());
+ assertEquals("disc", cssValue.toString()); // default value
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginBottomTest.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_MarginBottomTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginBottomTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginBottomTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,32 @@
+/*
+ * 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.StyleConstants;
+
+public class StyleSheet_ConvertAttr_MarginBottomTest
+ extends StyleSheet_ConvertAttr_MarginTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scKey = StyleConstants.SpaceBelow;
+ cssKey = CSS.Attribute.MARGIN_BOTTOM;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginLeftTest.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_MarginLeftTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginLeftTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginLeftTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,32 @@
+/*
+ * 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.StyleConstants;
+
+public class StyleSheet_ConvertAttr_MarginLeftTest
+ extends StyleSheet_ConvertAttr_MarginTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scKey = StyleConstants.LeftIndent;
+ cssKey = CSS.Attribute.MARGIN_LEFT;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginRightTest.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_MarginRightTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginRightTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginRightTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,32 @@
+/*
+ * 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.StyleConstants;
+
+public class StyleSheet_ConvertAttr_MarginRightTest
+ extends StyleSheet_ConvertAttr_MarginTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scKey = StyleConstants.RightIndent;
+ cssKey = CSS.Attribute.MARGIN_RIGHT;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTest.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_MarginTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,35 @@
+/*
+ * 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_MarginTest
+ extends StyleSheet_ConvertAttr_SpaceTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ shorthandKey = CSS.Attribute.MARGIN;
+ topKey = CSS.Attribute.MARGIN_TOP;
+ rightKey = CSS.Attribute.MARGIN_RIGHT;
+ bottomKey = CSS.Attribute.MARGIN_BOTTOM;
+ leftKey = CSS.Attribute.MARGIN_LEFT;
+
+ defaultValue = "0";
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTestCase.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_MarginTestCase.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTestCase.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,212 @@
+/*
+ * 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.html.CSS.Attribute;
+
+public abstract class StyleSheet_ConvertAttr_MarginTestCase
+ extends BasicSwingTestCase {
+
+ protected StyleSheet ss;
+
+ protected AttributeSet empty;
+ protected AttributeSet attr;
+ protected MutableAttributeSet simple;
+
+ protected Attribute cssKey;
+ protected Object cssValue;
+ protected Object scKey;
+ protected Object scValue;
+
+ protected String defUnits;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ss = new StyleSheet();
+ empty = ss.getEmptySet();
+ simple = new SimpleAttributeSet();
+ defUnits = isHarmony() ? "pt" : "";
+ }
+
+ // Specifies size in points.
+ public void testLength() {
+ attr = ss.addAttribute(empty, scKey, new Float(11.1));
+
+ Enumeration names = attr.getAttributeNames();
+ Object name = names.nextElement();
+ assertSame(cssKey, name);
+ assertFalse(names.hasMoreElements());
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertSame(Float.class, scValue.getClass());
+ assertNotSame(Float.class, cssValue.getClass());
+ assertNotSame(String.class, cssValue.getClass());
+ assertEquals(11.1f, ((Float)scValue).floatValue());
+ assertEquals("11.1" + defUnits, cssValue.toString());
+ }
+
+ public void testLengthString() {
+ if (!isHarmony()) {
+ testExceptionalCase(new ClassCastCase() {
+ public void exceptionalAction() throws Exception {
+ ss.addAttribute(empty, scKey, "11.1pt");
+ }
+ });
+ return;
+ }
+ attr = ss.addAttribute(empty, scKey, "11.1pt");
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals(11.1f, ((Float)scValue).floatValue());
+ assertEquals("11.1pt", cssValue.toString());
+ }
+
+ public void testLengthInteger() {
+ testExceptionalCase(new ExceptionalCase() {
+ public void exceptionalAction() throws Exception {
+ ss.addAttribute(empty, scKey, new Integer(11));
+ }
+
+ public Class expectedExceptionClass() {
+ return isHarmony() ? NullPointerException.class
+ : ClassCastException.class;
+ }
+ });
+ }
+
+ public void testLength11_1() {
+ ss.addCSSAttribute(simple, cssKey, "11.1");
+ if (isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ return;
+ }
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("11.1", cssValue.toString());
+ assertEquals(11.1f, ((Float)scValue).floatValue());
+ }
+
+ public void testLength0() {
+ ss.addCSSAttribute(simple, cssKey, "0");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("0", cssValue.toString());
+ assertEquals(0f, ((Float)scValue).floatValue());
+ }
+
+ public void testLength0px() {
+ ss.addCSSAttribute(simple, cssKey, "0px");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("0px", cssValue.toString());
+ assertEquals(0f, ((Float)scValue).floatValue());
+ }
+
+ public void testLength11_1pt() {
+ ss.addCSSAttribute(simple, cssKey, "11.1pt");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertSame(Float.class, scValue.getClass());
+ assertNotSame(Float.class, cssValue.getClass());
+ assertNotSame(String.class, cssValue.getClass());
+ assertEquals("11.1pt", cssValue.toString());
+ assertEquals(11.1f, ((Float)scValue).floatValue());
+ }
+
+ public void testLength11_1px() {
+ ss.addCSSAttribute(simple, cssKey, "11.1px");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("11.1px", cssValue.toString());
+ assertEquals(14.43f, ((Float)scValue).floatValue());
+ }
+
+ public void testLength11_1mm() {
+ ss.addCSSAttribute(simple, cssKey, "11.1mm");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("11.1mm", cssValue.toString());
+ assertEquals(31.464506f, ((Float)scValue).floatValue(), 0.00007f);
+ }
+
+ public void testLength11_1cm() {
+ ss.addCSSAttribute(simple, cssKey, "11.1cm");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("11.1cm", cssValue.toString());
+ assertEquals(314.64506f, ((Float)scValue).floatValue(), 0.0007f);
+ }
+
+ public void testLength11_1pc() {
+ ss.addCSSAttribute(simple, cssKey, "11.1pc");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("11.1pc", cssValue.toString());
+ assertEquals(133.20001f, ((Float)scValue).floatValue());
+ }
+
+ public void testLength11_1in() {
+ ss.addCSSAttribute(simple, cssKey, "11.1in");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("11.1in", cssValue.toString());
+ assertEquals(799.2f, ((Float)scValue).floatValue());
+ }
+
+ public void testLengthMinus11_1pt() {
+ ss.addCSSAttribute(simple, cssKey, "-11.1pt");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(cssKey);
+ scValue = attr.getAttribute(scKey);
+ assertEquals("-11.1pt", cssValue.toString());
+ assertEquals(isHarmony() ? -11.1f : 0, ((Float)scValue).floatValue());
+ }
+
+ private static void assertEquals(final float expected, final float actual) {
+ assertEquals(expected, actual, 0f);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTopTest.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_MarginTopTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTopTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_MarginTopTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,32 @@
+/*
+ * 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.StyleConstants;
+
+public class StyleSheet_ConvertAttr_MarginTopTest
+ extends StyleSheet_ConvertAttr_MarginTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ scKey = StyleConstants.SpaceAbove;
+ cssKey = CSS.Attribute.MARGIN_TOP;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_PaddingTest.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_PaddingTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_PaddingTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_PaddingTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,35 @@
+/*
+ * 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_PaddingTest
+ extends StyleSheet_ConvertAttr_SpaceTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ shorthandKey = CSS.Attribute.PADDING;
+ topKey = CSS.Attribute.PADDING_TOP;
+ rightKey = CSS.Attribute.PADDING_RIGHT;
+ bottomKey = CSS.Attribute.PADDING_BOTTOM;
+ leftKey = CSS.Attribute.PADDING_LEFT;
+
+ defaultValue = "0";
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_SpaceTestCase.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_SpaceTestCase.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_SpaceTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_SpaceTestCase.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,189 @@
+/*
+ * 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 abstract class StyleSheet_ConvertAttr_SpaceTestCase extends TestCase {
+ protected Attribute shorthandKey;
+ protected Attribute topKey;
+ protected Attribute rightKey;
+ protected Attribute bottomKey;
+ protected Attribute leftKey;
+
+ protected StyleSheet ss;
+ protected MutableAttributeSet simple;
+
+ protected Object top;
+ protected Object right;
+ protected Object bottom;
+ protected Object left;
+
+ protected String defaultValue;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ss = new StyleSheet();
+ simple = new SimpleAttributeSet();
+ }
+
+ public void testSpace01() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7pt");
+ assertProperties();
+ assertEquals("7pt", top.toString());
+ assertEquals("7pt", right.toString());
+ assertEquals("7pt", bottom.toString());
+ assertEquals("7pt", left.toString());
+ }
+
+ public void testSpace02() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7pt 14mm");
+ assertProperties();
+ assertEquals("7pt", top.toString());
+ assertEquals("14mm", right.toString());
+ assertEquals("7pt", bottom.toString());
+ assertEquals("14mm", left.toString());
+ }
+
+ public void testSpace03() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7pt 14mm 21cm");
+ assertProperties();
+ assertEquals("7pt", top.toString());
+ assertEquals("14mm", right.toString());
+ assertEquals("21cm", bottom.toString());
+ assertEquals("14mm", left.toString());
+ }
+
+ public void testSpace04() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7pt 14mm 21cm 28in");
+ assertProperties();
+ assertEquals("7pt", top.toString());
+ assertEquals("14mm", right.toString());
+ assertEquals("21cm", bottom.toString());
+ assertEquals("28in", left.toString());
+ }
+
+ public void testSpace05() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey,
+ "7pt 14mm 21cm 28in 144px");
+ assertProperties();
+ assertEquals("7pt", top.toString());
+ assertEquals("14mm", right.toString());
+ assertEquals("21cm", bottom.toString());
+ assertEquals("28in", left.toString());
+ }
+
+ public void testSpace03x() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7pt 14mm x 28in");
+ if (BasicSwingTestCase.isHarmony()) {
+ assertProperties(0);
+ assertAllNull();
+ return;
+ }
+ assertProperties(4);
+ assertEquals("7pt", top.toString());
+ assertEquals("14mm", right.toString());
+ assertEquals(defaultValue, bottom.toString());
+ assertEquals("28in", left.toString());
+ }
+
+ public void testSpace01x() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "em 14mm 14pt ex");
+ if (BasicSwingTestCase.isHarmony()) {
+ assertProperties(0);
+ return;
+ }
+ assertProperties(4);
+ assertEquals(defaultValue, top.toString());
+ assertEquals("14mm", right.toString());
+ assertEquals("14pt", bottom.toString());
+ assertEquals(defaultValue, left.toString());
+ }
+
+ public void testSpace01NoUnits() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7");
+ if (BasicSwingTestCase.isHarmony()) {
+ assertProperties(0);
+ return;
+ }
+ assertProperties(4);
+ assertEquals("7", top.toString());
+ assertEquals("7", right.toString());
+ assertEquals("7", bottom.toString());
+ assertEquals("7", left.toString());
+ }
+
+ public void testSpace02CommaSpace() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7pt, 14mm");
+ if (BasicSwingTestCase.isHarmony()) {
+ assertProperties(0);
+ return;
+ }
+ assertProperties(4);
+ assertEquals(defaultValue, top.toString());
+ assertEquals("14mm", right.toString());
+ assertEquals(defaultValue, bottom.toString());
+ assertEquals("14mm", left.toString());
+ }
+
+ public void testSpace02CommaNoSpace() throws Exception {
+ ss.addCSSAttribute(simple, shorthandKey, "7pt,14mm");
+ if (BasicSwingTestCase.isHarmony()) {
+ assertProperties(0);
+ return;
+ }
+ assertProperties(4);
+ assertEquals(defaultValue, top.toString());
+ assertEquals(defaultValue, right.toString());
+ assertEquals(defaultValue, bottom.toString());
+ assertEquals(defaultValue, left.toString());
+ }
+
+ private void assertProperties() {
+ assertProperties(4);
+ }
+
+ private void assertProperties(final int count) {
+ assertEquals(count, simple.getAttributeCount());
+ getProperties();
+ if (count == 0) {
+ assertAllNull();
+ }
+ }
+
+ private void getProperties() {
+ top = simple.getAttribute(topKey);
+ right = simple.getAttribute(rightKey);
+ bottom = simple.getAttribute(bottomKey);
+ left = simple.getAttribute(leftKey);
+ }
+
+ private void assertAllNull() {
+ assertNull(top);
+ assertNull(right);
+ assertNull(bottom);
+ assertNull(left);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_SpacingTestCase.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_SpacingTestCase.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_SpacingTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_SpacingTestCase.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+public abstract class StyleSheet_ConvertAttr_SpacingTestCase
+ extends StyleSheet_ConvertAttr_LengthTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ percentageValuesInvalid = true;
+ }
+
+ public void testSpacingNormal() throws Exception {
+ ss.addCSSAttribute(simple, cssKey, "normal");
+ cssValue = simple.getAttribute(cssKey);
+ assertEquals("normal", cssValue.toString());
+ }
+
+ public void testSpacingInvalid() throws Exception {
+ ss.addCSSAttribute(simple, cssKey, "condensed");
+ cssValue = simple.getAttribute(cssKey);
+ if (BasicSwingTestCase.isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ assertNull(cssValue);
+ } else {
+ assertEquals("condensed", cssValue.toString());
+ }
+ }
+
+ public void testLength11_1Percent() {
+ percentageValuesInvalid = BasicSwingTestCase.isHarmony();
+ super.testLength11_1Percent();
+ }
+
+ public void testLengthMinus11_1Percent() {
+ percentageValuesInvalid = BasicSwingTestCase.isHarmony();
+ super.testLengthMinus11_1Percent();
+ }
+
+ public void testLengthPlus11_1Percent() {
+ percentageValuesInvalid = BasicSwingTestCase.isHarmony();
+ super.testLengthPlus11_1Percent();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_TextAlignTest.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_TextAlignTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_TextAlignTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/StyleSheet_ConvertAttr_TextAlignTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,197 @@
+/*
+ * 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_TextAlignTest 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 testTextAlign() {
+ attr = ss.addAttribute(empty, StyleConstants.Alignment,
+ new Integer(StyleConstants.ALIGN_RIGHT));
+
+ Enumeration names = attr.getAttributeNames();
+ Object name = names.nextElement();
+ assertSame(Attribute.TEXT_ALIGN, name);
+ assertFalse(names.hasMoreElements());
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertSame(Integer.class, scValue.getClass());
+ assertNotSame(Integer.class, cssValue.getClass());
+ assertNotSame(String.class, cssValue.getClass());
+ }
+
+ public void testTextAlignInvalid() {
+ attr = ss.addAttribute(empty, StyleConstants.Alignment,
+ new Integer(100));
+
+ Enumeration names = attr.getAttributeNames();
+ Object name = names.nextElement();
+ assertSame(Attribute.TEXT_ALIGN, name);
+ assertFalse(names.hasMoreElements());
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertSame(Integer.class, scValue.getClass());
+ assertNotSame(Integer.class, cssValue.getClass());
+ assertNotSame(String.class, cssValue.getClass());
+ assertEquals("left", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_LEFT, ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignLeft() {
+ attr = ss.addAttribute(empty, StyleConstants.Alignment,
+ new Integer(StyleConstants.ALIGN_LEFT));
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("left", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_LEFT, ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignCenter() {
+ attr = ss.addAttribute(empty, StyleConstants.Alignment,
+ new Integer(StyleConstants.ALIGN_CENTER));
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("center", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_CENTER,
+ ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignRight() {
+ attr = ss.addAttribute(empty, StyleConstants.Alignment,
+ new Integer(StyleConstants.ALIGN_RIGHT));
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("right", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_RIGHT, ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignJustify() {
+ attr = ss.addAttribute(empty, StyleConstants.Alignment,
+ new Integer(StyleConstants.ALIGN_JUSTIFIED));
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("justify", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_JUSTIFIED,
+ ((Integer)scValue).intValue());
+ }
+
+
+
+ public void testTextAlignStringLeft() {
+ ss.addCSSAttribute(simple, Attribute.TEXT_ALIGN, "left");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("left", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_LEFT, ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignStringCenter() {
+ ss.addCSSAttribute(simple, Attribute.TEXT_ALIGN, "center");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("center", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_CENTER,
+ ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignStringRight() {
+ ss.addCSSAttribute(simple, Attribute.TEXT_ALIGN, "right");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("right", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_RIGHT, ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignStringJustify() {
+ ss.addCSSAttribute(simple, Attribute.TEXT_ALIGN, "justify");
+ attr = ss.createSmallAttributeSet(simple);
+
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("justify", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_JUSTIFIED,
+ ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignStringJustified() {
+ assertEquals(0, simple.getAttributeCount());
+ ss.addCSSAttribute(simple, Attribute.TEXT_ALIGN, "justified");
+ if (isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ return;
+ }
+
+ attr = ss.createSmallAttributeSet(simple);
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("justified", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_LEFT,
+ ((Integer)scValue).intValue());
+ }
+
+ public void testTextAlignStringInvalid() {
+ assertEquals(0, simple.getAttributeCount());
+ ss.addCSSAttribute(simple, Attribute.TEXT_ALIGN, "super-align");
+ if (isHarmony()) {
+ assertEquals(0, simple.getAttributeCount());
+ return;
+ }
+
+ attr = ss.createSmallAttributeSet(simple);
+ cssValue = attr.getAttribute(Attribute.TEXT_ALIGN);
+ scValue = attr.getAttribute(StyleConstants.Alignment);
+ assertEquals("super-align", cssValue.toString());
+ assertEquals(StyleConstants.ALIGN_LEFT,
+ ((Integer)scValue).intValue());
+ }
+}