1 29 30 package nextapp.echo2.app.test; 31 32 import nextapp.echo2.app.Button; 33 import nextapp.echo2.app.Color; 34 import nextapp.echo2.app.Label; 35 import nextapp.echo2.app.MutableStyle; 36 import nextapp.echo2.app.MutableStyleSheet; 37 import junit.framework.TestCase; 38 39 42 public class StyleSheetTest extends TestCase { 43 44 public void testBasicOperation() { 45 MutableStyleSheet styleSheet = new MutableStyleSheet(); 46 47 MutableStyle alphaButtonStyle = new MutableStyle(); 48 alphaButtonStyle.setProperty(Button.PROPERTY_BORDER, TestConstants.BORDER_THICK_ORANGE); 49 alphaButtonStyle.setProperty(Button.PROPERTY_BACKGROUND, Color.YELLOW); 50 styleSheet.addStyle(Button.class, "alpha", alphaButtonStyle); 51 52 assertEquals(alphaButtonStyle, styleSheet.getStyle(Button.class, "alpha")); 53 assertNull(styleSheet.getStyle(Button.class, "bravo")); 54 55 MutableStyle bravoButtonStyle = new MutableStyle(); 56 bravoButtonStyle.setProperty(Button.PROPERTY_BORDER, TestConstants.BORDER_THIN_YELLOW); 57 bravoButtonStyle.setProperty(Button.PROPERTY_BACKGROUND, Color.GREEN); 58 styleSheet.addStyle(Button.class, "bravo", bravoButtonStyle); 59 60 assertEquals(alphaButtonStyle, styleSheet.getStyle(Button.class, "alpha")); 61 assertEquals(bravoButtonStyle, styleSheet.getStyle(Button.class, "bravo")); 62 63 MutableStyle bravoLabelStyle = new MutableStyle(); 64 bravoLabelStyle.setProperty(Label.PROPERTY_FOREGROUND, Color.RED); 65 styleSheet.addStyle(Label.class, "bravo", bravoLabelStyle); 66 67 assertEquals(alphaButtonStyle, styleSheet.getStyle(Button.class, "alpha")); 68 assertEquals(bravoButtonStyle, styleSheet.getStyle(Button.class, "bravo")); 69 assertEquals(bravoLabelStyle, styleSheet.getStyle(Label.class, "bravo")); 70 } 71 } 72 | Popular Tags |