diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2015-08-31 22:51:19 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-09-14 08:12:54 +0000 |
commit | 9e99e3e793ab14c3623f810b53471dde3d9f9816 (patch) | |
tree | 6cd00611dc83f101b9d46280c8d10ee8ab4dd634 /uitest | |
parent | 47fe6d931ddd550d35ab87d8a38eed4f3e8c7fff (diff) | |
download | vaadin-framework-9e99e3e793ab14c3623f810b53471dde3d9f9816.tar.gz vaadin-framework-9e99e3e793ab14c3623f810b53471dde3d9f9816.zip |
Disable sidebar button when grid is disabled. (#18696)
Change-Id: If334cebd85fcfe9b368b1b360181abaadd5cb4ef
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridDisabledSideBarTest.java | 85 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java | 21 |
2 files changed, 106 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDisabledSideBarTest.java b/uitest/src/com/vaadin/tests/components/grid/GridDisabledSideBarTest.java new file mode 100644 index 0000000000..0f207b68f2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridDisabledSideBarTest.java @@ -0,0 +1,85 @@ +package com.vaadin.tests.components.grid; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.By; +import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; + +public class GridDisabledSideBarTest extends GridBasicClientFeaturesTest { + + @Override + public void setup() throws Exception { + super.setup(); + + openTestURL(); + } + + private void makeColumnHidable() { + selectMenuPath("Component", "Columns", "Column 0", "Hidable"); + } + + private void toggleSideBarMenuAndDisable() { + selectMenuPath("Component", "Sidebar", "Open sidebar and disable grid"); + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return !findElement(By.className("v-grid-sidebar-button")).isEnabled(); + } + }); + } + private void clickSideBarButton() { + findElement(By.cssSelector(".v-grid-sidebar-button")).click(); + } + + private void toggleEnabled() { + selectMenuPath("Component", "State", "Enabled"); + } + + private void assertSideBarContainsClass(String cssClass) { + assertThat(findElement(By.cssSelector(".v-grid-sidebar")).getAttribute("class"), containsString(cssClass)); + } + + @Test + public void sidebarButtonIsDisabledOnCreation() { + selectMenuPath("Component", "State", "Enabled"); + makeColumnHidable(); + + clickSideBarButton(); + + assertSideBarContainsClass("closed"); + } + + @Test + public void sidebarButtonCanBeEnabled() { + makeColumnHidable(); + + clickSideBarButton(); + + assertSideBarContainsClass("open"); + } + + @Test + public void sidebarButtonCanBeDisabled() { + makeColumnHidable(); + toggleEnabled(); + + clickSideBarButton(); + + assertSideBarContainsClass("closed"); + } + + @Test + public void sidebarIsClosedOnDisable() { + makeColumnHidable(); + + toggleSideBarMenuAndDisable(); + + assertSideBarContainsClass("closed"); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index aa1d7d60a4..b6386afe44 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Random; import java.util.logging.Logger; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; @@ -1593,6 +1594,26 @@ public class GridBasicClientFeaturesWidget extends grid.setSidebarOpen(!grid.isSidebarOpen()); } }, menupath); + + addMenuCommand("Open sidebar and disable grid", new ScheduledCommand() { + @Override + public void execute() { + grid.setSidebarOpen(true); + + Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() { + @Override + public boolean execute() { + if(grid.isSidebarOpen()) { + grid.setEnabled(false); + + return false; + } + + return true; + } + }, 250); + } + }, menupath); } private MenuItem createSidebarMenuItem(final int index) { |