Author: maksimkaszynski
Date: 2007-10-15 12:47:37 -0400 (Mon, 15 Oct 2007)
New Revision: 3378
Modified:
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
Log:
http://jira.jboss.com/jira/browse/RF-1096
added logic to renderer
Modified:
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
===================================================================
---
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-15
16:47:31 UTC (rev 3377)
+++
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-15
16:47:37 UTC (rev 3378)
@@ -21,6 +21,14 @@
package org.richfaces.component.util;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
import junit.framework.TestCase;
/**
@@ -29,6 +37,19 @@
*
*/
public class HtmlUtilTest extends TestCase {
+
+ public HtmlUtilTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
public void testQualifySize() throws Exception {
assertEquals("", HtmlUtil.qualifySize(""));
@@ -48,4 +69,48 @@
assertEquals("120px", HtmlUtil.addToSize("100", "20"));
assertEquals("120px", HtmlUtil.addToSize("100px",
"20px"));
}
+
+ public void testExpandIdSelector() {
+ String selector = ".class_form+#:Test .class2 #_1aaaa:";
+
+ UIComponent component = new UIComponentBase() {
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public UIComponent findComponent(String expr) {
+ if (":Test".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component1";
+ }
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ } else if ("_1aaaa:".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component2";
+ }
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+
+ return null;
+ }
+ };
+
+ String string =
+ HtmlUtil.expandIdSelector(selector, component, null);
+
+ assertEquals(".class_form+#component1 .class2 #component2", string);
+
+ String s = ".class_form+.component1 .class2 #1component2";
+ assertEquals(s, HtmlUtil.expandIdSelector(s, component, null));
+ }
}