diff options
author | John Ahlroos <john@vaadin.com> | 2013-12-05 13:09:26 +0200 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-12-10 10:10:02 +0200 |
commit | 6e8b34434e07490bc5813f62f993d5a8f920afad (patch) | |
tree | a4619d09b603da9dd49b3af1d78df232154b8071 /uitest | |
parent | 117b7915617bc3835f766bccd49e5af6bb3bc723 (diff) | |
download | vaadin-framework-6e8b34434e07490bc5813f62f993d5a8f920afad.tar.gz vaadin-framework-6e8b34434e07490bc5813f62f993d5a8f920afad.zip |
Support primary style names in Escalator and Grid #13058
Change-Id: I8fa99a96c2120583bb1ecd152f8f337aef702614
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java | 20 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java | 112 |
2 files changed, 98 insertions, 34 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java index 42750b1525..82b2d7a4e8 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java @@ -16,6 +16,7 @@ package com.vaadin.tests.components.grid; import java.util.ArrayList; +import java.util.LinkedHashMap; import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; @@ -70,6 +71,8 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { grid.getColumn("Column" + col).setWidth(100 + col * 50); } + createGridActions(); + createColumnActions(); createHeaderActions(); @@ -81,6 +84,23 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { return grid; } + protected void createGridActions() { + LinkedHashMap<String, String> primaryStyleNames = new LinkedHashMap<String, String>(); + primaryStyleNames.put("v-grid", "v-grid"); + primaryStyleNames.put("v-escalator", "v-escalator"); + primaryStyleNames.put("my-grid", "my-grid"); + + createMultiClickAction("Primary style name", "State", + primaryStyleNames, new Command<Grid, String>() { + + @Override + public void execute(Grid grid, String value, Object data) { + grid.setPrimaryStyleName(value); + + } + }, primaryStyleNames.get("v-grid")); + } + protected void createHeaderActions() { createCategory("Headers", null); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java index 3833feeed1..8beee46156 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java @@ -39,9 +39,7 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { openTestURL(); // Column headers should be visible - List<WebElement> cells = getDriver() - .findElements( - By.xpath("//thead[contains(@class, 'v-escalator-header')]//th")); + List<WebElement> cells = getGridHeaderRowCells(); assertEquals(10, cells.size()); assertEquals("Column0", cells.get(0).getText()); assertEquals("Column1", cells.get(1).getText()); @@ -52,19 +50,15 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { 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()); + List<WebElement> cells = getGridFooterRowCells(); + assertEquals(0, cells.size()); // Open footer row selectMenuPath("Component", "Footers", "Visible"); // Footers should now be visible - List<WebElement> cells = getDriver().findElements( - By.xpath(footerCellPath)); + cells = getGridFooterRowCells(); assertEquals(10, cells.size()); assertEquals("Footer 0", cells.get(0).getText()); assertEquals("Footer 1", cells.get(1).getText()); @@ -78,27 +72,24 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { // Hide column headers for this test selectMenuPath("Component", "Headers", "Visible"); - String headerCellPath = "//thead[contains(@class, 'v-escalator-header')]//th"; + List<WebElement> cells = getGridHeaderRowCells(); // header row should be empty - assertEquals(0, getDriver().findElements(By.xpath(headerCellPath)) - .size()); + assertEquals(0, cells.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()); + cells = getGridHeaderRowCells(); + assertEquals(10, cells.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)); + cells = getGridHeaderRowCells(); assertEquals("Column 0 & 1", cells.get(0).getText()); - assertEquals("Column 0 & 1", cells.get(1).getText()); } @Test @@ -116,13 +107,8 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { 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)); + List<WebElement> cells = getGridFooterRowCells(); assertEquals("Column 0 & 1", cells.get(0).getText()); - assertEquals("Column 0 & 1", cells.get(1).getText()); } @Test @@ -150,16 +136,14 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { openTestURL(); // Column 0 should be visible - String headerCellPath = "//thead[contains(@class, 'v-escalator-header')]//th"; - List<WebElement> cells = getDriver().findElements( - By.xpath(headerCellPath)); + List<WebElement> cells = getGridHeaderRowCells(); 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)); + cells = getGridHeaderRowCells(); assertEquals("Column1", cells.get(0).getText()); } @@ -168,16 +152,14 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { openTestURL(); // Column 0 should be visible - String headerCellPath = "//thead[contains(@class, 'v-escalator-header')]//th"; - List<WebElement> cells = getDriver().findElements( - By.xpath(headerCellPath)); + List<WebElement> cells = getGridHeaderRowCells(); 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)); + cells = getGridHeaderRowCells(); assertEquals("Column1", cells.get(0).getText()); } @@ -251,13 +233,46 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { cell = getBodyCellByRowAndColumn(1, 1); assertEquals((100 - cellBorder - cellMargin) + "px", cell.getCssValue("width")); + } + + @Test + public void testPrimaryStyleNames() throws Exception { + openTestURL(); + + // v-grid is default primary style namea + assertPrimaryStylename("v-grid"); + + selectMenuPath("Component", "State", "Primary style name", + "v-escalator"); + assertPrimaryStylename("v-escalator"); + + selectMenuPath("Component", "State", "Primary style name", "my-grid"); + assertPrimaryStylename("my-grid"); + + selectMenuPath("Component", "State", "Primary style name", "v-grid"); + assertPrimaryStylename("v-grid"); + } + + private void assertPrimaryStylename(String stylename) { + assertTrue(getGridElement().getAttribute("class").contains(stylename)); + + String tableWrapperStyleName = getTableWrapper().getAttribute("class"); + assertTrue(tableWrapperStyleName.contains(stylename + "-tablewrapper")); + + String hscrollStyleName = getHorizontalScroller().getAttribute("class"); + assertTrue(hscrollStyleName.contains(stylename + "-scroller")); + assertTrue(hscrollStyleName + .contains(stylename + "-scroller-horizontal")); + String vscrollStyleName = getVerticalScroller().getAttribute("class"); + assertTrue(vscrollStyleName.contains(stylename + "-scroller")); + assertTrue(vscrollStyleName.contains(stylename + "-scroller-vertical")); } private WebElement getBodyCellByRowAndColumn(int row, int column) { return getDriver().findElement( - By.xpath("//tbody[contains(@class, 'v-escalator-body')]/tr[" - + row + "]/td[" + column + "]")); + By.xpath("//div[@id='testComponent']//tbody/tr[" + row + + "]/td[" + column + "]")); } private void selectSubMenu(String menuCaption) { @@ -276,4 +291,33 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { selectSubMenu(menuCaptions[i]); } } + + private WebElement getVerticalScroller() { + return getDriver().findElement( + By.xpath("//div[@id='testComponent']/div[1]")); + } + + private WebElement getHorizontalScroller() { + return getDriver().findElement( + By.xpath("//div[@id='testComponent']/div[2]")); + } + + private WebElement getTableWrapper() { + return getDriver().findElement( + By.xpath("//div[@id='testComponent']/div[3]")); + } + + private WebElement getGridElement() { + return getDriver().findElement(By.id("testComponent")); + } + + private List<WebElement> getGridHeaderRowCells() { + return getDriver().findElements( + By.xpath("//div[@id='testComponent']//thead//th")); + } + + private List<WebElement> getGridFooterRowCells() { + return getDriver().findElements( + By.xpath("//div[@id='testComponent']//tfoot//td")); + } } |