Author: konstantin.mishin
Date: 2009-03-05 10:41:28 -0500 (Thu, 05 Mar 2009)
New Revision: 12843
Removed:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/include1.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/include2.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/include3.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/ajaxIncludeTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/step1.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/step2.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxIncludeTest.java
Log:
RF-6303
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java 2009-03-05
14:36:26 UTC (rev 12842)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java 2009-03-05
15:41:28 UTC (rev 12843)
@@ -20,135 +20,71 @@
*/
package org.ajax4jsf.bean;
+import javax.faces.component.UIComponent;
+
/**
* A4JInclude Test Bean
* @author Alexandr Levkovsky
*
*/
public class A4JIncludeTestBean {
+
+ private String layout;
- private Integer include1Counter = 0;
- private Integer include2Counter = 0;
- private Integer include3Counter = 0;
- private Boolean include3ChildRenderedFlag = true;
- private Boolean include4RenderedFlag = true;
- private String inputValue;
+ private Boolean keepTransient;
- /**
- * @return the inputValue
- */
- public String getInputValue() {
- return inputValue;
- }
+ private String text;
- /**
- * @param inputValue the inputValue to set
- */
- public void setInputValue(String inputValue) {
- this.inputValue = inputValue;
- }
+ private UIComponent binding;
+
+ public void init() {
+ layout = "inline";
+ text = "text";
+ keepTransient = true;
+ binding = null;
+ }
- /**
- * @return the include1Counter
- */
- public Integer getInclude1Counter() {
- return include1Counter;
- }
+ public String submit() {
+ return text;
+ }
- /**
- * @param include1Counter the include1Counter to set
- */
- public void setInclude1Counter(Integer include1Counter) {
- this.include1Counter = include1Counter;
- }
+ public void setTransient() {
+ binding.setTransient(true);
+ }
- /**
- * @return the include2Counter
- */
- public Integer getInclude2Counter() {
- return include2Counter;
- }
+ public void setText(String text) {
+ this.text = text;
+ }
- /**
- * @param include2Counter the include2Counter to set
- */
- public void setInclude2Counter(Integer include2Counter) {
- this.include2Counter = include2Counter;
- }
+ public String getText() {
+ return text;
+ }
- /**
- * @return the include3Counter
- */
- public Integer getInclude3Counter() {
- return include3Counter;
- }
+ public void setLayout(String layout) {
+ this.layout = layout;
+ }
- /**
- * @param include3Counter the include3Counter to set
- */
- public void setInclude3Counter(Integer include3Counter) {
- this.include3Counter = include3Counter;
- }
+ public String getLayout() {
+ return layout;
+ }
- /**
- * @return the include4RenderedFlag
- */
- public Boolean getInclude4RenderedFlag() {
- return include4RenderedFlag;
- }
+ public void setKeepTransient(Boolean keepTransient) {
+ this.keepTransient = keepTransient;
+ }
- /**
- * @param include4RenderedFlag the include4RenderedFlag to set
- */
- public void setInclude4RenderedFlag(Boolean include4RenderedFlag) {
- this.include4RenderedFlag = include4RenderedFlag;
- }
-
-
+ public Boolean getKeepTransient() {
+ return keepTransient;
+ }
- /**
- * @return the include3ChildRenderedFlag
- */
- public Boolean getInclude3ChildRenderedFlag() {
- return include3ChildRenderedFlag;
- }
+ public String getTransientState() {
+ return binding != null ? Boolean.toString(binding.isTransient()) : "";
+ }
- /**
- * @param include3ChildRenderedFlag the include3ChildRenderedFlag to set
- */
- public void setInclude3ChildRenderedFlag(Boolean include3ChildRenderedFlag) {
- this.include3ChildRenderedFlag = include3ChildRenderedFlag;
- }
+ public void setBinding(UIComponent binding) {
+ this.binding = binding;
+ }
- public String b1Action() {
- include2Counter++;
- return null;
- }
-
- public String b2Action() {
- include1Counter++;
- include2Counter++;
- return null;
- }
-
- public String b3Action() {
- include3Counter++;
- include3ChildRenderedFlag = false;
- return null;
- }
-
- public String b4Action() {
- setInclude4RenderedFlag(include4RenderedFlag ? false : true);
- return null;
- }
-
- public String reset() {
- include1Counter = 0;
- include2Counter = 0;
- include3Counter = 0;
- include3ChildRenderedFlag = true;
- include4RenderedFlag = true;
- return null;
- }
-
+ public UIComponent getBinding() {
+ return binding;
+ }
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/ajaxIncludeTest.xhtml
===================================================================
(Binary files differ)
Deleted:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/include1.xhtml
===================================================================
(Binary files differ)
Deleted:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/include2.xhtml
===================================================================
(Binary files differ)
Deleted:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/include3.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/step1.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxInclude/step2.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxIncludeTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxIncludeTest.java 2009-03-05
14:36:26 UTC (rev 12842)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxIncludeTest.java 2009-03-05
15:41:28 UTC (rev 12843)
@@ -20,7 +20,11 @@
*/
package org.richfaces.testng;
+import java.util.HashMap;
+import java.util.Map;
+
import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -32,129 +36,99 @@
*/
public class AjaxIncludeTest extends SeleniumTestBase {
- private final static String FORM1_ID = "form1:";
- private final static String FORM2_ID = "form2:";
- private final static String INCLUDE1_ID = "include1";
- private final static String INCLUDE2_ID = "include2";
- private final static String INCLUDE3_ID = "include3";
- private final static String INCLUDE4_ID = "include4";
-
- private final static String BUTTON4_ID = "b4";
-
- private final static String INPUT_ID = "input";
- private final static String OUTPUT_ID = "output";
-
- private final static String NEXT_BUTTON_ID = "next";
- private final static String PREVIOUS_BUTTON_ID = "previous";
-
- private final static String RESET_BUTTON_ID = "reset";
-
- private final static String STEP1_PANEL_ID = "step1_panel";
- private final static String STEP2_PANEL_ID = "step2_panel";
-
+ private String layout;
+
+ private String keepTransient;
+
+ private String mainForm;
+
+ private String include;
+
+ private String text;
+
+ private String transientState;
+
+ private String submit;
+
+ private String setTransient;
+
+ private void init(Template template) {
+ renderPage(null, template, "#{a4jIncludeBean.init}");
+ String attrForm = getParentId() + "attrForm";
+ layout = attrForm + ":layout";
+ keepTransient = attrForm + ":keepTransient";
+ mainForm = getParentId() + "mainForm";
+ include = mainForm + ":include";
+ text = include + ":text";
+ transientState = include + ":transientState";
+ submit = include + ":submit";
+ setTransient = mainForm + ":setTransient";
+ }
+
+ /**
+ * component is rendered together with page contents defined as viewId
+ */
+ @Test
+ public void testPresent(Template template) {
+ init(template);
+ Assert.assertTrue(selenium.isElementPresent(include));
+ Assert.assertTrue(selenium.isElementPresent(text));
+ }
+
+ /**
+ * transient components are kept when keepTransient = true
+ */
+ @Test
+ public void testKeepTransient(Template template) {
+ init(template);
+ Assert.assertEquals(selenium.getText(transientState), "false");
+ clickAjaxCommandAndWait(setTransient);
+ clickAjaxCommandAndWait(submit);
+ Assert.assertEquals(selenium.getText(transientState), "false");
+ clickAjaxCommandAndWait(keepTransient);
+ Assert.assertEquals(selenium.getText(transientState), "false");
+ clickAjaxCommandAndWait(setTransient);
+ clickAjaxCommandAndWait(submit);
+ Assert.assertEquals(selenium.getText(transientState), "true");
+ }
+
/**
- * @see org.richfaces.SeleniumTestBase#getTestUrl()
+ * component with rendered = false is not present on the page,
+ * style and classes, standard HTML attributes are output to client
*/
- @Override
- public String getTestUrl() {
- return "pages/ajaxInclude/ajaxIncludeTest.xhtml";
- }
+ //@Test
+ public void testStandardAttributes(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, null);
+ autoTester.testRendered();
+ Map<String, String> styleAttributes = new HashMap<String, String>();
+ styleAttributes.put("width", "100%");
+ styleAttributes.put("color", "yellow");
+ autoTester.testStyleAndClasses(new String[]{"noname"}, styleAttributes);
+ autoTester.testHTMLEvents();
+ }
- @Test
- public void testAjaxInclude(Template template) throws Exception {
- renderPage(template);
- String include1Prefix = getParentId() + FORM2_ID + INCLUDE4_ID + ":";
-
- AssertRendered(include1Prefix + STEP1_PANEL_ID);
- AssertNotRendered(include1Prefix + STEP2_PANEL_ID);
-
- String text = "1";
- type(include1Prefix + INPUT_ID, text);
- clickNext();
-
- AssertRendered(include1Prefix + STEP2_PANEL_ID);
- AssertNotRendered(include1Prefix + STEP1_PANEL_ID);
- AssertTextEquals(include1Prefix + OUTPUT_ID, text);
-
- clickPrevious();
-
- AssertRendered(include1Prefix + STEP1_PANEL_ID);
- AssertNotRendered(include1Prefix + STEP2_PANEL_ID);
- AssertValueEquals(include1Prefix + INPUT_ID, text);
-
+ @Test
+ public void testLayoutAttribute(Template template) {
+ init(template);
+ Assert.assertEquals(selenium.getAttribute("xpath=id('" + mainForm +
"')/span/span/input@id"), text);
+ selenium.type(layout, "block");
+ waitForAjaxCompletion();
+ Assert.assertEquals(selenium.getAttribute("xpath=id('" + mainForm +
"')/span/div/input@id"), text);
+ selenium.type(layout, "none");
+ waitForAjaxCompletion();
+ Assert.assertEquals(selenium.getAttribute("xpath=id('" + mainForm +
"')/span/input@id"), text);
+ }
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/ajaxInclude/ajaxIncludeAutoTest.xhtml";
+ }
+
+ @Override
+ public String getTestUrl() {
+ return "pages/ajaxInclude/ajaxIncludeTest.xhtml";
}
- @Test
- public void testLayoutAttribute(Template template) throws Exception {
- renderPage(template);
- // inlude_1 has layout=inline(default)
- // include_2 has layout=block
- // include_3 has layout=none
- writeStatus("Testing layout attribute...");
-
- String inlude1Id = getParentId() + FORM1_ID + INCLUDE1_ID;
- String inlude2Id = getParentId() + FORM1_ID + INCLUDE2_ID;
- String inlude3Id = getParentId() + FORM1_ID + INCLUDE3_ID;
-
- Assert.assertTrue(isPresentById(inlude1Id));
- Number type = selenium.getXpathCount("//*[@id='" + inlude1Id + "'
and (name()='span' or name()='SPAN')]");
- Assert.assertTrue(type.intValue() == 1, "panel_1 has layout=inline(default) and
should be 'span' element");
-
- Assert.assertTrue(isPresentById(inlude2Id));
- type = selenium.getXpathCount("//*[@id='" + inlude2Id + "' and
(name()='DIV' or name()='div')]");
- Assert.assertTrue(type.intValue() == 1, "panel_2 has layout=block and should be
'div' element");
-
- // panel_3 has layout=none and should not present if a child component
- // is rendered
- Assert.assertFalse(isPresentById(inlude3Id), "panel_3 has layout=none and should
not peresent if a child component is rendered ");
-
- // // remove child component rendering
- // writeStatus("Click button 3");
- // String buttonId = getParentId() + FORM1_ID + BUTTON3_ID;
- // clickById(buttonId);
- // waitForAjaxCompletion();
- //
- // // panel_3 has layout=none and should present if no child component is
- // // rendered with id of a child component and display:none style
- // Assert.assertTrue(isPresentById(inlude3Id + "_text"), "panel_3 has
layout=none and should peresent if no child component is rendered with id of a child
component");
- // Assert.assertFalse(isVisibleById(inlude3Id + "_text"), "panel_3 has
layout=none and should peresent if no child component is rendered with display:none
style");
- clickReset();
- }
-
- @Test
- public void testRenderedAttribute(Template template) throws Exception {
- renderPage(template);
- writeStatus("Testing rendered attribute...");
-
- String panelId = getParentId() + FORM2_ID + INCLUDE4_ID;
-
- // panel_4 has rendered=true and should present on page
- AssertRendered(panelId);
-
- // change rendered attribute to false
- writeStatus("Click button 4");
- String buttonId = getParentId() + FORM2_ID + BUTTON4_ID;
- clickCommandAndWait(buttonId);
-
- // panel_4 has rendered=false and should not present on page
- AssertNotRendered(panelId);
- clickReset();
- }
-
- private void clickNext() {
- String buttonId = getParentId() + FORM2_ID + INCLUDE4_ID + ":" +
NEXT_BUTTON_ID;
- clickAjaxCommandAndWait(buttonId);
- }
-
- private void clickPrevious() {
- String buttonId = getParentId() + FORM2_ID + INCLUDE4_ID + ":" +
PREVIOUS_BUTTON_ID;
- clickAjaxCommandAndWait(buttonId);
- }
-
- private void clickReset() {
- String buttonId = getParentId() + FORM1_ID + RESET_BUTTON_ID;
- writeStatus("Click reset button");
- clickCommandAndWait(buttonId);
- }
}
Show replies by date