01: /*
02: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
03: * Copyright (C) 2002-2005 NextApp, Inc.
04: *
05: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
06: *
07: * The contents of this file are subject to the Mozilla Public License Version
08: * 1.1 (the "License"); you may not use this file except in compliance with
09: * the License. You may obtain a copy of the License at
10: * http://www.mozilla.org/MPL/
11: *
12: * Software distributed under the License is distributed on an "AS IS" basis,
13: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14: * for the specific language governing rights and limitations under the
15: * License.
16: *
17: * Alternatively, the contents of this file may be used under the terms of
18: * either the GNU General Public License Version 2 or later (the "GPL"), or
19: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20: * in which case the provisions of the GPL or the LGPL are applicable instead
21: * of those above. If you wish to allow use of your version of this file only
22: * under the terms of either the GPL or the LGPL, and not to allow others to
23: * use your version of this file under the terms of the MPL, indicate your
24: * decision by deleting the provisions above and replace them with the notice
25: * and other provisions required by the GPL or the LGPL. If you do not delete
26: * the provisions above, a recipient may use your version of this file under
27: * the terms of any one of the MPL, the GPL or the LGPL.
28: */
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: /**
37: * Unit tests for
38: * <code>nextapp.echo2.webcontainer.propertyrender.ExtentRender</code>.
39: */
40: public class ExtentRenderTest extends TestCase {
41:
42: /**
43: * Test <code>ExtentRender.renderCssAttributeValue()</code>.
44: */
45: public void testExtentRender() {
46: assertEquals("50cm", ExtentRender
47: .renderCssAttributeValue(new Extent(50, Extent.CM)));
48: assertEquals("50em", ExtentRender
49: .renderCssAttributeValue(new Extent(50, Extent.EM)));
50: assertEquals("50ex", ExtentRender
51: .renderCssAttributeValue(new Extent(50, Extent.EX)));
52: assertEquals("50in", ExtentRender
53: .renderCssAttributeValue(new Extent(50, Extent.IN)));
54: assertEquals("50mm", ExtentRender
55: .renderCssAttributeValue(new Extent(50, Extent.MM)));
56: assertEquals("50%",
57: ExtentRender.renderCssAttributeValue(new Extent(50,
58: Extent.PERCENT)));
59: assertEquals("50pc", ExtentRender
60: .renderCssAttributeValue(new Extent(50, Extent.PC)));
61: assertEquals("50pt", ExtentRender
62: .renderCssAttributeValue(new Extent(50, Extent.PT)));
63: assertEquals("50px", ExtentRender
64: .renderCssAttributeValue(new Extent(50, Extent.PX)));
65: }
66:
67: /**
68: * Test <code>ExtentRender.toExtent()</code>.
69: */
70: public void testToExtent() {
71: assertEquals(new Extent(50, Extent.CM), ExtentRender
72: .toExtent("50cm"));
73: assertEquals(new Extent(50, Extent.EM), ExtentRender
74: .toExtent("50em"));
75: assertEquals(new Extent(50, Extent.EX), ExtentRender
76: .toExtent("50ex"));
77: assertEquals(new Extent(50, Extent.IN), ExtentRender
78: .toExtent("50in"));
79: assertEquals(new Extent(50, Extent.MM), ExtentRender
80: .toExtent("50mm"));
81: assertEquals(new Extent(50, Extent.PERCENT), ExtentRender
82: .toExtent("50%"));
83: assertEquals(new Extent(50, Extent.PC), ExtentRender
84: .toExtent("50pc"));
85: assertEquals(new Extent(50, Extent.PT), ExtentRender
86: .toExtent("50pt"));
87: assertEquals(new Extent(50, Extent.PX), ExtentRender
88: .toExtent("50px"));
89: assertEquals(null, ExtentRender.toExtent(null));
90: assertEquals(null, ExtentRender.toExtent("50foo"));
91: assertEquals(null, ExtentRender.toExtent("50"));
92: assertEquals(null, ExtentRender.toExtent("foo"));
93: assertEquals(null, ExtentRender.toExtent("50m30cm"));
94: }
95: }
|