Author: dsvyatobatsko
Date: 2008-11-28 12:00:50 -0500 (Fri, 28 Nov 2008)
New Revision: 11446
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tree/treeTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java
Log:
https://jira.jboss.org/jira/browse/RF-4831
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-11-28
16:50:21 UTC (rev 11445)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-11-28
17:00:50 UTC (rev 11446)
@@ -33,6 +33,7 @@
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.xmlrules.DigesterLoader;
import org.richfaces.component.UITree;
+import org.richfaces.component.state.TreeStateAdvisor;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
@@ -299,4 +300,43 @@
setRichModel(true);
}
+ private TreeStateAdvisor advisor;
+
+ /**
+ * Gets value of advisor field.
+ * @return value of advisor field
+ */
+ public TreeStateAdvisor getAdvisor() {
+ return advisor;
+ }
+
+ /**
+ * Set a new value for advisor field.
+ * @param advisor a new value for advisor field
+ */
+ public void setAdvisor(TreeStateAdvisor advisor) {
+ this.advisor = advisor;
+ }
+
+ public void initStateAdvisorTest() {
+ if(advisor == null) {
+ setAdvisor(new TestAdvisor());
+ }
+ }
+
+ static class TestAdvisor implements TreeStateAdvisor {
+
+ public Boolean adviseNodeOpened(UITree tree) {
+ return true;
+ }
+
+ public Boolean adviseNodeSelected(UITree tree) {
+ return null;
+ }
+ }
+
+ public void tearDown() {
+ setAdvisor(null);
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tree/treeTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java 2008-11-28
16:50:21 UTC (rev 11445)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java 2008-11-28
17:00:50 UTC (rev 11446)
@@ -22,6 +22,8 @@
private final static String INIT_SERVER_MODE =
"#{treeBean.initServerMode}";
private final static String INIT_AJAX_MODE = "#{treeBean.initAjaxMode}";
private final static String INIT_CLIENT_MODE =
"#{treeBean.initClientMode}";
+ private final static String INIT_ADVISOR_TEST =
"#{treeBean.initStateAdvisorTest}";
+ private final static String TEAR_DOWN_METHOD = "#{treeBean.tearDown}";
static {
params.put("parameter1", "value1");
@@ -318,34 +320,6 @@
}
@Test
- public void testIconsAttributesAreApplied(Template template) {
- renderPage(template, null);
-
- writeStatus("Check icons attributes applied: are output to client and images
are accessible");
-
- String compId = getParentId() + "_form:tree";
-
- testIcon("//*[@id='"+ compId +
":childs']/table[1]/tbody/tr/td[2]/img", "singer");
- clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/table[1]/tbody/tr/td/div/a");
- testIcon("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td[2]/img", "disc");
- clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
- testIcon("//*[@id='"+ compId +
":childs']/div/div/table[1]/tbody/tr/td[2]/img", "song");
- }
-
- /**
- * Test an icon.
- *
- * @param location location of image representing icon to be tested
- * @param iconName substring that icon uri has to contain
- */
- private void testIcon(String location, String iconSubstring) {
- String iconSrc = selenium.getAttribute(location + "/@src");
- if (null == iconSrc || !iconSrc.matches(".*" + iconSubstring +
".*")) {
- Assert.fail("It looks as if the icon is not proper. Uri of icon is being
tested must contain [" + iconSubstring + "]");
- }
- }
-
- @Test
public void testServerMode(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, INIT_SERVER_MODE);
@@ -450,7 +424,7 @@
@Test
public void
testNodePresentationCanBeCustomizedUsingRenderedAndNodeFaceAttributes(Template template)
{
- renderPage(template, null);
+ renderPage(template, TEAR_DOWN_METHOD);
writeStatus("Check node presentation can be customized using rendered and
nodeFace attributes");
String compId = getParentId() + "_form:tree";
@@ -463,6 +437,42 @@
AssertTextEquals("//*[@id='"+ compId +
":childs']/table[2]/tbody/tr/td[3]", "Christina Aguilera [Oh, Lord!
She's my favorite]");
}
+ @Test
+ public void testIconsAttributesAreApplied(Template template) {
+ renderPage(template, TEAR_DOWN_METHOD);
+
+ writeStatus("Check icons attributes applied: are output to client and images
are accessible");
+
+ String compId = getParentId() + "_form:tree";
+
+ testIcon("//*[@id='"+ compId +
":childs']/table[1]/tbody/tr/td[2]/img", "singer");
+ clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/table[1]/tbody/tr/td/div/a");
+ testIcon("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td[2]/img", "disc");
+ clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ testIcon("//*[@id='"+ compId +
":childs']/div/div/table[1]/tbody/tr/td[2]/img", "song");
+ }
+
+ @Test
+ public void testTreeStateAdvisor(Template template) {
+ renderPage(template, INIT_ADVISOR_TEST);
+ writeStatus("Check tree state advisors work properly");
+ writeStatus("All nodes have to be expanded thanks to advisor set. Test
it");
+
+ String compId = getParentId() + "_form:tree";
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId +
":childs']/div[1]"), "It looks as if there are unexpanded nodes
here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId +
":childs']/div[1]"), "It looks as if there are unexpanded nodes
here");
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId +
":childs']/div[1]/div"), "It looks as if there are unexpanded nodes
here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId +
":childs']/div[1]/div"), "It looks as if there are unexpanded nodes
here");
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId +
":childs']/div[2]"), "It looks as if there are unexpanded nodes
here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId +
":childs']/div[2]"), "It looks as if there are unexpanded nodes
here");
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId +
":childs']/div[2]/div"), "It looks as if there are unexpanded nodes
here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId +
":childs']/div[2]/div"), "It looks as if there are unexpanded nodes
here");
+ }
+
@Override
public void sendAjax() {
AutoTester tester = getAutoTester(this);
@@ -481,4 +491,17 @@
return "pages/tree/treeAutoTest.xhtml";
}
+ /**
+ * Test an icon.
+ *
+ * @param location location of image representing icon to be tested
+ * @param iconName substring that icon uri has to contain
+ */
+ private void testIcon(String location, String iconSubstring) {
+ String iconSrc = selenium.getAttribute(location + "/@src");
+ if (null == iconSrc || !iconSrc.matches(".*" + iconSubstring +
".*")) {
+ Assert.fail("It looks as if the icon is not proper. Uri of icon is being
tested must contain [" + iconSubstring + "]");
+ }
+ }
+
}