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 Sergey Burlak
019: * @version $Revision$
020: */package javax.swing.plaf.metal;
021:
022: import java.awt.Font;
023: import java.util.Properties;
024: import javax.swing.SwingTestCase;
025: import javax.swing.plaf.FontUIResource;
026:
027: public class DefaultMetalThemeTest extends SwingTestCase {
028: private DefaultMetalTheme theme;
029:
030: private Properties props;
031:
032: @Override
033: public void setUp() {
034: theme = new DefaultMetalTheme();
035: props = new Properties();
036: props.putAll(System.getProperties());
037: }
038:
039: @Override
040: public void tearDown() {
041: theme = null;
042: System.getProperties().clear();
043: System.getProperties().putAll(props);
044: }
045:
046: public void testGetSystemTextFontFromProperty() {
047: String font = "aaa-bold-10";
048: System.setProperty("swing.plaf.metal.systemFont", font);
049: assertEquals(new FontUIResource(Font.decode(font)), theme
050: .getSystemTextFont());
051: }
052:
053: public void testGetControlTextFontFromProperty() {
054: String font = "test-plain-5";
055: System.setProperty("swing.plaf.metal.controlFont", font);
056: assertEquals(new FontUIResource(Font.decode(font)), theme
057: .getControlTextFont());
058: }
059:
060: public void testGetSmallTextFontFromProperty() {
061: String font = "aaa-bold-3";
062: System.setProperty("swing.plaf.metal.smallFont", font);
063: assertEquals(new FontUIResource(Font.decode(font)), theme
064: .getSubTextFont());
065: }
066:
067: public void testGetUserTextFontFromProperty() {
068: String font = "aaa-bold-1";
069: System.setProperty("swing.plaf.metal.userFont", font);
070: assertEquals(new FontUIResource(Font.decode(font)), theme
071: .getUserTextFont());
072: }
073:
074: public void testGetWindowTitleFont() {
075: assertEquals(new FontUIResource("Dialog", Font.BOLD, 12), theme
076: .getWindowTitleFont());
077: }
078:
079: public void testGetUserTextFont() {
080: assertEquals(new FontUIResource("Dialog", Font.PLAIN, 12),
081: theme.getUserTextFont());
082: }
083:
084: public void testGetSystemTextFont() {
085: assertEquals(new FontUIResource("Dialog", Font.PLAIN, 12),
086: theme.getSystemTextFont());
087: }
088:
089: public void testGetSubTextFont() {
090: assertEquals(new FontUIResource("Dialog", Font.PLAIN, 10),
091: theme.getSubTextFont());
092: }
093:
094: public void testGetMenuTextFont() {
095: assertEquals(new FontUIResource("Dialog", Font.BOLD, 12), theme
096: .getMenuTextFont());
097: }
098:
099: public void testGetControlTextFont() {
100: assertEquals(new FontUIResource("Dialog", Font.BOLD, 12), theme
101: .getControlTextFont());
102: }
103:
104: public void testGetSecondary3() {
105: assertNotNull(theme.getSecondary3());
106: }
107:
108: public void testGetSecondary2() {
109: assertNotNull(theme.getSecondary2());
110: }
111:
112: public void testGetSecondary1() {
113: assertNotNull(theme.getSecondary1());
114: }
115:
116: public void testGetPrimary3() {
117: assertNotNull(theme.getPrimary3());
118: }
119:
120: public void testGetPrimary2() {
121: assertNotNull(theme.getPrimary2());
122: }
123:
124: public void testGetPrimary1() {
125: assertNotNull(theme.getPrimary1());
126: }
127:
128: public void testGetName() {
129: assertNotNull(theme.getName());
130: }
131: }
|