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: * Created on 22.02.2005
021:
022: */package javax.swing.plaf.metal;
023:
024: import java.awt.Color;
025: import javax.swing.JButton;
026: import javax.swing.UIManager;
027: import javax.swing.plaf.ColorUIResource;
028: import javax.swing.plaf.basic.BasicButtonUITest;
029:
030: public class MetalButtonUITest extends BasicButtonUITest {
031: protected MetalButtonUI metalUI;
032:
033: @Override
034: protected void setUp() throws Exception {
035: super .setUp();
036: ui = new MetalButtonUI();
037: metalUI = (MetalButtonUI) ui;
038: }
039:
040: @Override
041: public void testCreateUI() {
042: assertTrue("created UI is not null", null != MetalButtonUI
043: .createUI(new JButton()));
044: assertTrue("created UI is of the proper class", MetalButtonUI
045: .createUI(null) instanceof MetalButtonUI);
046: assertTrue("created UI is of unique", MetalButtonUI
047: .createUI(null) == MetalButtonUI.createUI(null));
048: }
049:
050: public void testMetalButtonUI() {
051: assertNull(metalUI.disabledTextColor);
052: assertNull(metalUI.focusColor);
053: assertNull(metalUI.selectColor);
054: }
055:
056: public void testGetDisabledTextColor() {
057: assertTrue("DisabledTextColor is ColorUIResource", metalUI
058: .getDisabledTextColor() instanceof ColorUIResource);
059: assertTrue("DisabledTextColor is ColorUIResource",
060: metalUI.disabledTextColor instanceof ColorUIResource);
061: metalUI.disabledTextColor = Color.WHITE;
062: assertSame("DisabledTextColor", Color.WHITE,
063: metalUI.disabledTextColor);
064: assertTrue("DisabledTextColor is ColorUIResource", metalUI
065: .getDisabledTextColor() instanceof ColorUIResource);
066: assertNotSame("DisabledTextColor", Color.WHITE,
067: metalUI.disabledTextColor);
068: final ColorUIResource red = new ColorUIResource(Color.RED);
069: metalUI.disabledTextColor = red;
070: assertNotSame("DisabledTextColor", red, metalUI
071: .getDisabledTextColor());
072: metalUI.disabledTextColor = null;
073: assertNotNull("DisabledTextColor", metalUI
074: .getDisabledTextColor());
075: UIManager.put("Button.disabledText", red);
076: metalUI.disabledTextColor = null;
077: assertSame("DisabledTextColor", red, metalUI
078: .getDisabledTextColor());
079: }
080:
081: public void testGetFocusColor() {
082: assertTrue("FocusColor is ColorUIResource", metalUI
083: .getFocusColor() instanceof ColorUIResource);
084: assertTrue("FocusColor is ColorUIResource",
085: metalUI.focusColor instanceof ColorUIResource);
086: metalUI.focusColor = Color.WHITE;
087: assertEquals("FocusColor", Color.WHITE, metalUI.focusColor);
088: assertTrue("FocusColor is ColorUIResource", metalUI
089: .getFocusColor() instanceof ColorUIResource);
090: final ColorUIResource red = new ColorUIResource(Color.RED);
091: metalUI.focusColor = red;
092: assertNotSame(red, metalUI.getFocusColor());
093: metalUI.disabledTextColor = null;
094: assertNotNull(metalUI.getFocusColor());
095: }
096:
097: public void testGetSelectColor() {
098: assertTrue("SelectColor is ColorUIResource", metalUI
099: .getSelectColor() instanceof ColorUIResource);
100: assertTrue("SelectColor is ColorUIResource",
101: metalUI.selectColor instanceof ColorUIResource);
102: metalUI.selectColor = Color.WHITE;
103: assertEquals("SelectColor", Color.WHITE, metalUI.selectColor);
104: assertTrue("FocusColor is ColorUIResource", metalUI
105: .getSelectColor() instanceof ColorUIResource);
106: final ColorUIResource red = new ColorUIResource(Color.RED);
107: metalUI.selectColor = red;
108: assertNotSame(red, metalUI.getSelectColor());
109: metalUI.selectColor = null;
110: assertNotNull(metalUI.getSelectColor());
111: }
112: }
|