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 Alexander T. Simbirtsev
019: * @version $Revision$
020: */package javax.swing;
021:
022: import javax.accessibility.AccessibleRole;
023: import javax.swing.plaf.SeparatorUI;
024: import javax.swing.plaf.basic.BasicSeparatorUI;
025: import junit.framework.TestCase;
026:
027: public class JSeparatorTest extends TestCase {
028: protected JSeparator separator;
029:
030: @Override
031: protected void setUp() throws Exception {
032: super .setUp();
033: separator = new JSeparator();
034: }
035:
036: @Override
037: protected void tearDown() throws Exception {
038: separator = null;
039: super .tearDown();
040: }
041:
042: /*
043: * Test method for 'javax.swing.JSeparator.JSeparator()'
044: */
045: public void testJSeparator() {
046: assertEquals(SwingConstants.HORIZONTAL, separator
047: .getOrientation());
048: }
049:
050: /*
051: * Test method for 'javax.swing.JSeparator.JSeparator(int)'
052: */
053: public void testJSeparatorInt() {
054: separator = new JSeparator(SwingConstants.HORIZONTAL);
055: assertEquals(SwingConstants.HORIZONTAL, separator
056: .getOrientation());
057: separator = new JSeparator(SwingConstants.VERTICAL);
058: assertEquals(SwingConstants.VERTICAL, separator
059: .getOrientation());
060: try {
061: separator = new JSeparator(1000);
062: fail("no exception has been thrown");
063: } catch (IllegalArgumentException e) {
064: }
065: }
066:
067: /*
068: * Test method for 'javax.swing.JSeparator.getAccessibleContext()'
069: */
070: public void testGetAccessibleContext() {
071: boolean assertedValue = (separator.getAccessibleContext() != null && separator
072: .getAccessibleContext().getClass().getName().equals(
073: "javax.swing.JSeparator$AccessibleJSeparator"));
074: assertTrue("AccessibleContext created properly ", assertedValue);
075: assertEquals("AccessibleRole", AccessibleRole.SEPARATOR,
076: separator.getAccessibleContext().getAccessibleRole());
077: }
078:
079: /*
080: * Test method for 'javax.swing.JSeparator.getUIClassID()'
081: */
082: public void testGetUIClassID() {
083: assertEquals("SeparatorUI", separator.getUIClassID());
084: }
085:
086: /*
087: * Test method for 'javax.swing.JSeparator.getUI()'
088: */
089: public void testGetUI() {
090: assertNotNull("ui is returned ", separator.getUI());
091: }
092:
093: /*
094: * Test method for 'javax.swing.JSeparator.setUI(SeparatorUI)'
095: */
096: public void testSetUISeparatorUI() {
097: SeparatorUI ui1 = new BasicSeparatorUI();
098: SeparatorUI ui2 = new BasicSeparatorUI();
099: separator.setUI(ui1);
100: assertEquals(ui1, separator.ui);
101: assertEquals(ui1, separator.getUI());
102: separator.setUI(ui2);
103: assertEquals(ui2, separator.ui);
104: assertEquals(ui2, separator.getUI());
105: }
106:
107: /*
108: * Test method for 'javax.swing.JSeparator.setOrientation(int)'
109: */
110: public void testGetSetOrientation() {
111: separator.setOrientation(SwingConstants.HORIZONTAL);
112: assertEquals(SwingConstants.HORIZONTAL, separator
113: .getOrientation());
114: separator.setOrientation(SwingConstants.VERTICAL);
115: assertEquals(SwingConstants.VERTICAL, separator
116: .getOrientation());
117: try {
118: separator.setOrientation(1000);
119: fail("no exception has been thrown");
120: } catch (IllegalArgumentException e) {
121: }
122: }
123:
124: public void testIsFocusable() {
125: // Regression test for HARMONY-2631
126: assertFalse(new JSeparator().isFocusable());
127: }
128: }
|