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 Vadim L. Bogdanov
019: * @version $Revision$
020: */package javax.swing;
021:
022: import java.awt.Dimension;
023:
024: public class JToolBar_SeparatorTest extends SwingTestCase {
025: private JToolBar.Separator separator;
026:
027: @Override
028: protected void setUp() throws Exception {
029: super .setUp();
030: separator = new JToolBar.Separator(new Dimension(5, 10));
031: }
032:
033: @Override
034: protected void tearDown() throws Exception {
035: super .tearDown();
036: }
037:
038: public JToolBar_SeparatorTest(String name) {
039: super (name);
040: }
041:
042: public void testGetMaximumSize() {
043: assertEquals(separator.getSeparatorSize(), separator
044: .getMaximumSize());
045: separator.setOrientation(SwingConstants.VERTICAL);
046: assertEquals(separator.getSeparatorSize(), separator
047: .getMaximumSize());
048: }
049:
050: public void testGetMinimumSize() {
051: assertEquals(separator.getSeparatorSize(), separator
052: .getMinimumSize());
053: separator.setOrientation(SwingConstants.VERTICAL);
054: assertEquals(separator.getSeparatorSize(), separator
055: .getMinimumSize());
056: }
057:
058: public void testGetPreferredSize() {
059: assertEquals(separator.getSeparatorSize(), separator
060: .getPreferredSize());
061: separator.setOrientation(SwingConstants.VERTICAL);
062: assertEquals(separator.getSeparatorSize(), separator
063: .getPreferredSize());
064: }
065:
066: public void testGetUIClassID() {
067: assertEquals("ToolBarSeparatorUI", separator.getUIClassID());
068: }
069:
070: public void testSeparator() {
071: separator = new JToolBar.Separator();
072: assertNotNull(separator.getUI());
073: assertEquals(UIManager.get("ToolBar.separatorSize"), separator
074: .getSeparatorSize());
075: assertEquals(SwingConstants.HORIZONTAL, separator
076: .getOrientation());
077: }
078:
079: public void testSeparatorDimension() {
080: Dimension dimension = new Dimension(1, 2);
081: separator = new JToolBar.Separator(dimension);
082: assertNotNull(separator.getUI());
083: assertEquals(dimension, separator.getSeparatorSize());
084: assertEquals(SwingConstants.HORIZONTAL, separator
085: .getOrientation());
086: separator = new JToolBar.Separator(null);
087: assertNotNull(separator.getUI());
088: assertEquals(UIManager.get("ToolBar.separatorSize"), separator
089: .getSeparatorSize());
090: }
091:
092: public void testSetGetSeparatorSize() {
093: PropertyChangeController controller = new PropertyChangeController();
094: separator.addPropertyChangeListener(controller);
095: Dimension dimension = new Dimension(1, 2);
096: separator.setSeparatorSize(dimension);
097: assertFalse(controller.isChanged());
098: assertSame(dimension, separator.getSeparatorSize());
099: separator.setSeparatorSize(null);
100: assertSame(dimension, separator.getSeparatorSize());
101: }
102: }
|