Author: andrei_exadel
Date: 2008-10-01 07:06:44 -0400 (Wed, 01 Oct 2008)
New Revision: 10637
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/controlLayout.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/layout.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ModalPanelTest.java
Log:
Add reset method invoking during component rendering
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java 2008-10-01
10:13:41 UTC (rev 10636)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java 2008-10-01
11:06:44 UTC (rev 10637)
@@ -80,13 +80,14 @@
}
public String reset(){
- rendered = true;
- showWhenRendered = false;
- moveable = true;
- resizeable = true;
- input = null;
- return null;
+ rendered = true;
+ showWhenRendered = false;
+ moveable = true;
+ resizeable = true;
+ input = null;
+ return null;
}
+
/**
* @return the input
*/
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java 2008-10-01
10:13:41 UTC (rev 10636)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java 2008-10-01
11:06:44 UTC (rev 10637)
@@ -24,22 +24,26 @@
import java.util.ArrayList;
import java.util.List;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import org.ajax4jsf.template.Template;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public class TemplateBean {
+
+ private static final Log log = LogFactory.getLog(TemplateBean.class);
+
public static final String PARAM_NAME = "t";
-
+
private Template template = Template.SIMPLE;
+
+ private String methodName;
- /*
- * public void initTemplate (ActionEvent event) { Map<String, String>
- * reqMap =
- * FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
- * String template = reqMap.get(PARAM_NAME); this.template = template !=
- * null ? template : "simple"; }
- */
public String getTemplateId() {
return template.toString();
@@ -76,5 +80,47 @@
return retVal;
}
+
+ /**
+ * Invokes reset method of appropriate backing bean
+ * @param actionEvent
+ */
+ public void reset(ActionEvent actionEvent) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context != null) {
+ if (methodName != null && methodName.trim().length() > 0) {
+ try {
+ ExpressionFactory factory = context.getApplication()
+ .getExpressionFactory();
+ if (factory != null) {
+ MethodExpression methodExpression = factory
+ .createMethodExpression(context.getELContext(),
+ methodName, Void.class, new Class[] {});
+ methodExpression.invoke(context.getELContext(),
+ new Object[] {});
+ }
+ } catch (Exception e) {
+ log.error(
+ "Reset method has not been found by this expression: "
+ + methodName, e);
+ }
+ }
+ }
+ }
+
+ /**
+ * @return the methodName
+ */
+ public String getMethodName() {
+ return methodName;
+ }
+
+ /**
+ * @param methodName the methodName to set
+ */
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
}
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/controlLayout.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/layout.xhtml
===================================================================
(Binary files differ)
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 2008-10-01
10:13:41 UTC (rev 10636)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-10-01
11:06:44 UTC (rev 10637)
@@ -190,7 +190,29 @@
checkJSError();
}
+
+ /**
+ * Renders page
+ */
+ protected void renderPage(Template template, String resetMethodName) {
+ selenium.open(protocol + "://" + host + ":" + port +
"/" + APPLICATION_NAME + filterPrefix + getTestUrl());
+ selenium.waitForPageToLoad(String.valueOf(pageRenderTime));
+ setParentId(template.getPrefix());
+ runScript("loadTemplate('" + template + "');",
false);
+ waitForPageToLoad();
+
+ checkPageRendering(); // At the first we check if page has been
+ // rendered
+ checkJSError(); // At the second we check if JS errors occurred
+
+ reRenderForm(resetMethodName); // ReRender component
+
+ checkPageRendering(); // Check all again
+ checkJSError();
+
+ }
+
/**
* Writes status message on client side
*
@@ -225,6 +247,14 @@
// clickById("_Selenium_Test_ReRender_Form:_reRender");
waitForAjaxCompletion(3000);
}
+
+ /**
+ * ReRenders the component
+ */
+ private void reRenderForm(String resetMethodName) {
+
selenium.getEval("selenium.browserbot.getCurrentWindow().reRenderAll('"+resetMethodName+"');");
+ waitForAjaxCompletion(3000);
+ }
/**
* Performs script defined in parameter
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ModalPanelTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ModalPanelTest.java 2008-10-01
10:13:41 UTC (rev 10636)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ModalPanelTest.java 2008-10-01
11:06:44 UTC (rev 10637)
@@ -20,6 +20,7 @@
private final static String PANEL_ID="test_panel";
private final static String FORM_ID="form:";
+ private final static String FORM2_ID="_f:";
private final static String RESET_ID="reset";
private final static String CHANGE_RENDERED_ID="change_rendered";
private final static String CHANGE_ATTRIBUTES_ID="change_attributes";
@@ -30,7 +31,9 @@
private final static String PANEL_CONTAINER_DIV_ID = PANEL_ID +
"Container";
private final static String PANEL_HEADER_ID = PANEL_ID + "Header";
+ private final static String RESET_METHOD_NAME = "#{modalPanelBean.reset}";
+
/**
* @see org.richfaces.SeleniumTestBase#getTestUrl()
*/
@@ -41,10 +44,10 @@
@Test
public void testModalPanel(Template template) throws Exception {
- renderPage(template);
+ renderPage(template, RESET_METHOD_NAME);
writeStatus("Testing modal panel");
- String panelId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
+ String panelId = getParentId() + PANEL_CONTAINER_DIV_ID;
AssertPresent(panelId);
AssertNotVisible(panelId);
@@ -63,25 +66,25 @@
@Test
public void testRenderedAttribute(Template template) throws Exception {
- renderPage(template);
+ renderPage(template, RESET_METHOD_NAME);
writeStatus("Testing rendered attribute");
- String panelId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
+ String panelId = getParentId() + PANEL_CONTAINER_DIV_ID;
AssertPresent(panelId);
clickChangeRendered();
AssertNotPresent(panelId);
- clickReset();
+
}
@Test
public void testShowWhenRenderedAttribute(Template template) throws Exception {
- renderPage(template);
+ renderPage(template, RESET_METHOD_NAME);
writeStatus("Testing showWhenRendered attribute");
- String panelId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
+ String panelId = getParentId() + PANEL_CONTAINER_DIV_ID;
AssertPresent(panelId);
AssertNotVisible(panelId);
@@ -90,19 +93,18 @@
AssertPresent(panelId);
AssertVisible(panelId);
- clickReset();
}
@Test
public void testLayoutAttributes(Template template) throws Exception {
- renderPage(template);
+ renderPage(template, RESET_METHOD_NAME);
writeStatus("Testing layout attribute");
clickShow();
- String panelContainerId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
- String panelContentId = getParentId() + FORM_ID + PANEL_CONTENT_DIV_ID;
- String panelCDivId = getParentId() + FORM_ID + PANEL_C_DIV_ID;
+ String panelContainerId = getParentId() + PANEL_CONTAINER_DIV_ID;
+ String panelContentId = getParentId() + PANEL_CONTENT_DIV_ID;
+ String panelCDivId = getParentId() + PANEL_C_DIV_ID;
AssertPresent(panelContainerId);
AssertPresent(panelContentId);
@@ -128,12 +130,12 @@
@Test
public void testDragByHeader(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD_NAME);
clickShow();
- String headerId = getParentId() + FORM_ID + PANEL_HEADER_ID;
- String cIdvId = getParentId() + FORM_ID + PANEL_C_DIV_ID;
+ String headerId = getParentId() + PANEL_HEADER_ID;
+ String cIdvId = getParentId() + PANEL_C_DIV_ID;
Integer left = (Integer)getLeftById(cIdvId);
Integer top = (Integer)getTopById(cIdvId);
@@ -152,12 +154,12 @@
@Test
public void testMinWidthAndMinHeight(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD_NAME);
clickShow();
- String resizerId = getParentId() + FORM_ID + PANEL_ID + "ResizerSEL";
- String contentId = getParentId() + FORM_ID + PANEL_CONTENT_DIV_ID;
+ String resizerId = getParentId() + PANEL_ID + "ResizerSEL";
+ String contentId = getParentId() + PANEL_CONTENT_DIV_ID;
selenium.dragAndDrop(resizerId, "-100,-100");
@@ -169,6 +171,31 @@
}
+ @Test
+ public void testNestedInputAndCommand(Template template) {
+ renderPage(template, RESET_METHOD_NAME);
+
+ final String VALUE = "69";
+
+ clickShow();
+
+ String inputId = getParentId() + FORM2_ID + "input";
+ String commandId = getParentId() + FORM2_ID + "submit";
+
+ AssertPresent(inputId);
+ AssertPresent(commandId);
+
+ setValueById(inputId, VALUE);
+
+ clickCommandAndWait(commandId);
+ clickShow();
+
+ AssertPresent(inputId);
+ AssertPresent(commandId);
+ AssertValueEquals(inputId, VALUE, "Input value does not equal to correct
");
+
+ }
+
private String getWidth(String id) {
String w = runScript("$('"+id+"').style.width", false);
@@ -205,7 +232,7 @@
}
private void clickHide() {
- String buttonId = getParentId() + FORM_ID + HIDE_ID;
+ String buttonId = getParentId() + FORM2_ID + HIDE_ID;
writeStatus("Click hide button");
clickById(buttonId);
}