1 29 30 package nextapp.echo2.webcontainer.test; 31 32 import nextapp.echo2.app.Extent; 33 import nextapp.echo2.webcontainer.propertyrender.ExtentRender; 34 import junit.framework.TestCase; 35 36 40 public class ExtentRenderTest extends TestCase { 41 42 45 public void testExtentRender() { 46 assertEquals("50cm", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.CM))); 47 assertEquals("50em", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.EM))); 48 assertEquals("50ex", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.EX))); 49 assertEquals("50in", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.IN))); 50 assertEquals("50mm", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.MM))); 51 assertEquals("50%", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PERCENT))); 52 assertEquals("50pc", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PC))); 53 assertEquals("50pt", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PT))); 54 assertEquals("50px", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PX))); 55 } 56 57 60 public void testToExtent() { 61 assertEquals(new Extent(50, Extent.CM), ExtentRender.toExtent("50cm")); 62 assertEquals(new Extent(50, Extent.EM), ExtentRender.toExtent("50em")); 63 assertEquals(new Extent(50, Extent.EX), ExtentRender.toExtent("50ex")); 64 assertEquals(new Extent(50, Extent.IN), ExtentRender.toExtent("50in")); 65 assertEquals(new Extent(50, Extent.MM), ExtentRender.toExtent("50mm")); 66 assertEquals(new Extent(50, Extent.PERCENT), ExtentRender.toExtent("50%")); 67 assertEquals(new Extent(50, Extent.PC), ExtentRender.toExtent("50pc")); 68 assertEquals(new Extent(50, Extent.PT), ExtentRender.toExtent("50pt")); 69 assertEquals(new Extent(50, Extent.PX), ExtentRender.toExtent("50px")); 70 assertEquals(null, ExtentRender.toExtent(null)); 71 assertEquals(null, ExtentRender.toExtent("50foo")); 72 assertEquals(null, ExtentRender.toExtent("50")); 73 assertEquals(null, ExtentRender.toExtent("foo")); 74 assertEquals(null, ExtentRender.toExtent("50m30cm")); 75 } 76 } 77 | Popular Tags |