1 29 30 package nextapp.echo2.app.test.componentxml; 31 32 import java.io.InputStream ; 33 34 import nextapp.echo2.app.Color; 35 import nextapp.echo2.app.Component; 36 import nextapp.echo2.app.ImageReference; 37 import nextapp.echo2.app.Insets; 38 import nextapp.echo2.app.ResourceImageReference; 39 import nextapp.echo2.app.Column; 40 import nextapp.echo2.app.Style; 41 import nextapp.echo2.app.StyleSheet; 42 import nextapp.echo2.app.componentxml.StyleSheetLoader; 43 import nextapp.echo2.app.layout.GridLayoutData; 44 import junit.framework.TestCase; 45 46 49 public class GridLayoutDataPeerTest extends TestCase { 50 51 private StyleSheet styleSheet; 52 53 56 public void setUp() 57 throws Exception { 58 InputStream in = FillImagePeerTest.class.getResourceAsStream("GridLayoutDataPeerTest.stylesheet"); 59 styleSheet = StyleSheetLoader.load(in, StyleSheetLoaderTest.class.getClassLoader()); 60 in.close(); 61 } 62 63 public void testBasic() { 64 Style alphaStyle = styleSheet.getStyle(Column.class, "alpha"); 65 GridLayoutData layoutData = (GridLayoutData) alphaStyle.getProperty(Component.PROPERTY_LAYOUT_DATA); 66 assertEquals(2, layoutData.getColumnSpan()); 67 assertEquals(1, layoutData.getRowSpan()); 68 assertEquals(new Color(0xabcdef), layoutData.getBackground()); 69 assertEquals(new Insets(20, 30), layoutData.getInsets()); 70 assertNotNull(layoutData.getBackgroundImage()); 71 ImageReference imageReference = layoutData.getBackgroundImage().getImage(); 72 assertNotNull(imageReference); 73 assertTrue(imageReference instanceof ResourceImageReference); 74 assertEquals("nextapp/echo2/test/componentxml/BackgroundImage.png", 75 ((ResourceImageReference) imageReference).getResource()); 76 } 77 } 78 | Popular Tags |