aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorIlia Motornyi <elmot@vaadin.com>2018-07-19 15:32:05 +0300
committerGitHub <noreply@github.com>2018-07-19 15:32:05 +0300
commitde42456db1d81d84388583dd1ad0d3ac85c298ba (patch)
treefe149f5832fa24c3a1e769caea91e76b64a2ff3d /uitest
parent504d4995786e8909f609be09897325bd16ffebe5 (diff)
downloadvaadin-framework-de42456db1d81d84388583dd1ad0d3ac85c298ba.tar.gz
vaadin-framework-de42456db1d81d84388583dd1ad0d3ac85c298ba.zip
Fix removal tabsheets if last one is selected (#11070)
Fixes #10925
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabs.java35
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabsTest.java30
2 files changed, 65 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabs.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabs.java
new file mode 100644
index 0000000000..1cfea46201
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabs.java
@@ -0,0 +1,35 @@
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TabSheet;
+
+public class TabsheetCloseSelectedTabs extends AbstractTestUI {
+
+ private TabSheet tabsheet = new TabSheet();
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ generateTabs();
+ tabsheet.setSizeFull();
+ addComponent(tabsheet);
+ addButton("Select last tab", event -> {
+ tabsheet.setSelectedTab(tabsheet.getComponentCount() - 1);
+ });
+ addButton("Remove all tabs", event -> {
+ while (tabsheet.getComponentCount() > 0) {
+ tabsheet.removeTab(tabsheet.getTab(0));
+ }
+ });
+
+ }
+
+ private void generateTabs() {
+ tabsheet.removeAllComponents();
+ for (int i = 0; i < 100; ++i) {
+ tabsheet.addTab(new Panel(), "Tab" + i);
+ }
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabsTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabsTest.java
new file mode 100644
index 0000000000..8116548326
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetCloseSelectedTabsTest.java
@@ -0,0 +1,30 @@
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TabSheetElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+import org.junit.Test;
+
+import java.io.IOException;
+
+/**
+ * Tests that tabsheet's scroll button are rendered correctly in Chameleon
+ * theme.
+ *
+ * Ticket #12154
+ *
+ * @author Vaadin Ltd
+ */
+public class TabsheetCloseSelectedTabsTest extends SingleBrowserTest {
+
+ @Test
+ public void deleteSelectedTab() {
+ openTestURL();
+ $(ButtonElement.class).caption("Select last tab").first().click();
+ assertElementPresent(By.className("v-tabsheet-tabitem"));
+ $(TabSheetElement.class).first().waitForVaadin();
+ $(ButtonElement.class).caption("Remove all tabs").first().click();
+ assertElementNotPresent(By.className("v-tabsheet-tabitem"));
+ }
+}