Author: jpapouse
Date: 2011-08-16 10:00:20 -0400 (Tue, 16 Aug 2011)
New Revision: 22635
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/iterationStatus.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestIterationStatus.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/list.xhtml
Log:
RFPL-743:
- metamer page containing data grid and iteration status
- selenium tests checking iteration state in data grid
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/iterationStatus.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/iterationStatus.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/iterationStatus.xhtml 2011-08-16
14:00:20 UTC (rev 22635)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
xmlns:rich="http://richfaces.org/rich">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010-2011, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="view">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="head"/>
+
+ <ui:define name="component">
+
+ <rich:dataGrid id="richDataGrid"
+
columns="#{richDataGridBean.attributes['columns'].value}"
+
first="#{richDataGridBean.attributes['first'].value}"
+
elements="#{richDataGridBean.attributes['elements'].value}"
+ iterationStatusVar="status"
+
keepSaved="#{richDataGridBean.attributes['keepSaved'].value}"
+
rendered="#{richDataGridBean.attributes['rendered'].value}"
+
style="#{richDataGridBean.attributes['style'].value}"
+
styleClass="#{richDataGridBean.attributes['styleClass'].value}"
+
title="#{richDataGridBean.attributes['title'].value}"
+ value="#{richDataGridBean.state ? model.capitals :
null}"
+ var="record">
+
+ <f:facet name="noData">
+ <h:outputText value="There is no data."
style="color: red;"/>
+ </f:facet>
+
+ <f:facet name="header">
+ <h:outputText value="header" />
+ </f:facet>
+
+ <f:facet name="сaption">
+ <h:outputText value="caption" />
+ </f:facet>
+
+ <a4j:outputPanel id="statusPanel"
styleClass="statuses">
+ <h:outputText id="recordState"
value="#{record.state} " style="font-weight: bold;" />
+ <br />
+ <h:outputText id="recordName"
value="#{record.name}" />
+ <hr />
+ <h:outputText id="statusBegin"
value="begin=#{status.begin}" />,
+ <h:outputText id="statusEnd"
value="end=#{status.end}" />,
+ <h:outputText id="statusIndex"
value="index=#{status.index}" />,
+ <h:outputText id="statusCount"
value="count=#{status.count}" />,
+ <h:outputText id="statusFirst"
value="first=#{status.first}" />,
+ <h:outputText id="statusLast"
value="last=#{status.last}" />,
+ <h:outputText id="statusEven"
value="even=#{status.even}" />,
+ <h:outputText id="statusRowCount"
value="rowCount=#{status.rowCount}" />
+ </a4j:outputPanel>
+
+ <f:facet name="footer">
+ <h:outputText value="footer" />
+ </f:facet>
+
+ </rich:dataGrid>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richDataGridBean.attributes}"
id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/list.xhtml 2011-08-16
12:55:42 UTC (rev 22634)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/list.xhtml 2011-08-16
14:00:20 UTC (rev 22635)
@@ -61,6 +61,11 @@
Page for testing attribute keepSaved of
<b>rich:dataGrid</b>.
</metamer:testPageLink>
+ <metamer:testPageLink id="iterationStatus"
outcome="iterationStatus" value="Iteration Status">
+ Simple page that contains <b>rich:dataGrid</b> (with model
containing capitals) with iteration status and
+ input boxes for all its attributes.
+ </metamer:testPageLink>
+
</ui:define>
</ui:composition>
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestIterationStatus.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestIterationStatus.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestIterationStatus.java 2011-08-16
14:00:20 UTC (rev 22635)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataGrid;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import javax.xml.bind.JAXBException;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestIterationStatus extends AbstractDataGridTest {
+
+ public TestIterationStatus() throws JAXBException {
+ super();
+ }
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richDataGrid/iterationStatus.xhtml");
+ }
+
+ @Test
+ public void testBegin() {
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ JQueryLocator beginLocator = jq("span[id$=statusBegin]:eq(" + i +
")");
+ assertEquals(selenium.getText(beginLocator), "begin=0", "The
iteration status property <begin> doesn't match (item: " + i +
").");
+ }
+ }
+
+ @Test
+ public void testCount() {
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ JQueryLocator propertyLocator = jq("span[id$=statusCount]:eq(" + i
+ ")");
+ String expected = "count=" + (i + 1);
+ assertEquals(selenium.getText(propertyLocator), expected, "The iteration
status property <count> doesn't match (item: " + i + ").");
+ }
+ }
+
+ @Test
+ public void testEnd() {
+ String expected = "end=" + (dataGrid.getElementCount() - 1);
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ JQueryLocator propertyLocator = jq("span[id$=statusEnd]:eq(" + i +
")");
+ assertEquals(selenium.getText(propertyLocator), expected, "The iteration
status property <end> doesn't match (item: " + i + ").");
+ }
+ }
+
+ @Test
+ public void testEven() {
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ boolean expected = false;
+ if (i%2 == 1) {
+ expected = true;
+ }
+ JQueryLocator propertyLocator = jq("span[id$=statusEven]:eq(" + i +
")");
+ assertEquals(selenium.getText(propertyLocator), "even=" +
Boolean.toString(expected), "The iteration status property <even> doesn't
match (item: " + i + ").");
+ }
+ }
+
+ @Test
+ public void testFirst() {
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ boolean expected = false;
+ if (i == 0) {
+ expected = true;
+ }
+ JQueryLocator propertyLocator = jq("span[id$=statusFirst]:eq(" + i
+ ")");
+ assertEquals(selenium.getText(propertyLocator), "first=" +
Boolean.toString(expected), "The iteration status property <first> doesn't
match (item: " + i + ").");
+ }
+ }
+
+ @Test
+ public void testIndex() {
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ JQueryLocator propertyLocator = jq("span[id$=statusIndex]:eq(" + i
+ ")");
+ String expected = "index=" + i;
+ assertEquals(selenium.getText(propertyLocator), expected, "The iteration
status property <index> doesn't match (item: " + i + ").");
+ }
+ }
+
+ @Test
+ public void testLast() {
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ boolean expected = false;
+ if (i == dataGrid.getElementCount() - 1) {
+ expected = true;
+ }
+ JQueryLocator propertyLocator = jq("span[id$=statusLast]:eq(" + i +
")");
+ assertEquals(selenium.getText(propertyLocator), "last=" +
Boolean.toString(expected), "The iteration status property <last> doesn't
match (item: " + i + ").");
+ }
+ }
+
+ @Test
+ public void testRowCount() {
+ String expected = "rowCount=" + dataGrid.getElementCount();
+ for(int i=0; i<dataGrid.getElementCount(); i++) {
+ JQueryLocator propertyLocator = jq("span[id$=statusRowCount]:eq(" +
i + ")");
+ assertEquals(selenium.getText(propertyLocator), expected, "The iteration
status property <rowCount> doesn't match (item: " + i + ").");
+ }
+ }
+}