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.Extent; 36 import nextapp.echo2.app.FillImage; 37 import nextapp.echo2.app.FillImageBorder; 38 import nextapp.echo2.app.ImageReference; 39 import nextapp.echo2.app.Insets; 40 import nextapp.echo2.app.ResourceImageReference; 41 import nextapp.echo2.app.Style; 42 import nextapp.echo2.app.StyleSheet; 43 import nextapp.echo2.app.WindowPane; 44 import nextapp.echo2.app.componentxml.StyleSheetLoader; 45 import junit.framework.TestCase; 46 47 50 public class FillImageBorderPeerTest extends TestCase { 51 52 private StyleSheet styleSheet; 53 54 57 public void setUp() 58 throws Exception { 59 InputStream in = FillImageBorderPeerTest.class.getResourceAsStream("FillImageBorderPeerTest.stylesheet"); 60 styleSheet = StyleSheetLoader.load(in, StyleSheetLoaderTest.class.getClassLoader()); 61 in.close(); 62 } 63 64 public void testSimple() { 65 Style alphaStyle = styleSheet.getStyle(WindowPane.class, "alpha"); 66 FillImageBorder fillImageBorder = (FillImageBorder) alphaStyle.getProperty(WindowPane.PROPERTY_BORDER); 67 assertEquals(new Color(0xabcdef), fillImageBorder.getColor()); 68 assertEquals(new Insets(12), fillImageBorder.getContentInsets()); 69 assertEquals(new Insets(6, 4), fillImageBorder.getBorderInsets()); 70 71 FillImage topLeftFillImage = fillImageBorder.getFillImage(FillImageBorder.TOP_LEFT); 72 assertNotNull(topLeftFillImage); 73 ImageReference imageReference = topLeftFillImage.getImage(); 74 assertNotNull(imageReference); 75 assertTrue(imageReference instanceof ResourceImageReference); 76 assertEquals("nextapp/echo2/test/componentxml/BackgroundImage.png", 77 ((ResourceImageReference) imageReference).getResource()); 78 assertEquals(FillImage.REPEAT_HORIZONTAL, topLeftFillImage.getRepeat()); 79 assertEquals(new Extent(50), topLeftFillImage.getHorizontalOffset()); 80 assertEquals(new Extent(-30, Extent.PERCENT), topLeftFillImage.getVerticalOffset()); 81 } 82 } 83 | Popular Tags |