[richfaces-svn-commits] JBoss Rich Faces SVN: r12342 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Jan 19 13:59:33 EST 2009


Author: dsvyatobatsko
Date: 2009-01-19 13:59:33 -0500 (Mon, 19 Jan 2009)
New Revision: 12342

Modified:
   trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
   trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
   trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TogglePanelTest.java
Log:
TogglePanel test fixed and refactored

Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java	2009-01-19 18:21:17 UTC (rev 12341)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java	2009-01-19 18:59:33 UTC (rev 12342)
@@ -24,11 +24,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
 import javax.faces.event.ActionEvent;
 
 public class RichPanelTestBean {
@@ -43,7 +38,7 @@
     private String itemAction;
 
     private boolean rendered;
-    
+
     private boolean immediate;
 
     private String content;
@@ -51,7 +46,7 @@
     private String switchType = "server";
 
     private String selectedTab = "tab1";
-    
+
     private boolean disabled;
 
     private Map<String, String> inputs = new HashMap<String, String>();
@@ -206,16 +201,16 @@
     public void itemActionNone() {
         setItemAction("NOT none");
     }
-    
+
     public String initImmediateTest() {
-    	reset();
+        reset();
         setImmediate(true);
         return null;
     }
-    
+
     public String initAjaxSingleTest() {
-    	reset();
-    	inputs = new HashMap<String, String>();   
+        reset();
+        inputs = new HashMap<String, String>();
         return null;
     }
 
@@ -227,6 +222,16 @@
         return null;
     }
 
+    public String action1() {
+        this.value2 = 1;
+        return null;
+    }
+
+    public String action2() {
+        this.value2 = 2;
+        return null;
+    }
+
     public void hide() {
         rendered = false;
     }
@@ -269,7 +274,7 @@
 
     /**
      * @param selectedTab
-     *            the selectedTab to set
+     *                the selectedTab to set
      */
     public void setSelectedTab(String selectedTab) {
         this.selectedTab = selectedTab;
@@ -284,40 +289,40 @@
 
     /**
      * @param inputs
-     *            the inputs to set
+     *                the inputs to set
      */
     public void setInputs(Map<String, String> inputs) {
         this.inputs = inputs;
     }
 
-	/**
-	 * @return the immediate
-	 */
-	public boolean isImmediate() {
-		return immediate;
-	}
+    /**
+     * @return the immediate
+     */
+    public boolean isImmediate() {
+        return immediate;
+    }
 
-	/**
-	 * @param immediate the immediate to set
-	 */
-	public void setImmediate(boolean immediate) {
-		this.immediate = immediate;
-	}
+    /**
+     * @param immediate
+     *                the immediate to set
+     */
+    public void setImmediate(boolean immediate) {
+        this.immediate = immediate;
+    }
 
-	/**
-	 * @return the disabled
-	 */
-	public boolean isDisabled() {
-		return disabled;
-	}
+    /**
+     * @return the disabled
+     */
+    public boolean isDisabled() {
+        return disabled;
+    }
 
-	/**
-	 * @param disabled the disabled to set
-	 */
-	public void setDisabled(boolean disabled) {
-		this.disabled = disabled;
-	}
-	
+    /**
+     * @param disabled
+     *                the disabled to set
+     */
+    public void setDisabled(boolean disabled) {
+        this.disabled = disabled;
+    }
 
-
 }

Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java	2009-01-19 18:21:17 UTC (rev 12341)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java	2009-01-19 18:59:33 UTC (rev 12342)
@@ -629,6 +629,17 @@
     }
 
     /**
+     * Asserts DOM node is present and visible
+     * 
+     * @param id -
+     *                DOM element id
+     */
+    public void AssertPresentAndVisible(String id, String message) {
+        AssertPresent(id, message);
+        AssertVisible(id, message);
+    }
+
+    /**
      * Asserts DOM node is not present
      * 
      * @param id -

Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TogglePanelTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TogglePanelTest.java	2009-01-19 18:21:17 UTC (rev 12341)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TogglePanelTest.java	2009-01-19 18:59:33 UTC (rev 12342)
@@ -22,17 +22,17 @@
 
 import org.ajax4jsf.template.Template;
 import org.richfaces.SeleniumTestBase;
-import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import com.thoughtworks.selenium.SeleniumException;
-
 public class TogglePanelTest extends SeleniumTestBase {
 
+    private static final String RESET_METHOD = "#{panelBean.cleanValues}";
+
     @Test
     public void testTogglePanelComponentAjaxMode(Template template) {
-        renderPage(template);
+        renderPage(template, RESET_METHOD);
 
+        //FIXME: https://jira.jboss.org/jira/browse/RF-5828
         String parentId = getParentId() + "_form:";
 
         String inputId = parentId + "_value";
@@ -45,51 +45,34 @@
         String oneFacet = parentId + "ajax_state_one";
         String twoFacet = parentId + "ajax_state_two";
 
-        reset();
-
+        writeStatus("Check ajax mode");
         writeStatus("Click on ajax controlNext");
         clickAjaxCommandAndWait(controlNext);
-        // pause(6000, "panel_ajax");
         AssertValueEquals(inputId, "ajax_next");
         AssertTextEquals(outputId, "1");
-        Assert.assertTrue(isVisibleById(twoFacet));
-        try {
-            getTextById(oneFacet);
-            Assert.fail("Both of 'one' and 'two' states were rendered for ajax toggle panel.");
-        } catch (SeleniumException se) {
+        AssertPresentAndVisible(twoFacet, "State 'one' has to give place to state 'two'");
+        AssertNotPresent(oneFacet, "Both of 'one' and 'two' states were rendered for ajax toggle panel.");
 
-        }
-
         writeStatus("Click on ajax controlOne");
-        clickById(controlOne);
-        waitForAjaxCompletion(5000);
+        clickAjaxCommandAndWait(controlOne);
         AssertValueEquals(inputId, "ajax_one");
         AssertTextEquals(outputId, "2");
-        Assert.assertTrue(isVisibleById(oneFacet));
-        try {
-            getTextById(twoFacet);
-            Assert.fail("Both of 'one' and 'two' states were rendered for ajax toggle panel.");
-        } catch (SeleniumException se) {
+        AssertPresentAndVisible(oneFacet, "State 'two' has to give place to state 'one'");
+        AssertNotPresent(twoFacet, "Both of 'one' and 'two' states were rendered for ajax toggle panel.");
 
-        }
-
         writeStatus("Click on ajax controlTwo");
-        clickById(controlTwo);
-        waitForAjaxCompletion(5000);
+        clickAjaxCommandAndWait(controlTwo);
         AssertValueEquals(inputId, "ajax_two");
         AssertTextEquals(outputId, "1");
-        Assert.assertTrue(isVisibleById(twoFacet));
-        try {
-            getTextById(oneFacet);
-            Assert.fail("Both of 'one' and 'two' states were rendered for ajax toggle panel.");
-        } catch (SeleniumException se) {
-        }
+        AssertPresentAndVisible(twoFacet, "State 'one' has to give place to state 'two'");
+        AssertNotPresent(oneFacet, "Both of 'one' and 'two' states were rendered for ajax toggle panel.");
     }
 
     @Test
     public void testTogglePanelComponentServerMode(Template template) {
-        renderPage(template);
+        renderPage(template, RESET_METHOD);
 
+        //FIXME: https://jira.jboss.org/jira/browse/RF-5828
         String parentId = getParentId() + "_form:";
 
         String inputId = parentId + "_value";
@@ -98,80 +81,64 @@
         String controlNext = parentId + "server_next";
         String controlOne = parentId + "server_one";
         String controlTwo = parentId + "server_two";
+
         String oneFacet = parentId + "server_state_one";
         String twoFacet = parentId + "server_state_two";
 
-        reset();
-
+        writeStatus("Check server mode");
         writeStatus("Click on controlNext");
         clickCommandAndWait(controlNext);
         AssertValueEquals(inputId, "server_next");
         AssertTextEquals(outputId, "1");
-        Assert.assertTrue(isVisibleById(twoFacet));
-        try {
-            getTextById(oneFacet);
-            Assert.fail("Both of 'one' and 'two' states were rendered for server toggle panel.");
-        } catch (SeleniumException se) {
+        AssertPresentAndVisible(twoFacet, "State 'one' has to give place to state 'two'");
+        AssertNotPresent(oneFacet, "Both of 'one' and 'two' states were rendered for server toggle panel.");
 
-        }
-
         writeStatus("Click on server controlOne");
         clickCommandAndWait(controlOne);
         AssertValueEquals(inputId, "server_one");
         AssertTextEquals(outputId, "2");
-        Assert.assertTrue(isVisibleById(oneFacet));
-        try {
-            getTextById(twoFacet);
-            Assert.fail("Both of 'one' and 'two' states were rendered for server toggle panel.");
-        } catch (SeleniumException se) {
+        AssertPresentAndVisible(oneFacet, "State 'two' has to give place to state 'one'");
+        AssertNotPresent(twoFacet, "Both of 'one' and 'two' states were rendered for server toggle panel.");
 
-        }
-
         writeStatus("Click on server controlTwo");
         clickCommandAndWait(controlTwo);
         AssertValueEquals(inputId, "server_two");
         AssertTextEquals(outputId, "3");
-        Assert.assertTrue(isVisibleById(twoFacet));
-        try {
-            getTextById(oneFacet);
-            Assert.fail("Both of 'one' and 'two' states were rendered for server toggle panel.");
-        } catch (SeleniumException se) {
-        }
+        AssertPresentAndVisible(twoFacet, "State 'one' has to give place to state 'two'");
+        AssertNotPresent(oneFacet, "Both of 'one' and 'two' states were rendered for server toggle panel.");
     }
 
     @Test
     public void testTogglePanelComponentClientMode(Template template) {
-        renderPage(template);
+        renderPage(template, RESET_METHOD);
 
         String parentId = getParentId() + "_form:";
 
         String controlNext = parentId + "client_next";
         String controlOne = parentId + "client_one";
         String controlTwo = parentId + "client_two";
+
         String oneFacet = parentId + "client_state_one";
         String twoFacet = parentId + "client_state_two";
 
+        writeStatus("Check client mode");
         writeStatus("Click on client controlNext");
         clickById(controlNext);
-        Assert.assertTrue(isVisibleById(twoFacet));
-        Assert.assertFalse(isVisibleById(oneFacet));
+        AssertVisible(twoFacet, "State 'one' has to give place to state 'two'");
+        AssertNotVisible(oneFacet, "Both of 'one' and 'two' states were rendered for client toggle panel.");
 
         writeStatus("Click on client controlOne");
         clickById(controlOne);
-        Assert.assertTrue(isVisibleById(oneFacet));
-        Assert.assertFalse(isVisibleById(twoFacet));
+        AssertVisible(oneFacet, "State 'two' has to give place to state 'one'");
+        AssertNotVisible(twoFacet, "Both of 'one' and 'two' states were rendered for client toggle panel.");
 
         writeStatus("Click on client controlTwo");
         clickById(controlTwo);
-        Assert.assertTrue(isVisibleById(twoFacet));
-        Assert.assertFalse(isVisibleById(oneFacet));
+        AssertVisible(twoFacet, "State 'one' has to give place to state 'two'");
+        AssertNotVisible(oneFacet, "Both of 'one' and 'two' states were rendered for client toggle panel.");
     }
 
-    private void reset() {
-        writeStatus("Clean bean values");
-        clickAjaxCommandAndWait(getParentId() + "_form:clean");
-    }
-
+    @Override
     public String getTestUrl() {
         return "pages/togglePanel/togglePanelTest.xhtml";
     }




More information about the richfaces-svn-commits mailing list