Author: lfryc(a)redhat.com
Date: 2011-01-13 10:31:54 -0500 (Thu, 13 Jan 2011)
New Revision: 20993
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumnGroup/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumnGroup/TestColumnGroupHeaderFooter.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnModelTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/ColumnModel.java
Log:
rich:columnGroup - Header and Footer sample automated (RFPL730)
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnModelTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnModelTest.java 2011-01-13
15:28:51 UTC (rev 20992)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/AbstractColumnModelTest.java 2011-01-13
15:31:54 UTC (rev 20993)
@@ -35,8 +35,8 @@
*/
public abstract class AbstractColumnModelTest extends AbstractMetamerTest {
- ColumnAttributes attributes = new ColumnAttributes();
- ColumnModel model = new ColumnModel("richDataTable",
pjq("table.rf-dt[id$=richDataTable]"));
+ protected ColumnAttributes attributes = new ColumnAttributes();
+ protected ColumnModel model = new ColumnModel("richDataTable",
pjq("table.rf-dt[id$=richDataTable]"));
List<Capital> capitals;
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/ColumnModel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/ColumnModel.java 2011-01-13
15:28:51 UTC (rev 20992)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumn/ColumnModel.java 2011-01-13
15:31:54 UTC (rev 20993)
@@ -45,17 +45,32 @@
private ReferencedLocator<JQueryLocator> tableHeader = ref(root, ">
thead.rf-dt-thd");
private ReferencedLocator<JQueryLocator> tableBody = ref(root, ">
tbody.rf-dt-b");
+ private ReferencedLocator<JQueryLocator> tableFooter = ref(root, ">
tfoot.rf-dt-tft");
private ReferencedLocator<JQueryLocator> headerRow = ref(tableHeader,
"> tr.rf-dt-hdr");
private ReferencedLocator<JQueryLocator> bodyRow = ref(tableBody, ">
tr.rf-dt-r");
+ private ReferencedLocator<JQueryLocator> footerRow = ref(tableFooter,
"> tr.rf-dt-ftr");
private JQueryLocator headerCell = jq("th.rf-dt-hdr-c");
private JQueryLocator bodyCell = jq("td.rf-dt-c");
+ private JQueryLocator footerCell = jq("td.rf-dt-ftr-c");
public ColumnModel(String name, JQueryLocator root) {
super(name, root);
}
+ public int getBodyRowCount() {
+ return selenium.getCount(bodyRow.getChild(bodyCell).getNthChildElement(1));
+ }
+
+ public int getHeaderRowCount() {
+ return selenium.getCount(headerRow.getChild(headerCell).getNthChildElement(1));
+ }
+
+ public int getFooterRowCount() {
+ return selenium.getCount(footerRow.getChild(footerCell).getNthChildElement(1));
+ }
+
public int getBodyRowCellCount(int row) {
return selenium.getCount(bodyRow.getNthChildElement(row).getChild(bodyCell));
}
@@ -64,6 +79,10 @@
return
selenium.getCount(headerRow.getNthChildElement(row).getChild(headerCell));
}
+ public int getFooterRowCellCount(int row) {
+ return
selenium.getCount(footerRow.getNthChildElement(row).getChild(footerCell));
+ }
+
public JQueryLocator getBodyCell(int row, int column) {
return
bodyRow.getNthChildElement(row).getChild(bodyCell).getNthChildElement(column);
}
@@ -72,6 +91,10 @@
return
headerRow.getNthChildElement(row).getChild(headerCell).getNthChildElement(column);
}
+ public JQueryLocator getFooterCell(int row, int column) {
+ return
footerRow.getNthChildElement(row).getChild(footerCell).getNthChildElement(column);
+ }
+
public Capital getCapital(int index) {
String state = selenium.getText(getBodyCell(index + 1, 1));
String name = selenium.getText(getBodyCell(index + 1, 2));
@@ -80,7 +103,7 @@
result.setState(state);
return result;
}
-
+
public Collection<Capital> getCapitals() {
int count = getBodyRowCount();
List<Capital> capitals = new LinkedList<Capital>();
@@ -89,8 +112,5 @@
}
return capitals;
}
-
- public int getBodyRowCount() {
- return selenium.getCount(bodyRow.getChild(bodyCell).getNthChildElement(1));
- }
+
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumnGroup/TestColumnGroupHeaderFooter.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumnGroup/TestColumnGroupHeaderFooter.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richColumnGroup/TestColumnGroupHeaderFooter.java 2011-01-13
15:31:54 UTC (rev 20993)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.richColumnGroup;
+
+import static org.jboss.test.selenium.locator.Attribute.ROWSPAN;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.richColumn.AbstractColumnModelTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestColumnGroupHeaderFooter extends AbstractColumnModelTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richColumnGroup/headerFooter.xhtml");
+ }
+
+ @Test
+ public void testRendered() {
+ int bodyRowCount = model.getBodyRowCount();
+
+ assertTrue(bodyRowCount > 0);
+
+ assertEquals(model.getHeaderRowCount(), 2);
+ assertEquals(model.getHeaderRowCellCount(1), 2);
+ assertEquals(model.getHeaderRowCellCount(2), 4);
+ assertEquals(selenium.getAttribute(model.getHeaderCell(1,
1).getAttribute(ROWSPAN)), "2");
+
+ assertEquals(model.getFooterRowCount(), 3);
+ assertEquals(model.getFooterRowCellCount(1), 1);
+ assertEquals(model.getFooterRowCellCount(2), 5);
+ assertEquals(model.getFooterRowCellCount(3), 1);
+ assertEquals(selenium.getAttribute(model.getFooterCell(2,
1).getAttribute(ROWSPAN)), "2");
+
+ attributes.setRendered(false);
+
+ assertEquals(model.getBodyRowCount(), bodyRowCount);
+ assertEquals(model.getHeaderRowCount(), 0);
+ assertEquals(model.getFooterRowCount(), 0);
+ }
+}