01: package org.uispec4j;
02:
03: import org.uispec4j.utils.UnitTestCase;
04: import org.uispec4j.xml.XmlAssert;
05:
06: import javax.swing.*;
07: import java.awt.*;
08:
09: public class AbstractUIComponentTest extends UnitTestCase {
10:
11: public void testGetComponentTypeName() throws Exception {
12: XmlAssert.assertEquivalent("<awtLabel name='myName'/>",
13: new DummyAwtUIComponent("myName").getDescription());
14: }
15:
16: private static final class DummyAwtUIComponent extends
17: AbstractUIComponent {
18: private final Component comp = new Label();
19:
20: DummyAwtUIComponent(String name) {
21: comp.setName(name);
22: }
23:
24: public Component getAwtComponent() {
25: return comp;
26: }
27:
28: public String getDescriptionTypeName() {
29: return "awtLabel";
30: }
31: }
32:
33: public void testComponentUsesBlackAsDefaultForegroundColor()
34: throws Exception {
35: final JComponent jComponent = new JComponent() {
36: };
37: AbstractUIComponent uiComponent = new AbstractUIComponent() {
38: public Component getAwtComponent() {
39: return jComponent;
40: }
41:
42: public String getDescriptionTypeName() {
43: return "";
44: }
45: };
46:
47: assertTrue(uiComponent.foregroundEquals("black"));
48: }
49: }
|