blob: e0caa189d5ef11fc1aa8b74045d76c291c4567a8 (
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
|
package com.vaadin.tests.components.table;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
import com.vaadin.v7.data.util.IndexedContainer;
import com.vaadin.v7.ui.Table;
/**
* Test UI Class for testing memory leak in table (#14159).
*
* @author Vaadin Ltd
*/
public class MemoryLeakTable extends AbstractReindeerTestUI {
Button btnAdd = new Button("Add rows");
Button btnRemove = new Button("Remove rows");
Button btnTenTimes = new Button("Do ten times");
Table tbl = new Table();
static final int COLS = 15;
static final int ROWS = 2000;
private void addRows() {
IndexedContainer idx = new IndexedContainer();
for (int i = 0; i < COLS; i++) {
idx.addContainerProperty("name " + i, String.class, "value");
}
for (int i = 0; i < ROWS; i++) {
idx.addItem("item" + i);
}
tbl.setContainerDataSource(idx);
addComponent(tbl);
}
private void removeRows() {
tbl.removeAllItems();
removeComponent(tbl);
}
@Override
protected void setup(VaadinRequest request) {
btnAdd.addClickListener(event -> addRows());
btnRemove.addClickListener(event -> removeRows());
addComponent(btnAdd);
addComponent(btnRemove);
}
@Override
protected String getTestDescription() {
return "Generates table for memory leaking test";
}
@Override
protected Integer getTicketNumber() {
return 14159;
}
}
|