]> source.dussan.org Git - vaadin-framework.git/commitdiff
Apply layout after remove tab in Accordion (#11366, #13423)
authorDenis Anisimov <denis@vaadin.com>
Sun, 6 Apr 2014 13:25:21 +0000 (16:25 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 25 Apr 2014 12:09:35 +0000 (12:09 +0000)
Change-Id: Ia56729d2d533697bea78bdb1de6b2710e166893a

client/src/com/vaadin/client/ui/accordion/AccordionConnector.java
uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTabTest.java [new file with mode: 0644]

index ce843dc22f4c9d2d8e595071b2531c6295401bed..25c56ab745863a7c8dd6f51a8085d55de4f563e2 100644 (file)
@@ -59,6 +59,7 @@ public class AccordionConnector extends TabsheetBaseConnector implements
         } else if (getWidget().getOpenStackItem() != null) {
             getWidget().close(getWidget().getOpenStackItem());
         }
+        getLayoutManager().setNeedsVerticalLayout(this);
     }
 
     @Override
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java
new file mode 100644 (file)
index 0000000..86e7185
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2013 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.accordion;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Accordion;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet.Tab;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * Test UI for Accordion: tabs should stay selectable after remove tab.
+ * 
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class AccordionRemoveTab extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final Accordion tabs = new Accordion();
+        addComponent(tabs);
+        tabs.setHeight(300, Unit.PIXELS);
+        final VerticalLayout one = new VerticalLayout();
+        one.setCaption("One");
+        one.addComponent(new Label("On first tab"));
+        tabs.addTab(one);
+        VerticalLayout two = new VerticalLayout();
+        two.setCaption("Two");
+        two.addComponent(new Label("On second tab"));
+        tabs.addTab(two);
+
+        tabs.setSelectedTab(two);
+
+        VerticalLayout l = new VerticalLayout();
+        l.addComponent(new Label("On third tab"));
+        Tab last = tabs.addTab(l);
+        last.setCaption("Three");
+
+        Button remove = new Button("Remove First");
+        remove.addClickListener(new Button.ClickListener() {
+
+            @Override
+            public void buttonClick(ClickEvent event) {
+                tabs.removeComponent(tabs.iterator().next());
+            }
+        });
+
+        addComponent(remove);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Tabs should stay selectable after remove tab.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 11366;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTabTest.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTabTest.java
new file mode 100644 (file)
index 0000000..f5651e0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2013 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.accordion;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for Accordion: tabs should stay selectable after remove tab.
+ * 
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class AccordionRemoveTabTest extends MultiBrowserTest {
+
+    @Test
+    public void testRemoveTab() {
+        openTestURL();
+
+        WebElement button = driver.findElement(By.className("v-button"));
+        button.click();
+
+        checkFirstItemHeight("On second tab");
+
+        button.click();
+
+        checkFirstItemHeight("On third tab");
+    }
+
+    private void checkFirstItemHeight(String text) {
+        WebElement firstItem = driver.findElement(By
+                .className("v-accordion-item-first"));
+        WebElement label = firstItem.findElement(By.className("v-label"));
+        Assert.assertEquals("Unexpected text in first item", text,
+                label.getText());
+        int height = firstItem.getSize().getHeight();
+        WebElement accordion = driver.findElement(By.className("v-accordion"));
+        Assert.assertTrue("First item in accordion has unexpected height",
+                height > accordion.getSize().getHeight() / 2);
+    }
+
+}