diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2015-08-26 21:43:17 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-05-13 12:21:46 +0000 |
commit | 7f3481b7a69d9edc31c7e70b305ece6816eee36f (patch) | |
tree | a96219d0ff50c4531625886c0af271ed97e7384a /uitest/src | |
parent | c6f185a1c420af5ca67a5dc9200db15dcc8e2365 (diff) | |
download | vaadin-framework-7f3481b7a69d9edc31c7e70b305ece6816eee36f.tar.gz vaadin-framework-7f3481b7a69d9edc31c7e70b305ece6816eee36f.zip |
Disable multiselect checkboxes when Grid is disabled. (#18560)
Change-Id: Ief0531fe90b9bc8bcf0a60132211a0633b9401d4
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java | 32 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridDisabledMultiselectTest.java | 81 |
2 files changed, 113 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java new file mode 100644 index 0000000000..4846a41672 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.components.grid; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Grid; + +public class GridDisabledMultiselect extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Grid grid = new Grid(); + grid.addColumn("foo", String.class); + grid.addRow("bar"); + grid.setSelectionMode(Grid.SelectionMode.SINGLE); + addComponent(grid); + + addButton("Multi", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + grid.setSelectionMode(Grid.SelectionMode.MULTI); + } + }); + + addButton("Disable", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + grid.setEnabled(!grid.isEnabled()); + } + }); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..390b855c55 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisabledMultiselectTest.java @@ -0,0 +1,81 @@ +package com.vaadin.tests.components.grid; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridDisabledMultiselectTest extends MultiBrowserTest { + + @Override + public void setup() throws Exception { + super.setup(); + + openTestURL(); + } + + private void disable() { + $(ButtonElement.class).caption("Disable").first().click(); + } + + private void setMultiselect() { + $(ButtonElement.class).caption("Multi").first().click(); + } + + private WebElement getSelectAllCheckBox() { + return findCheckBoxes().get(0); + } + + private List<WebElement> findCheckBoxes() { + return findElements(By.cssSelector("span input")); + } + + private WebElement getFirstSelectCheckBox() { + return findCheckBoxes().get(1); + } + + @Test + public void checkBoxesAreDisabledAfterModeChange() { + disable(); + + setMultiselect(); + + assertThat(getSelectAllCheckBox().isEnabled(), is(false)); + assertThat(getFirstSelectCheckBox().isEnabled(), is(false)); + } + + @Test + public void checkBoxesAreDisabledAfterDisabled() { + setMultiselect(); + + assertThat(getSelectAllCheckBox().isEnabled(), is(true)); + assertThat(getFirstSelectCheckBox().isEnabled(), is(true)); + + disable(); + + assertThat(getSelectAllCheckBox().isEnabled(), is(false)); + assertThat(getFirstSelectCheckBox().isEnabled(), is(false)); + } + + @Test + public void parentSpanCannotBeClickedWhenDisabled() { + setMultiselect(); + disable(); + + WebElement firstCheckBoxSpan + = findElements(By.cssSelector("span")).get(1); + new Actions(driver).moveToElement(firstCheckBoxSpan, 1, 1) + .click() + .perform(); + + assertThat(getFirstSelectCheckBox().isSelected(), is(false)); + } +}
\ No newline at end of file |