blob: 94cb3e0c0b7bec621075fca275161bb86ed35618 (
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
|
package com.itmill.toolkit.tests.robustness;
import com.itmill.toolkit.tests.util.Log;
import com.itmill.toolkit.tests.util.RandomComponents;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.ComponentContainer;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Button.ClickEvent;
public class RobustnessComplex extends com.itmill.toolkit.Application implements
Button.ClickListener {
static int totalCount = 0;
int count = 0;
final Window main = new Window("Robustness tests by featurebrowser");
final Button button = new Button("Create");
final Label label = new Label();
ComponentContainer stressLayout;
RandomComponents randomComponents = new RandomComponents();
public void init() {
createNewView();
}
public void createNewView() {
setMainWindow(main);
main.removeAllComponents();
main.addComponent(label);
main.addComponent(button);
button.addListener(this);
button.setDebugId("createButton");
create();
}
public void buttonClick(ClickEvent event) {
create();
}
/**
* Create complex layouts with components and listeners.
*/
public void create() {
count++;
// remove old stressLayout, all dependant components should be now
// allowed for garbage collection.
if (stressLayout != null)
main.removeComponent(stressLayout);
// create new stress layout
stressLayout = randomComponents
.getRandomComponentContainer("Component container " + count);
Label label = new Label("Label " + Log.getMemoryStatistics(),
Label.CONTENT_PREFORMATTED);
stressLayout.addComponent(label);
// fill with random components
randomComponents.fillLayout(stressLayout, 20);
// add new component container to main layout
main.addComponent(stressLayout);
// if ((count % 100) == 0) {
System.out.println("Created " + count + " times.");
// }
}
}
|