aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-07-29 17:19:28 +0300
committerVaadin Code Review <review@vaadin.com>2014-07-31 10:56:25 +0000
commit5d0aa11b2c83e7f5abfa4c6d9ef71871b810a016 (patch)
tree2e9f388995a103fd3c6d5ad3311c6dcbd7086b0e /uitest/src
parent91f14489833ccad2f3c5aeaabfd4d5c4a5a60728 (diff)
downloadvaadin-framework-5d0aa11b2c83e7f5abfa4c6d9ef71871b810a016.tar.gz
vaadin-framework-5d0aa11b2c83e7f5abfa4c6d9ef71871b810a016.zip
Add server side API for Headers and Footers (#13334)
Change-Id: I52f282089cc55b1f281b9aeb934886442b0c34f3
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java135
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridKeyboardNavigationTest.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSortingTest.java33
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridStructureTest.java37
4 files changed, 150 insertions, 59 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
index cfe3646295..bff16d8db7 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -36,6 +36,9 @@ import com.vaadin.ui.components.grid.ColumnGroupRow;
import com.vaadin.ui.components.grid.Grid;
import com.vaadin.ui.components.grid.Grid.SelectionMode;
import com.vaadin.ui.components.grid.GridColumn;
+import com.vaadin.ui.components.grid.GridFooter;
+import com.vaadin.ui.components.grid.GridHeader;
+import com.vaadin.ui.components.grid.GridHeader.HeaderRow;
import com.vaadin.ui.components.grid.SortOrderChangeEvent;
import com.vaadin.ui.components.grid.SortOrderChangeListener;
import com.vaadin.ui.components.grid.renderers.DateRenderer;
@@ -142,15 +145,20 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
new NumberRenderer());
}
+ // Create footer
+ GridFooter footer = grid.getFooter();
+ footer.appendRow();
+ footer.setVisible(false);
+
// Add footer values (header values are automatically created)
for (int col = 0; col < COLUMNS; col++) {
- grid.getColumn(getColumnProperty(col)).setFooterCaption(
- "Footer " + col);
+ footer.getRow(0).getCell(getColumnProperty(col))
+ .setText("Footer " + col);
}
// Set varying column widths
for (int col = 0; col < COLUMNS; col++) {
- grid.getColumn("Column" + col).setWidth(100 + col * 50);
+ grid.getColumn(getColumnProperty(col)).setWidth(100 + col * 50);
}
grid.addSortOrderChangeListener(new SortOrderChangeListener() {
@@ -226,29 +234,125 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
protected void createHeaderActions() {
- createCategory("Headers", null);
+ createCategory("Header", null);
- createBooleanAction("Visible", "Headers", true,
+ createBooleanAction("Visible", "Header", true,
new Command<Grid, Boolean>() {
@Override
public void execute(Grid grid, Boolean value, Object data) {
- grid.setColumnHeadersVisible(value);
+ grid.getHeader().setVisible(value);
}
});
+
+ LinkedHashMap<String, String> defaultRows = new LinkedHashMap<String, String>();
+ defaultRows.put("Top", "Top");
+ defaultRows.put("Bottom", "Bottom");
+ defaultRows.put("Unset", "Unset");
+
+ createMultiClickAction("Default row", "Header", defaultRows,
+ new Command<Grid, String>() {
+
+ @Override
+ public void execute(Grid grid, String value, Object data) {
+ HeaderRow defaultRow = null;
+ GridHeader header = grid.getHeader();
+ if (value.equals("Top")) {
+ defaultRow = header.getRow(0);
+ } else if (value.equals("Bottom")) {
+ defaultRow = header.getRow(header.getRowCount() - 1);
+ }
+ header.setDefaultRow(defaultRow);
+ }
+
+ }, defaultRows.get("Top"));
+
+ createClickAction("Prepend row", "Header", new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getHeader().prependRow();
+ }
+
+ }, null);
+ createClickAction("Append row", "Header", new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getHeader().appendRow();
+ }
+
+ }, null);
+
+ createClickAction("Remove top row", "Header",
+ new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getHeader().removeRow(0);
+ }
+
+ }, null);
+ createClickAction("Remove bottom row", "Header",
+ new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getHeader().removeRow(
+ grid.getHeader().getRowCount() - 1);
+ }
+
+ }, null);
}
protected void createFooterActions() {
- createCategory("Footers", null);
+ createCategory("Footer", null);
- createBooleanAction("Visible", "Footers", false,
+ createBooleanAction("Visible", "Footer", false,
new Command<Grid, Boolean>() {
@Override
public void execute(Grid grid, Boolean value, Object data) {
- grid.setColumnFootersVisible(value);
+ grid.getFooter().setVisible(value);
}
});
+
+ createClickAction("Prepend row", "Footer", new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getFooter().prependRow();
+ }
+
+ }, null);
+ createClickAction("Append row", "Footer", new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getFooter().appendRow();
+ }
+
+ }, null);
+
+ createClickAction("Remove top row", "Footer",
+ new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getFooter().removeRow(0);
+ }
+
+ }, null);
+ createClickAction("Remove bottom row", "Footer",
+ new Command<Grid, Object>() {
+
+ @Override
+ public void execute(Grid grid, Object value, Object data) {
+ grid.getFooter().removeRow(
+ grid.getFooter().getRowCount() - 1);
+ }
+
+ }, null);
}
protected void createColumnActions() {
@@ -278,7 +382,8 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
@Override
public void execute(Grid grid, String value, Object data) {
grid.getContainerDatasource()
- .removeContainerProperty("Column" + data);
+ .removeContainerProperty(
+ getColumnProperty((Integer) data));
}
}, null, c);
@@ -287,7 +392,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
@Override
public void execute(Grid grid, String value, Object data) {
- grid.setLastFrozenPropertyId("Column" + data);
+ grid.setLastFrozenPropertyId(getColumnProperty((Integer) data));
}
}, null, c);
@@ -306,9 +411,9 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
}, c);
- createCategory("Column" + c + " Width", getColumnProperty(c));
+ createCategory("Column " + c + " Width", getColumnProperty(c));
- createClickAction("Auto", "Column" + c + " Width",
+ createClickAction("Auto", "Column " + c + " Width",
new Command<Grid, Integer>() {
@Override
@@ -324,7 +429,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}, -1, c);
for (int w = 50; w < 300; w += 50) {
- createClickAction(w + "px", "Column" + c + " Width",
+ createClickAction(w + "px", "Column " + c + " Width",
new Command<Grid, Integer>() {
@Override
@@ -343,7 +448,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
private static String getColumnProperty(int c) {
- return "Column" + c;
+ return "Column " + c;
}
protected void createColumnGroupActions() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridKeyboardNavigationTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridKeyboardNavigationTest.java
index 805213027e..e20b45bd1d 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridKeyboardNavigationTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridKeyboardNavigationTest.java
@@ -104,7 +104,7 @@ public class GridKeyboardNavigationTest extends GridBasicFeaturesTest {
public void testNavigationFromFooterToBody() {
openTestURL();
- selectMenuPath("Component", "Footers", "Visible");
+ selectMenuPath("Component", "Footer", "Visible");
GridElement grid = getGridElement();
grid.scrollToRow(300);
@@ -146,7 +146,7 @@ public class GridKeyboardNavigationTest extends GridBasicFeaturesTest {
public void testNavigateBetweenFooterAndBodyWithTab() {
openTestURL();
- selectMenuPath("Component", "Footers", "Visible");
+ selectMenuPath("Component", "Footer", "Visible");
GridElement grid = getGridElement();
grid.getCell(10, 2).click();
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSortingTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSortingTest.java
index 4a1d7b7be1..ee3f2a632b 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSortingTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSortingTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
-import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;
@@ -30,11 +29,7 @@ import com.vaadin.tests.components.grid.GridElement;
public class GridSortingTest extends GridBasicFeaturesTest {
- /*
- * TODO unignore once column header captions are reimplemented
- */
@Test
- @Ignore
public void testProgrammaticSorting() throws IOException {
openTestURL();
@@ -43,7 +38,7 @@ public class GridSortingTest extends GridBasicFeaturesTest {
// Sorting by column 9 is sorting by row index that is represented as a
// String.
// First cells for first 3 rows are (9, 0), (99, 0) and (999, 0)
- sortBy("Column9, DESC");
+ sortBy("Column 9, DESC");
assertTrue("Column 9 should have the sort-desc stylename", grid
.getHeaderCell(0, 9).getAttribute("class")
@@ -53,12 +48,12 @@ public class GridSortingTest extends GridBasicFeaturesTest {
for (int i = 0; i < 3; ++i) {
row += "9";
assertEquals(
- "Grid is not sorted by Column9 using descending direction.",
+ "Grid is not sorted by Column 9 using descending direction.",
"(" + row + ", 0)", grid.getCell(i, 0).getText());
}
// Column 10 is random numbers from Random with seed 13334
- sortBy("Column10, ASC");
+ sortBy("Column 10, ASC");
assertFalse(
"Column 9 should no longer have the sort-desc stylename",
@@ -75,7 +70,7 @@ public class GridSortingTest extends GridBasicFeaturesTest {
for (int i = 0; i < 5; ++i) {
assertGreater(
- "Grid is not sorted by Column10 using ascending direction",
+ "Grid is not sorted by Column 10 using ascending direction",
Integer.parseInt(grid.getCell(i + 1, 10).getText()),
Integer.parseInt(grid.getCell(i, 10).getText()));
@@ -83,10 +78,10 @@ public class GridSortingTest extends GridBasicFeaturesTest {
// Column 7 is row index as a number. Last three row are original rows
// 2, 1 and 0.
- sortBy("Column7, DESC");
+ sortBy("Column 7, DESC");
for (int i = 0; i < 3; ++i) {
assertEquals(
- "Grid is not sorted by Column7 using descending direction",
+ "Grid is not sorted by Column 7 using descending direction",
"(" + i + ", 0)",
grid.getCell(GridBasicFeatures.ROWS - (i + 1), 0).getText());
}
@@ -118,18 +113,18 @@ public class GridSortingTest extends GridBasicFeaturesTest {
for (int i = 0; i < 3; ++i) {
row += "9";
assertEquals(
- "Grid is not sorted by Column9 using descending direction.",
+ "Grid is not sorted by Column 9 using descending direction.",
"(" + row + ", 0)", grid.getCell(i, 0).getText());
}
- assertEquals("2. Sort order: [Column9 ASCENDING]", getLogRow(2));
- assertEquals("4. Sort order: [Column9 DESCENDING]", getLogRow(0));
+ assertEquals("2. Sort order: [Column 9 ASCENDING]", getLogRow(2));
+ assertEquals("4. Sort order: [Column 9 DESCENDING]", getLogRow(0));
// Column 10 is random numbers from Random with seed 13334
// Click header to sort ascending
grid.getHeaderCell(0, 10).click();
- assertEquals("6. Sort order: [Column10 ASCENDING]", getLogRow(0));
+ assertEquals("6. Sort order: [Column 10 ASCENDING]", getLogRow(0));
// Not cleaning up correctly causes exceptions when scrolling.
grid.scrollToRow(50);
@@ -138,7 +133,7 @@ public class GridSortingTest extends GridBasicFeaturesTest {
for (int i = 0; i < 5; ++i) {
assertGreater(
- "Grid is not sorted by Column10 using ascending direction",
+ "Grid is not sorted by Column 10 using ascending direction",
Integer.parseInt(grid.getCell(i + 1, 10).getText()),
Integer.parseInt(grid.getCell(i, 10).getText()));
@@ -151,13 +146,13 @@ public class GridSortingTest extends GridBasicFeaturesTest {
grid.getHeaderCell(0, 7).click();
for (int i = 0; i < 3; ++i) {
assertEquals(
- "Grid is not sorted by Column7 using descending direction",
+ "Grid is not sorted by Column 7 using descending direction",
"(" + i + ", 0)",
grid.getCell(GridBasicFeatures.ROWS - (i + 1), 0).getText());
}
- assertEquals("9. Sort order: [Column7 ASCENDING]", getLogRow(3));
- assertEquals("11. Sort order: [Column7 DESCENDING]", getLogRow(1));
+ assertEquals("9. Sort order: [Column 7 ASCENDING]", getLogRow(3));
+ assertEquals("11. Sort order: [Column 7 DESCENDING]", getLogRow(1));
}
@Test
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridStructureTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridStructureTest.java
index 94f04e10a2..ced6963c32 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridStructureTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridStructureTest.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
-import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
@@ -31,44 +30,36 @@ import com.vaadin.testbench.TestBenchElement;
public class GridStructureTest extends GridBasicFeaturesTest {
- /*
- * TODO unignore once column header captions are reimplemented
- */
@Test
- @Ignore
public void testHidingColumn() throws Exception {
openTestURL();
// Column 0 should be visible
List<TestBenchElement> cells = getGridHeaderRowCells();
- assertEquals("Column0", cells.get(0).getText());
+ assertEquals("Column 0", cells.get(0).getText());
// Hide column 0
- selectMenuPath("Component", "Columns", "Column0", "Visible");
+ selectMenuPath("Component", "Columns", "Column 0", "Visible");
// Column 1 should now be the first cell
cells = getGridHeaderRowCells();
- assertEquals("Column1", cells.get(0).getText());
+ assertEquals("Column 1", cells.get(0).getText());
}
- /*
- * TODO unignore once column header captions are reimplemented
- */
@Test
- @Ignore
public void testRemovingColumn() throws Exception {
openTestURL();
// Column 0 should be visible
List<TestBenchElement> cells = getGridHeaderRowCells();
- assertEquals("Column0", cells.get(0).getText());
+ assertEquals("Column 0", cells.get(0).getText());
// Hide column 0
- selectMenuPath("Component", "Columns", "Column0", "Remove");
+ selectMenuPath("Component", "Columns", "Column 0", "Remove");
// Column 1 should now be the first cell
cells = getGridHeaderRowCells();
- assertEquals("Column1", cells.get(0).getText());
+ assertEquals("Column 1", cells.get(0).getText());
}
@Test
@@ -76,9 +67,9 @@ public class GridStructureTest extends GridBasicFeaturesTest {
openTestURL();
// Remove columns 2,3,4
- selectMenuPath("Component", "Columns", "Column2", "Remove");
- selectMenuPath("Component", "Columns", "Column3", "Remove");
- selectMenuPath("Component", "Columns", "Column4", "Remove");
+ selectMenuPath("Component", "Columns", "Column 2", "Remove");
+ selectMenuPath("Component", "Columns", "Column 3", "Remove");
+ selectMenuPath("Component", "Columns", "Column 4", "Remove");
// Scroll so new data is lazy loaded
scrollGridVerticallyTo(1000);
@@ -95,7 +86,7 @@ public class GridStructureTest extends GridBasicFeaturesTest {
openTestURL();
// Freeze column 2
- selectMenuPath("Component", "Columns", "Column2", "Freeze");
+ selectMenuPath("Component", "Columns", "Column 2", "Freeze");
WebElement cell = getBodyCellByRowAndColumn(0, 0);
assertTrue(cell.getAttribute("class").contains("frozen"));
@@ -127,20 +118,20 @@ public class GridStructureTest extends GridBasicFeaturesTest {
assertEquals(100, cell.getSize().getWidth());
// Set first column to be 200px wide
- selectMenuPath("Component", "Columns", "Column0", "Column0 Width",
+ selectMenuPath("Component", "Columns", "Column 0", "Column 0 Width",
"200px");
cell = getBodyCellByRowAndColumn(0, 0);
assertEquals(200, cell.getSize().getWidth());
// Set second column to be 150px wide
- selectMenuPath("Component", "Columns", "Column1", "Column1 Width",
+ selectMenuPath("Component", "Columns", "Column 1", "Column 1 Width",
"150px");
cell = getBodyCellByRowAndColumn(0, 1);
assertEquals(150, cell.getSize().getWidth());
// Set first column to be auto sized (defaults to 100px currently)
- selectMenuPath("Component", "Columns", "Column0", "Column0 Width",
+ selectMenuPath("Component", "Columns", "Column 0", "Column 0 Width",
"Auto");
cell = getBodyCellByRowAndColumn(0, 0);
@@ -203,7 +194,7 @@ public class GridStructureTest extends GridBasicFeaturesTest {
selectMenuPath("Component", "Body rows",
"Modify first row (getContainerProperty)");
assertEquals("(Second) modification with getItemProperty failed",
- "modified: Column0", getBodyCellByRowAndColumn(0, 0).getText());
+ "modified: Column 0", getBodyCellByRowAndColumn(0, 0).getText());
}
private void assertPrimaryStylename(String stylename) {