Author: andrei_exadel
Date: 2008-09-29 10:40:16 -0400 (Mon, 29 Sep 2008)
New Revision: 10603
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/IndexBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
Log:
Datascroller test (Initial version)
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java 2008-09-29
14:40:16 UTC (rev 10603)
@@ -0,0 +1,137 @@
+/*
+ * DataScrollerBean.java Date created: 29.09.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.ajax4jsf.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.event.ActionEvent;
+
+/**
+ * Bean class for dataScroller component testing
+ * @author Andrey Markavtsov
+ *
+ */
+@SuppressWarnings("unchecked")
+public class DataScrollerBean {
+
+ private boolean rendered = true;
+
+ private List data;
+
+ private Integer tableRows = 1;
+
+ private Integer totalRows = 10;
+
+ private Integer maxPages = 10;
+
+ private Integer page;
+
+ public DataScrollerBean() {
+ init();
+ }
+
+ private void init() {
+ data = new ArrayList();
+ for (int i = 0; i < totalRows; i++) {
+ String content = "Page " + (i / tableRows + 1);
+ data.add(new Object [] {i + 1, content});
+ }
+ }
+
+ public void apply(ActionEvent event) {
+ init();
+ }
+
+ /**
+ * @return the rendered
+ */
+ public boolean isRendered() {
+ return rendered;
+ }
+
+ /**
+ * @param rendered the rendered to set
+ */
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
+
+ /**
+ * @return the data
+ */
+ public List getData() {
+ return data;
+ }
+
+ /**
+ * @param data the data to set
+ */
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ /**
+ * @return the tableRows
+ */
+ public Integer getTableRows() {
+ return tableRows;
+ }
+
+ /**
+ * @param tableRows the tableRows to set
+ */
+ public void setTableRows(Integer tableRows) {
+ this.tableRows = tableRows;
+ }
+
+ /**
+ * @return the totalRows
+ */
+ public Integer getTotalRows() {
+ return totalRows;
+ }
+
+ /**
+ * @param totalRows the totalRows to set
+ */
+ public void setTotalRows(Integer totalRows) {
+ this.totalRows = totalRows;
+ }
+
+ /**
+ * @return the maxPages
+ */
+ public Integer getMaxPages() {
+ return maxPages;
+ }
+
+ /**
+ * @param maxPages the maxPages to set
+ */
+ public void setMaxPages(Integer maxPages) {
+ this.maxPages = maxPages;
+ }
+
+ /**
+ * @return the page
+ */
+ public Integer getPage() {
+ return page;
+ }
+
+ /**
+ * @param page the page to set
+ */
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+
+
+
+
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/IndexBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/IndexBean.java 2008-09-29
14:33:38 UTC (rev 10602)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/IndexBean.java 2008-09-29
14:40:16 UTC (rev 10603)
@@ -96,6 +96,7 @@
list.add(new ComponentItem("<rich:inputNumberSlider>",
"inputNumberSlider/inputNumberSliderTest.xhtml"));
list.add(new ComponentItem("<rich:modalPanel>",
"modalPanel/modalPanelTest.xhtml"));
list.add(new ComponentItem("<rich:toolBar>",
"toolBar/toolBarTest.xhtml"));
+ list.add(new ComponentItem("<rich:datascroller>",
"dataScroller/dataScroller.xhtml"));
sortList();
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia 2008-09-29
14:33:38 UTC (rev 10602)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia 2008-09-29
14:40:16 UTC (rev 10603)
@@ -1,2 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
-<PROCESS ENTITY="JSFProcess"/>
+<PROCESS ENTITY="JSFProcess">
+ <PROCESS-ITEM ENTITY="JSFProcessGroup"
+ NAME="rules:#pages#ajaxInclude#step1.xhtml"
+ PATH="/pages/ajaxInclude/step1.xhtml" SHAPE="32,17,0,0">
+ <PROCESS-ITEM ENTITY="JSFProcessItem"
+ ID="rules:#pages#ajaxInclude#step1.xhtml:0" NAME="item"
PATH="/pages/ajaxInclude/step1.xhtml">
+ <PROCESS-ITEM-OUTPUT ENTITY="JSFProcessItemOutput"
+ ID="next::#pages#ajaxInclude#step2.xhtml" NAME="output"
+ PATH="/pages/ajaxInclude/step2.xhtml"
+ TARGET="rules:#pages#ajaxInclude#step2.xhtml" TITLE="next"/>
+ </PROCESS-ITEM>
+ </PROCESS-ITEM>
+ <PROCESS-ITEM ENTITY="JSFProcessGroup"
+ NAME="rules:#pages#ajaxInclude#step2.xhtml"
+ PATH="/pages/ajaxInclude/step2.xhtml" SHAPE="240,33,0,0">
+ <PROCESS-ITEM ENTITY="JSFProcessItem"
+ ID="rules:#pages#ajaxInclude#step2.xhtml:0" NAME="item"
PATH="/pages/ajaxInclude/step2.xhtml">
+ <PROCESS-ITEM-OUTPUT ENTITY="JSFProcessItemOutput"
+ ID="previous::#pages#ajaxInclude#step1.xhtml" NAME="output"
+ PATH="/pages/ajaxInclude/step1.xhtml"
+ TARGET="rules:#pages#ajaxInclude#step1.xhtml"
TITLE="previous"/>
+ </PROCESS-ITEM>
+ </PROCESS-ITEM>
+</PROCESS>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-09-29
14:33:38 UTC (rev 10602)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-09-29
14:40:16 UTC (rev 10603)
@@ -230,6 +230,11 @@
<managed-bean-name>dndBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.DnDBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>dataScrollerBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.DataScrollerBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml 2008-09-29
14:40:16 UTC (rev 10603)
@@ -0,0 +1,50 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<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="component">
+ <h:form id="_controls">
+ <table>
+ <tr>
+ <td>Total Rows:</td><td><h:inputText
value="#{dataScrollerBean.totalRows}" /></td>
+ </tr>
+ <tr>
+ <td>Table Rows:</td><td><h:inputText
value="#{dataScrollerBean.tableRows}" /></td>
+ </tr>
+ </table>
+ <h:commandButton id="apply"
actionListener="#{dataScrollerBean.apply}" value="apply"/>
+ </h:form>
+ <br/>
+ <h:form id="_data">
+ <rich:datascroller id="scroller"
+ rendered="#{dataScrollerBean.rendered}"
+ for="tbl"
+ align="left"
+ maxPages="#{dataScrollerBean.maxPages}"
+ page="#{dataScrollerBean.page}"
+ />
+
+ <br/><br/>
+ <rich:dataTable id="tbl" value="#{dataScrollerBean.data}"
rows="#{dataScrollerBean.tableRows}" var="var">
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="#" />
+ </f:facet>
+ <h:outputText value="#{var[0]}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Data" />
+ </f:facet>
+ <h:outputText value="#{var[1]}" />
+ </rich:column>
+ </rich:dataTable>
+ </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 2008-09-29
14:33:38 UTC (rev 10602)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-09-29
14:40:16 UTC (rev 10603)
@@ -799,12 +799,22 @@
* @param tableId id of table to be checked
*/
public void assertColumnsCount(int i, String tableId) {
+ assertColumnsCount(i, tableId, "");
+ }
+
+ /**
+ * Asserts that expected columns count equals actual one.
+ * @param i the expected columns count
+ * @param tableId id of table to be checked
+ * @param message - error message to insert in log
+ */
+ public void assertColumnsCount(int i, String tableId, String mesage) {
StringBuffer script = new StringBuffer("$('");
script.append(tableId);
script.append("').rows[0].cells.length");
String count = runScript(script.toString());
- Assert.assertEquals(count, String.valueOf(i));
+ Assert.assertEquals(count, String.valueOf(i), mesage);
}
/**
@@ -845,4 +855,26 @@
return runScript("fireMouseEvent('" + id + "','" +
eventName + "', "
+ x + "," + y + ","+ctrl+");");
}
+
+ /**
+ * Check is DOM element contain defined class names
+ * @param id - Element DOM id
+ * @param classNames - Class names to check
+ * @param message - Message will be inserted in the log after test failure
+ * @param isId - Pass true if ID is string, false - if ID is expression to load
appropriate DOM element
+ */
+ public void assertClassNames(String id, String[] classNames, String message, boolean
isId) {
+ for (String s : classNames) {
+ String result = null;
+ if (isId) {
+
runScript("$('"+id+"').hasClassName('"+s+"')",
false).toLowerCase();
+ }else {
+ runScript("$("+id+").hasClassName('"+s+"')",
false).toLowerCase();
+ }
+ if (Boolean.FALSE.toString().toLowerCase().equals(result)) {
+ Assert.fail(message + " Element [id="+id+"] should contain class
name '"+s+"'");
+ }
+ }
+ }
+
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java 2008-09-29
14:40:16 UTC (rev 10603)
@@ -0,0 +1,152 @@
+/*
+ * DataScrollerTest.java Date created: 29.09.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;
+
+/**
+ * DataScroller selenium test class
+ * @author Andrey Markavtsov
+ *
+ */
+public class DataScrollerTest extends SeleniumTestBase {
+
+ String dataScrollerId;
+
+ String dataScrollerTableId;
+
+ String dataTableId;
+
+ @Test
+ public void testDataScroller(Template template) {
+ renderPage(template);
+ String parentId = getParentId();
+ dataScrollerId = parentId + "_data:scroller";
+ dataScrollerTableId = parentId + "_data:scroller_table";
+ dataTableId = (!template.getName().equals(Template.DATA_TABLE.getName())) ? parentId +
"_data:tbl" : parentId + "_data:tbl:0";
+
+ testRendering();
+ }
+
+ private void testRendering() {
+ assertClassNames(dataScrollerId,new String []
+ {"dr-dscr",
+ "rich-datascr"},
+ "DataScroller rendering failed: ", true);
+
+ assertClassNames(dataScrollerTableId,new String []
+ {"dr-dscr-t",
+ "rich-dtascroller-table"},
+ "DataScroller rendering failed: ", true);
+
+ testPageCount();
+ testControls();
+ testData(1,"Page 1");
+ }
+
+ private void testPageCount() {
+ assertColumnsCount(16, dataScrollerTableId, "DataScroller inner table contains
invalid columns count");
+ String text = selenium.getTable("id=" + dataScrollerTableId +
".0.3");
+ Assert.assertEquals("1", text, "DataScroller does not contain first page
link or its position is invalid");
+ text = selenium.getTable("id=" + dataScrollerTableId + ".0.7");
+ Assert.assertEquals("5", text, "DataScroller does not contain 5th page
link or its position is invalid");
+ text = selenium.getTable("id=" + dataScrollerTableId + ".0.12");
+ Assert.assertEquals("10", text, "DataScroller does not contain 10th page
link or its position is invalid");
+ }
+
+ private void testControls() {
+ // Check '��' link
+ String text = selenium.getTable("id=" + dataScrollerTableId +
".0.0");
+ Assert.assertEquals("��", text, "DataScroller does not contain
'��' link or its position is invalid");
+ assertClassNames(getPageLinkRefScript(0),new String []
+ {"dr-dscr-button-dsbld",
+ "rich-datascr-button-dsbld",
+ "dr-dscr-button",
+ "rich-datascr-button"
+ },
+ "DataScroller rendering failed: ", false);
+
+ // Check '�' link
+ text = selenium.getTable("id=" + dataScrollerTableId + ".0.1");
+ Assert.assertEquals("�", text, "DataScroller does not contain
'�' link or its position is invalid");
+ assertClassNames(getPageLinkRefScript(1),new String []
+ {"dr-dscr-button-dsbld",
+ "rich-datascr-button-dsbld",
+ "dr-dscr-button",
+ "rich-datascr-button"
+ },
+ "DataScroller rendering failed: ", false);
+
+ // Check '1' link
+ text = selenium.getTable("id=" + dataScrollerTableId + ".0.3");
+ Assert.assertEquals("1", text, "DataScroller does not contain
'1' link or its position is invalid");
+ assertClassNames(getPageLinkRefScript(3),new String []
+ {"dr-dscr-act",
+ "rich-datascr-act"
+ },
+ "DataScroller rendering failed: ", false);
+
+ // Check '5' link
+ text = selenium.getTable("id=" + dataScrollerTableId + ".0.7");
+ Assert.assertEquals("5", text, "DataScroller does not contain
'5' link or its position is invalid");
+ assertClassNames(getPageLinkRefScript(7),new String []
+ {"dr-dscr-inact",
+ "rich-datascr-inact"
+ },
+ "DataScroller rendering failed: ", false);
+
+ // Check '�' link
+ text = selenium.getTable("id=" + dataScrollerTableId + ".0.14");
+ Assert.assertEquals("�", text, "DataScroller does not contain
'�' link or its position is invalid");
+ assertClassNames(getPageLinkRefScript(14),new String []
+ {"dr-dscr-button",
+ "rich-datascr-button"
+ },
+ "DataScroller rendering failed: ", false);
+
+ // Check '��' link
+ text = selenium.getTable("id=" + dataScrollerTableId + ".0.15");
+ Assert.assertEquals("��", text, "DataScroller does not contain
'��' link or its position is invalid");
+ assertClassNames(getPageLinkRefScript(15),new String []
+ {"dr-dscr-button",
+ "rich-datascr-button"
+ },
+ "DataScroller rendering failed: ", false);
+
+ }
+
+ private void testData(int rowCount, String data) {
+ assertRowsCount(rowCount, dataTableId);
+
+ for (int i=1; i <= rowCount; i++) {
+ String text = selenium.getTable("id=" + dataTableId +
"."+rowCount+".1");
+ Assert.assertEquals(data, text,"Data Table content is invalid");
+ }
+ }
+
+ private String getPageLinkRefScript(int n) {
+ StringBuffer b = new StringBuffer(WINDOW_JS_RESOLVER);
+ b.append("$('");
+ b.append(dataScrollerTableId);
+ b.append("').rows[0].cells[");
+ b.append(n);
+ b.append("]");
+ return b.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.SeleniumTestBase#getTestUrl()
+ */
+ @Override
+ public String getTestUrl() {
+ return "pages/dataScroller/dataScroller.xhtml";
+ }
+
+}