001: /*
002: * Copyright (c) 2002-2003 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.webwork.views.jsp.ui;
006:
007: import com.mockobjects.servlet.MockBodyContent;
008: import com.mockobjects.servlet.MockJspWriter;
009: import com.opensymphony.webwork.TestConfigurationProvider;
010: import com.opensymphony.webwork.views.jsp.AbstractUITagTest;
011: import com.opensymphony.webwork.views.jsp.ParamTag;
012: import com.opensymphony.webwork.views.jsp.WebWorkMockBodyContent;
013: import com.opensymphony.xwork.config.ConfigurationManager;
014:
015: /**
016: * UI components Tooltip test case.
017: *
018: * @author tm_jee
019: * @version $Date: 2006-02-27 14:41:01 +0100 (Mon, 27 Feb 2006) $ $Id: TooltipTest.java 2289 2006-02-27 13:41:01Z tmjee $
020: */
021: public class TooltipTest extends AbstractUITagTest {
022:
023: public void testWithoutFormOverriding() throws Exception {
024: ConfigurationManager.clearConfigurationProviders();
025: ConfigurationManager
026: .addConfigurationProvider(new TestConfigurationProvider());
027:
028: // we test it on textfield component, but since the tooltip are common to
029: // all components, it will be the same for other components as well.
030: FormTag formTag = new FormTag();
031: formTag.setPageContext(pageContext);
032: formTag.setId("myFormId");
033: formTag.setAction("testAction");
034: formTag.setName("myForm");
035:
036: TextFieldTag tag = new TextFieldTag();
037: tag.setPageContext(pageContext);
038: tag.setLabel("MyLabel");
039: tag.setId("myId");
040:
041: tag.setTooltip("myTooltip");
042: tag.setTooltipConfig("#{"
043: + "'tooltipIcon':'/webwork/tooltip/myTooltip.gif', "
044: + "'tooltipAboveMousePointer':'true', "
045: + "'tooltipBgColor':'#ffffff', "
046: + "'tooltipBgImg':'/webwork/tooltip/myBgImg.gif', "
047: + "'tooltipBorderWidth':'10', "
048: + "'tooltipBorderColor':'#eeeeee', "
049: + "'tooltipDelay':'2000', "
050: + "'tooltipFixCoordinateX':'300', "
051: + "'tooltipFixCoordinateY':'300', "
052: + "'tooltipFontColor':'#dddddd', "
053: + "'tooltipFontFace':'San-Serif,Verdana', "
054: + "'tooltipFontSize':'20', "
055: + "'tooltipFontWeight':'bold', "
056: + "'tooltipLeftOfMousePointer':'true', "
057: + "'tooltipOffsetX':'10', " + "'tooltipOffsetY':'20', "
058: + "'tooltipOpacity':'90', " + "'tooltipPadding':'30', "
059: + "'tooltipShadowColor':'#cccccc', "
060: + "'tooltipShadowWidth':'40', "
061: + "'tooltipStatic':'true', "
062: + "'tooltipSticky':'true', "
063: + "'tooltipStayAppearTime':'3000', "
064: + "'tooltipTextAlign':'right', "
065: + "'tooltipTitle':'MyTitle', "
066: + "'tooltipTitleColor':'#bbbbbb', "
067: + "'tooltipWidth':'600' " + "}");
068:
069: formTag.doStartTag();
070: tag.doStartTag();
071: tag.doEndTag();
072: formTag.doEndTag();
073:
074: verify(TooltipTest.class.getResource("tooltip-1.txt"));
075: }
076:
077: public void testWithFormOverriding() throws Exception {
078:
079: ConfigurationManager.clearConfigurationProviders();
080: ConfigurationManager
081: .addConfigurationProvider(new TestConfigurationProvider());
082:
083: FormTag formTag = new FormTag();
084: formTag.setPageContext(pageContext);
085: formTag.setName("myForm");
086: formTag.setId("myFormId");
087: formTag.setAction("testAction");
088:
089: formTag
090: .setTooltipConfig("#{ "
091: + "'tooltipIcon':'/webwork/tooltip/formMyTooltip.gif', "
092: + "'tooltipAboveMousePointer':'false', "
093: + "'tooltipBgColor':'#aaaaaa', "
094: + "'tooltipBgImg':'/webwork/tooltip/formMyBgImg.gif', "
095: + "'tooltipBorderWidth':'11', "
096: + "'tooltipBorderColor':'#bbbbbb', "
097: + "'tooltipDelay':'2001', "
098: + "'tooltipFixCoordinateX':'301', "
099: + "'tooltipFixCoordinateY':'301', "
100: + "'tooltipFontColor':'#cccccc', "
101: + "'tooltipFontFace':'Verdana,San-Serif', "
102: + "'tooltipFontSize':'21', "
103: + "'tooltipFontWeight':'normal', "
104: + "'tooltipLeftOfMousePointer':'false', "
105: + "'tooltipOffsetX':'11', "
106: + "'tooltipOffsetY':'21', "
107: + "'tooltipOpacity':'91', "
108: + "'tooltipPadding':'31', "
109: + "'tooltipShadowColor':'#cccccc', "
110: + "'tooltipShadowWidth':'41', "
111: + "'tooltipStatic':'false', "
112: + "'tooltipSticky':'false', "
113: + "'tooltipStayAppearTime':'3001', "
114: + "'tooltipTextAlign':'left', "
115: + "'tooltipTitle':'FormMyTitle', "
116: + "'tooltipTitleColor':'#dddddd', "
117: + "'tooltipWidth':'601' " + "}");
118:
119: TextFieldTag tag = new TextFieldTag();
120: tag.setPageContext(pageContext);
121: tag.setLabel("MyLabel");
122: tag.setId("myId");
123:
124: tag.setTooltip("myTooltip");
125:
126: formTag.doStartTag();
127: tag.doStartTag();
128: tag.doEndTag();
129: formTag.doEndTag();
130:
131: verify(TooltipTest.class.getResource("tooltip-2.txt"));
132: }
133:
134: public void testWithPartialFormOverriding() throws Exception {
135:
136: ConfigurationManager.clearConfigurationProviders();
137: ConfigurationManager
138: .addConfigurationProvider(new TestConfigurationProvider());
139:
140: FormTag formTag = new FormTag();
141: formTag.setName("myForm");
142: formTag.setPageContext(pageContext);
143: formTag.setId("myFormId");
144: formTag.setAction("testAction");
145:
146: formTag
147: .setTooltipConfig("#{ "
148: + "'tooltipIcon':'/webwork/tooltip/formMyTooltip.gif', "
149: + "'tooltipAboveMousePointer':'false', "
150: + "'tooltipBgColor':'#aaaaaa', "
151: + "'tooltipBgImg':'/webwork/tooltip/formMyBgImg.gif', "
152: + "'tooltipBorderWidth':'11', "
153: + "'tooltipBorderColor':'#bbbbbb', "
154: + "'tooltipDelay':'2001', "
155: + "'tooltipFixCoordinateX':'301', "
156: + "'tooltipFixCoordinateY':'301', "
157: + "'tooltipFontColor':'#cccccc', "
158: + "'tooltipFontFace':'Verdana,San-Serif', "
159: + "'tooltipFontSize':'21', "
160: + "'tooltipFontWeight':'normal', "
161: + "'tooltipLeftOfMousePointer':'false', "
162: + "'tooltipOffsetX':'11', "
163: + "'tooltipOffsetY':'21', "
164: + "'tooltipOpacity':'91', "
165: + "'tooltipPadding':'31', "
166: + "'tooltipShadowColor':'#cccccc', "
167: + "'tooltipShadowWidth':'41', "
168: + "'tooltipStatic':'false', "
169: + "'tooltipSticky':'false', "
170: + "'tooltipStayAppearTime':'3001', "
171: + "'tooltipTextAlign':'left', "
172: + "'tooltipTitle':'FormMyTitle', "
173: + "'tooltipTitleColor':'#dddddd', "
174: + "'tooltipWidth':'601' " + "}");
175:
176: TextFieldTag tag = new TextFieldTag();
177: tag.setPageContext(pageContext);
178: tag.setLabel("MyLabel");
179: tag.setId("myId");
180:
181: tag.setTooltip("myTooltip");
182: tag.setTooltipConfig("#{ "
183: + "'tooltipIcon':'/webwork/tooltip/myTooltip.gif', "
184: + "'tooltipAboveMousePointer':'true', "
185: + "'tooltipBgColor':'#ffffff', "
186: + "'tooltipBgImg':'/webwork/tooltip/myBgImg.gif' "
187: + "}");
188:
189: formTag.doStartTag();
190: tag.doStartTag();
191: tag.doEndTag();
192: formTag.doEndTag();
193:
194: verify(TooltipTest.class.getResource("tooltip-3.txt"));
195: }
196:
197: public void testUsingParamValueToSetConfigurations()
198: throws Exception {
199: ConfigurationManager.clearConfigurationProviders();
200: ConfigurationManager
201: .addConfigurationProvider(new TestConfigurationProvider());
202:
203: FormTag formTag = new FormTag();
204: formTag.setName("myForm");
205: formTag.setPageContext(pageContext);
206: formTag.setId("myFormId");
207: formTag.setAction("testAction");
208:
209: ParamTag formParamTag = new ParamTag();
210: formParamTag.setPageContext(pageContext);
211: formParamTag.setName("tooltipConfig");
212: formParamTag
213: .setValue("#{ "
214: + "'tooltipIcon':'/webwork/tooltip/formMyTooltip.gif', "
215: + "'tooltipAboveMousePointer':'false', "
216: + "'tooltipBgColor':'#aaaaaa', "
217: + "'tooltipBgImg':'/webwork/tooltip/formMyBgImg.gif', "
218: + "'tooltipBorderWidth':'11', "
219: + "'tooltipBorderColor':'#bbbbbb', "
220: + "'tooltipDelay':'2001', "
221: + "'tooltipFixCoordinateX':'301', "
222: + "'tooltipFixCoordinateY':'301', "
223: + "'tooltipFontColor':'#cccccc', "
224: + "'tooltipFontFace':'Verdana,San-Serif', "
225: + "'tooltipFontSize':'21', "
226: + "'tooltipFontWeight':'normal', "
227: + "'tooltipLeftOfMousePointer':'false', "
228: + "'tooltipOffsetX':'11', "
229: + "'tooltipOffsetY':'21', "
230: + "'tooltipOpacity':'91', "
231: + "'tooltipPadding':'31', "
232: + "'tooltipShadowColor':'#cccccc', "
233: + "'tooltipShadowWidth':'41', "
234: + "'tooltipStatic':'false', "
235: + "'tooltipSticky':'false', "
236: + "'tooltipStayAppearTime':'3001', "
237: + "'tooltipTextAlign':'left', "
238: + "'tooltipTitle':'FormMyTitle', "
239: + "'tooltipTitleColor':'#dddddd', "
240: + "'tooltipWidth':'601' " + "}");
241:
242: TextFieldTag tag = new TextFieldTag();
243: tag.setPageContext(pageContext);
244: tag.setLabel("MyLabel");
245: tag.setId("myId");
246: tag.setTooltip("myTooltip");
247:
248: ParamTag textFieldParamTag = new ParamTag();
249: textFieldParamTag.setPageContext(pageContext);
250: textFieldParamTag.setName("tooltipConfig");
251: textFieldParamTag.setValue("#{ "
252: + "'tooltipIcon':'/webwork/tooltip/myTooltip.gif', "
253: + "'tooltipAboveMousePointer':'true', "
254: + "'tooltipBgColor':'#ffffff', "
255: + "'tooltipBgImg':'/webwork/tooltip/myBgImg.gif' "
256: + "}");
257:
258: formTag.doStartTag();
259: formParamTag.doStartTag();
260: formParamTag.doEndTag();
261: tag.doStartTag();
262: textFieldParamTag.doStartTag();
263: textFieldParamTag.doEndTag();
264: tag.doEndTag();
265: formTag.doEndTag();
266:
267: verify(TooltipTest.class.getResource("tooltip-3.txt"));
268: }
269:
270: public void testUsingParamBodyValueToSetConfigurations()
271: throws Exception {
272: ConfigurationManager.clearConfigurationProviders();
273: ConfigurationManager
274: .addConfigurationProvider(new TestConfigurationProvider());
275:
276: FormTag formTag = new FormTag();
277: formTag.setName("myForm");
278: formTag.setPageContext(pageContext);
279: formTag.setId("myFormId");
280: formTag.setAction("testAction");
281:
282: ParamTag formParamTag = new ParamTag();
283: formParamTag.setPageContext(pageContext);
284: formParamTag.setName("tooltipConfig");
285: WebWorkMockBodyContent bodyContent = new WebWorkMockBodyContent(
286: new MockJspWriter());
287: bodyContent
288: .setString("tooltipIcon = /webwork/tooltip/formMyTooltip.gif | "
289: + "tooltipAboveMousePointer = false | "
290: + "tooltipBgColor = #aaaaaa| "
291: + "tooltipBgImg = /webwork/tooltip/formMyBgImg.gif | "
292: + "tooltipBorderWidth = 11 | "
293: + "tooltipBorderColor = #bbbbbb| "
294: + "tooltipDelay = 2001 | "
295: + "tooltipFixCoordinateX = 301| "
296: + "tooltipFixCoordinateY = 301| "
297: + "tooltipFontColor = #cccccc | "
298: + "tooltipFontFace = Verdana,San-Serif | "
299: + "tooltipFontSize = 21 | "
300: + "tooltipFontWeight = normal | "
301: + "tooltipLeftOfMousePointer = false | "
302: + "tooltipOffsetX = 11 | "
303: + "tooltipOffsetY = 21| "
304: + "tooltipOpacity = 91| "
305: + "tooltipPadding = 31| "
306: + "tooltipShadowColor = #cccccc| "
307: + "tooltipShadowWidth = 41| "
308: + "tooltipStatic = false | "
309: + "tooltipSticky = false| "
310: + "tooltipStayAppearTime = 3001| "
311: + "tooltipTextAlign = left| "
312: + "tooltipTitle = FormMyTitle| "
313: + "tooltipTitleColor = #dddddd| "
314: + "tooltipWidth = 601 ");
315: formParamTag.setBodyContent(bodyContent);
316:
317: TextFieldTag tag = new TextFieldTag();
318: tag.setPageContext(pageContext);
319: tag.setLabel("MyLabel");
320: tag.setId("myId");
321: tag.setTooltip("myTooltip");
322:
323: ParamTag textFieldParamTag = new ParamTag();
324: textFieldParamTag.setPageContext(pageContext);
325: textFieldParamTag.setName("tooltipConfig");
326: WebWorkMockBodyContent bodyContent2 = new WebWorkMockBodyContent(
327: new MockJspWriter());
328: bodyContent2
329: .setString("tooltipIcon = /webwork/tooltip/myTooltip.gif | "
330: + "tooltipAboveMousePointer = true | "
331: + "tooltipBgColor = #ffffff | "
332: + "tooltipBgImg = /webwork/tooltip/myBgImg.gif ");
333: textFieldParamTag.setBodyContent(bodyContent2);
334:
335: formTag.doStartTag();
336: formParamTag.doStartTag();
337: formParamTag.doEndTag();
338: tag.doStartTag();
339: textFieldParamTag.doStartTag();
340: textFieldParamTag.doEndTag();
341: tag.doEndTag();
342: formTag.doEndTag();
343:
344: verify(TooltipTest.class.getResource("tooltip-3.txt"));
345: }
346:
347: }
|