aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2016-11-21 12:54:17 +0200
committerPekka Hyvönen <pekka@vaadin.com>2016-11-30 11:49:04 +0200
commitc3ad14183d72ed48088b7a5bb528e896a9797e32 (patch)
tree8bbc0b880f819b188f5eea42a6469a08f8952864 /uitest/src/test
parent373bd63dcd2ed659d953ad591c4099b658aec8f6 (diff)
downloadvaadin-framework-c3ad14183d72ed48088b7a5bb528e896a9797e32.tar.gz
vaadin-framework-c3ad14183d72ed48088b7a5bb528e896a9797e32.zip
Enable select all checkbox for MultiSelection Grid.
It is by default shown only if used data provider is in-memory. Can be configured to be explicitly shown or hidden. Change-Id: I50569d915604c3722a22e14b7628663d5680ed83
Diffstat (limited to 'uitest/src/test')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridDisabledMultiselectTest.java10
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java8
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllTest.java201
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java52
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicSelectionTest.java84
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java35
6 files changed, 244 insertions, 146 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisabledMultiselectTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisabledMultiselectTest.java
index 8bc58450c8..8ddf7cb1ff 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisabledMultiselectTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisabledMultiselectTest.java
@@ -48,22 +48,20 @@ public class GridDisabledMultiselectTest extends MultiBrowserTest {
setMultiselect();
- // TODO enable once select all is added back
- // assertThat(getSelectAllCheckBox().isEnabled(), is(false));
+ assertThat(getSelectAllCheckBox().isEnabled(), is(false));
assertThat(getFirstSelectCheckBox().isEnabled(), is(false));
}
@Test
public void checkBoxesAreDisabledAfterDisabled() {
setMultiselect();
- // TODO enable once select all is added back
- // assertThat(getSelectAllCheckBox().isEnabled(), is(true));
+
+ assertThat(getSelectAllCheckBox().isEnabled(), is(true));
assertThat(getFirstSelectCheckBox().isEnabled(), is(true));
disable();
- // TODO enable once select all is added back
- // assertThat(getSelectAllCheckBox().isEnabled(), is(false));
+ assertThat(getSelectAllCheckBox().isEnabled(), is(false));
assertThat(getFirstSelectCheckBox().isEnabled(), is(false));
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java
index 6abcb71e8c..09be45414b 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java
@@ -35,8 +35,7 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridMultiSelectionOnInitTest extends MultiBrowserTest {
- // TODO enable when select all is added back
- // @Test
+ @Test
public void testSelectAllCheckBoxExists() {
openTestURL();
assertTrue("The select all checkbox was missing.",
@@ -44,9 +43,10 @@ public class GridMultiSelectionOnInitTest extends MultiBrowserTest {
.isElementPresent(By.tagName("input")));
}
- // TODO enable when select all is added back
- // @Test
+ @Test
public void selectAllCellCanBeClicked() throws IOException {
+ openTestURL();
+
GridElement.GridCellElement selectAllCell = $(GridElement.class).first()
.getHeaderCell(0, 0);
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllTest.java
index 26fdeedd7b..f58e0db6b4 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllTest.java
@@ -1,5 +1,6 @@
package com.vaadin.tests.components.grid;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -12,18 +13,7 @@ import com.vaadin.tests.components.grid.basics.GridBasicsTest;
public class GridSelectAllTest extends GridBasicsTest {
- // TODO remove once select all is added
@Test
- public void testSelectAllCheckBoxNotVisble() {
- setSelectionModelMulti();
- GridCellElement header = getGridElement().getHeaderCell(0, 0);
-
- assertFalse("Checkbox visible",
- header.isElementPresent(By.tagName("input")));
- }
-
- // TODO enable once select all is added
- // @Test
public void testSelectAllCheckbox() {
setSelectionModelMulti();
GridCellElement header = getGridElement().getHeaderCell(0, 0);
@@ -41,8 +31,7 @@ public class GridSelectAllTest extends GridBasicsTest {
getGridElement().getRow(100).isSelected());
}
- // TODO enable once select all is added
- // @Test
+ @Test
public void testSelectAllAndSort() {
setSelectionModelMulti();
GridCellElement header = getGridElement().getHeaderCell(0, 0);
@@ -60,13 +49,12 @@ public class GridSelectAllTest extends GridBasicsTest {
"Exception occured, java.lang.IllegalStateException: No item id for key 101 found."));
}
- // TODO enable once select all is added
- // @Test
+ @Test
public void testSelectAllCheckboxWhenChangingModels() {
GridCellElement header;
header = getGridElement().getHeaderCell(0, 0);
assertFalse(
- "Check box shouldn't have been in header for None Selection Model",
+ "Check box shouldn't have been in header for Single Selection Model",
header.isElementPresent(By.tagName("input")));
setSelectionModelMulti();
@@ -93,16 +81,189 @@ public class GridSelectAllTest extends GridBasicsTest {
header.isElementPresent(By.tagName("input")));
}
- // TODO enable once select all is added
- // @Test
+ @Test
public void testSelectAllCheckboxWithHeaderOperations() {
setSelectionModelMulti();
- selectMenuPath("Component", "Header", "Prepend row");
- selectMenuPath("Component", "Header", "Append row");
+ selectMenuPath("Component", "Header", "Prepend header row");
+ assertEquals(2, getGridElement().getHeaderCount());
+ selectMenuPath("Component", "Header", "Append header row");
+ assertEquals(3, getGridElement().getHeaderCount());
GridCellElement header = getGridElement().getHeaderCell(1, 0);
assertTrue("Multi Selection Model should have select all checkbox",
header.isElementPresent(By.tagName("input")));
}
+ @Test
+ public void testSelectAllCheckboxAfterPrependHeaderOperations() {
+ selectMenuPath("Component", "Header", "Prepend header row");
+ assertEquals(2, getGridElement().getHeaderCount());
+
+ setSelectionModelMulti();
+ GridCellElement header = getGridElement().getHeaderCell(1, 0);
+ assertTrue("Multi Selection Model should have select all checkbox",
+ header.isElementPresent(By.tagName("input")));
+
+ setSelectionModelSingle();
+ header = getGridElement().getHeaderCell(1, 0);
+ assertFalse(
+ "Check box shouldn't have been in header for Single Selection Model",
+ header.isElementPresent(By.tagName("input")));
+
+ selectMenuPath("Component", "Header", "Append header row");
+ assertEquals(3, getGridElement().getHeaderCount());
+
+ setSelectionModelMulti();
+ header = getGridElement().getHeaderCell(1, 0);
+ assertTrue("Multi Selection Model should have select all checkbox",
+ header.isElementPresent(By.tagName("input")));
+ }
+
+ @Test
+ public void testSelectAllCheckbox_selectedAllFromClient_afterDeselectingOnClientSide_notSelected() {
+ setSelectionModelMulti();
+
+ verifyAllSelected(false);
+
+ getSelectAllCheckbox().click();
+
+ verifyAllSelected(true);
+
+ getGridElement().getCell(5, 0).click();
+
+ verifyAllSelected(false);
+
+ getGridElement().getCell(5, 0).click();
+
+ verifyAllSelected(false); // EXPECTED since multiselection model can't
+ // verify that all have been selected
+ }
+
+ @Test
+ public void testSelectAllCheckbox_selectedAllFromClient_afterDeselectingOnServerSide_notSelected() {
+ setSelectionModelMulti();
+
+ verifyAllSelected(false);
+
+ getSelectAllCheckbox().click();
+
+ verifyAllSelected(true);
+
+ toggleFirstRowSelection();
+
+ verifyAllSelected(false);
+
+ toggleFirstRowSelection();
+
+ verifyAllSelected(false); // EXPECTED since multiselection model can't
+ // verify that all have been selected
+ }
+
+ @Test
+ public void testSelectAllCheckbox_selectedAllFromServer_afterDeselectingOnClientSide_notSelected() {
+ selectAll(); // triggers selection model change
+
+ verifyAllSelected(true);
+
+ getGridElement().getCell(5, 0).click();
+
+ verifyAllSelected(false);
+
+ getGridElement().getCell(5, 0).click();
+
+ verifyAllSelected(false); // EXPECTED since multiselection model can't
+ // verify that all have been selected
+ }
+
+ @Test
+ public void testSelectAllCheckbox_selectedAllFromServer_afterDeselectingOnServerSide_notSelected() {
+ selectAll(); // triggers selection model change
+
+ verifyAllSelected(true);
+
+ toggleFirstRowSelection();
+
+ verifyAllSelected(false);
+
+ toggleFirstRowSelection();
+
+ verifyAllSelected(false); // EXPECTED since multiselection model can't
+ // verify that all have been selected
+ }
+
+ @Test
+ public void testSelectAllCheckbox_triggerVisibility() {
+ verifySelectAllNotVisible();
+
+ setSelectionModelMulti();
+
+ verifySelectAllVisible();
+
+ setSelectAllCheckBoxHidden();
+
+ verifySelectAllNotVisible();
+
+ setSelectAllCheckBoxDefault();
+
+ verifySelectAllVisible(); // visible because in memory data provider
+
+ setSelectAllCheckBoxHidden();
+
+ verifySelectAllNotVisible();
+
+ setSelectAllCheckBoxVisible();
+
+ verifySelectAllVisible();
+ }
+
+ @Test
+ public void testSelectAllCheckboxNotVisible_selectAllFromServer_staysHidden() {
+ setSelectionModelMulti();
+
+ verifySelectAllVisible();
+
+ setSelectAllCheckBoxHidden();
+
+ verifySelectAllNotVisible();
+
+ selectAll();
+
+ verifySelectAllNotVisible();
+ }
+
+ @Test
+ public void testSelectAll_immediatelyWhenSettingSelectionModel() {
+ verifySelectAllNotVisible();
+
+ selectAll(); // changes selection model too
+
+ verifyAllSelected(true);
+ }
+
+ @Test
+ public void testSelectAllCheckBoxHidden_immediatelyWhenChaningModel() {
+ verifySelectAllNotVisible();
+
+ setSelectAllCheckBoxHidden(); // changes selection model
+
+ verifySelectAllNotVisible();
+ }
+
+ private void verifyAllSelected(boolean selected) {
+ verifySelectAllVisible();
+ assertEquals("Select all checkbox selection state wrong", selected,
+ getSelectAllCheckbox().isSelected());
+ }
+
+ private void verifySelectAllVisible() {
+ assertTrue("Select all checkbox should be displayed",
+ getSelectAllCheckbox().isDisplayed());
+ }
+
+ private void verifySelectAllNotVisible() {
+ assertEquals("Select all checkbox should not be displayed", 0,
+ getGridElement().getHeaderCell(0, 0)
+ .findElements(By.tagName("input")).size());
+ }
+
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java
index f7bd514e7b..e42fcf2d69 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java
@@ -127,9 +127,8 @@ public class GridSelectionTest extends GridBasicsTest {
"SingleSelectionEvent: Selected: DataObject[0]"));
}
- // TODO enable once select with space key is added
- // @Test
- public void testKeyboardSelection() {
+ @Test
+ public void testKeyboardWithMultiSelection() {
openTestURL();
setSelectionModelMulti();
@@ -153,8 +152,7 @@ public class GridSelectionTest extends GridBasicsTest {
grid.getRow(3).isSelected());
}
- // TODO enable once select with space key is added
- // @Test
+ @Test
public void testKeyboardWithSingleSelection() {
openTestURL();
setSelectionModelSingle();
@@ -189,7 +187,7 @@ public class GridSelectionTest extends GridBasicsTest {
setSelectionModelMulti();
- getGridElement().getCell(5, 1).click();
+ getGridElement().getCell(5, 0).click();
assertTrue("Row should be selected after clicking",
getRow(5).isSelected());
@@ -210,40 +208,36 @@ public class GridSelectionTest extends GridBasicsTest {
.getAttribute("class")
.contains("v-grid-selection-checkbox"));
- // TODO enable once select all is added
- // GridCellElement header = getGridElement().getHeaderCell(0, 0);
- // assertTrue("Select all CheckBox should have the proper style name
- // set",
- // header.findElement(By.tagName("span")).getAttribute("class")
- // .contains("v-grid-select-all-checkbox"));
+ GridCellElement header = getGridElement().getHeaderCell(0, 0);
+ assertTrue("Select all CheckBox should have the proper style name set",
+ header.findElement(By.tagName("span")).getAttribute("class")
+ .contains("v-grid-select-all-checkbox"));
}
- // TODO enable once select all is added
- // @Test
+ @Test
public void testServerSideSelectTogglesSelectAllCheckBox() {
openTestURL();
setSelectionModelMulti();
- GridCellElement header = getGridElement().getHeaderCell(0, 0);
-
- WebElement selectAll = header.findElement(By.tagName("input"));
+ assertFalse("Select all CheckBox should not be selected",
+ getSelectAllCheckbox().isSelected());
- selectMenuPath("Component", "State", "Select all");
- waitUntilCheckBoxValue(selectAll, true);
+ selectAll();
+ waitUntilCheckBoxValue(getSelectAllCheckbox(), true);
assertTrue("Select all CheckBox wasn't selected as expected",
- selectAll.isSelected());
+ getSelectAllCheckbox().isSelected());
- selectMenuPath("Component", "State", "Select none");
- waitUntilCheckBoxValue(selectAll, false);
+ deselectAll();
+ waitUntilCheckBoxValue(getSelectAllCheckbox(), false);
assertFalse("Select all CheckBox was selected unexpectedly",
- selectAll.isSelected());
+ getSelectAllCheckbox().isSelected());
- selectMenuPath("Component", "State", "Select all");
- waitUntilCheckBoxValue(selectAll, true);
+ selectAll();
+ waitUntilCheckBoxValue(getSelectAllCheckbox(), true);
getGridElement().getCell(5, 0).click();
- waitUntilCheckBoxValue(selectAll, false);
+ waitUntilCheckBoxValue(getSelectAllCheckbox(), false);
assertFalse("Select all CheckBox was selected unexpectedly",
- selectAll.isSelected());
+ getSelectAllCheckbox().isSelected());
}
@Test
@@ -272,10 +266,6 @@ public class GridSelectionTest extends GridBasicsTest {
}, 5);
}
- private void toggleFirstRowSelection() {
- selectMenuPath("Component", "Body rows", "Toggle first row selection");
- }
-
private GridRowElement getRow(int i) {
return getGridElement().getRow(i);
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicSelectionTest.java
deleted file mode 100644
index 82de23a90b..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicSelectionTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.vaadin.tests.components.grid.basics;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.openqa.selenium.Keys;
-import org.openqa.selenium.interactions.Actions;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.GridElement.GridRowElement;
-
-public class GridBasicSelectionTest extends GridBasicsTest {
-
- @Test
- public void testKeyboardWithSingleSelection() {
-
- GridElement grid = getGridElement();
- grid.getCell(3, 1).click();
-
- assertTrue("Grid row 3 was not selected with clicking.",
- grid.getRow(3).isSelected());
-
- new Actions(getDriver()).sendKeys(Keys.SPACE).perform();
-
- assertTrue("Grid row 3 was not deselected with space key.",
- !grid.getRow(3).isSelected());
-
- new Actions(getDriver()).sendKeys(Keys.SPACE).perform();
-
- assertTrue("Grid row 3 was not selected with space key.",
- grid.getRow(3).isSelected());
-
- grid.scrollToRow(500);
-
- new Actions(getDriver()).sendKeys(Keys.SPACE).perform();
-
- assertTrue("Grid row 3 was not deselected with space key.",
- !grid.getRow(3).isSelected());
- }
-
- @Test
- public void testSingleSelectionUpdatesFromServer() {
- GridElement grid = getGridElement();
- assertFalse("First row was selected from start",
- grid.getRow(0).isSelected());
- toggleFirstRowSelection();
- assertTrue("First row was not selected.", getRow(0).isSelected());
- assertTrue("Selection event was not correct", logContainsText(
- "SingleSelectionEvent: Selected: DataObject[0]"));
- grid.getCell(5, 0).click();
- assertTrue("Fifth row was not selected.", getRow(5).isSelected());
- assertFalse("First row was still selected.", getRow(0).isSelected());
- assertTrue("Selection event was not correct", logContainsText(
- "SingleSelectionEvent: Selected: DataObject[5]"));
- grid.getCell(0, 3).click();
- assertTrue("Selection event was not correct", logContainsText(
- "SingleSelectionEvent: Selected: DataObject[0]"));
- toggleFirstRowSelection();
- assertTrue("Selection event was not correct",
- logContainsText("SingleSelectionEvent: Selected: none"));
- assertFalse("First row was still selected.", getRow(0).isSelected());
- assertFalse("Fifth row was still selected.", getRow(5).isSelected());
-
- grid.scrollToRow(600);
- grid.getCell(595, 3).click();
- assertTrue("Row 595 was not selected.", getRow(595).isSelected());
- assertTrue("Selection event was not correct", logContainsText(
- "SingleSelectionEvent: Selected: DataObject[595]"));
- toggleFirstRowSelection();
- assertFalse("Row 595 was still selected.", getRow(595).isSelected());
- assertTrue("First row was not selected.", getRow(0).isSelected());
- assertTrue("Selection event was not correct", logContainsText(
- "SingleSelectionEvent: Selected: DataObject[0]"));
- }
-
- private void toggleFirstRowSelection() {
- selectMenuPath("Component", "Body rows", "Toggle first row selection");
- }
-
- private GridRowElement getRow(int i) {
- return getGridElement().getRow(i);
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java
index ff6789f600..20e94cb7a6 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java
@@ -215,6 +215,18 @@ public abstract class GridBasicsTest extends MultiBrowserTest {
getGridVerticalScrollbar())).intValue();
}
+ protected void toggleFirstRowSelection() {
+ selectMenuPath("Component", "Body rows", "Toggle first row selection");
+ }
+
+ protected void selectAll() {
+ selectMenuPath("Component", "State", "Selection model", "Select All");
+ }
+
+ protected void deselectAll() {
+ selectMenuPath("Component", "State", "Selection model", "Deselect All");
+ }
+
protected void setSelectionModelMulti() {
selectMenuPath("Component", "State", "Selection model", "multi");
}
@@ -223,7 +235,28 @@ public abstract class GridBasicsTest extends MultiBrowserTest {
selectMenuPath("Component", "State", "Selection model", "single");
}
- // TODO enable once select all is added
+ protected void setSelectAllCheckBoxVisible() {
+ selectMenuPath("Component", "State", "Selection model",
+ "SelectAllCheckbox: Visible");
+ }
+
+ protected void setSelectAllCheckBoxHidden() {
+ selectMenuPath("Component", "State", "Selection model",
+ "SelectAllCheckbox: Hidden");
+ }
+
+ protected void setSelectAllCheckBoxDefault() {
+ selectMenuPath("Component", "State", "Selection model",
+ "SelectAllCheckbox: Default");
+ }
+
+ protected WebElement getSelectAllCheckbox() {
+ GridCellElement header = getGridElement().getHeaderCell(0, 0);
+
+ return header.findElement(By.tagName("input"));
+ }
+
+ // TODO enable once select model none is added
// protected void setSelectionModelNone() {
// selectMenuPath("Component", "State", "Selection model", "none");
// }