Author: lfryc(a)redhat.com
Date: 2011-01-21 11:03:53 -0500 (Fri, 21 Jan 2011)
New Revision: 21155
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeNodeBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java
Log:
rich:tree - fix wrong @expanded usage + fix tests (RF-10264)
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeBean.java 2011-01-21
15:48:44 UTC (rev 21154)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeBean.java 2011-01-21
16:03:53 UTC (rev 21155)
@@ -27,6 +27,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
@@ -66,6 +68,8 @@
private boolean testLoadingFacet = false;
private boolean delayedRender = false;
+
+ private Map<TreeNode, Boolean> expanded = new HashMap<TreeNode,
Boolean>();
/**
* Initializes the managed bean.
@@ -87,6 +91,7 @@
attributes.remove("var");
attributes.remove("rowKeyVar");
attributes.remove("stateVar");
+ attributes.remove("nodeType");
for (CompactDiscXmlDescriptor descriptor : model.getCompactDiscs()) {
createCompactDisc(descriptor);
@@ -107,6 +112,7 @@
CompactDisc cd = new CompactDisc(descriptor.getTitle(), descriptor.getArtist(),
company, descriptor.getPrice(),
descriptor.getYear());
company.getCds().add(cd);
+ expanded.put(cd, false);
return cd;
}
@@ -121,6 +127,7 @@
company.setParent(country);
country.getCompanies().add(company);
companiesCache.put(companyName, company);
+ expanded.put(company, false);
}
return company;
}
@@ -132,6 +139,7 @@
country = new Country();
country.setName(countryName);
countriesCache.put(countryName, country);
+ expanded.put(country, false);
root.add(country);
}
return country;
@@ -179,4 +187,20 @@
}
}
}
+
+ public Map<TreeNode, Boolean> getExpanded() {
+ return expanded;
+ }
+
+ public void expandAll() {
+ for (Entry<TreeNode, Boolean> entry : expanded.entrySet()) {
+ entry.setValue(true);
+ }
+ }
+
+ public void collapseAll() {
+ for (Entry<TreeNode, Boolean> entry : expanded.entrySet()) {
+ entry.setValue(false);
+ }
+ }
}
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeNodeBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeNodeBean.java 2011-01-21
15:48:44 UTC (rev 21154)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeNodeBean.java 2011-01-21
16:03:53 UTC (rev 21155)
@@ -58,6 +58,7 @@
// attributes which needs to be tested another way
attributes[i].remove("type");
+ attributes[i].remove("expanded");
}
}
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml 2011-01-21
15:48:44 UTC (rev 21154)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml 2011-01-21
16:03:53 UTC (rev 21155)
@@ -97,8 +97,8 @@
<rich:treeNode type="country"
+ expanded="#{richTreeBean.expanded[node]}"
rendered="#{richTreeNodeBean.attributes[0]['rendered'].value}"
- expanded="#{richTreeNodeBean.attributes[0]['expanded'].value}"
iconLeaf="#{richTreeNodeBean.attributes[0]['iconLeaf'].value}"
iconExpanded="#{richTreeNodeBean.attributes[0]['iconExpanded'].value}"
iconCollapsed="#{richTreeNodeBean.attributes[0]['iconCollapsed'].value}"
@@ -115,8 +115,8 @@
<rich:treeNode type="company"
icon="/images/tree/disc.gif"
+ expanded="#{richTreeBean.expanded[node]}"
rendered="#{richTreeNodeBean.attributes[1]['rendered'].value}"
- expanded="#{richTreeNodeBean.attributes[1]['expanded'].value}"
iconLeaf="#{richTreeNodeBean.attributes[1]['iconLeaf'].value}"
iconExpanded="#{richTreeNodeBean.attributes[1]['iconExpanded'].value}"
iconCollapsed="#{richTreeNodeBean.attributes[1]['iconCollapsed'].value}"
@@ -134,8 +134,8 @@
<rich:treeNode type="cd"
icon="/images/tree/song.gif"
+ expanded="#{richTreeBean.expanded[node]}"
rendered="#{richTreeNodeBean.attributes[2]['rendered'].value}"
- expanded="#{richTreeNodeBean.attributes[2]['expanded'].value}"
iconLeaf="#{richTreeNodeBean.attributes[2]['iconLeaf'].value}"
iconExpanded="#{richTreeNodeBean.attributes[2]['iconExpanded'].value}"
iconCollapsed="#{richTreeNodeBean.attributes[2]['iconCollapsed'].value}"
@@ -204,9 +204,12 @@
<ui:define name="outOfTemplateAfter">
-
+ <a4j:commandButton id="expandAll" value="Expand All"
action="#{richTreeBean.expandAll}" render="#{nestedComponentId}"
/>
+ <a4j:commandButton id="collapseAll" value="Collapse All"
action="#{richTreeBean.collapseAll}" render="#{nestedComponentId}"
/>
+
<a4j:outputPanel ajaxRendered="true">
<h:panelGrid columns="2">
+
<h:outputLabel value="Test Loading Facet:" />
<h:selectBooleanCheckbox
value="#{richTreeBean.testLoadingFacet}">
<a4j:ajax render="#{nestedComponentId}" />
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java 2011-01-21
15:48:44 UTC (rev 21154)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java 2011-01-21
16:03:53 UTC (rev 21155)
@@ -34,6 +34,8 @@
import static org.jboss.test.selenium.dom.Event.MOUSEOVER;
import static org.jboss.test.selenium.dom.Event.MOUSEUP;
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
import static org.testng.Assert.assertEquals;
@@ -72,11 +74,6 @@
Event domEvent;
Event[] domEvents = { CLICK, DBLCLICK, KEYDOWN, KEYPRESS, KEYUP, MOUSEDOWN,
MOUSEMOVE, MOUSEOUT, MOUSEOVER, MOUSEUP };
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/richTree/simple.xhtml");
- }
-
TreeModel tree = new TreeModel(pjq("div.rf-tr[id$=richTree]"));
TreeNodeModel treeNode;
@@ -86,6 +83,13 @@
new TreeNodeAttributes(pjq("span[id*=treeNode2Attributes]")),
new TreeNodeAttributes(pjq("span[id*=treeNode3Attributes]")) };
+ JQueryLocator expandAll = jq("input:submit[id$=expandAll]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richTree/simple.xhtml");
+ }
+
@Test
public void testData() {
attributes.setData("RichFaces 4");
@@ -149,7 +153,7 @@
assertEquals(with > 0, i < 2);
assertEquals(without > 0, i > 0);
- nodeAttributes[i].setExpanded(true);
+ expandLevel(i);
}
}
@@ -168,7 +172,7 @@
assertEquals(with > 0, i > 0);
assertEquals(without > 0, i < 2);
- nodeAttributes[i].setExpanded(true);
+ expandLevel(i);
}
}
@@ -187,7 +191,7 @@
assertEquals(with > 0, i > 1);
assertEquals(without > 0, i < 2);
- nodeAttributes[i].setExpanded(true);
+ expandLevel(i);
}
}
@@ -313,7 +317,23 @@
}
private void expandAll() {
- nodeAttributes[0].setExpanded(true);
- nodeAttributes[1].setExpanded(true);
+ guardXhr(selenium).click(expandAll);
}
+
+ private void expandLevel(int level) {
+ switch (level) {
+ case 0:
+ for (TreeNodeModel treeNode1 : tree.getNodes()) {
+ treeNode1.expand();
+ }
+ break;
+ case 1:
+ for (TreeNodeModel treeNode1 : tree.getNodes()) {
+ for (TreeNodeModel treeNode2 : treeNode1.getNodes()) {
+ treeNode2.expand();
+ }
+ }
+ default:
+ }
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java 2011-01-21
15:48:44 UTC (rev 21154)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java 2011-01-21
16:03:53 UTC (rev 21155)
@@ -42,10 +42,6 @@
setProperty("dir", dir);
}
- public void setExpanded(Boolean expanded) {
- setProperty("expanded", expanded);
- }
-
public void setIconCollapsed(String iconCollapsed) {
setProperty("iconCollapsed", iconCollapsed);
}