summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/tests/robustness/Robustness.java
blob: 41af72f3b5d1d421868b22151404b2e92f4addf7 (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
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 abstract class Robustness 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 close = new Button("Close application");

    final Button create = 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(close);
        main.addComponent(create);
        close.addListener(this);
        create.addListener(this);

        create.setDebugId("createButton");
    }

    public void buttonClick(ClickEvent event) {
        if (event.getButton() == create)
            create();
        else if (event.getButton() == close) {
            System.out.println("Before close, memory statistics:");
            System.out.println(Log.getMemoryStatistics());
            close();
            System.out.println("After close, memory statistics:");
            System.out.println(Log.getMemoryStatistics());
        }
    }

    public abstract void create();
}