001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexey A. Ivanov
019: * @version $Revision$
020: */package javax.swing.text.html;
021:
022: import javax.swing.BasicSwingTestCase;
023: import javax.swing.text.MutableAttributeSet;
024: import javax.swing.text.SimpleAttributeSet;
025: import javax.swing.text.html.CSS.Attribute;
026:
027: import junit.framework.TestCase;
028:
029: public class StyleSheet_ConvertAttr_BorderStyleTest extends TestCase {
030: private StyleSheet ss;
031: private MutableAttributeSet simple;
032: private Object cssValue;
033:
034: protected void setUp() throws Exception {
035: super .setUp();
036: ss = new StyleSheet();
037: simple = new SimpleAttributeSet();
038: }
039:
040: public void testBorderStyleNone() throws Exception {
041: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "none");
042: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
043: if (BasicSwingTestCase.isHarmony()) {
044: assertEquals("none", cssValue.toString());
045: } else {
046: assertEquals(0, simple.getAttributeCount());
047: assertNull(cssValue);
048: }
049: }
050:
051: public void testBorderStyleDotted() throws Exception {
052: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "dotted");
053: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
054: assertEquals("dotted", cssValue.toString());
055: }
056:
057: public void testBorderStyleDashed() throws Exception {
058: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "dashed");
059: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
060: assertEquals("dashed", cssValue.toString());
061: }
062:
063: public void testBorderStyleSolid() throws Exception {
064: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "solid");
065: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
066: assertEquals("solid", cssValue.toString());
067: }
068:
069: public void testBorderStyleDouble() throws Exception {
070: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "double");
071: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
072: assertEquals("double", cssValue.toString());
073: }
074:
075: public void testBorderStyleGroove() throws Exception {
076: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "groove");
077: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
078: assertEquals("groove", cssValue.toString());
079: }
080:
081: public void testBorderStyleRidge() throws Exception {
082: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "ridge");
083: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
084: assertEquals("ridge", cssValue.toString());
085: }
086:
087: public void testBorderStyleInset() throws Exception {
088: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "inset");
089: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
090: assertEquals("inset", cssValue.toString());
091: }
092:
093: public void testBorderStyleOutset() throws Exception {
094: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "outset");
095: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
096: assertEquals("outset", cssValue.toString());
097: }
098:
099: public void testBorderStyleSunken() throws Exception {
100: // Invalid value
101: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE, "sunken");
102: assertEquals(0, simple.getAttributeCount());
103: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
104: assertNull(cssValue);
105: }
106:
107: public void testBorderStyleInsetOutset() throws Exception {
108: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE,
109: "inset outset");
110: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
111: if (BasicSwingTestCase.isHarmony()) {
112: assertEquals(1, simple.getAttributeCount());
113: assertEquals("inset outset", cssValue.toString());
114: } else {
115: assertEquals(0, simple.getAttributeCount());
116: assertNull(cssValue);
117: }
118: }
119:
120: public void testBorderStyleOutsetInsetSolid() throws Exception {
121: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE,
122: "outset inset solid");
123: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
124: if (BasicSwingTestCase.isHarmony()) {
125: assertEquals(1, simple.getAttributeCount());
126: assertEquals("outset inset solid", cssValue.toString());
127: } else {
128: assertEquals(0, simple.getAttributeCount());
129: assertNull(cssValue);
130: }
131: }
132:
133: public void testBorderStyleInsetRidgeOutsetGroove()
134: throws Exception {
135: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE,
136: "inset ridge outset groove");
137: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
138: if (BasicSwingTestCase.isHarmony()) {
139: assertEquals(1, simple.getAttributeCount());
140: assertEquals("inset ridge outset groove", cssValue
141: .toString());
142: } else {
143: assertEquals(0, simple.getAttributeCount());
144: assertNull(cssValue);
145: }
146: }
147:
148: public void testBorderStyleInsetRidgeOutsetEtched()
149: throws Exception {
150: ss.addCSSAttribute(simple, Attribute.BORDER_STYLE,
151: "inset ridge outset etched");
152: cssValue = simple.getAttribute(Attribute.BORDER_STYLE);
153: assertEquals(0, simple.getAttributeCount());
154: assertNull(cssValue);
155: }
156: }
|