[richfaces-svn-commits] JBoss Rich Faces SVN: r12285 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/tabPanel and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Thu Jan 15 09:38:41 EST 2009
Author: andrei_exadel
Date: 2009-01-15 09:38:41 -0500 (Thu, 15 Jan 2009)
New Revision: 12285
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/testDisabledTab.xhtml
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/TabPanelTest.java
Log:
RF-5548
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-15 14:34:23 UTC (rev 12284)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-01-15 14:38:41 UTC (rev 12285)
@@ -51,6 +51,8 @@
private String switchType = "server";
private String selectedTab = "tab1";
+
+ private boolean disabled;
private Map<String, String> inputs = new HashMap<String, String>();
@@ -69,6 +71,8 @@
content = "content";
selectedTab = "tab1";
immediate = false;
+ disabled = false;
+ inputs.clear();
}
public void initAjaxCoreTest() {
@@ -293,6 +297,20 @@
public void setImmediate(boolean immediate) {
this.immediate = immediate;
}
+
+ /**
+ * @return the disabled
+ */
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ /**
+ * @param disabled the disabled to set
+ */
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/testDisabledTab.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/testDisabledTab.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/testDisabledTab.xhtml 2009-01-15 14:38:41 UTC (rev 12285)
@@ -0,0 +1,46 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.template}">
+ <ui:define name="style">
+ .link {margin: 0px 5px}
+ </ui:define>
+ <ui:define name="component">
+ <h:form id="control">
+ <h:inputText id="selected" value="#{panelBean.selectedTab}"></h:inputText>
+ <h:commandButton id="apply" value="Apply"></h:commandButton>
+ </h:form>
+<h:form id="_form">
+ <rich:tabPanel id="panel1" switchType="ajax" selectedTab="#{panelBean.selectedTab}">
+ <rich:tab label="tab1"
+ id="tab1"
+ actionListener="#{panelBean.actionListener}"
+ switchType="server"
+ disabled="true"
+ >
+ <h:outputText value="Tab one" /><br/>
+ <h:inputText id="tab1_input" value="#{panelBean.inputs['tab1']}"></h:inputText>
+ </rich:tab>
+ <rich:tab label="tab2"
+ id="tab2"
+ actionListener="#{panelBean.actionListener}"
+ reRender="_value, _inputs"
+ disabled="true"
+ >
+ <h:outputText value="Tab two" />
+ <h:inputText id="tab2_input" value="#{panelBean.inputs['tab2']}"></h:inputText>
+ </rich:tab>
+ </rich:tabPanel><br/>
+
+ <h:outputText value="#{panelBean.value}" id="_value"></h:outputText><br/>
+ <h:outputText value="#{panelBean.inputs}" id="_inputs"></h:outputText><br/>
+ <h:commandLink id="submit" value="Submit"></h:commandLink><br/>
+
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
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-15 14:34:23 UTC (rev 12284)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-15 14:38:41 UTC (rev 12285)
@@ -1380,7 +1380,11 @@
StringBuffer b = new StringBuffer("document.getElementById('");
b.append(id);
b.append("').onclick");
- return runScript(b.toString());
+ String onclick = runScript(b.toString());
+ if (onclick != null && ("null".equals(onclick) || "undefined".equals(onclick))) {
+ onclick = null;
+ }
+ return onclick;
}
public String getHTMLById(String id) {
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-15 14:34:23 UTC (rev 12284)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java 2009-01-15 14:38:41 UTC (rev 12285)
@@ -29,9 +29,13 @@
import org.testng.Assert;
import org.testng.annotations.Test;
+import com.thoughtworks.selenium.SeleniumException;
+
public class TabPanelTest extends SeleniumTestBase {
private static final String FORM_ID = "_form:";
+
+ private static final String CONTROLS_FORM_ID = "control:";
private static final String RESET_METHOD = "#{panelBean.reset}";
@@ -42,8 +46,12 @@
private final static String INIT_IMMEDIATE_TEST_URL = "pages/tabPanel/immediateTabPanelTest.xhtml";
private final static String TAB_FACET_TEST_URL = "pages/tabPanel/tabFacetTest.xhtml";
+
+ private final static String DISABLED_TAB_URL = "pages/tabPanel/testDisabledTab.xhtml";
private static Map<String, String> params = new HashMap<String, String>();
+
+ private static final String [] DISABLED_TAB_CLASSES = new String [] { "dr-tbpnl-tb", "rich-tab-header", "dr-tbpnl-tb-dsbl", "rich-tab-disabled"};
static {
params.put("parameter1", "value1");
@@ -170,6 +178,68 @@
AssertNotPresent(tabId2);
AssertNotPresent(tabId4);
}
+
+ @Test
+ public void testDisabledTabs(Template template) {
+ renderPage(DISABLED_TAB_URL, template, RESET_METHOD);
+
+
+ String parentId = getParentId();
+ String selectedTabInputId = parentId + CONTROLS_FORM_ID + "selected";
+ String applyButtonId = parentId + CONTROLS_FORM_ID + "apply";
+ String submitButtonId = parentId + FORM_ID + "submit";
+ String tabId1 = parentId + FORM_ID + "tab1_lbl";
+ String tabId2 = parentId + FORM_ID + "tab2_lbl";
+ String tab1_shifted = parentId + FORM_ID + "tab1_shifted";
+ String tab2_shifted = parentId + FORM_ID + "tab2_shifted";
+ String _inputsId = parentId + FORM_ID + "_inputs";
+ String tabInputId = parentId + FORM_ID + "tab2_input";
+
+
+ // Check css classes for disabled tabs
+ assertClassNames(tabId1, DISABLED_TAB_CLASSES, "Tab1 has not been disabled", true);
+ String onclick = getElementOnclickAttr(tab1_shifted);
+ if (onclick != null) {
+ Assert.fail("Onclick should not be rendered for disabled tab. But was: " + onclick);
+ }
+
+ assertClassNames(tabId2, DISABLED_TAB_CLASSES, "Tab2 has not been disabled", true);
+ onclick = getElementOnclickAttr(tab2_shifted);
+ if (onclick != null) {
+ Assert.fail("Onclick should not be rendered for disabled tab. But was: " + onclick);
+ }
+
+ // Check that tab panel does not switch to disabled tab
+ boolean tabSwitched = true;
+
+ try {
+ clickById(tabId2);
+ waitForAjaxCompletion(3000);
+ }catch (SeleniumException e) {
+ tabSwitched = false;
+ }
+
+ if (tabSwitched) {
+ Assert.fail("Tab panel was switched to dislabled tab2");
+ }
+
+ // Check that disabled tabs can be switched on server side
+ AssertValueEquals(selectedTabInputId, "tab1", "First tab should be selected now");
+ AssertTextEquals(parentId + FORM_ID + "tab1", "Tab one", "Content of disabled tab has not been rendered");
+ setValueById(selectedTabInputId, "tab2");
+ clickCommandAndWait(applyButtonId);
+
+ AssertValueEquals(selectedTabInputId, "tab2", "The second tab should be selected now");
+ AssertTextEquals(parentId + FORM_ID + "tab2", "Tab two", "Content of disabled tab has not been rendered");
+
+
+ // Check that children inputs does not update the model in case of disabled tab
+ setValueById(tabInputId, "Some text");
+ clickCommandAndWait(submitButtonId);
+ AssertValueEquals(tabInputId, "", "Text for the inputs should not be applied to model in case of disabled tab");
+ AssertTextEquals(_inputsId, "{}", "Text for the inputs should not be applied to model in case of disabled tab");
+
+ }
private void testListener(String parentId) {
@@ -196,15 +266,13 @@
// Set input for the first tab
setValueById(tabId1 + "_input", "text1");
- clickById(tabId2 + "_lbl");
- waitForAjaxCompletion();
- checkDecodes(parentId, "text1", "", "");
+ clickAjaxCommandAndWait(tabId2 + "_lbl");
+ checkDecodes(parentId, "text1", null, null);
// Set input for the second and 4th tabs
setValueById(tabId2 + "_input", "text2");
setValueById(tabId4 + "_input", "text4");
- clickById(tabId1 + "_lbl");
- waitForPageToLoad();
+ clickCommandAndWait(tabId1 + "_lbl");
checkDecodes(parentId, "text1", "text2", "text4");
// Reset model. Swtich to tyhe first tab
@@ -215,7 +283,7 @@
setValueById(tabId4 + "_input", "text");
submit(parentId);
AssertVisible(tabId4, "Tab4 (client) should be kept as active after form submition");
- checkDecodes(parentId, "", "", "text");
+ checkDecodes(parentId, null, null, "text");
// Switch to 2nd tab
clickById(tabId2 + "_lbl");
@@ -223,7 +291,7 @@
setValueById(tabId4 + "_input", "text4");
setValueById(tabId2 + "_input", "text2");
ajaxSubmit(parentId);
- checkDecodes(parentId, "", "text2", "text4");
+ checkDecodes(parentId, null, "text2", "text4");
}
@@ -231,15 +299,15 @@
String inputsId = parentId + FORM_ID + "_inputs";
String inputs = getTextById(inputsId);
- if (!inputs.contains("tab1=" + input1)) {
+ if (input1 != null && !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)) {
+ if (input2 != null && !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)) {
+ if (input4 != null && !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");
}
More information about the richfaces-svn-commits
mailing list