Author: andrei_exadel
Date: 2009-01-13 08:51:48 -0500 (Tue, 13 Jan 2009)
New Revision: 12254
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java
Log:
RF-5547
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-13
13:40:22 UTC (rev 12253)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-01-13
13:51:48 UTC (rev 12254)
@@ -21,193 +21,215 @@
package org.ajax4jsf.bean;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.faces.event.ActionEvent;
public class RichPanelTestBean {
- private String value;
+ private String value;
- private int value2;
+ private int value2;
- private Object panelValue;
+ private Object panelValue;
- private Object panelValue2;
+ private Object panelValue2;
- private String itemAction;
+ private String itemAction;
- private boolean rendered;
+ private boolean rendered;
- private String content;
+ private String content;
- private String switchType = "server";
-
- private String selectedTab;
+ private String switchType = "server";
- public RichPanelTestBean() {
- reset();
- }
-
- public void reset() {
- value = "";
- value2 = 0;
- rendered = true;
- content = "content";
- }
+ private String selectedTab = "tab1";
- /**
- * Gets value of switchType field.
- * @return value of switchType field
- */
- public String getSwitchType() {
- return switchType;
- }
+ private Map<String, String> inputs = new HashMap<String, String>();
- /**
- * Set a new value for switchType field.
- * @param switchType a new value for switchType field
- */
- public void setSwitchType(String switchType) {
- this.switchType = switchType;
- }
+ public RichPanelTestBean() {
+ value = "";
+ value2 = 0;
+ rendered = true;
+ content = "content";
+ }
- public String getValue() {
- return value;
- }
+ public void reset() {
+ value = "";
+ value2 = 0;
+ rendered = true;
+ content = "content";
+ selectedTab = "tab1";
+ }
- public void setValue(String value) {
- this.value = value;
- }
+ public void reset(ActionEvent event) {
+ reset();
+ }
- public int getValue2() {
- return value2;
- }
+ /**
+ * Gets value of switchType field.
+ *
+ * @return value of switchType field
+ */
+ public String getSwitchType() {
+ return switchType;
+ }
- public void setValue2(int value2) {
- this.value2 = value2;
- }
+ /**
+ * Set a new value for switchType field.
+ *
+ * @param switchType
+ * a new value for switchType field
+ */
+ public void setSwitchType(String switchType) {
+ this.switchType = switchType;
+ }
- public Object getPanelValue() {
- return panelValue;
- }
+ public String getValue() {
+ return value;
+ }
- public void setPanelValue(Object panelValue) {
- this.panelValue = panelValue;
- }
+ public void setValue(String value) {
+ this.value = value;
+ }
- public Object getPanelValue2() {
- return panelValue2;
- }
+ public int getValue2() {
+ return value2;
+ }
- public void setPanelValue2(Object panelValue2) {
- this.panelValue2 = panelValue2;
- }
+ public void setValue2(int value2) {
+ this.value2 = value2;
+ }
- /**
- * Gets value of content field.
- * @return value of content field
- */
- public String getContent() {
- return content;
- }
+ public Object getPanelValue() {
+ return panelValue;
+ }
- /**
- * Set a new value for content field.
- * @param content a new value for content field
- */
- public void setContent(String content) {
- this.content = content;
- }
+ public void setPanelValue(Object panelValue) {
+ this.panelValue = panelValue;
+ }
- /**
- * Gets value of itemAction field.
- *
- * @return value of itemAction field
- */
- public String getItemAction() {
- return itemAction;
- }
+ public Object getPanelValue2() {
+ return panelValue2;
+ }
- /**
- * Set a new value for itemAction field.
- *
- * @param itemAction
- * a new value for itemAction field
- */
- public void setItemAction(String itemAction) {
- this.itemAction = itemAction;
- }
+ public void setPanelValue2(Object panelValue2) {
+ this.panelValue2 = panelValue2;
+ }
- /**
- * Gets value of rendered field.
- * @return value of rendered field
- */
- public boolean isRendered() {
- return rendered;
- }
+ /**
+ * Gets value of content field.
+ *
+ * @return value of content field
+ */
+ public String getContent() {
+ return content;
+ }
- /**
- * Set a new value for rendered field.
- * @param rendered a new value for rendered field
- */
- public void setRendered(boolean rendered) {
- this.rendered = rendered;
- }
+ /**
+ * Set a new value for content field.
+ *
+ * @param content
+ * a new value for content field
+ */
+ public void setContent(String content) {
+ this.content = content;
+ }
- public void actionListener(ActionEvent event) {
- this.value = event.getComponent().getId();
- }
+ /**
+ * Gets value of itemAction field.
+ *
+ * @return value of itemAction field
+ */
+ public String getItemAction() {
+ return itemAction;
+ }
- public void itemActionServer() {
- setItemAction("server");
- }
+ /**
+ * Set a new value for itemAction field.
+ *
+ * @param itemAction
+ * a new value for itemAction field
+ */
+ public void setItemAction(String itemAction) {
+ this.itemAction = itemAction;
+ }
- public void itemActionAjax() {
- setItemAction("ajax");
- }
+ /**
+ * Gets value of rendered field.
+ *
+ * @return value of rendered field
+ */
+ public boolean isRendered() {
+ return rendered;
+ }
- public void itemActionNone() {
- setItemAction("NOT none");
- }
+ /**
+ * Set a new value for rendered field.
+ *
+ * @param rendered
+ * a new value for rendered field
+ */
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
- public String increment() {
- if (4 == this.value2) {
- this.value2 = 0;
- }
- this.value2++;
- return null;
- }
+ public void actionListener(ActionEvent event) {
+ this.value = event.getComponent().getId();
+ }
- public void hide() {
- rendered = false;
- }
-
- public void reset2Server() {
- cleanValues();
- content = "";
- switchType = "server";
- }
+ public void itemActionServer() {
+ setItemAction("server");
+ }
- public void reset2Ajax() {
- cleanValues();
- content = "";
- switchType = "ajax";
- }
+ public void itemActionAjax() {
+ setItemAction("ajax");
+ }
- public void reset2Client() {
- cleanValues();
- content = "";
- switchType = "client";
- }
+ public void itemActionNone() {
+ setItemAction("NOT none");
+ }
- public void cleanValues() {
- value = "";
- value2 = 0;
- panelValue = null;
- panelValue2 = null;
- itemAction = "";
- rendered = true;
- content = "content";
- }
+ public String increment() {
+ if (4 == this.value2) {
+ this.value2 = 0;
+ }
+ this.value2++;
+ return null;
+ }
+ public void hide() {
+ rendered = false;
+ }
+
+ public void reset2Server() {
+ cleanValues();
+ content = "";
+ switchType = "server";
+ }
+
+ public void reset2Ajax() {
+ cleanValues();
+ content = "";
+ switchType = "ajax";
+ }
+
+ public void reset2Client() {
+ cleanValues();
+ content = "";
+ switchType = "client";
+ }
+
+ public void cleanValues() {
+ value = "";
+ value2 = 0;
+ panelValue = null;
+ panelValue2 = null;
+ itemAction = "";
+ rendered = true;
+ content = "content";
+ }
+
/**
* @return the selectedTab
*/
@@ -216,11 +238,26 @@
}
/**
- * @param selectedTab the selectedTab to set
+ * @param selectedTab
+ * the selectedTab to set
*/
public void setSelectedTab(String selectedTab) {
this.selectedTab = selectedTab;
}
-
-
+
+ /**
+ * @return the inputs
+ */
+ public Map<String, String> getInputs() {
+ return inputs;
+ }
+
+ /**
+ * @param inputs
+ * the inputs to set
+ */
+ public void setInputs(Map<String, String> inputs) {
+ this.inputs = inputs;
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java 2009-01-13
13:40:22 UTC (rev 12253)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java 2009-01-13
13:51:48 UTC (rev 12254)
@@ -17,7 +17,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+ */
package org.richfaces.testng;
import org.ajax4jsf.template.Template;
@@ -28,52 +28,150 @@
import com.thoughtworks.selenium.SeleniumException;
public class TabPanelTest extends SeleniumTestBase {
+
+ static final String FORM_ID = "_form:";
- static final String RESET_METHOD = "#{panelBean.reset}";
+ static final String RESET_METHOD = "#{panelBean.reset}";
- @Test
- public void testRichTabPanelComponent(Template template) {
- renderPage(template, RESET_METHOD);
- String parentId = getParentId() + "_form:";
- String linkId = parentId + "tab2_lbl";
- String tabId1 = parentId + "tab1";
- String tabId2 = parentId + "tab2";
- String tabId4 = parentId + "tab4";
- String inputId = parentId + "_value";
- //String outputId = parentId + "_value2";
+ @Test
+ public void testRichTabPanelComponent(Template template) {
+ renderPage(template, RESET_METHOD);
+ String parentId = getParentId() + FORM_ID;
+ String linkId = parentId + "tab2_lbl";
+ String tabId1 = parentId + "tab1";
+ String tabId2 = parentId + "tab2";
+ String tabId4 = parentId + "tab4";
- writeStatus("Click on tab2");
- clickById(linkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "tab2");
- AssertTextEquals(tabId2, "Tab two");
- AssertVisible(tabId2);
- AssertNotVisible(tabId4);
-
- writeStatus("Click on tab1");
- linkId = parentId + "tab1_lbl";
- clickCommandAndWait(linkId);
- AssertValueEquals(inputId, "tab1");
- AssertTextEquals(tabId1, "Tab one");
- AssertVisible(tabId1);
- AssertNotVisible(tabId4);
-
- writeStatus("Click on tab3");
- linkId = parentId + "tab3_lbl";
- clickById(linkId);
- AssertValueEquals(inputId, "tab1");
- AssertVisible(tabId1);
+ writeStatus("Click on tab2");
+ clickById(linkId);
+ waitForAjaxCompletion();
+ AssertTextEquals(tabId2, "Tab two");
+ AssertVisible(tabId2);
+ AssertNotVisible(tabId4);
- writeStatus("Click on tab4");
- linkId = parentId + "tab4_lbl";
- clickById(linkId);
- AssertVisible(tabId4);
- AssertNotVisible(tabId1);
- }
+ writeStatus("Click on tab1");
+ linkId = parentId + "tab1_lbl";
+ clickCommandAndWait(linkId);
+ AssertTextEquals(tabId1, "Tab one");
+ AssertVisible(tabId1);
+ AssertNotVisible(tabId4);
- @Override
- public String getTestUrl() {
- return "pages/tabPanel/tabPanelTest.xhtml";
- }
+ writeStatus("Click on tab3");
+ linkId = parentId + "tab3_lbl";
+ clickById(linkId);
+ AssertVisible(tabId1);
+ writeStatus("Click on tab4");
+ linkId = parentId + "tab4_lbl";
+ clickById(linkId);
+ AssertVisible(tabId4);
+ AssertNotVisible(tabId1);
+ }
+
+ @Test
+ public void testSubmissionModesAndListeners(Template template) {
+ renderPage(template, RESET_METHOD);
+
+ String parentId = getParentId();
+
+ testListener(parentId);
+ testSubmissionModes(parentId);
+
+ }
+
+ private void testListener (String parentId) {
+
+ String linkId = parentId + FORM_ID + "tab2_lbl";
+ String inputId = parentId + FORM_ID + "_value";
+
+ writeStatus("Click on tab2");
+ clickById(linkId);
+ waitForAjaxCompletion();
+ AssertTextEquals(inputId, "tab2", "Listener for the second tab [ajax
mode] has not been called");
+
+ writeStatus("Click on tab1");
+ linkId = parentId + FORM_ID + "tab1_lbl";
+ clickCommandAndWait(linkId);
+ AssertTextEquals(inputId, "tab1", "Listener for the first tab [server
mode] has not been called");
+ }
+
+
+ private void testSubmissionModes(String parentId) {
+ String tabId1 = parentId + FORM_ID + "tab1";
+ String tabId2 = parentId + FORM_ID + "tab2";
+ String tabId4 = parentId + FORM_ID + "tab4";
+
+ reset(parentId);
+
+ // Set input for the first tab
+ setValueById(tabId1 + "_input", "text1");
+ clickById(tabId2 + "_lbl");
+ waitForAjaxCompletion();
+ checkDecodes(parentId, "text1", "", "");
+
+
+ // Set input for the second and 4th tabs
+ setValueById(tabId2 + "_input", "text2");
+ setValueById(tabId4 + "_input", "text4");
+ clickById(tabId1 + "_lbl");
+ waitForPageToLoad();
+ checkDecodes(parentId, "text1", "text2", "text4");
+
+ // Reset model. Swtich to tyhe first tab
+ reset(parentId);
+
+ // Switch to 4th tab
+ clickById(tabId4 + "_lbl");
+ setValueById(tabId4 + "_input", "text");
+ submit(parentId);
+ AssertVisible(tabId4, "Tab4 (client) should be kept as active after form
submition");
+ checkDecodes(parentId, "", "", "text");
+
+
+ // Switch to 2nd tab
+ clickById(tabId2 + "_lbl");
+ waitForAjaxCompletion();
+ setValueById(tabId4 + "_input", "text4");
+ setValueById(tabId2 + "_input", "text2");
+ ajaxSubmit(parentId);
+ checkDecodes(parentId, "", "text2", "text4");
+
+
+ }
+
+ private void checkDecodes(String parentId, String input1, String input2, String input4)
{
+ String inputsId = parentId + FORM_ID + "_inputs";
+ String inputs = getTextById(inputsId);
+
+ if (!inputs.contains("tab1=" + input1)) {
+ Assert.fail("Decode or update model for the first tab processed incorrect. The
model should contain ['"+input1+"'] value submitted from the
tab");
+ }
+ if (!inputs.contains("tab2=" + input2)) {
+ Assert.fail("Decode or update model for the second tab processed incorrect. The
model should contain ['"+input2+"'] value submitted from the
tab");
+ }
+ if (!inputs.contains("tab4=" + input4)) {
+ Assert.fail("Decode or update model for the 4th tab processed incorrect. The
model should contain ['"+input4+"'] value submitted from the
tab");
+ }
+ }
+
+ private void submit(String parentId) {
+ String commandId = parentId + FORM_ID + "submit";
+ clickCommandAndWait(commandId);
+ }
+
+ private void ajaxSubmit(String parentId) {
+ String commandId = parentId + FORM_ID + "ajaxSubmit";
+ clickAjaxCommandAndWait(commandId);
+ }
+
+ private void reset(String parentId) {
+ String commandId = parentId + "controls:reset";
+ clickCommandAndWait(commandId);
+ }
+
+ @Override
+ public String getTestUrl() {
+ return "pages/tabPanel/tabPanelTest.xhtml";
+ }
+
}