Author: dsvyatobatsko
Date: 2008-08-07 14:52:59 -0400 (Thu, 07 Aug 2008)
New Revision: 9981
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/columns/columnsTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ColumnsTest.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/DataTableTest.java
Log:
columns test completed
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/columns/columnsTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-08-07
18:43:48 UTC (rev 9980)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-08-07
18:52:59 UTC (rev 9981)
@@ -386,17 +386,17 @@
/**
* Asserts DOM node text equals to text defined
- *
- * @param id -
- * DOM element id
+ *
+ * @param locator -
+ * locator an element locator
* @param value -
* text defined
*/
- public void AssertTextEquals(String id, String value) {
- String _v = getTextById(id);
+ public void AssertTextEquals(String locator, String value) {
+ String _v = selenium.getText(locator);
Assert.assertEquals(_v, value);
}
-
+
/**
* Asserts DOM node text equals to text defined
*
@@ -813,12 +813,8 @@
* @param tableId id of table to be checked
*/
public void assertRowsCount(int i, String tableId) {
- StringBuffer script = new StringBuffer("$('");
- script.append(tableId);
- script.append("').rows.length");
-
- String count = runScript(script.toString());
- Assert.assertEquals(count, String.valueOf(i));
+ int count = selenium.getXpathCount("//table[@id='" + tableId +
"']/tbody/tr").intValue();
+ Assert.assertEquals(count, i);
}
/**
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java 2008-08-07
18:43:48 UTC (rev 9980)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java 2008-08-07
18:52:59 UTC (rev 9981)
@@ -260,11 +260,6 @@
clickCommandAndWait(buttonId);
}
- private void assertRowsCount(int i, String tableId) {
- int count = selenium.getXpathCount("//table[@id='" + tableId +
"']/tbody/tr").intValue();
- Assert.assertEquals(count, i);
- }
-
private void assertInputValue(int row, String inputId, String value) {
String fullInputId = getFullTableElementId(row, inputId);
String elementValue = getValueById(fullInputId);
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ColumnsTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ColumnsTest.java 2008-08-07
18:43:48 UTC (rev 9980)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ColumnsTest.java 2008-08-07
18:52:59 UTC (rev 9981)
@@ -6,11 +6,94 @@
public class ColumnsTest extends SeleniumTestBase {
+ private static final String DATA_TABLE = "table";
+
+ private static final String APPLY_BUTTON = "apply";
+
+ private static final String RESET_BUTTON = "reset";
+
+ private static final String CTRL_FORM = "_controls";
+
+ private static final String ROWS_COUNT_CTRL = "rows";
+
+ private static final String COLUMNS_COUNT_CTRL = "rows";
+
+ private static final String BEGIN_ROW = "begin";
+
+ private static final String END_ROW = "end";
+
@Test
- public void testColumnsComponent(Template template) {
+ public void testColumnsComponentLayout(Template template) {
renderPage(template);
+ writeStatus("Testing columns component layout");
+
+ String parentId = getParentId() + "_form:";
+ String tableId = parentId + DATA_TABLE;
+
+ writeStatus("Check columns count equals to 3 ");
+ assertColumnsCount(3, tableId);
+
+ writeStatus("Check rows count equals to 20 ");
+ assertRowsCount(20, tableId);
+
+ writeStatus("Check columns headers");
+
+ AssertTextEquals("xpath=//table[@id='" + tableId +
"']/tHead/tr[1]/th[1]", "header0");
+ AssertTextEquals("xpath=//table[@id='" + tableId +
"']/tHead/tr[1]/th[2]", "header1");
+ AssertTextEquals("xpath=//table[@id='" + tableId +
"']/tHead/tr[1]/th[3]", "header2");
+
+ writeStatus("Check columns footers");
+
+ AssertTextEquals("xpath=//table[@id='" + tableId +
"']/tFoot/tr[1]/td[1]", "footer0");
+ AssertTextEquals("xpath=//table[@id='" + tableId +
"']/tFoot/tr[1]/td[2]", "footer1");
+ AssertTextEquals("xpath=//table[@id='" + tableId +
"']/tFoot/tr[1]/td[3]", "footer2");
+
}
+ @Test
+ public void testColumnsComponentCoreAttributes(Template template) {
+ renderPage(template);
+
+ writeStatus("Testing columns component core attributes");
+
+ String parentId = getParentId() + "_form:";
+ String tableId = parentId + DATA_TABLE;
+
+ writeStatus("Set columns count == 5, rows count == 10");
+ adjustTableParams(10, 5, 0, 10);
+
+ writeStatus("Check columns count equals to 5 ");
+ assertColumnsCount(5, tableId);
+ writeStatus("Check rows count equals to 10 ");
+ assertRowsCount(10, tableId);
+
+ writeStatus("Set begin column == 2, end column == 2, rows count = 2");
+ adjustTableParams(2, 5, 2, 2);
+
+ writeStatus("Only one column has to be rendered");
+ assertColumnsCount(1, tableId);
+ assertRowsCount(2, tableId);
+
+ writeStatus("Set end column == 0. there have to be no rows and no columns in
the table");
+ adjustTableParams(10, 5, 10, 0);
+ assertRowsCount(0, tableId);
+
+ reset();
+ }
+
+ private void adjustTableParams(int rows, int columns, int begin, int end) {
+ String ctrlForm = getParentId() + CTRL_FORM;
+ type(ctrlForm + ":rows", String.valueOf(rows));
+ type(ctrlForm + ":columns", String.valueOf(columns));
+ type(ctrlForm + ":begin", String.valueOf(begin));
+ type(ctrlForm + ":end", String.valueOf(end));
+ clickAjaxCommandAndWait(ctrlForm + ":apply");
+ }
+
+ private void reset() {
+ clickAjaxCommandAndWait(getParentId() + CTRL_FORM + ":reset");
+ }
+
@Override
public String getTestUrl() {
return "pages/columns/columnsTest.xhtml";
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/DataTableTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/DataTableTest.java 2008-08-07
18:43:48 UTC (rev 9980)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/DataTableTest.java 2008-08-07
18:52:59 UTC (rev 9981)
@@ -23,8 +23,8 @@
writeStatus("Check columns count equals to 3 ");
assertColumnsCount(3, dataTableId);
- writeStatus("Check rows count equals to 22 ");
- assertRowsCount(22, dataTableId);
+ writeStatus("Check rows count equals to 20 ");
+ assertRowsCount(20, dataTableId);
String columnsId = getColumnId(dataTableId, 0);
@@ -90,8 +90,8 @@
writeStatus("Check columns count equals to 5 ");
assertColumnsCount(5, dataTableId);
- writeStatus("Check rows count equals to 12 ");
- assertRowsCount(12, dataTableId);
+ writeStatus("Check rows count equals to 10 ");
+ assertRowsCount(10, dataTableId);
columnsId = getColumnId(dataTableId, 0);
@@ -137,7 +137,7 @@
changeColumnCount(getParentId(),2, 5, 2, 2);
assertColumnsCount(1, dataTableId);
- assertRowsCount(4, dataTableId);
+ assertRowsCount(2, dataTableId);
changeColumnCount(getParentId(), 10, 5, 10, 0);
assertRowsCount(0, dataTableId);