summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authoradam <adam@vaadin.com>2016-07-18 16:21:52 +0300
committerVaadin Code Review <review@vaadin.com>2016-08-03 09:57:31 +0000
commit35078caabebfda612867c68b38f1d554dd3192a7 (patch)
tree60940ee452272b9936ed3b843edefe1f9b30855e /uitest
parentc7ce7a129720490c31e466d62f725f9d866e0753 (diff)
downloadvaadin-framework-35078caabebfda612867c68b38f1d554dd3192a7.tar.gz
vaadin-framework-35078caabebfda612867c68b38f1d554dd3192a7.zip
Fixing TabSheet scrolling within SplitPanel (#20052)
This patch fixes an issue with disappearing tabs in a TabSheet placed in a SplitPanel. Scrolling a tab into view needs to be done after layout has happened. Otherwise the available width for TabSheet is unknown and causes unexpected behaviour. Change-Id: Ibcea04ddadfafc5028efe44a6817517b16e21bde
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java81
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java47
2 files changed, 128 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java
new file mode 100644
index 0000000000..4b68dd61af
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java
@@ -0,0 +1,81 @@
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
+
+public class TabsheetScrollIntoView extends AbstractTestUI {
+
+ public static final String BTN_SELECT_LAST_TAB = "showAndSelectLastTab";
+
+ private TabSheet tabSheetInSplitPanel;
+ private HorizontalSplitPanel panel = new HorizontalSplitPanel();
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ panel.setHeight("200px");
+ tabSheetInSplitPanel = new TabSheet();
+ tabSheetInSplitPanel.setWidth(100, Unit.PERCENTAGE);
+ for (int i = 0; i < 100; i++) {
+ tabSheetInSplitPanel.addTab(new Label("Tab " + i), "Tab " + i);
+ }
+
+ Layout buttonLayout = new VerticalLayout();
+
+ buttonLayout
+ .addComponent(new Button("Hide TabSheet", new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ panel.setSplitPosition(100, Unit.PERCENTAGE);
+ panel.removeComponent(tabSheetInSplitPanel);
+ }
+ }));
+
+ Button showLast = new Button("Show TabSheet and select last tab",
+ new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ panel.setSecondComponent(tabSheetInSplitPanel);
+ panel.setSplitPosition(250, Unit.PIXELS);
+ tabSheetInSplitPanel.setSelectedTab(
+ tabSheetInSplitPanel.getComponentCount() - 1);
+ }
+ });
+ showLast.setId(BTN_SELECT_LAST_TAB);
+ buttonLayout.addComponent(showLast);
+
+ buttonLayout.addComponent(new Button(
+ "Show TabSheet and select first tab", new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ panel.setSecondComponent(tabSheetInSplitPanel);
+ panel.setSplitPosition(250, Unit.PIXELS);
+ tabSheetInSplitPanel.setSelectedTab(0);
+ }
+ }));
+
+ panel.setFirstComponent(buttonLayout);
+ panel.setSplitPosition(100, Unit.PERCENTAGE);
+ addComponent(panel);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Clicking \"Show TabSheet and select last tab\" should scroll to the last tab and not disable tab scrolling.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 20052;
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java
new file mode 100644
index 0000000000..8e107859e5
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.tabsheet;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TabSheetElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TabsheetScrollIntoViewTest extends MultiBrowserTest {
+
+ @Test
+ public void scrollIntoView() {
+ openTestURL();
+
+ $(ButtonElement.class).id(TabsheetScrollIntoView.BTN_SELECT_LAST_TAB)
+ .click();
+ TabSheetElement tabSheet = $(TabSheetElement.class).first();
+ Assert.assertTrue("Select last should not hide other tabs",
+ tabSheet.getTabCaptions().contains("Tab 98"));
+
+ List<WebElement> scrollerPrev = tabSheet
+ .findElements(By.className("v-tabsheet-scrollerPrev"));
+ Assert.assertTrue("Select last should not disable tab scrolling",
+ !scrollerPrev.isEmpty() && scrollerPrev.get(0).isDisplayed());
+ }
+
+}