blob: 848c0309a156b49c21216885631d6f3496adc95c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package com.vaadin.tests.components.orderedlayout;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.TextField;
/**
* HorizontalLayout and VerticalLayout should not leak caption elements via
* listeners when removing components from a layout.
*
* @since 7.1.13
* @author Vaadin Ltd
*/
public class CaptionLeak extends AbstractReindeerTestUI {
/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
* VaadinRequest)
*/
@Override
protected void setup(VaadinRequest request) {
VerticalLayout root = new VerticalLayout();
root.setSizeFull();
root.setMargin(false);
root.setSpacing(false);
HorizontalLayout layout = new HorizontalLayout();
Panel parent = new Panel();
Button setLeakyContent = makeButton("Set leaky content", parent,
VerticalLayout.class);
Button setNonLeakyContent = makeButton("Set non leaky content", parent,
CssLayout.class);
layout.addComponent(setLeakyContent);
layout.addComponent(setNonLeakyContent);
root.addComponent(layout);
root.addComponent(parent);
setContent(root);
}
private Button makeButton(String caption, final Panel parent,
final Class<? extends ComponentContainer> targetClass) {
Button btn = new Button(caption);
btn.setId(caption);
btn.addClickListener(event -> {
try {
ComponentContainer target = targetClass.newInstance();
for (int i = 0; i < 61; i++) {
target.addComponent(new TextField("Test"));
}
parent.setContent(target);
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
});
return btn;
}
/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
*/
@Override
protected String getTestDescription() {
return "Open this UI with ?debug and count measured non-connector elements after setting leaky and non leaky content.";
}
/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
*/
@Override
protected Integer getTicketNumber() {
return null;
}
}
|