diff options
author | Henri Sara <hesara@vaadin.com> | 2014-02-17 10:27:37 +0200 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2014-02-17 10:27:37 +0200 |
commit | 6f21052f2d952fd614c22b11e350e404a40761bb (patch) | |
tree | ade858183298371cb17d798d72e71b03ac265661 /uitest | |
parent | 3b327f6131166d3b503a55b7e91b853d179a3595 (diff) | |
download | vaadin-framework-6f21052f2d952fd614c22b11e350e404a40761bb.tar.gz vaadin-framework-6f21052f2d952fd614c22b11e350e404a40761bb.zip |
Eliminate spacing memory leak on client (#13315)
Change-Id: I432ae4a04d74826dd1cce108177bd503774a8463
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeak.java | 54 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeakTest.java | 39 |
2 files changed, 93 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeak.java b/uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeak.java new file mode 100644 index 0000000000..647c187568 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeak.java @@ -0,0 +1,54 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +/** + * HorizontalLayout and VerticalLayout should not leak .v-spacing elements via + * listeners when removing components from a layout. + * + * @since 7.1.12 + * @author Vaadin Ltd + */ +public class SpacingLeak extends UI { + + private HorizontalLayout spacingLayout; + + @Override + public void init(VaadinRequest req) { + final VerticalLayout root = new VerticalLayout(); + setContent(root); + root.setSizeUndefined(); + + final Button spacingButton = new Button("Add layout with spacing"); + spacingButton.setId("addbutton"); + root.addComponent(spacingButton); + spacingButton.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + spacingLayout = new HorizontalLayout(); + spacingLayout.setSpacing(true); + spacingLayout.setWidth("100%"); + + for (int i = 0; i < 100; ++i) { + spacingLayout.addComponent(new Button("" + i)); + } + + root.addComponent(spacingLayout); + } + }); + + final Button removeButton = new Button("Remove layouts"); + removeButton.setId("removebutton"); + root.addComponent(removeButton); + removeButton.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + root.removeComponent(spacingLayout); + } + }); + } +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeakTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeakTest.java new file mode 100644 index 0000000000..3a24cb7620 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/SpacingLeakTest.java @@ -0,0 +1,39 @@ +/* + * 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.orderedlayout; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SpacingLeakTest extends MultiBrowserTest { + + @Test + public void testSpacingLeak() throws Exception { + setDebug(true); + openTestURL(); + getDriver().findElement(By.id("addbutton")).click(); + getDriver().findElement(By.xpath("//button[@title = 'Clear log']")) + .click(); + getDriver().findElement(By.id("removebutton")).click(); + + // this should be present + getDriver() + .findElement( + By.xpath("//span[text() = 'Measured 0 non connector elements']")); + } +} |