summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-10-13 14:56:50 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-10-29 15:39:18 +0200
commit3cbfc41c1e1b17593862bdc66ee333a7f7edc88b (patch)
tree2c7ed39fac2183f92d88fc2f41aa04e56c78ab02
parent4c637047d39328c9088f6ef944638f9ece76957b (diff)
downloadvaadin-framework-3cbfc41c1e1b17593862bdc66ee333a7f7edc88b.tar.gz
vaadin-framework-3cbfc41c1e1b17593862bdc66ee333a7f7edc88b.zip
Add addButton() AbstractTestUI.
Change-Id: I55a02e96466b63f6b00047cc87ab111f6c08e45b
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/AbstractTestUI.java7
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/page/PageReload.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java5
-rw-r--r--uitest/src/com/vaadin/tests/push/BarInUIDL.java4
-rw-r--r--uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java6
-rw-r--r--uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java4
13 files changed, 20 insertions, 49 deletions
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java b/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java
index 8fc6d56161..206e763497 100644
--- a/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java
+++ b/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java
@@ -17,7 +17,6 @@ package com.vaadin.tests.applicationservlet;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
@@ -26,15 +25,13 @@ public class SessionExpiration extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
getSession().getSession().setMaxInactiveInterval(2);
- Button b = new Button("Click to avoid expiration");
- b.addClickListener(new ClickListener() {
+ addButton("Click to avoid expiration", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
log("Clicked");
}
});
- addComponent(b);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
index 558379260b..3a7d42e29c 100644
--- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
+++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
@@ -10,6 +10,7 @@ import com.vaadin.shared.communication.PushMode;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
+import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
@@ -181,6 +182,12 @@ public abstract class AbstractTestUI extends UI {
getLayout().replaceComponent(oldComponent, newComponent);
}
+ protected void addButton(String caption, Button.ClickListener listener) {
+ Button button = new Button(caption);
+ button.addClickListener(listener);
+ addComponent(button);
+ }
+
protected String getTestDescription() {
return null;
};
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java
index 86e718596e..af54e15b5a 100644
--- a/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java
+++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java
@@ -53,16 +53,13 @@ public class AccordionRemoveTab extends AbstractTestUI {
Tab last = tabs.addTab(l);
last.setCaption("Three");
- Button remove = new Button("Remove First");
- remove.addClickListener(new Button.ClickListener() {
+ addButton("Remove First", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tabs.removeComponent(tabs.iterator().next());
}
});
-
- addComponent(remove);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java
index d3f30f3b37..66d1c34ab7 100644
--- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java
@@ -7,7 +7,6 @@ import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.DateField;
@@ -42,8 +41,7 @@ public class DateFieldIsValid extends AbstractTestUIWithLog {
}
});
addComponent(dateField);
- Button button = new Button("check dateField");
- button.addClickListener(new ClickListener() {
+ addButton("check dateField", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -51,7 +49,6 @@ public class DateFieldIsValid extends AbstractTestUIWithLog {
+ ", is valid: " + dateField.isValid());
}
});
- addComponent(button);
}
/**
diff --git a/uitest/src/com/vaadin/tests/components/page/PageReload.java b/uitest/src/com/vaadin/tests/components/page/PageReload.java
index c1799b29e3..033da4e0e8 100644
--- a/uitest/src/com/vaadin/tests/components/page/PageReload.java
+++ b/uitest/src/com/vaadin/tests/components/page/PageReload.java
@@ -2,7 +2,6 @@ package com.vaadin.tests.components.page;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
@@ -10,14 +9,12 @@ public class PageReload extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
- Button b = new Button("Press to reload");
- b.addClickListener(new ClickListener() {
+ addButton("Press to reload", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getPage().reload();
}
});
- addComponent(b);
log("UI id: " + getUIId());
}
diff --git a/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java b/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java
index 4c0bea77ac..177f4d68fc 100644
--- a/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java
+++ b/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java
@@ -49,8 +49,7 @@ public class FocusOnSelectedItem extends AbstractTestUI {
}
addComponent(table);
- Button button = new Button("Select");
- button.addClickListener(new Button.ClickListener() {
+ addButton("Select", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setValue("Item 198");
@@ -58,7 +57,6 @@ public class FocusOnSelectedItem extends AbstractTestUI {
table.focus();
}
});
- addComponent(button);
}
/*
diff --git a/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java b/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java
index e783951d86..7789d0ae19 100644
--- a/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java
+++ b/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java
@@ -19,7 +19,6 @@ import com.vaadin.annotations.Theme;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table;
@@ -53,15 +52,13 @@ public class LeftColumnAlignment extends AbstractTestUI {
addComponent(table);
- Button button = new Button("Align to Left");
- button.addClickListener(new ClickListener() {
+ addButton("Align to Left", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setColumnAlignment("name", Align.LEFT);
}
});
- addComponent(button);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java b/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java
index 79a85cd49b..bd84fab309 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java
@@ -17,7 +17,6 @@ package com.vaadin.tests.components.table;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table;
@@ -46,17 +45,14 @@ public class TableWidthItemRemove extends AbstractTestUI {
table.setColumnWidth("lastName", 100);
table.setColumnWidth("year", 50);
- Button cleanButton = new Button("Clean");
- cleanButton.addClickListener(new ClickListener() {
+ addButton("Clean", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.removeAllItems();
}
});
- addComponent(cleanButton);
- Button populateButton = new Button("Populate");
- populateButton.addClickListener(new ClickListener() {
+ addButton("Populate", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.addItem(
@@ -64,7 +60,6 @@ public class TableWidthItemRemove extends AbstractTestUI {
Math.random() * 1000);
}
});
- addComponent(populateButton);
addComponent(table);
}
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java
index b51a8dde08..0d7ec48a99 100644
--- a/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java
@@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
@@ -59,15 +58,13 @@ public class TabSelectionRevertedByServer extends AbstractTestUI {
addComponent(tabsheet);
- Button button = new Button("Select Last Tab");
- button.addClickListener(new ClickListener() {
+ addButton("Select Last Tab", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tabsheet.setSelectedTab(lastTab);
}
});
- addComponent(button);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java
index 8b7890e63c..9031a76e66 100644
--- a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java
+++ b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java
@@ -32,8 +32,7 @@ public class TreeItemDoubleClick extends AbstractTestUIWithLog {
addComponent(tree);
- Button button = new Button("Change immediate flag");
- button.addClickListener(new Button.ClickListener() {
+ addButton("Change immediate flag", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -44,8 +43,6 @@ public class TreeItemDoubleClick extends AbstractTestUIWithLog {
});
- addComponent(button);
-
}
@Override
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
index b380edcb75..a5d23dcd1f 100644
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.java
+++ b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
@@ -35,14 +35,12 @@ public class BarInUIDL extends AbstractTestUI {
*/
@Override
protected void setup(VaadinRequest request) {
- Button button = new Button("Click Me");
- button.addClickListener(new Button.ClickListener() {
+ addButton("Click Me", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
addComponent(new Label("Thank you for clicking | bar"));
}
});
- addComponent(button);
}
diff --git a/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java b/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
index 8834a05069..af19f8849f 100644
--- a/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
+++ b/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
@@ -5,7 +5,6 @@ import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
@@ -24,16 +23,13 @@ public class PushWithPreserveOnRefresh extends AbstractTestUI {
addComponent(new Label("UI id: " + getUIId()));
addComponent(log);
- Button b = new Button("click me");
- b.addClickListener(new ClickListener() {
+ addButton("click me", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
log.log("Button has been clicked " + (++times) + " times");
}
});
-
- addComponent(b);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java
index ec22edd205..0ea5c18bc9 100644
--- a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java
+++ b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java
@@ -36,8 +36,7 @@ public class ThemeChangeOnTheFly extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
- Button inject = new Button("Inject blue background");
- inject.addClickListener(new ClickListener() {
+ addButton("Inject blue background", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -46,7 +45,6 @@ public class ThemeChangeOnTheFly extends AbstractTestUIWithLog {
}
});
- addComponent(inject);
GridLayout gl = new GridLayout(2, 4);
gl.setCaption("Change theme by clicking a button");