Author: andrei_exadel
Date: 2008-04-28 08:12:21 -0400 (Mon, 28 Apr 2008)
New Revision: 8226
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TestListener.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/test/
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/test/ProgressBarTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ProgressBarTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonTest.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandLink/ajaxLinkTest.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/progressBar/progressBarTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/Templates.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandButtonTest.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandLinkTest.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java
Log:
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -6,17 +6,16 @@
public class A4JCommandTestBean {
- private Integer value = 0;
+ private String value = "1";
private String param;
-
public void actionListener(ActionEvent event) {
- this.value++;
+ this.value = this.value + "3";
}
public String action () {
- this.value++;
+ this.value = this.value + "4";
return null;
}
@@ -27,15 +26,15 @@
/**
* @return the value
*/
- public Integer getValue() {
+ public String getValue() {
return value;
}
/**
* @param value the value to set
*/
- public void setValue(Integer value) {
- value++;
+ public void setValue(String value) {
+ value = value + "2";
this.value = value;
}
@@ -53,4 +52,4 @@
this.param = param;
}
-}
+}
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ProgressBarTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ProgressBarTestBean.java 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ProgressBarTestBean.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -2,6 +2,8 @@
import java.util.Date;
+import javax.faces.event.ActionEvent;
+
public class ProgressBarTestBean {
private boolean enabled = false;
@@ -15,6 +17,14 @@
public String getCompleteDate() {
return String.valueOf(new Date().getTime());
}
+
+ public void reset(ActionEvent event) {
+ this.value = -5L;
+ }
+
+ public void complete(ActionEvent event) {
+ this.value = 120L;
+ }
/**
* @return the enabled
Added: trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TestListener.java
===================================================================
--- trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TestListener.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TestListener.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -0,0 +1,30 @@
+package org.ajax4jsf;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.event.AjaxListener;
+
+public class TestListener implements AjaxListener {
+
+ public void processAjax(AjaxEvent event) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ ExternalContext etx = context.getExternalContext();
+ Map<String, String> requestParams = etx.getRequestParameterMap();
+ String Id = requestParams.get("_ID");
+ UIComponent component = event.getComponent().findComponent(Id);
+ if (component instanceof UIInput) {
+ UIInput i = (UIInput)component;
+ String v = (String)i.getValue();
+ i.setValue(v + "5");
+ }
+
+
+ }
+
+}
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-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-04-28
12:12:21 UTC (rev 8226)
@@ -31,6 +31,7 @@
<managed-bean-class>org.ajax4jsf.A4JCommandTestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
+
<managed-bean>
<managed-bean-name>progressBarBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.ProgressBarTestBean</managed-bean-class>
Modified: trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml 2008-04-28
11:46:08 UTC (rev 8225)
+++ trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml 2008-04-28
12:12:21 UTC (rev 8226)
@@ -32,9 +32,14 @@
}
function loadTemplate (name) {
- document.getElementById('_Selenium_Test_ReRender_Form:_Selenium_Template_' +
name).onclick();
+ document.getElementById('_Selenium_Template_Name').value = name;
+ document.getElementById('_Selenium_Test_ReRender_Form:_Selenium_Template_Setup').onclick();
return;
}
+
+ function writeStatus (mess) {
+ document.getElementById('_Selenium_Test_Status_Message').value = mess;
+ }
</script>
<style type="text/css">
<ui:insert name="style"/>
@@ -45,27 +50,26 @@
<div style="padding: 10px; font-size: 24px;">Rich faces component testing
by Selenium</div><br/>
<h:form id="_Selenium_Test_ReRender_Form">
- <table border="0" cellpadding="5" cellspacing="0">
+<input type="hidden" name="t" value=""
id="_Selenium_Template_Name" />
+ <table border="0" cellpadding="5" cellspacing="0"
style="display: none">
<tr>
<td colspan="2">
- <a4j:commandLink reRender="_Selenium_Test_Common_Grid"
style="" value="ReRenderAll" id="_reRender">
+ <a4j:commandLink reRender="_Selenium_Test_Common_Grid"
value="ReRenderAll" id="_reRender">
</a4j:commandLink>
- <h:commandLink value="setTemplate" style=""
id="_Selenium_Template_DataTable"
actionListener="#{templateBean.initTemplate}">
- <f:param name="t" value="dataTable"/>
- </h:commandLink>
- <h:commandLink value="setTemplate" style=""
id="_Selenium_Template_Simple"
actionListener="#{templateBean.initTemplate}">
- <f:param name="t" value="simple"/>
- </h:commandLink>
- <h:commandLink value="setTemplate" style=""
id="_Selenium_Template_ModalPanel"
actionListener="#{templateBean.initTemplate}">
- <f:param name="t" value="modalPanel"/>
- </h:commandLink>
+ <h:commandLink value="setTemplate" style=""
id="_Selenium_Template_Setup"
actionListener="#{templateBean.initTemplate}" />
</td>
</tr>
</table>
</h:form>
<div id="_Selenium_Test_ControlPoint1" style="display:
none;">Control1</div>
<h:panelGrid id="_Selenium_Test_Common_Grid">
+ <div>
+ <b>Status: </b> <input style="border: 0px; color: black"
id="_Selenium_Test_Status_Message" />
+ </div>
+ <br/>
+ <div>
<ui:insert name="template"/>
+ </div>
</h:panelGrid>
<script type="text/javascript">
window.done=false; A4J.AJAX.AddListener(new
A4J.AJAX.Listener(function(){window.done=true;}));
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonTest.xhtml 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonTest.xhtml 2008-04-28
12:12:21 UTC (rev 8226)
@@ -15,6 +15,8 @@
actionListener="#{commandBean.actionListener}"
reRender="_value"
value="Button1">
+ <a4j:ajaxListener
type="org.ajax4jsf.TestListener"></a4j:ajaxListener>
+ <f:param name="_ID" value="_value" />
</a4j:commandButton>
<a4j:commandButton
@@ -24,8 +26,10 @@
immediate="true"
reRender="_value"
value="Button2">
+ <a4j:ajaxListener
type="org.ajax4jsf.TestListener"></a4j:ajaxListener>
+ <f:param name="_ID" value="_value" />
</a4j:commandButton>
-
+
<a4j:commandButton
id="b3"
action="#{commandBean.action}"
@@ -41,6 +45,8 @@
ajaxSingle="true"
reRender="_value"
value="Button4">
+ <a4j:ajaxListener
type="org.ajax4jsf.TestListener"></a4j:ajaxListener>
+ <f:param name="_ID" value="_value" />
</a4j:commandButton>
<a4j:commandButton
@@ -54,8 +60,8 @@
<br/>
<h:inputText value="#{commandBean.value}"
id="_value"></h:inputText>
+ </h:form>
<br/>
- </h:form>
</ui:define>
<ui:define name="description">
<ui:include src="ajaxButtonDescription.xhtml" />
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandLink/ajaxLinkTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/progressBar/progressBarTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/progressBar/progressBarTest.xhtml 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/progressBar/progressBarTest.xhtml 2008-04-28
12:12:21 UTC (rev 8226)
@@ -28,6 +28,8 @@
</f:facet>
<h:outputText value="{value}%"></h:outputText>
</rich:progressBar> <br/>
+ <a4j:commandButton id="_reset"
actionListener="#{progressBarBean.reset}" value="Reset
value"></a4j:commandButton><br/>
+ <a4j:commandButton id="_complete" reRender="progressBar1"
actionListener="#{progressBarBean.complete}"
value="Complete"></a4j:commandButton>
</h:form>
</ui:define>
<ui:define name="description">
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -115,9 +115,7 @@
selenium.open(protocol + "://" + host + ":" + port +
"/" + APPLICATION_NAME + homePage);
selenium.waitForPageToLoad(String.valueOf(pageRenderTime));
- if (!template.equals(Templates.SIMPLE)) {
- template.loadTemplate(this);
- }
+ template.loadTemplate(this);
checkPageRendering(); // At the first we check if page has been
// rendered
@@ -130,27 +128,18 @@
}
+ /**
+ * Writes status message on client side
+ * @param message
+ */
+ public void writeStatus(String message) {
+ StringBuffer buffer = new StringBuffer("writeStatus('");
+ buffer.append(message);
+ buffer.append("')");
+ runScript(buffer.toString());
+ }
-// /**
-// * Return component id inside Data table
-// *
-// * @param id
-// * @return
-// */
-// public String getComponentIdInsideTable(String id) {
-// return COMPONENT_PREFIX_INSIDE_TABLE + id;
-// }
-// /**
-// * Return component id inside Panel
-// *
-// * @param id
-// * @return
-// */
-// public String getComponentIdInsidePanel(String id) {
-// return COMPONENT_PREFIX_SIMPLE + id;
-// }
-
/**
* ReRenders the component
*/
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/Templates.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/Templates.java 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/Templates.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -1,6 +1,8 @@
package org.ajax4jsf.test.base;
+import sun.java2d.pipe.SpanShapeRenderer.Simple;
+
public class Templates {
public static final String COMPONENT_PREFIX_INSIDE_TABLE =
"_Selenium_Test_DataTable:0:";
@@ -29,8 +31,10 @@
public void loadTemplate(SeleniumTestBase test) {
setParentId(test);
- test.runScript("loadTemplate('" + template + "');",
false);
- test.waitForPageToLoad();
+ if (!this.equals(SIMPLE)) {
+ test.runScript("loadTemplate('" + template + "');",
false);
+ test.waitForPageToLoad();
+ }
}
public boolean equals(Object obj) {
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandButtonTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandButtonTest.java 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandButtonTest.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -34,6 +34,7 @@
@Test
public void testAjaxCommandButtonComponent() throws Exception {
+ _testAjaxCommandButtonComponent(Templates.SIMPLE);
_testAjaxCommandButtonComponent(Templates.DATATABLE);
}
@@ -45,49 +46,44 @@
String buttonId = parentId + "b1";
String inputId = parentId + "_value";
+ writeStatus("Click button 1 : ");
clickById(buttonId);
waitForAjaxCompletion();
- AssertValueEquals(inputId, "3");
+ AssertValueEquals(inputId, "12345");
+ writeStatus("Click button 1 again: ");
clickById(buttonId);
waitForAjaxCompletion();
- AssertValueEquals(inputId, "6");
+ AssertValueEquals(inputId, "123452345");
buttonId = parentId + "b2";
+ writeStatus("Click button 2: ");
clickById(buttonId);
waitForAjaxCompletion();
- AssertValueEquals(inputId, "6");
+ AssertValueEquals(inputId, "123452345");
buttonId = parentId + "b3";
+ writeStatus("Click button 3: ");
clickById(buttonId);
waitForAjaxCompletion();
- AssertValueEquals(inputId, "6");
+ AssertValueEquals(inputId, "123452345");
buttonId = parentId + "b4";
+ writeStatus("Click button 4: ");
clickById(buttonId);
waitForAjaxCompletion();
- AssertValueEquals(inputId, "1");
+ AssertValueEquals(inputId, "12345234555");
buttonId = parentId + "b5";
+ writeStatus("Click button 5: ");
clickById(buttonId);
waitForAjaxCompletion();
- AssertValueEquals(inputId, "2");
-
- buttonId = parentId + "b1";
-
- clickById(buttonId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "5");
-
- buttonId = parentId + "b3";
-
- clickById(buttonId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "5");
+ AssertValueEquals(inputId, "12345234555");
+
}
public String getTestUrl() {
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandLinkTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandLinkTest.java 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandLinkTest.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -1,96 +1,92 @@
-package org.richfaces;
-
-import org.ajax4jsf.test.base.RichSeleniumTest;
-import org.ajax4jsf.test.base.SeleniumTestBase;
-import org.ajax4jsf.test.base.Templates;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-public class AjaxCommandLinkTest extends SeleniumTestBase implements RichSeleniumTest {
-
- public AjaxCommandLinkTest() {
- super("http", "localhost", "8080");
- }
-
- /**
- * This method are invoking before selenium tests started
- */
- @BeforeTest
- @Parameters( { "browser" })
- public void startSelenium(String browser) {
- super.startSelenium(browser);
- }
-
- /**
- * This method are invoking after selenium tests completed
- */
- @AfterTest
- public void stopSelenium() {
- super.stopSelenium();
- }
-
- @Test
- public void testAjaxCommandLinkComponent() throws Exception {
- _testAjaxCommandLinkComponent(Templates.DATATABLE);
- }
-
- private void _testAjaxCommandLinkComponent(Templates template) {
- renderPage(getTestUrl(), template);
-
- String parentId = getParentId() + "_form:";
-
- String LinkId = parentId + "l1";
- String inputId = parentId + "_value";
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "3");
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "6");
-
- LinkId = parentId + "l2";
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "6");
-
- LinkId = parentId + "l3";
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "6");
-
- LinkId = parentId + "l4";
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "1");
-
- LinkId = parentId + "l5";
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "2");
-
- LinkId = parentId + "l1";
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "5");
-
- LinkId = parentId + "l3";
-
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "5");
- }
-
- public String getTestUrl() {
- return "/faces/pages/ajaxCommandLink/ajaxLinkTest.xhtml";
- }
-
-}
+package org.richfaces;
+
+import org.ajax4jsf.test.base.RichSeleniumTest;
+import org.ajax4jsf.test.base.SeleniumTestBase;
+import org.ajax4jsf.test.base.Templates;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+public class AjaxCommandLinkTest extends SeleniumTestBase implements RichSeleniumTest {
+
+ public AjaxCommandLinkTest() {
+ super("http", "localhost", "8080");
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeTest
+ @Parameters( { "browser" })
+ public void startSelenium(String browser) {
+ super.startSelenium(browser);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterTest
+ public void stopSelenium() {
+ super.stopSelenium();
+ }
+
+ @Test
+ public void testAjaxCommandLinkComponent() throws Exception {
+ _testAjaxCommandLinkComponent(Templates.SIMPLE);
+ _testAjaxCommandLinkComponent(Templates.DATATABLE);
+ }
+
+ private void _testAjaxCommandLinkComponent(Templates template) {
+ renderPage(getTestUrl(), template);
+
+ String parentId = getParentId() + "_form:";
+
+ String LinkId = parentId + "l1";
+ String inputId = parentId + "_value";
+
+ writeStatus("Click link 1 : ");
+ clickById(LinkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "12345");
+
+ writeStatus("Click link 1 again: ");
+ clickById(LinkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "123452345");
+
+ LinkId = parentId + "l2";
+
+ writeStatus("Click link 2 : ");
+ clickById(LinkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "123452345");
+
+ LinkId = parentId + "l3";
+
+ writeStatus("Click link 3 : ");
+ clickById(LinkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "123452345");
+
+ LinkId = parentId + "l4";
+
+ writeStatus("Click link 4 : ");
+ clickById(LinkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "12345234555");
+
+ LinkId = parentId + "l5";
+
+ writeStatus("Click link 5 : ");
+ clickById(LinkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "12345234555");
+
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/ajaxCommandLink/ajaxLinkTest.xhtml";
+ }
+
+}
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java 2008-04-28
11:46:08 UTC (rev 8225)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -35,6 +35,7 @@
@Test
public void testProgressBarComponent() {
+ _testProgressBarComponent(Templates.SIMPLE);
_testProgressBarComponent(Templates.DATATABLE);
}
@@ -48,49 +49,71 @@
int value = getProgressBarValue(progressBarId);
Assert.assertTrue(value < 0);
String text = getTextById(progressBarId);
+ writeStatus("Check if process not started");
Assert.assertTrue(text.startsWith("Process not started"));
+ writeStatus("Enable polling");
enableProgressBar(progressBarId, true);
pause(5000, progressBarId);
+ writeStatus("Disable polling");
enableProgressBar(progressBarId, false);
+ writeStatus("Check label");
text = getTextById(progressBarId + ":remain");
Assert.assertTrue(text.endsWith("%"));
+ writeStatus("Check value");
value = getProgressBarValue(progressBarId);
Assert.assertTrue(value > 0);
+ writeStatus("Enable polling");
enableProgressBar(progressBarId, true);
pause(5000, progressBarId);
+ writeStatus("Check value");
Assert.assertTrue((getProgressBarValue(progressBarId).intValue() != value));
+ writeStatus("Disable polling");
enableProgressBar(progressBarId, false);
value = getProgressBarValue(progressBarId);
- delay(1500);
+ pause(1500, progressBarId);
+ writeStatus("Check value");
Assert.assertTrue(getProgressBarValue(progressBarId) == value);
+ clickById(parentId + "_complete");
+ waitForAjaxCompletion();
+ writeStatus("Check if process completed");
+ text = getTextById(progressBarId);
+ Assert.assertTrue(text.startsWith("Process completed"));
+
// - Test client mode
+ writeStatus("Check value");
progressBarId = parentId + "progressBar2";
value = getProgressBarValue(progressBarId);
Assert.assertTrue(value == -5);
text = getTextById(progressBarId);
+ writeStatus("Check if process not started");
Assert.assertTrue(text.startsWith("Process not started"));
setProgressBarValue(progressBarId, 20);
value = getProgressBarValue(progressBarId);
+ writeStatus("Check value");
Assert.assertTrue(value == 20);
setProgressBarValue(progressBarId, 60);
value = getProgressBarValue(progressBarId);
+ writeStatus("Check value");
Assert.assertTrue(value == 60);
+ clickById(parentId + "_reset");
+ waitForAjaxCompletion();
+
}
private void enableProgressBar(String id, boolean enable) {
@@ -108,7 +131,7 @@
}
public String getTestUrl() {
- return null;
+ return "/faces/pages/progressBar/progressBarTest.xhtml";
}
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/test/ProgressBarTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/test/ProgressBarTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/test/ProgressBarTest.java 2008-04-28
12:12:21 UTC (rev 8226)
@@ -0,0 +1,138 @@
+package org.richfaces.test;
+
+import org.ajax4jsf.test.base.RichSeleniumTest;
+import org.ajax4jsf.test.base.SeleniumTestBase;
+import org.ajax4jsf.test.base.Templates;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+public class ProgressBarTest extends SeleniumTestBase implements
+ RichSeleniumTest {
+
+ public ProgressBarTest() {
+ super("http", "localhost", "8080");
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeTest
+ @Parameters( { "browser" })
+ public void startSelenium(String browser) {
+ super.startSelenium(browser);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterTest
+ public void stopSelenium() {
+ super.stopSelenium();
+ }
+
+ @Test
+ public void testProgressBarComponent() {
+ _testProgressBarComponent(Templates.SIMPLE);
+ _testProgressBarComponent(Templates.DATATABLE);
+ }
+
+ private void _testProgressBarComponent(Templates template) {
+
+ renderPage(getTestUrl(), template);
+
+ String parentId = getParentId() + "_form:";
+
+ String progressBarId = parentId + "progressBar1";
+ int value = getProgressBarValue(progressBarId);
+ Assert.assertTrue(value < 0);
+ String text = getTextById(progressBarId);
+ writeStatus("Check if process not started");
+ Assert.assertTrue(text.startsWith("Process not started"));
+
+ writeStatus("Enable polling");
+ enableProgressBar(progressBarId, true);
+
+ pause(5000, progressBarId);
+
+ writeStatus("Disable polling");
+ enableProgressBar(progressBarId, false);
+
+ writeStatus("Check label");
+ text = getTextById(progressBarId + ":remain");
+ Assert.assertTrue(text.endsWith("%"));
+
+ writeStatus("Check value");
+ value = getProgressBarValue(progressBarId);
+ Assert.assertTrue(value > 0);
+
+ writeStatus("Enable polling");
+ enableProgressBar(progressBarId, true);
+
+ pause(5000, progressBarId);
+ writeStatus("Check value");
+ Assert.assertTrue((getProgressBarValue(progressBarId).intValue() != value));
+
+ writeStatus("Disable polling");
+ enableProgressBar(progressBarId, false);
+
+ value = getProgressBarValue(progressBarId);
+ pause(1500, progressBarId);
+ writeStatus("Check value");
+ Assert.assertTrue(getProgressBarValue(progressBarId) == value);
+
+ clickById(parentId + "_complete");
+ waitForAjaxCompletion();
+ writeStatus("Check if process completed");
+ text = getTextById(progressBarId);
+ Assert.assertTrue(text.startsWith("Process completed"));
+
+
+ // - Test client mode
+
+ writeStatus("Check value");
+ progressBarId = parentId + "progressBar2";
+ value = getProgressBarValue(progressBarId);
+ Assert.assertTrue(value == -5);
+
+ text = getTextById(progressBarId);
+ writeStatus("Check if process not started");
+ Assert.assertTrue(text.startsWith("Process not started"));
+
+ setProgressBarValue(progressBarId, 20);
+ value = getProgressBarValue(progressBarId);
+ writeStatus("Check value");
+ Assert.assertTrue(value == 20);
+
+ setProgressBarValue(progressBarId, 60);
+ value = getProgressBarValue(progressBarId);
+ writeStatus("Check value");
+ Assert.assertTrue(value == 60);
+
+ clickById(parentId + "_reset");
+ waitForAjaxCompletion();
+
+ }
+
+ private void enableProgressBar(String id, boolean enable) {
+ invokeFromComponent(id, (enable ? "enable" : "disable"), null);
+ }
+
+ private void setProgressBarValue(String id, Object value) {
+ invokeFromComponent(id, "setValue", value);
+ }
+
+ private Integer getProgressBarValue(String id) {
+ String value = invokeFromComponent(id, "getValue", null);
//runScript(script.toString());
+ Integer v = Integer.parseInt(value);
+ return v;
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/progressBar/progressBarTest.xhtml";
+ }
+
+
+}