Author: lfryc(a)redhat.com
Date: 2011-01-14 11:00:47 -0500 (Fri, 14 Jan 2011)
New Revision: 21031
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/CollapsibleSubTable.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java
Log:
rich:collapsibleSubTable - automated Facets sample (RFPL-731)
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java 2011-01-14
15:56:02 UTC (rev 21030)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java 2011-01-14
16:00:47 UTC (rev 21031)
@@ -39,6 +39,10 @@
public void setHeader(String header) {
setProperty("header", header);
}
+
+ public void setFooter(String footer) {
+ setProperty("footer", footer);
+ }
public void setStateHeader(String stateHeader) {
setProperty("stateHeader", stateHeader);
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/CollapsibleSubTable.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/CollapsibleSubTable.java 2011-01-14
15:56:02 UTC (rev 21030)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/CollapsibleSubTable.java 2011-01-14
16:00:47 UTC (rev 21031)
@@ -1,10 +1,13 @@
package org.richfaces.tests.metamer.ftest.model;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.ExtendedLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
public class CollapsibleSubTable extends AbstractModel<JQueryLocator> {
@@ -13,6 +16,10 @@
JQueryLocator subtableRow = jq("tr[class^=rf-cst][class$=-r]");
JQueryLocator subtableCell = jq("td.rf-cst-c");
+ ReferencedLocator<JQueryLocator> noData = ref(root, "> tr.rf-cst-nd
> td.rf-cst-nd-c");
+ ReferencedLocator<JQueryLocator> header = ref(root, "> tr.rf-cst-hdr
> td.rf-cst-hdr-c");
+ ReferencedLocator<JQueryLocator> footer = ref(root, "> tr.rf-cst-ftr
> td.rf-cst-ftr-c");
+
JQueryLocator visible = jq("{0}:visible");
public CollapsibleSubTable(JQueryLocator root) {
@@ -40,4 +47,20 @@
public JQueryLocator getCell(int column, int row) {
return getRow(row).getChild(subtableCell).getNthOccurence(column);
}
+
+ public ExtendedLocator<JQueryLocator> getNoData() {
+ return noData;
+ }
+
+ public boolean isNoData() {
+ return selenium.isElementPresent(noData) && selenium.isVisible(noData);
+ }
+
+ public ExtendedLocator<JQueryLocator> getHeader() {
+ return header;
+ }
+
+ public ExtendedLocator<JQueryLocator> getFooter() {
+ return footer;
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java 2011-01-14
15:56:02 UTC (rev 21030)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java 2011-01-14
16:00:47 UTC (rev 21031)
@@ -5,6 +5,7 @@
import org.richfaces.tests.metamer.bean.Model;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableFacets;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Use;
import org.richfaces.tests.metamer.ftest.model.CollapsibleSubTable;
@@ -21,7 +22,8 @@
private static final List<Employee> EMPLOYEES = Model.unmarshallEmployees();
CollapsibleSubTableAttributes attributes = new CollapsibleSubTableAttributes();
- DataTable model = new DataTable(pjq("table.rf-dt"));;
+ DataTable dataTable = new DataTable(pjq("table.rf-dt"));;
+ DataTableFacets facets = new DataTableFacets();
@Inject
@Use(value = "configuration*")
@@ -58,8 +60,8 @@
public Configuration(int i, String name) {
this.name = name;
- subtable = model.getSubtable(i);
- toggler = model.getToggler(i);
+ subtable = dataTable.getSubtable(i);
+ toggler = dataTable.getToggler(i);
final Employee.Sex sex = (i == 1) ? Employee.Sex.MALE : Employee.Sex.FEMALE;
employees = new LinkedList<Employee>(Collections2.filter(EMPLOYEES, new
Predicate<Employee>() {
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java 2011-01-14
15:56:02 UTC (rev 21030)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java 2011-01-14
16:00:47 UTC (rev 21031)
@@ -1,12 +1,25 @@
package org.richfaces.tests.metamer.ftest.richCollapsibleSubTable;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
+
import java.util.Collection;
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.ExpandMode;
import org.richfaces.model.SortMode;
import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
public class CollapsibleSubTableAttributes extends AbstractComponentAttributes {
+
+ JQueryLocator showDataLocator = pjq("input[id$=noDataCheckbox]");
+
+ public void setShowData(boolean showData) {
+ selenium.check(showDataLocator, showData);
+ guardXhr(selenium).fireEvent(showDataLocator, Event.CLICK);
+ }
+
public void setExpandMode(ExpandMode expandMode) {
setProperty("expandMode", expandMode);
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java 2011-01-14
16:00:47 UTC (rev 21031)
@@ -0,0 +1,61 @@
+package org.richfaces.tests.metamer.ftest.richCollapsibleSubTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.testng.annotations.Test;
+
+public class TestCollapsibleSubTableFacets extends AbstractCollapsibleSubTableTest {
+
+ private static final String SAMPLE_STRING = "Abc123!@#ĚščСам";
+ private static final String EMPTY_STRING = "";
+
+ @Override
+ public URL getTestUrl() {
+
+ return buildUrl(contextPath,
"faces/components/richCollapsibleSubTable/facets.xhtml");
+ }
+
+ @Test
+ public void testNoDataFacet() {
+ assertTrue(subtable.hasVisibleRows());
+ attributes.setShowData(false);
+ assertFalse(subtable.hasVisibleRows());
+
+ assertTrue(subtable.isNoData());
+ assertEquals(selenium.getText(subtable.getNoData()), EMPTY_STRING);
+
+ facets.setNoData(SAMPLE_STRING);
+
+ attributes.setShowData(true);
+ assertTrue(subtable.hasVisibleRows());
+
+ attributes.setShowData(false);
+ assertFalse(subtable.hasVisibleRows());
+
+ assertTrue(subtable.isNoData());
+ assertEquals(selenium.getText(subtable.getNoData()), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testHeaderInstantChange() {
+ facets.setHeader(SAMPLE_STRING);
+ assertEquals(selenium.getText(subtable.getHeader()), SAMPLE_STRING);
+
+ facets.setHeader(EMPTY_STRING);
+ assertEquals(selenium.getText(subtable.getHeader()), EMPTY_STRING);
+ }
+
+ @Test
+ public void testFooterInstantChange() {
+ facets.setFooter(SAMPLE_STRING);
+ assertEquals(selenium.getText(subtable.getFooter()), SAMPLE_STRING);
+
+ facets.setFooter(EMPTY_STRING);
+ assertEquals(selenium.getText(subtable.getFooter()), EMPTY_STRING);
+ }
+}