Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/newsfighter/tests/layout/SkinTest.java


1   /*
2    * SkinTest.java
3    *
4    * Created on March 14, 2003, 10:22 PM
5    */
6   
7   package com.newsfighter.tests.layout;
8   
9   import junit.framework.*;
10  import com.newsfighter.layout.Skin;
11  
12  /** SkinTest.java runs tests against a known and well-formatted skin.xml file.
13   * it checks the values of the different attributes throughout the file, and
14   * should let us know if we did anything wrong.
15   *
16   * @author  N. Alex Rupp
17   */
18  public class SkinTest extends TestCase {
19  
20    String s;
21    Skin skin;
22  
23    // ==== local variables ============================================= //
24    String name;
25    String bgColor;
26    String displayCssId;
27    String displayMargin;
28    String displayWidth;
29    String gutterWidth;
30    String logoImageHeight;
31    String logoImageSrc;
32    String logoImageWidth;
33    String menuCssId;
34    String menuHeight;
35    String menuRightMargin;
36    String panelImageSrc;
37    String panelImageWidth;
38    String panelWidth;
39  
40    // ==== test variables ============================================== //
41    String xmlName;
42    String xmlBgColor;
43  
44    String xmlDisplayCssId;
45    String xmlDisplayMargin;
46    String xmlDisplayWidth;
47  
48    String xmlGutterWidth;
49    String xmlLogoImageHeight;
50    String xmlLogoImageSrc;
51    String xmlLogoImageWidth;
52  
53    String xmlMenuCssId;
54    String xmlMenuHeight;
55    String xmlMenuRightMargin;
56    String xmlPanelImageSrc;
57    String xmlPanelImageWidth;
58    String xmlPanelWidth;
59  
60  
61      protected void setUp() {
62          s = "E:/cygwin/cvsandbox/unit-test/com/newsfighter/tests/layout/skin.xml";
63          skin = new Skin(s);
64  
65          // ================================================= //
66          name = "unit-test";
67          bgColor = "ffffff";
68          displayCssId = "default";
69          displayMargin = "4";
70          displayWidth = "175";
71          gutterWidth = "10";
72          logoImageHeight = "146";
73          logoImageSrc = "logo_01.gif";
74          logoImageWidth = "121";
75          menuCssId = "menu";
76          menuHeight = "45";
77          menuRightMargin = "38";
78          panelImageSrc = "spacer.gif";
79          panelImageWidth = "185";
80          panelWidth = "185";
81  
82          // ================================================== //
83          xmlName = skin.getName();
84          xmlBgColor = skin.getBgColor();
85          xmlDisplayCssId = skin.getDisplayCssId("200");
86          xmlDisplayMargin = skin.getDisplayMargin("200");
87          xmlDisplayWidth = skin.getDisplayWidth("200");
88          xmlGutterWidth = skin.getGutterWidth();
89          xmlLogoImageHeight = skin.getLogoImageHeight("1");
90          xmlLogoImageSrc = skin.getLogoImageSrc("1");
91          xmlLogoImageWidth = skin.getLogoImageWidth("1");
92          xmlMenuCssId = skin.getMenuCssId();
93          xmlMenuHeight = skin.getMenuHeight();
94          xmlMenuRightMargin = skin.getMenuRightMargin();
95          xmlPanelImageSrc = skin.getPanelImageSrc("200", "bottom");
96          xmlPanelImageWidth = skin.getPanelWidth("200");
97          xmlPanelWidth = skin.getPanelWidth("200");
98      }
99  
100     protected void tearDown() {
101         s = null;
102         skin = null;
103 
104         // ================================================= //
105         name = null;
106         bgColor = null;
107         displayCssId = null;
108         displayMargin = null;
109         displayWidth = null;
110         gutterWidth = null;
111         logoImageHeight = null;
112         logoImageSrc = null;
113         logoImageWidth = null;
114         menuCssId = null;
115         menuHeight = null;
116         menuRightMargin = null;
117         panelImageSrc = null;
118         panelImageWidth = null;
119         panelWidth = null;
120 
121         // ================================================== //
122         xmlName = null;
123         xmlBgColor = null;
124 
125         xmlDisplayCssId = null;
126         xmlDisplayMargin = null;
127         xmlDisplayWidth = null;
128 
129         xmlGutterWidth = null;
130         xmlLogoImageHeight = null;
131         xmlLogoImageSrc = null;
132         xmlLogoImageWidth = null;
133 
134         xmlMenuCssId = null;
135         xmlMenuHeight = null;
136         xmlMenuRightMargin = null;
137         xmlPanelImageSrc = null;
138         xmlPanelImageWidth = null;
139         xmlPanelWidth = null;
140     }
141 
142     // ==== test cases ====================================================== //
143 
144     public void testName() {
145       assertEquals(name, xmlName);
146   }
147 
148   public void testBgColor() {
149     assertEquals(bgColor, xmlBgColor);
150   }
151 
152   public void testDisplayCssId() {
153     assertEquals(displayCssId, xmlDisplayCssId);
154   }
155 
156   public void testDisplayMargin() {
157     assertEquals(displayMargin, xmlDisplayMargin);
158   }
159 
160   public void testDisplayWidth() {
161     assertEquals(displayWidth, xmlDisplayWidth);
162   }
163 
164   public void testGutterWidth() {
165     assertEquals(gutterWidth, xmlGutterWidth);
166   }
167 
168   public void testLogoImageHeight() {
169     assertEquals(logoImageHeight, xmlLogoImageHeight);
170   }
171 
172   public void testLogoImageSrc() {
173     assertEquals(logoImageSrc, xmlLogoImageSrc);
174   }
175 
176   public void testLogoImageWidth() {
177     assertEquals(logoImageWidth, xmlLogoImageWidth);
178   }
179 
180   public void testMenuCssId() {
181     assertEquals(menuCssId, xmlMenuCssId);
182   }
183 
184   public void testMenuHeight() {
185     assertEquals(menuHeight, xmlMenuHeight);
186   }
187 
188   public void testMenuRightMargin() {
189     assertEquals(menuRightMargin, xmlMenuRightMargin);
190   }
191 
192   public void testPanelImageSrc() {
193     assertEquals(panelImageSrc, xmlPanelImageSrc);
194   }
195 
196   public void testPanelImageWidth() {
197     assertEquals(panelImageWidth, xmlPanelImageWidth);
198   }
199 
200   public void testPanelWidth() {
201     assertEquals(panelWidth, xmlPanelWidth);
202   }
203     
204     
205     // ==== runner code ===================================================== //
206     public static void main (String[] args) {
207     junit.textui.TestRunner.run(suite());
208   }
209     
210     public static Test suite() {
211         return new TestSuite(SkinTest.class);
212     }
213 }