aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2013-11-25 11:23:04 +0200
committerVaadin Code Review <review@vaadin.com>2013-11-26 07:52:49 +0000
commit48045b06c90d0b88f431ddd075e1e7774e614bf6 (patch)
treea4228ad6b43a6b8397df248641189dcd7c44e212 /uitest
parenta512c349efed5caf6ad4b0ed585a7bc1f912d5f2 (diff)
downloadvaadin-framework-48045b06c90d0b88f431ddd075e1e7774e614bf6.tar.gz
vaadin-framework-48045b06c90d0b88f431ddd075e1e7774e614bf6.zip
Testbench tests for Column api #12830
Change-Id: Icb07f2540db2299de95873e4062eb680d6ab5bd2
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java218
2 files changed, 219 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java
index afc9f91e68..82e8d5d908 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java
@@ -181,7 +181,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
}, row);
- for (int i = 0; i < COLUMNS; i += 2) {
+ for (int i = 0; i < COLUMNS; i++) {
final int columnIndex = i;
createClickAction("Group Column " + columnIndex
+ " & " + (columnIndex + 1),
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java
new file mode 100644
index 0000000000..7d0e840390
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class GridBasicFeaturesTest extends MultiBrowserTest {
+
+ @Test
+ public void testColumnHeaderCaptions() throws Exception {
+ openTestURL();
+
+ // Column headers should be visible
+ List<WebElement> cells = getDriver()
+ .findElements(
+ By.xpath("//thead[contains(@class, 'v-escalator-header')]//th"));
+ assertEquals(10, cells.size());
+ assertEquals("Column0", cells.get(0).getText());
+ assertEquals("Column1", cells.get(1).getText());
+ assertEquals("Column2", cells.get(2).getText());
+ }
+
+ @Test
+ public void testColumnFooterCaptions() throws Exception {
+ openTestURL();
+
+ String footerCellPath = "//tfoot[contains(@class, 'v-escalator-footer')]"
+ + "//td[contains(@class, 'v-escalator-cell')]";
+
+ // footer row should by default be hidden
+ assertEquals(0, getDriver().findElements(By.xpath(footerCellPath))
+ .size());
+
+ // Open footer row
+ selectMenuPath("Component", "Footers", "Visible");
+
+ // Footers should now be visible
+ List<WebElement> cells = getDriver().findElements(
+ By.xpath(footerCellPath));
+ assertEquals(10, cells.size());
+ assertEquals("Footer 0", cells.get(0).getText());
+ assertEquals("Footer 1", cells.get(1).getText());
+ assertEquals("Footer 2", cells.get(2).getText());
+ }
+
+ @Test
+ public void testColumnGroupHeaders() throws Exception {
+ openTestURL();
+
+ // Hide column headers for this test
+ selectMenuPath("Component", "Headers", "Visible");
+
+ String headerCellPath = "//thead[contains(@class, 'v-escalator-header')]//th";
+
+ // header row should be empty
+ assertEquals(0, getDriver().findElements(By.xpath(headerCellPath))
+ .size());
+
+ // add a group row
+ selectMenuPath("Component", "Column groups", "Add group row");
+
+ // Empty group row cells should be present
+ assertEquals(10, getDriver().findElements(By.xpath(headerCellPath))
+ .size());
+
+ // Group columns 0 & 1
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 0 & 1");
+
+ List<WebElement> cells = getDriver().findElements(
+ By.xpath(headerCellPath));
+ assertEquals("Column 0 & 1", cells.get(0).getText());
+ assertEquals("Column 0 & 1", cells.get(1).getText());
+ }
+
+ @Test
+ public void testColumnGroupFooters() throws Exception {
+ openTestURL();
+
+ // add a group row
+ selectMenuPath("Component", "Column groups", "Add group row");
+
+ // Set footer visible
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Footer Visible");
+
+ // Group columns 0 & 1
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 0 & 1");
+
+ String footerCellPath = "//tfoot[contains(@class, 'v-escalator-footer')]"
+ + "//td[contains(@class, 'v-escalator-cell')]";
+
+ List<WebElement> cells = getDriver().findElements(
+ By.xpath(footerCellPath));
+ assertEquals("Column 0 & 1", cells.get(0).getText());
+ assertEquals("Column 0 & 1", cells.get(1).getText());
+ }
+
+ @Test
+ public void testGroupingSameColumnsOnRowThrowsException() throws Exception {
+ openTestURL();
+
+ // add a group row
+ selectMenuPath("Component", "Column groups", "Add group row");
+
+ // Group columns 0 & 1
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 0 & 1");
+
+ // Group columns 1 & 2 shoud fail
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 1 & 2");
+
+ assertTrue(getLogRow(0)
+ .contains(
+ "Exception occured, java.lang.IllegalArgumentExceptionColumn Column1 already belongs to another group."));
+ }
+
+ @Test
+ public void testHidingColumn() throws Exception {
+ openTestURL();
+
+ // Column 0 should be visible
+ String headerCellPath = "//thead[contains(@class, 'v-escalator-header')]//th";
+ List<WebElement> cells = getDriver().findElements(
+ By.xpath(headerCellPath));
+ assertEquals("Column0", cells.get(0).getText());
+
+ // Hide column 0
+ selectMenuPath("Component", "Columns", "Column0", "Visible");
+
+ // Column 1 should now be the first cell
+ cells = getDriver().findElements(By.xpath(headerCellPath));
+ assertEquals("Column1", cells.get(0).getText());
+ }
+
+ @Test
+ public void testRemovingColumn() throws Exception {
+ openTestURL();
+
+ // Column 0 should be visible
+ String headerCellPath = "//thead[contains(@class, 'v-escalator-header')]//th";
+ List<WebElement> cells = getDriver().findElements(
+ By.xpath(headerCellPath));
+ assertEquals("Column0", cells.get(0).getText());
+
+ // Hide column 0
+ selectMenuPath("Component", "Columns", "Column0", "Remove");
+
+ // Column 1 should now be the first cell
+ cells = getDriver().findElements(By.xpath(headerCellPath));
+ assertEquals("Column1", cells.get(0).getText());
+ }
+
+ @Test
+ public void testFreezingColumn() throws Exception {
+ openTestURL();
+
+ // Freeze column 2
+ selectMenuPath("Component", "Columns", "Column2", "Freeze");
+
+ WebElement cell = getDriver()
+ .findElement(
+ By.xpath("//tbody[contains(@class, 'v-escalator-body')]/tr[1]/td[1]"));
+ assertTrue(cell.getAttribute("class").contains("frozen"));
+
+ cell = getDriver()
+ .findElement(
+ By.xpath("//tbody[contains(@class, 'v-escalator-body')]/tr[1]/td[2]"));
+ assertTrue(cell.getAttribute("class").contains("frozen"));
+ }
+
+ private void selectSubMenu(String menuCaption) {
+ selectMenu(menuCaption);
+ new Actions(getDriver()).moveByOffset(100, 0).build().perform();
+ }
+
+ private void selectMenu(String menuCaption) {
+ getDriver().findElement(
+ By.xpath("//span[text() = '" + menuCaption + "']")).click();
+ }
+
+ private void selectMenuPath(String... menuCaptions) {
+ selectMenu(menuCaptions[0]);
+ for (int i = 1; i < menuCaptions.length; i++) {
+ selectSubMenu(menuCaptions[i]);
+ }
+ }
+}