summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeppo Kurki <teppo.kurki@vaadin.com>2015-07-09 23:23:35 +0300
committerpatrik <patrik@vaadin.com>2015-08-05 12:36:42 +0300
commitf031c9a46c9d4b1eedb9e86c2e72ab97f5847593 (patch)
tree9eeee879bf0a5e2f77c77ad6d59f919313fb7623 /uitest
parent4f3533115bae0acd251405a1c70feb8c62756c2f (diff)
downloadvaadin-framework-f031c9a46c9d4b1eedb9e86c2e72ab97f5847593.tar.gz
vaadin-framework-f031c9a46c9d4b1eedb9e86c2e72ab97f5847593.zip
Update Select all -CheckBox from server and partial selections (#17590)
Change-Id: Iab111504502dc104cb9ce8777dbaf87bba1e31a0
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java20
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java40
2 files changed, 60 insertions, 0 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 ef51cdf446..6511866897 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -683,6 +683,26 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
c.setColumnReorderingAllowed(value);
}
});
+
+ createClickAction("Select all", "State", new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ SelectionModel selectionModel = c.getSelectionModel();
+ if (selectionModel instanceof SelectionModel.Multi) {
+ ((SelectionModel.Multi) selectionModel).selectAll();
+ }
+ }
+ }, null);
+
+ createClickAction("Select none", "State", new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ SelectionModel selectionModel = c.getSelectionModel();
+ if (selectionModel instanceof SelectionModel.Multi) {
+ ((SelectionModel.Multi) selectionModel).deselectAll();
+ }
+ }
+ }, null);
}
protected void createHeaderActions() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java
index 9953bbcae0..1f3085d273 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java
@@ -20,8 +20,10 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.GridElement;
@@ -335,6 +337,44 @@ public class GridSelectionTest extends GridBasicFeaturesTest {
getRow(5).isSelected());
}
+ @Test
+ public void testServerSideSelectTogglesSelectAllCheckBox() {
+ openTestURL();
+
+ setSelectionModelMulti();
+ GridCellElement header = getGridElement().getHeaderCell(0, 0);
+
+ WebElement selectAll = header.findElement(By.tagName("input"));
+
+ selectMenuPath("Component", "State", "Select all");
+ waitUntilCheckBoxValue(selectAll, true);
+ assertTrue("Select all CheckBox wasn't selected as expected",
+ selectAll.isSelected());
+
+ selectMenuPath("Component", "State", "Select none");
+ waitUntilCheckBoxValue(selectAll, false);
+ assertFalse("Select all CheckBox was selected unexpectedly",
+ selectAll.isSelected());
+
+ selectMenuPath("Component", "State", "Select all");
+ waitUntilCheckBoxValue(selectAll, true);
+ getGridElement().getCell(5, 0).click();
+ waitUntilCheckBoxValue(selectAll, false);
+ assertFalse("Select all CheckBox was selected unexpectedly",
+ selectAll.isSelected());
+ }
+
+ private void waitUntilCheckBoxValue(final WebElement checkBoxElememnt,
+ final boolean expectedValue) {
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ return expectedValue ? checkBoxElememnt.isSelected()
+ : !checkBoxElememnt.isSelected();
+ }
+ }, 5);
+ }
+
private void setSelectionModelMulti() {
selectMenuPath("Component", "State", "Selection mode", "multi");
}