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 javax.swing.SwingTestCase;
023: import javax.swing.plaf.ColorUIResource;
024: import javax.swing.plaf.FontUIResource;
025:
026: public class MetalLookAndFeelTest extends SwingTestCase {
027: private DefaultMetalTheme defaultMetalTheme;
028:
029: @Override
030: public void setUp() {
031: defaultMetalTheme = new DefaultMetalTheme();
032: }
033:
034: @Override
035: public void tearDown() {
036: defaultMetalTheme = null;
037: }
038:
039: public void testSize() throws Exception {
040: if (isHarmony()) {
041: assertEquals(559, new MetalLookAndFeel().getDefaults()
042: .size());
043: }
044: }
045:
046: public void testGetAcceleratorForeground() {
047: checkColor(MetalLookAndFeel.getAcceleratorForeground(),
048: defaultMetalTheme.getAcceleratorForeground());
049: }
050:
051: public void testGetAcceleratorSelectedForeground() {
052: checkColor(MetalLookAndFeel.getAcceleratorSelectedForeground(),
053: defaultMetalTheme.getAcceleratorSelectedForeground());
054: }
055:
056: public void testGetBlack() {
057: checkColor(MetalLookAndFeel.getBlack(), defaultMetalTheme
058: .getBlack());
059: }
060:
061: public void testGetControl() {
062: checkColor(MetalLookAndFeel.getControl(), defaultMetalTheme
063: .getControl());
064: }
065:
066: public void testGetControlDarkShadow() {
067: checkColor(MetalLookAndFeel.getControlDarkShadow(),
068: defaultMetalTheme.getControlDarkShadow());
069: }
070:
071: public void testGetControlDisabled() {
072: checkColor(MetalLookAndFeel.getControlDisabled(),
073: defaultMetalTheme.getControlDisabled());
074: }
075:
076: public void testGetControlHighlight() {
077: checkColor(MetalLookAndFeel.getControlHighlight(),
078: defaultMetalTheme.getControlHighlight());
079: }
080:
081: public void testGetControlInfo() {
082: checkColor(MetalLookAndFeel.getControlInfo(), defaultMetalTheme
083: .getControlInfo());
084: }
085:
086: public void testGetControlShadow() {
087: checkColor(MetalLookAndFeel.getControlShadow(),
088: defaultMetalTheme.getControlShadow());
089: }
090:
091: public void testGetControlTextColor() {
092: checkColor(MetalLookAndFeel.getControlTextColor(),
093: defaultMetalTheme.getControlTextColor());
094: }
095:
096: public void testGetControlTextFont() {
097: FontUIResource font = MetalLookAndFeel.getControlTextFont();
098: assertNotNull(font);
099: assertEquals(defaultMetalTheme.getControlTextFont(), font);
100: }
101:
102: public void testGetDeskTopColor() {
103: checkColor(MetalLookAndFeel.getDesktopColor(),
104: defaultMetalTheme.getDesktopColor());
105: }
106:
107: public void testGetFocusColor() {
108: checkColor(MetalLookAndFeel.getFocusColor(), defaultMetalTheme
109: .getFocusColor());
110: }
111:
112: public void testGetHighlightedTextColor() {
113: checkColor(MetalLookAndFeel.getHighlightedTextColor(),
114: defaultMetalTheme.getHighlightedTextColor());
115: }
116:
117: public void testGetInactiveControlTextColor() {
118: checkColor(MetalLookAndFeel.getInactiveControlTextColor(),
119: defaultMetalTheme.getInactiveControlTextColor());
120: }
121:
122: public void testGetInactiveSystemTextColor() {
123: checkColor(MetalLookAndFeel.getInactiveSystemTextColor(),
124: defaultMetalTheme.getInactiveSystemTextColor());
125: }
126:
127: public void testGetMenuBackground() {
128: checkColor(MetalLookAndFeel.getMenuBackground(),
129: defaultMetalTheme.getMenuBackground());
130: }
131:
132: public void testGetMenuDisabledBackground() {
133: checkColor(MetalLookAndFeel.getMenuDisabledForeground(),
134: defaultMetalTheme.getMenuDisabledForeground());
135: }
136:
137: public void testGetMenuForeground() {
138: checkColor(MetalLookAndFeel.getMenuForeground(),
139: defaultMetalTheme.getMenuForeground());
140: }
141:
142: public void testGetMenuSelectedBackground() {
143: checkColor(MetalLookAndFeel.getMenuSelectedBackground(),
144: defaultMetalTheme.getMenuSelectedBackground());
145: }
146:
147: public void testGetMenuSelectedForeground() {
148: checkColor(MetalLookAndFeel.getMenuSelectedForeground(),
149: defaultMetalTheme.getMenuSelectedForeground());
150: }
151:
152: public void testGetMenuTextFont() {
153: FontUIResource font = MetalLookAndFeel.getMenuTextFont();
154: assertNotNull(font);
155: assertEquals(defaultMetalTheme.getMenuTextFont(), font);
156: }
157:
158: public void testGetName() {
159: assertNotNull(new MetalLookAndFeel().getName());
160: }
161:
162: public void testGetId() {
163: assertNotNull(new MetalLookAndFeel().getID());
164: }
165:
166: public void testGetPrimaryControl() {
167: checkColor(MetalLookAndFeel.getPrimaryControl(),
168: defaultMetalTheme.getPrimaryControl());
169: }
170:
171: public void testGetPrimaryControlDarkShadow() {
172: checkColor(MetalLookAndFeel.getPrimaryControlDarkShadow(),
173: defaultMetalTheme.getPrimaryControlDarkShadow());
174: }
175:
176: public void testGetPrimaryControlHighlight() {
177: checkColor(MetalLookAndFeel.getPrimaryControlHighlight(),
178: defaultMetalTheme.getPrimaryControlHighlight());
179: }
180:
181: public void testGetPrimaryControlInfo() {
182: checkColor(MetalLookAndFeel.getPrimaryControlInfo(),
183: defaultMetalTheme.getPrimaryControlInfo());
184: }
185:
186: public void testGetPrimaryControlShadow() {
187: checkColor(MetalLookAndFeel.getPrimaryControlShadow(),
188: defaultMetalTheme.getPrimaryControlShadow());
189: }
190:
191: public void testGetSeparatorBackground() {
192: checkColor(MetalLookAndFeel.getSeparatorBackground(),
193: defaultMetalTheme.getSeparatorBackground());
194: }
195:
196: public void testGetSeparatorForeground() {
197: checkColor(MetalLookAndFeel.getSeparatorForeground(),
198: defaultMetalTheme.getSeparatorForeground());
199: }
200:
201: public void testSubTextFont() {
202: FontUIResource font = MetalLookAndFeel.getSubTextFont();
203: assertNotNull(font);
204: assertEquals(defaultMetalTheme.getSubTextFont(), font);
205: }
206:
207: public void testGetSupportWindowDecorations() {
208: assertTrue(new MetalLookAndFeel()
209: .getSupportsWindowDecorations());
210: }
211:
212: public void testGetSystemTestColor() {
213: checkColor(MetalLookAndFeel.getSystemTextColor(),
214: defaultMetalTheme.getSystemTextColor());
215: }
216:
217: public void testSystemTextFont() {
218: FontUIResource font = MetalLookAndFeel.getSystemTextFont();
219: assertNotNull(font);
220: assertEquals(defaultMetalTheme.getSystemTextFont(), font);
221: }
222:
223: public void testGetTextHighlightColor() {
224: checkColor(MetalLookAndFeel.getTextHighlightColor(),
225: defaultMetalTheme.getTextHighlightColor());
226: }
227:
228: public void testUserTextFont() {
229: FontUIResource font = MetalLookAndFeel.getUserTextFont();
230: assertNotNull(font);
231: assertEquals(defaultMetalTheme.getUserTextFont(), font);
232: }
233:
234: public void testGetUserTextColor() {
235: checkColor(MetalLookAndFeel.getUserTextColor(),
236: defaultMetalTheme.getUserTextColor());
237: }
238:
239: public void testGetWhite() {
240: checkColor(MetalLookAndFeel.getWhite(), defaultMetalTheme
241: .getWhite());
242: }
243:
244: public void testGetWindowBackground() {
245: checkColor(MetalLookAndFeel.getWindowBackground(),
246: defaultMetalTheme.getWindowBackground());
247: }
248:
249: public void testGetWindowTitleBackground() {
250: checkColor(MetalLookAndFeel.getWindowTitleBackground(),
251: defaultMetalTheme.getWindowTitleBackground());
252: }
253:
254: public void testGetWindowTitleFont() {
255: FontUIResource font = MetalLookAndFeel.getWindowTitleFont();
256: assertNotNull(font);
257: assertEquals(defaultMetalTheme.getWindowTitleFont(), font);
258: }
259:
260: public void testGetWindowTitleForeground() {
261: checkColor(MetalLookAndFeel.getWindowTitleForeground(),
262: defaultMetalTheme.getWindowTitleForeground());
263: }
264:
265: public void testGetWindowTitleInactiveBackground() {
266: checkColor(MetalLookAndFeel.getWindowTitleInactiveBackground(),
267: defaultMetalTheme.getWindowTitleInactiveBackground());
268: }
269:
270: public void testGetWindowTitleInactiveForeground() {
271: checkColor(MetalLookAndFeel.getWindowTitleInactiveForeground(),
272: defaultMetalTheme.getWindowTitleInactiveForeground());
273: }
274:
275: public void testIsNativeLookAndFeel() {
276: assertFalse(new MetalLookAndFeel().isNativeLookAndFeel());
277: }
278:
279: public void testIsSupportedLookAndFeel() {
280: assertTrue(new MetalLookAndFeel().isSupportedLookAndFeel());
281: }
282:
283: private void checkColor(final ColorUIResource color,
284: final ColorUIResource themeColor) {
285: assertNotNull(color);
286: assertSame(color, themeColor);
287: }
288: }
|