* @see VTabsheet#isClipped(Tab)
*/
private int getNextVisibleTab(int i) {
+ i = Math.max(i, -1);
int tabs = getTabCount();
do {
i++;
* @see VTabsheet#isClipped(Tab)
*/
private int getPreviousVisibleTab(int i) {
+ i = Math.min(i, getTabCount());
do {
i--;
} while (i >= 0 && getTab(i).isHiddenOnServer());
--- /dev/null
+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.Label;
+import com.vaadin.ui.TabSheet;
+
+public class TabSheetScrolledRemoveAllButLast extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final TabSheet tabSheet = new TabSheet();
+ tabSheet.setWidth("300px");
+
+ for (int i = 0; i < 10; i++) {
+ String caption = "Tab #" + (i + 1);
+ tabSheet.addTab(new Label(caption), caption);
+ }
+ // scroll
+ tabSheet.setSelectedTab(5);
+
+ addComponent(tabSheet);
+
+ Button button = new Button("Close all except last");
+ button.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent clickEvent) {
+ int tabsCount = tabSheet.getComponentCount();
+ for (int i = 0; i < tabsCount - 1; i++) {
+ TabSheet.Tab tab = tabSheet.getTab(0);
+ tabSheet.removeTab(tab);
+ }
+ }
+ });
+ addComponent(button);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Closing tabs shouldn't cause a client-side exception.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11673;
+ }
+}
--- /dev/null
+package com.vaadin.tests.components.tabsheet;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TabSheetScrolledRemoveAllButLastTest
+ extends MultiBrowserTest {
+
+ @Test
+ public void closeTabs() {
+ openTestURL("debug");
+ WebElement firstTab = findElement(
+ By.className("v-tabsheet-tabitemcell-first"));
+ assertNotEquals(
+ "Tab bar should be scrolled, unexpected first visible tab",
+ "Tab #1", firstTab.getText());
+
+ $(ButtonElement.class).first().click();
+ assertEquals("Unexpected error notification(s),", 0,
+ findElements(By.className("v-Notification-error")).size());
+ }
+}