Author: alevkovsky
Date: 2008-06-27 10:02:32 -0400 (Fri, 27 Jun 2008)
New Revision: 9278
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxInclude/ajaxIncludeTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxIncludeTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
Log:
Add a4j:include selenium test
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java 2008-06-27
14:02:32 UTC (rev 9278)
@@ -0,0 +1,140 @@
+/*
+ * A4JIncludeTestBean.java Date created: 26.06.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.ajax4jsf.bean;
+
+/**
+ * TODO Class description goes here.
+ * @author Alexandr Levkovsky
+ *
+ */
+public class A4JIncludeTestBean {
+
+ private Integer include1Counter = 0;
+ private Integer include2Counter = 0;
+ private Integer include3Counter = 0;
+ private Boolean include3ChildRenderedFlag = true;
+ private Boolean include4RenderedFlag = true;
+ private String inputValue;
+
+ /**
+ * @return the inputValue
+ */
+ public String getInputValue() {
+ return inputValue;
+ }
+
+ /**
+ * @param inputValue the inputValue to set
+ */
+ public void setInputValue(String inputValue) {
+ this.inputValue = inputValue;
+ }
+
+ /**
+ * @return the include1Counter
+ */
+ public Integer getInclude1Counter() {
+ return include1Counter;
+ }
+
+ /**
+ * @param include1Counter the include1Counter to set
+ */
+ public void setInclude1Counter(Integer include1Counter) {
+ this.include1Counter = include1Counter;
+ }
+
+ /**
+ * @return the include2Counter
+ */
+ public Integer getInclude2Counter() {
+ return include2Counter;
+ }
+
+ /**
+ * @param include2Counter the include2Counter to set
+ */
+ public void setInclude2Counter(Integer include2Counter) {
+ this.include2Counter = include2Counter;
+ }
+
+ /**
+ * @return the include3Counter
+ */
+ public Integer getInclude3Counter() {
+ return include3Counter;
+ }
+
+ /**
+ * @param include3Counter the include3Counter to set
+ */
+ public void setInclude3Counter(Integer include3Counter) {
+ this.include3Counter = include3Counter;
+ }
+
+ /**
+ * @return the include4RenderedFlag
+ */
+ public Boolean getInclude4RenderedFlag() {
+ return include4RenderedFlag;
+ }
+
+ /**
+ * @param include4RenderedFlag the include4RenderedFlag to set
+ */
+ public void setInclude4RenderedFlag(Boolean include4RenderedFlag) {
+ this.include4RenderedFlag = include4RenderedFlag;
+ }
+
+
+
+ /**
+ * @return the include3ChildRenderedFlag
+ */
+ public Boolean getInclude3ChildRenderedFlag() {
+ return include3ChildRenderedFlag;
+ }
+
+ /**
+ * @param include3ChildRenderedFlag the include3ChildRenderedFlag to set
+ */
+ public void setInclude3ChildRenderedFlag(Boolean include3ChildRenderedFlag) {
+ this.include3ChildRenderedFlag = include3ChildRenderedFlag;
+ }
+
+ 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;
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JIncludeTestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java 2008-06-27
14:00:51 UTC (rev 9277)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java 2008-06-27
14:02:32 UTC (rev 9278)
@@ -24,18 +24,21 @@
public Boolean getPanel1VisibleFlag() {
return panel1VisibleFlag;
}
+
/**
* @param panel1VisibleFlag the panel1VisibleFlag to set
*/
public void setPanel1VisibleFlag(Boolean panel1VisibleFlag) {
this.panel1VisibleFlag = panel1VisibleFlag;
}
+
/**
* @return the panel2VisibleFlag
*/
public Boolean getPanel2VisibleFlag() {
return panel2VisibleFlag;
}
+
/**
* @param panel2VisibleFlag the panel2VisibleFlag to set
*/
Modified: trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-06-27
14:00:51 UTC (rev 9277)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-06-27
14:02:32 UTC (rev 9278)
@@ -136,6 +136,11 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>a4jIncludeBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.A4JIncludeTestBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>calendarBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.CalendarTestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
@@ -160,4 +165,19 @@
<managed-bean-class>org.ajax4jsf.bean.A4JSupport</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
+
+ <navigation-rule>
+ <from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>next</from-outcome>
+ <to-view-id>/pages/ajaxInclude/step2.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ <navigation-rule>
+ <from-view-id>/pages/ajaxInclude/step2.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>previous</from-outcome>
+ <to-view-id>/pages/ajaxInclude/step1.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxInclude/ajaxIncludeTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxInclude/ajaxIncludeTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxIncludeTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxIncludeTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxIncludeTest.java 2008-06-27
14:02:32 UTC (rev 9278)
@@ -0,0 +1,146 @@
+/*
+ * AjaxIncludeTest.java Date created: 26.06.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * ajaxInclude component sselenium test
+ * @author Alexandr Levkovsky
+ *
+ */
+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";
+
+ /**
+ * @see org.richfaces.SeleniumTestBase#getTestUrl()
+ */
+ @Override
+ public String getTestUrl() {
+ return "pages/ajaxInclude/ajaxIncludeTest.xhtml";
+ }
+
+ @Test(dataProvider = "templates")
+ 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(dataProvider = "templates")
+ 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(dataProvider = "templates")
+ 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);
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxIncludeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Show replies by date