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_VerticalAlignTest 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 testVerticalAlignBaseline() {
041: ss
042: .addCSSAttribute(simple, Attribute.VERTICAL_ALIGN,
043: "baseline");
044: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
045: assertEquals("baseline", cssValue.toString());
046: }
047:
048: public void testVerticalAlignMiddle() {
049: ss.addCSSAttribute(simple, Attribute.VERTICAL_ALIGN, "middle");
050: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
051: assertEquals("middle", cssValue.toString());
052: }
053:
054: public void testVerticalAlignSub() {
055: ss.addCSSAttribute(simple, Attribute.VERTICAL_ALIGN, "sub");
056: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
057: assertEquals("sub", cssValue.toString());
058: }
059:
060: public void testVerticalAlignSuper() {
061: ss.addCSSAttribute(simple, Attribute.VERTICAL_ALIGN, "super");
062: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
063: assertEquals("super", cssValue.toString());
064: }
065:
066: public void testVerticalAlignTextTop() {
067: ss
068: .addCSSAttribute(simple, Attribute.VERTICAL_ALIGN,
069: "text-top");
070: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
071: assertEquals("text-top", cssValue.toString());
072: }
073:
074: public void testVerticalAlignTextBottom() {
075: ss.addCSSAttribute(simple, Attribute.VERTICAL_ALIGN,
076: "text-bottom");
077: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
078: assertEquals("text-bottom", cssValue.toString());
079: }
080:
081: public void testVerticalAlignTop() {
082: ss.addCSSAttribute(simple, Attribute.VERTICAL_ALIGN, "top");
083: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
084: assertEquals("top", cssValue.toString());
085: }
086:
087: public void testVerticalAlignBottom() {
088: ss.addCSSAttribute(simple, Attribute.VERTICAL_ALIGN, "bottom");
089: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
090: assertEquals("bottom", cssValue.toString());
091: }
092:
093: public void testVerticalAlignInvalid() {
094: ss.addCSSAttribute(simple, Attribute.VERTICAL_ALIGN, "botom");
095: cssValue = simple.getAttribute(Attribute.VERTICAL_ALIGN);
096: if (BasicSwingTestCase.isHarmony()) {
097: assertEquals(0, simple.getAttributeCount());
098: assertNull(cssValue);
099: } else {
100: assertEquals(1, simple.getAttributeCount());
101: assertEquals("botom", cssValue.toString());
102: }
103: }
104: }
|