summaryrefslogtreecommitdiffstats
path: root/tests/testbench
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-01-12 11:17:28 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-01-12 11:17:28 +0000
commit4f6bc36661f0d07a6bafd7af3a0cd386f3ab9675 (patch)
tree196a59679668115c8df88d9d2d74c062a2442c4a /tests/testbench
parentd90f3ed208c5b5f8f6580afa95f8f22125361c2b (diff)
downloadvaadin-framework-4f6bc36661f0d07a6bafd7af3a0cd386f3ab9675.tar.gz
vaadin-framework-4f6bc36661f0d07a6bafd7af3a0cd386f3ab9675.zip
Merge from 6.7
svn changeset:22607/svn branch:6.8
Diffstat (limited to 'tests/testbench')
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java197
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java91
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java10
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java43
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html42
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java42
-rw-r--r--tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java54
-rw-r--r--tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java57
8 files changed, 533 insertions, 3 deletions
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
new file mode 100644
index 0000000000..d8b01c4099
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
@@ -0,0 +1,197 @@
+package com.vaadin.tests.components.orderedlayout;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.VerticalLayout;
+
+public class OrderedLayoutCases extends TestBase {
+ private static final String[] dimensionValues = { "-1px", "5px", "300px",
+ "800px", "100%", "50%" };
+
+ private static class SampleChild extends VerticalLayout {
+ public SampleChild() {
+ setStyleName("showBorders");
+ addComponent(createSimpleSelector("Child width",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ setWidth(event.getProperty().getValue().toString());
+ }
+ }, dimensionValues));
+ addComponent(createSimpleSelector("Child height",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ setHeight(event.getProperty().getValue().toString());
+ }
+ }, dimensionValues));
+ addComponent(createSimpleSelector("Caption",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ String value = event.getProperty().getValue()
+ .toString();
+ if (value.length() == 0) {
+ setCaption(null);
+ } else if (value.equals("Long")) {
+ setCaption("A rather long caption just to see what happens");
+ } else {
+ setCaption(value);
+ }
+ }
+ }, "", "Short", "Long"));
+
+ addComponent(createSimpleSelector("Expand ratio",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent();
+ if (parent == null) {
+ return;
+ }
+ String value = event.getProperty().getValue()
+ .toString();
+ parent.setExpandRatio(SampleChild.this,
+ Float.parseFloat(value));
+ }
+ }, "0", "1", "2"));
+
+ // Why is Alignment not an enum? Now we have to use reflection just
+ // to get the different values as hardcoding is never an option! ;)
+ List<String> alignmentValues = new ArrayList<String>();
+ Field[] fields = Alignment.class.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.getType() == Alignment.class) {
+ alignmentValues.add(field.getName());
+ }
+ }
+ addComponent(createSimpleSelector("Alignment",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ String value = event.getProperty().getValue()
+ .toString();
+ AlignmentHandler parent = (AlignmentHandler) getParent();
+ if (parent == null) {
+ return;
+ }
+ try {
+ Field field = Alignment.class
+ .getDeclaredField(value);
+ Alignment alignment = (Alignment) field
+ .get(null);
+ parent.setComponentAlignment(SampleChild.this,
+ alignment);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }, alignmentValues, "TOP_LEFT")); // Sorry for not using
+ // more reflection magic
+ // just to find the
+ // default value...
+
+ }
+ }
+
+ private AbstractOrderedLayout currentLayout;
+
+ @Override
+ public void setup() {
+ TestUtils.injectCSS(getMainWindow(),
+ ".showBorders {border: 1px solid black};");
+
+ currentLayout = new HorizontalLayout();
+ for (int i = 0; i < 3; i++) {
+ currentLayout.addComponent(new SampleChild());
+ }
+
+ HorizontalLayout sizeBar = new HorizontalLayout();
+ sizeBar.setSpacing(true);
+
+ sizeBar.addComponent(createSimpleSelector("Layout width",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentLayout.setWidth(event.getProperty().getValue()
+ .toString());
+ }
+ }, dimensionValues));
+ sizeBar.addComponent(createSimpleSelector("Layout height",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentLayout.setHeight(event.getProperty().getValue()
+ .toString());
+ }
+ }, dimensionValues));
+ sizeBar.addComponent(createSimpleSelector("Direction",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ Object value = event.getProperty().getValue();
+
+ AbstractOrderedLayout newLayout;
+ if (value.equals("Horizontal")) {
+ newLayout = new HorizontalLayout();
+ } else {
+ newLayout = new VerticalLayout();
+ }
+
+ while (currentLayout.getComponentCount() > 0) {
+ newLayout.addComponent(currentLayout
+ .getComponent(0));
+ }
+ newLayout.setStyleName("showBorders");
+
+ newLayout.setHeight(currentLayout.getHeight(),
+ currentLayout.getHeightUnits());
+ newLayout.setWidth(currentLayout.getWidth(),
+ currentLayout.getWidthUnits());
+
+ getLayout().replaceComponent(currentLayout, newLayout);
+ currentLayout = newLayout;
+ }
+ }, "Horizontal", "Vertical"));
+
+ addComponent(sizeBar);
+ addComponent(currentLayout);
+
+ getLayout().setSpacing(true);
+ getMainWindow().getContent().setSizeFull();
+ getLayout().setSizeFull();
+ getLayout().setExpandRatio(currentLayout, 1);
+ }
+
+ private static NativeSelect createSimpleSelector(String caption,
+ ValueChangeListener listener, String... values) {
+ return createSimpleSelector(caption, listener, Arrays.asList(values),
+ values[0]);
+ }
+
+ private static NativeSelect createSimpleSelector(String caption,
+ ValueChangeListener listener, List<String> values,
+ String defaultValue) {
+ NativeSelect selector = new NativeSelect(caption, values);
+ selector.setNullSelectionAllowed(false);
+ selector.setImmediate(true);
+ selector.addListener(listener);
+ selector.setValue(defaultValue);
+ return selector;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tester application for exploring how Horizontal/VerticalLayout reacts to various settings ";
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
new file mode 100644
index 0000000000..fe99cfaf2a
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
@@ -0,0 +1,91 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ScrollDetachSynchronization extends TestBase {
+
+ @Override
+ public void setup() {
+ Window mainWindow = new Window("Synctest Application");
+ mainWindow.setContent(buildLayout());
+ setMainWindow(mainWindow);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Scrolling, then detaching, a table causes out of sync on IE";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6970;
+ }
+
+ private Layout buildLayout() {
+ final VerticalLayout mainLayout = new VerticalLayout();
+ mainLayout.setSizeFull();
+
+ HorizontalLayout buttonBar = new HorizontalLayout();
+ buttonBar.setSizeUndefined();
+ Button first = new Button("First layout");
+ Button second = new Button("Second layout");
+ first.setDebugId("FirstButton");
+ second.setDebugId("SecondButton");
+ buttonBar.addComponent(first);
+ buttonBar.addComponent(second);
+ mainLayout.addComponent(buttonBar);
+
+ final HorizontalLayout firstLayout = buildTestLayout(true);
+ final HorizontalLayout secondLayout = buildTestLayout(false);
+
+ mainLayout.addComponent(firstLayout);
+ mainLayout.setExpandRatio(firstLayout, 1);
+
+ first.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (mainLayout.getComponent(1).equals(secondLayout)) {
+ mainLayout.replaceComponent(secondLayout, firstLayout);
+ mainLayout.setExpandRatio(firstLayout, 1);
+ }
+ }
+ });
+ second.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (mainLayout.getComponent(1).equals(firstLayout)) {
+ mainLayout.replaceComponent(firstLayout, secondLayout);
+ mainLayout.setExpandRatio(secondLayout, 1);
+ }
+ }
+ });
+ return mainLayout;
+ }
+
+ private HorizontalLayout buildTestLayout(boolean first) {
+ String which = first ? "First" : "Second";
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setSizeFull();
+ hl.setDebugId(which + "Layout");
+
+ Table t = new Table();
+ t.addContainerProperty("name", String.class, null);
+ for (int i = 0; i < 10; i++) {
+ String id = which + " " + i;
+ t.addItem(new String[] { id }, id);
+ }
+ t.setDebugId(which + "Table");
+ t.setItemCaptionPropertyId("name");
+ t.setSizeFull();
+
+ hl.addComponent(t);
+
+ return hl;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java
index 90a9191036..f7d85f1a3c 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java
@@ -10,10 +10,14 @@ public class TableHeaderZoom extends TestBase {
@Override
protected void setup() {
Table table = new Table();
- table.setHeight("100px");
- table.setWidth("200px");
- table.setEnabled(false);
+ table.setHeight("400px");
+ table.setWidth("400px");
table.addContainerProperty("Column 1", String.class, "");
+ table.addContainerProperty("Column 2", String.class, "");
+
+ for (int i = 0; i < 100; ++i) {
+ table.addItem(new Object[] { "" + i, "foo" }, i);
+ }
Window main = getMainWindow();
main.setContent(new CssLayout());
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
new file mode 100644
index 0000000000..a536303061
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+
+public class TableRepaintWhenMadeVisibile extends TestBase {
+
+ @Override
+ public void setup() {
+ final Table table = new Table();
+ table.addContainerProperty("sth", String.class, null);
+ table.addItem(new Object[] { "something" }, 1);
+ addComponent(table);
+
+ Button show = new Button("show", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setVisible(true);
+ }
+ });
+ addComponent(show);
+ Button hide = new Button("hide", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setVisible(false);
+ }
+ });
+ addComponent(hide);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A Table should be rendered correctly when made visible again after being initially rendered invisible. Click 'hide', refresh the application and then click 'show'";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7986;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html
new file mode 100644
index 0000000000..0563acd4a5
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>hidden-then-shown</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
new file mode 100644
index 0000000000..e5947576a2
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
@@ -0,0 +1,42 @@
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.Application;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class WrapTabSheetInTabSheet extends TestBase {
+ @Override
+ protected void setup() {
+ final VerticalLayout mainLayout = new VerticalLayout();
+ mainLayout.addComponent(new Label("This is main layout"));
+ addComponent(mainLayout);
+
+ Button b = new Button("Wrap main layout in a TabSheet");
+ b.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ TabSheet tabsheet = new TabSheet();
+ ComponentContainer mainParent = (ComponentContainer) mainLayout
+ .getParent();
+ mainParent.replaceComponent(mainLayout, tabsheet);
+ tabsheet.addTab(mainLayout, "Default tab");
+ }
+ });
+ mainLayout.addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the button to add a TabSheet and move the window content into the TabSheet. Every click should wrap the contents with a new TabSheet and the contents should remain visible.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8238;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java
new file mode 100644
index 0000000000..0fc63860e1
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java
@@ -0,0 +1,54 @@
+package com.vaadin.tests.components.textarea;
+
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+
+public class TextAreaCursorPosition extends TestBase {
+
+ private TextField cursorPosition = new TextField("Cursor position");
+
+ @Override
+ public void setup() {
+ Label label = new Label(
+ "Test of calculation of cursor position of TextArea");
+ TextArea textArea = new TextArea();
+ addListener(textArea);
+ addComponent(label);
+ addComponent(textArea);
+ addComponent(cursorPosition);
+ cursorPosition.setValue("?");
+ addComponent(new Button("Force position update"));
+ }
+
+ public void addListener(AbstractField newField) {
+ AbstractTextField newTextField = (AbstractTextField) newField;
+ newTextField.setTextChangeEventMode(TextChangeEventMode.EAGER);
+
+ newTextField.addListener(new TextChangeListener() {
+ public void textChange(TextChangeEvent event) {
+ AbstractTextField component = (AbstractTextField) event
+ .getComponent();
+ cursorPosition.setValue(component.getCursorPosition());
+ }
+ });
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Writing something in the field updates the cursor position field. The position field can also be updated using the button.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7726;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java
new file mode 100644
index 0000000000..6aac7caddd
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java
@@ -0,0 +1,57 @@
+package com.vaadin.tests.components.textfield;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.tests.components.TestBase;
+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.CheckBox;
+import com.vaadin.ui.TextField;
+
+public class TextFieldInputPromptAndClickShortcut extends TestBase {
+
+ @Override
+ protected void setup() {
+ final Log log = new Log(5);
+
+ final TextField textField = new TextField();
+ Button button = new Button("Show Text", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ log.log("Field value: " + textField.getValue());
+ }
+ });
+ button.setClickShortcut(KeyCode.ESCAPE);
+
+ final CheckBox inputPromptSelection = new CheckBox("Input prompt",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (event.getButton().getValue() == Boolean.TRUE) {
+ textField.setInputPrompt("Input prompt");
+ } else {
+ textField.setInputPrompt(null);
+ }
+ log.log("Set input prompt: "
+ + textField.getInputPrompt());
+ }
+ });
+ inputPromptSelection.setImmediate(true);
+
+ addComponent(textField);
+ addComponent(button);
+ addComponent(inputPromptSelection);
+ addComponent(log);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "With the input propmpt enabled, enter something into the field, press enter, remove the entered text and press the button. The previous text is still reported as the value. Without the input prompt, the new value is instead reported as blank.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}