summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Laakso <jani.laakso@itmill.com>2008-02-07 07:59:34 +0000
committerJani Laakso <jani.laakso@itmill.com>2008-02-07 07:59:34 +0000
commitf48ad7dfd15c69a342544b8eea294a4ab13210fe (patch)
tree79d0f42ba12ee165fa25bf63f1b4a99ea798f915
parent615d19da714c73bf3509d532ce21f3c4108e0e2b (diff)
downloadvaadin-framework-f48ad7dfd15c69a342544b8eea294a4ab13210fe.tar.gz
vaadin-framework-f48ad7dfd15c69a342544b8eea294a4ab13210fe.zip
Few robustness / memory leak tests.
svn changeset:3722/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/tests/robustness/RobustnessComplex.java74
-rw-r--r--src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java79
2 files changed, 153 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/tests/robustness/RobustnessComplex.java b/src/com/itmill/toolkit/tests/robustness/RobustnessComplex.java
new file mode 100644
index 0000000000..b15d29874c
--- /dev/null
+++ b/src/com/itmill/toolkit/tests/robustness/RobustnessComplex.java
@@ -0,0 +1,74 @@
+package com.itmill.toolkit.tests.robustness;
+
+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);
+
+ // 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.");
+ // }
+ }
+
+}
diff --git a/src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java b/src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java
new file mode 100644
index 0000000000..c66f100a71
--- /dev/null
+++ b/src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java
@@ -0,0 +1,79 @@
+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.OrderedLayout;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+public class RobustnessSimple 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 single orderedlayout with 100 labels.
+ */
+ public void create() {
+ count++;
+
+ // remove old stressLayout, all dependant components should be now
+ // allowed for garbage collection.
+ if (stressLayout != null) {
+ stressLayout.removeAllComponents();
+ main.removeComponent(stressLayout);
+ }
+
+ // create new stress layout
+ stressLayout = new OrderedLayout();
+
+ // fill with random components
+ Label label = new Label("Label " + Log.getMemoryStatistics(),
+ Label.CONTENT_PREFORMATTED);
+ byte[] data = new byte[1024 * 1024];
+ label.setData(data);
+ stressLayout.addComponent(label);
+
+ // add new component container to main layout
+ main.addComponent(stressLayout);
+
+ System.out.println("Created " + count + " times.");
+ }
+
+}