Author: andrei_exadel
Date: 2009-02-20 07:16:19 -0500 (Fri, 20 Feb 2009)
New Revision: 12698
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColspanRowspanBreakbefore.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsSorting.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java
Log:
Columns tests
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java 2009-02-20
11:56:17 UTC (rev 12697)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java 2009-02-20
12:16:19 UTC (rev 12698)
@@ -17,14 +17,19 @@
String status;
+ boolean rendered = true;
+ boolean selfSorted = true;
+
public class Column {
String header;
+ String footer;
Ordering ordering;
Object filterValue;
- public Column(String header) {
+ public Column(String header, String footer) {
super();
this.header = header;
+ this.footer = footer;
}
public void listener(ActionEvent event) {
@@ -59,6 +64,14 @@
public void setFilterValue(Object filterValue) {
this.filterValue = filterValue;
}
+
+ public String getFooter() {
+ return footer;
+ }
+
+ public void setFooter(String footer) {
+ this.footer = footer;
+ }
}
@@ -101,10 +114,14 @@
private int cols = 3;
+ private int headerCols = 5;
+
private List<Row []> model;
private List<Column> columns;
+ private List<Column> headerColumns;
+
public ColumnsBean() {
init();
}
@@ -112,7 +129,7 @@
private void init () {
columns = new ArrayList<Column>();
for (int i = 0; i < cols; i++) {
- columns.add(new Column("Header" + i));
+ columns.add(new Column("Header" + i, "Footer" + i));
}
model = new ArrayList<Row[]>();
@@ -128,7 +145,33 @@
public void reset() {
init();
status = null;
+ rendered = true;
+ selfSorted = true;
}
+
+ public void prepareRenderedTest () {
+ reset();
+ rendered = false;
+ }
+
+ public void prepareExternalSorting () {
+ reset();
+ selfSorted = false;
+ }
+
+ public String sortAscending() {
+ for (Column c : columns) {
+ c.setOrdering(Ordering.ASCENDING);
+ }
+ return null;
+ }
+
+ public String sortDescending() {
+ for (Column c : columns) {
+ c.setOrdering(Ordering.DESCENDING);
+ }
+ return null;
+ }
public List<Row[]> getModel() {
return model;
@@ -179,5 +222,23 @@
this.comparator = comparator;
}
+ public List<Column> getHeaderColumns() {
+ if (headerColumns == null) {
+ headerColumns = new ArrayList<Column>();
+ for (int i = 0; i < headerCols; i++) {
+ headerColumns.add(new Column("Header" + i, "Footer" + i));
+ }
+ }
+ return headerColumns;
+ }
+
+ public boolean isRendered() {
+ return rendered;
+ }
+
+ public boolean isSelfSorted() {
+ return selfSorted;
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsTest.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColspanRowspanBreakbefore.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColspanRowspanBreakbefore.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColspanRowspanBreakbefore.xhtml 2009-02-20
12:16:19 UTC (rev 12698)
@@ -0,0 +1,43 @@
+<!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="_form">
+ <br/><br/>
+ <rich:dataTable id="table" value="#{columnsBean.model}"
var="row">
+ <f:facet name="header">
+ <rich:columnGroup>
+ <rich:columns rowspan="#{(index == 0 || index == 3)? 2 : 1
}"
+ colspan="#{index == 4 ? 2 : 1}"
+ breakBefore="#{index==4 ? true : false}"
+ value="#{columnsBean.headerColumns}" var="column"
+ index="index">
+ <h:outputText value="#{column.header}"></h:outputText>
+ </rich:columns>
+ </rich:columnGroup>
+ </f:facet>
+ <rich:column>
+ <h:outputText value="Text" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="Text" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="Text" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="Text" />
+ </rich:column>
+ </rich:dataTable><br/>
+
+
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsSorting.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsSorting.xhtml 2009-02-20
11:56:17 UTC (rev 12697)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsSorting.xhtml 2009-02-20
12:16:19 UTC (rev 12698)
@@ -20,9 +20,12 @@
</rich:columns>
</rich:dataTable><br/>
+ <a4j:commandButton id="sortAsc" reRender="table2"
action="#{columnsBean.sortAscending}" value="Sort ASC" />
+ <a4j:commandButton id="sortDesc" reRender="table2"
action="#{columnsBean.sortDescending}" value="Sort DESC" />
+
<rich:dataTable id="table2" value="#{columnsBean.model}"
var="row">
<rich:columns id="c#{index}"
value="#{columnsBean.columns}" var="column"
- index="index" comparator="#{columnsBean.comparator}"
sortOrder="#{column.ordering}">
+ index="index" selfSorted="#{columnsBean.selfSorted}"
comparator="#{columnsBean.comparator}"
sortOrder="#{column.ordering}">
<f:facet name="header">
<h:outputText value="#{column.ordering}"></h:outputText>
</f:facet>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java 2009-02-20
11:56:17 UTC (rev 12697)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java 2009-02-20
12:16:19 UTC (rev 12698)
@@ -33,10 +33,13 @@
public class ColumnsTest extends SeleniumTestBase {
static final String RESET_METHOD = "#{columnsBean.reset}";
+ static final String RESET_METHOD_FOR_RENDERED_TEST =
"#{columnsBean.prepareRenderedTest}";
+ static final String RESET_METHOD_FOR_EXTERNAL_SORT_TEST =
"#{columnsBean.prepareExternalSorting}";
static final String SORTING_TEST_URL =
"pages/columns/testColumnsSorting.xhtml";
static final String FILTERING_TEST_URL =
"pages/columns/testColumnsFiltering.xhtml";
static final String VALUE_ATTRIBUTE_TEST_URL =
"pages/columns/testValueAttribute.xhtml";
+ static final String ROSPAN_COLSPAN_BREAKBEFORE_ATTRIBUTES_TEST_URL =
"pages/columns/testColspanRowspanBreakbefore.xhtml";
enum FEATURE {
SORTING,
@@ -46,6 +49,96 @@
static final String [] COLUMNS_CLASSSES = new String [] {"dr-table-cell",
"rich-table-cell", "columnClass"};
@Test
+ public void testExternalSorting(Template template) {
+ renderAutoTestPage(SORTING_TEST_URL, template, RESET_METHOD_FOR_EXTERNAL_SORT_TEST);
+
+ final int cols = 3;
+
+ String tableId = getParentId() + "_form:table2";
+ String testAscId = getParentId() + "_form:sortAsc";
+ String testDescId = getParentId() + "_form:sortDesc";
+
+ clickAjaxCommandAndWait(testAscId);
+
+ // Test external sorting ASC
+ for (int i = 0; i < cols; i++) {
+ checkColumnsData(tableId, i, new String [] {String.valueOf(i), String.valueOf(i+1)},
FEATURE.SORTING, "Sorting does not work as expected if selfSorted = false.");
+ checkSortOrderAttribute(tableId, i, Ordering.ASCENDING);
+ }
+
+ // Test external sorting DESC
+ clickAjaxCommandAndWait(testDescId);
+ for (int i = 0; i < cols; i++) {
+ checkColumnsData(tableId, i, new String [] {String.valueOf(i+1), String.valueOf(i)},
FEATURE.SORTING, "Sorting does not work as expected if selfSorted = false.");
+ checkSortOrderAttribute(tableId, i, Ordering.DESCENDING);
+ }
+
+ }
+
+ @Test
+ public void testRenderedAttribute (Template template) {
+ renderPage(template, RESET_METHOD_FOR_RENDERED_TEST);
+
+ String tableId = getParentId() + "_form:table";
+
+ int headerCount =
selenium.getXpathCount("//table[(a)id='"+tableId+"']/tbody/*").intValue();
+ int footerCount =
selenium.getXpathCount("//table[(a)id='"+tableId+"']/tfoot/*").intValue();
+ int dataCount =
selenium.getXpathCount("//table[(a)id='"+tableId+"']/tbody/*").intValue();
+
+ if (headerCount != 0 || footerCount != 0 || dataCount != 0) {
+ Assert.fail("Rendered attribute does not work. No data and no facets should be
output to client.");
+ }
+ }
+
+ @Test
+ public void testRowspanColspanBreakBeforeAttributes(Template template) {
+ renderPage(ROSPAN_COLSPAN_BREAKBEFORE_ATTRIBUTES_TEST_URL, template, RESET_METHOD);
+
+ String tableId = getParentId() + "_form:table";
+
+ // Check rowspan attribute
+ String col1Rowspan =
selenium.getAttribute("//table[@id='"+tableId+"']/thead/tr/th[1]/@rowspan");
+ String col3Rowspan =
selenium.getAttribute("//table[@id='"+tableId+"']/thead/tr/th[4]/@rowspan");
+
+ if (!col1Rowspan.equals("2") || !col3Rowspan.equals("2")) {
+ Assert.fail("Rowspan attributes was not output to client. The first and third
columns should have rowspan=2. But was: " + col1Rowspan + " and " +
col3Rowspan);
+ }
+
+ // Check breakBefore attribute
+ int headerRowsCount =
selenium.getXpathCount("//table[(a)id='"+tableId+"']/thead/tr").intValue();
+ int firstRowColsCount =
selenium.getXpathCount("//table[(a)id='"+tableId+"']/thead/tr[1]/th").intValue();
+ int secondRowColsCount =
selenium.getXpathCount("//table[(a)id='"+tableId+"']/thead/tr[2]/th").intValue();
+
+ if (headerRowsCount != 2 || firstRowColsCount != 4 || secondRowColsCount != 1) {
+ Assert.fail("BreakBefore attribute was not applied as expected. Table header
should have two rows. The first row should have 4 columns. The second - 1 column.");
+ }
+
+
+ // Check colspan attribute
+ String col4Colspan =
selenium.getAttribute("//table[@id='"+tableId+"']/thead/tr[2]/th/@colspan");
+
+ if (!col4Colspan.equals("2")) {
+ Assert.fail("Colspan attributes was not output to client. The 4th column should
have colspan=2. But was: " + col4Colspan);
+ }
+
+ }
+
+
+ @Test
+ public void testHeaderFooterFacets(Template template) {
+ renderPage(template, RESET_METHOD);
+
+ String tableId = getParentId() + "_form:table";
+
+ final int cols = 3;
+ for (int i = 0; i < cols; i++) {
+ AssertTextEquals("//table[@id='"+tableId+"']/thead/tr/th["+(i+1)+"]",
"Header" + i, "Header for column " + i + " was not output to
client");
+ AssertTextEquals("//table[@id='"+tableId+"']/tfoot/tr/td["+(i+1)+"]",
"Footer" + i, "Footer for column " + i + " was not output to
client");
+ }
+ }
+
+
+ @Test
public void testStylesClassesAndStandardHTMLAttributes(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, RESET_METHOD);
@@ -77,8 +170,6 @@
}
- private static final String CTRL_FORM = "_controls";
-
@Test
public void testSortingFeature(Template template) {
renderPage(SORTING_TEST_URL, template, RESET_METHOD);