diff options
author | Patrik Lindström <patrik@vaadin.com> | 2015-09-22 12:01:17 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2015-10-07 13:15:38 +0000 |
commit | d1e8d68248dd9ec97378fa9b909e29dde4358073 (patch) | |
tree | 4a3cee8071cf97d89833e540e669504dec695917 /uitest | |
parent | ec8f3e9bc6955e9916e297b74a12b4a431b69928 (diff) | |
download | vaadin-framework-d1e8d68248dd9ec97378fa9b909e29dde4358073.tar.gz vaadin-framework-d1e8d68248dd9ec97378fa9b909e29dde4358073.zip |
Add handles to Grid default header for column drag resize (#16838)
Change-Id: If8399a13585ae691ea3b3ee4a41a1a38b342adb9
Diffstat (limited to 'uitest')
4 files changed, 54 insertions, 18 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java b/uitest/src/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java index a9e0b03932..422c57d842 100644 --- a/uitest/src/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java @@ -99,9 +99,9 @@ public abstract class AbstractGridColumnAutoWidthTest extends MultiBrowserTest { private WebElement[] getColumn(int i) { WebElement[] col = new WebElement[3]; col[0] = getDriver().findElement( - By.xpath("//thead//th[" + (i + 1) + "]/span")); + By.xpath("//thead//th[" + (i + 1) + "]/div[1]/span")); col[1] = getDriver().findElement( - By.xpath("//tbody//td[" + (i + 1) + "]/span")); + By.xpath("//tbody//td[" + (i + 1) + "]//span")); col[2] = getDriver().findElement( By.xpath("//tbody//td[" + (i + 1) + "]")); return col; diff --git a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java index 8b3a81e660..f5216b4287 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java @@ -18,6 +18,7 @@ package com.vaadin.tests.components.grid; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import com.vaadin.testbench.elements.ButtonElement; @@ -41,10 +42,20 @@ public class GridHeaderStyleNamesTest extends SingleBrowserTest { return grid.getHeaderCell(0, 3); } + private WebElement getMergedHeaderCellContent() { + return getMergedHeaderCell().findElement( + By.cssSelector("div.v-grid-column-header-content")); + } + private GridCellElement getAgeFooterCell() { return grid.getFooterCell(0, 2); } + private WebElement getAgeFooterCellContent() { + return getAgeFooterCell().findElement( + By.cssSelector("div.v-grid-column-footer-content")); + } + @Test public void cellStyleNamesCanBeAddedAndRemoved() { ButtonElement toggleStyles = $(ButtonElement.class).caption( @@ -74,23 +85,23 @@ public class GridHeaderStyleNamesTest extends SingleBrowserTest { if (set) { assertHasStyleName( "Footer cell should have the assigned 'age-footer' class name", - getAgeFooterCell(), "age-footer"); + getAgeFooterCellContent(), "age-footer"); assertHasStyleName( "Header cell should have the assigned 'age' class name", - getAgeHeaderCell(), "age"); + getAgeHeaderCellContent(), "age"); assertHasStyleName( "The merged header cell should have the assigned 'city-country' class name", - getMergedHeaderCell(), "city-country"); + getMergedHeaderCellContent(), "city-country"); } else { assertHasNotStyleName( "Footer cell should not have the removed 'age-footer' class name", - getAgeFooterCell(), "age-footer"); + getAgeFooterCellContent(), "age-footer"); assertHasNotStyleName( "Header cell should not have the removed 'age' class name", - getAgeHeaderCell(), "age"); + getAgeHeaderCellContent(), "age"); assertHasNotStyleName( "Ther merged header cell should not have the removed 'city-country' class name", - getMergedHeaderCell(), "city-country"); + getMergedHeaderCellContent(), "city-country"); } assertHasStyleName( "The default v-grid-cell style name should not be removed from the header cell", @@ -133,6 +144,11 @@ public class GridHeaderStyleNamesTest extends SingleBrowserTest { return grid.getHeaderCell(1, 2); } + private WebElement getAgeHeaderCellContent() { + return getAgeHeaderCell().findElement( + By.cssSelector("div.v-grid-column-header-content")); + } + private WebElement getFooterRow() { return grid.getFooterRow(0); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridStaticSectionTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridStaticSectionTest.java index cc801bf870..ef7d15ff3d 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridStaticSectionTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridStaticSectionTest.java @@ -17,6 +17,9 @@ package com.vaadin.tests.components.grid.basicfeatures.client; import static org.junit.Assert.assertEquals; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + import com.vaadin.testbench.TestBenchElement; import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; @@ -32,16 +35,18 @@ public abstract class GridStaticSectionTest extends GridBasicClientFeaturesTest protected void assertHeaderTexts(int headerId, int rowIndex) { int i = 0; for (TestBenchElement cell : getGridElement().getHeaderCells(rowIndex)) { + WebElement content = cell.findElement(By.tagName("div")); if (i % 3 == 0) { - assertText(String.format("Header (%d,%d)", headerId, i), cell); + assertText(String.format("Header (%d,%d)", headerId, i), + content); } else if (i % 2 == 0) { assertHTML(String.format("<b>Header (%d,%d)</b>", headerId, i), - cell); + content); } else { assertHTML(String.format( "<div class=\"gwt-HTML\">Header (%d,%d)</div>", - headerId, i), cell); + headerId, i), content); } i++; @@ -52,27 +57,30 @@ public abstract class GridStaticSectionTest extends GridBasicClientFeaturesTest protected void assertFooterTexts(int footerId, int rowIndex) { int i = 0; for (TestBenchElement cell : getGridElement().getFooterCells(rowIndex)) { + WebElement content = cell.findElement(By.tagName("div")); + if (i % 3 == 0) { - assertText(String.format("Footer (%d,%d)", footerId, i), cell); + assertText(String.format("Footer (%d,%d)", footerId, i), + content); } else if (i % 2 == 0) { assertHTML(String.format("<b>Footer (%d,%d)</b>", footerId, i), - cell); + content); } else { assertHTML(String.format( "<div class=\"gwt-HTML\">Footer (%d,%d)</div>", - footerId, i), cell); + footerId, i), content); } i++; } assertEquals("number of footer columns", GridBasicFeatures.COLUMNS, i); } - protected static void assertText(String text, TestBenchElement e) { + protected static void assertText(String text, WebElement e) { // TBE.getText returns "" if the element is scrolled out of view assertEquals(text, e.getAttribute("innerHTML")); } - protected static void assertHTML(String text, TestBenchElement e) { + protected static void assertHTML(String text, WebElement e) { String html = e.getAttribute("innerHTML"); // IE 8 returns tags as upper case while other browsers do not, make the diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java index f44f39689c..024e54260a 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java @@ -40,6 +40,17 @@ import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; public class GridStructureTest extends GridBasicFeaturesTest { @Test + public void testResizeHandlesPresent() { + openTestURL(); + + // Test that all column headers contain resize handles + for (int i = 0; i < GridBasicFeatures.COLUMNS; ++i) { + assertFalse(getGridElement().getHeaderCell(0, i).findElement( + By.cssSelector("div.v-grid-column-resize-handle")) == null); + } + } + + @Test public void testRemovingAllColumns() { setDebug(true); openTestURL(); @@ -318,13 +329,14 @@ public class GridStructureTest extends GridBasicFeaturesTest { setDebug(true); openTestURL(); + int col = GridBasicFeatures.COLUMNS; String columnName = "Column " + (GridBasicFeatures.COLUMNS - 1); assertTrue(columnName + " was not present in DOM", - isElementPresent(By.xpath("//th[text()='" + columnName + "']"))); + isElementPresent(By.xpath("//th[" + col + "]/div[1]"))); selectMenuPath("Component", "Columns", columnName, "Add / Remove"); assertFalse(isElementPresent(NotificationElement.class)); assertFalse(columnName + " was still present in DOM", - isElementPresent(By.xpath("//th[text()='" + columnName + "']"))); + isElementPresent(By.xpath("//th[" + col + "]/div[1]"))); } @Test |