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