1 29 30 package nextapp.echo2.app.test.componentxml; 31 32 import java.io.InputStream ; 33 34 import nextapp.echo2.app.Button; 35 import nextapp.echo2.app.Color; 36 import nextapp.echo2.app.Component; 37 import nextapp.echo2.app.ContentPane; 38 import nextapp.echo2.app.Style; 39 import nextapp.echo2.app.StyleSheet; 40 import nextapp.echo2.app.componentxml.StyleSheetLoader; 41 import junit.framework.TestCase; 42 43 46 public class StyleSheetLoaderTest extends TestCase { 47 48 StyleSheet styleSheet; 49 50 53 public void setUp() 54 throws Exception { 55 InputStream in = StyleSheetLoaderTest.class.getResourceAsStream("Simple.stylesheet"); 56 styleSheet = StyleSheetLoader.load(in, StyleSheetLoaderTest.class.getClassLoader()); 57 in.close(); 58 } 59 60 public void testBasic() { 61 Style defaultContentPaneStyle = styleSheet.getStyle(ContentPane.class, "default"); 62 assertNotNull(defaultContentPaneStyle); 63 assertEquals(new Color(0x00ffff), defaultContentPaneStyle.getProperty(Component.PROPERTY_BACKGROUND)); 64 assertEquals(new Color(0xff0000), defaultContentPaneStyle.getProperty(Component.PROPERTY_FOREGROUND)); 65 } 66 67 public void testDerived() { 68 Style selectedButtonStyle = styleSheet.getStyle(Button.class, "selected"); 69 assertNotNull(selectedButtonStyle); 70 assertEquals(new Color(0xff0000), selectedButtonStyle.getProperty(Component.PROPERTY_BACKGROUND)); 71 assertEquals(new Color(0x00cc00), selectedButtonStyle.getProperty(Component.PROPERTY_FOREGROUND)); 72 } 73 } 74 | Popular Tags |