aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/server-side/com/vaadin/tests/data/bean/Person.java10
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java42
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java13
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java59
-rw-r--r--[-rwxr-xr-x]tests/testbench/com/vaadin/tests/components/formlayout/FormLayouts.java0
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java140
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.html57
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java56
8 files changed, 375 insertions, 2 deletions
diff --git a/tests/server-side/com/vaadin/tests/data/bean/Person.java b/tests/server-side/com/vaadin/tests/data/bean/Person.java
index 2cb3a29368..f7bad31d0e 100644
--- a/tests/server-side/com/vaadin/tests/data/bean/Person.java
+++ b/tests/server-side/com/vaadin/tests/data/bean/Person.java
@@ -130,4 +130,14 @@ public class Person {
this.birthDate = birthDate;
}
+ public static Person createTestPerson1() {
+ return new Person("Foo", "Bar", "yeah@cool.com", 46, Sex.MALE,
+ new Address("Street", 1123, "Turku", Country.FINLAND));
+ }
+
+ public static Person createTestPerson2() {
+ return new Person("Maya", "Dinkelstein", "maya@foo.bar", 18,
+ Sex.FEMALE, new Address("Red street", 12, "Amsterdam",
+ Country.NETHERLANDS));
+ }
}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
index 050ab282a6..7305e022ee 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
@@ -4,6 +4,7 @@ import java.util.Locale;
import junit.framework.TestCase;
+import com.vaadin.Application;
import com.vaadin.data.util.MethodProperty;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.StringToIntegerConverter;
@@ -159,4 +160,45 @@ public class AbstractFieldValueConversions extends TestCase {
}
+ public static class NumberBean {
+ private Number number;
+
+ public Number getNumber() {
+ return number;
+ }
+
+ public void setNumber(Number number) {
+ this.number = number;
+ }
+
+ }
+
+ public void testNumberDoubleConverterChange() {
+ final Application a = new Application();
+ Application.setCurrentApplication(a);
+ TextField tf = new TextField() {
+ @Override
+ public Application getApplication() {
+ return a;
+ }
+ };
+ NumberBean nb = new NumberBean();
+ nb.setNumber(490);
+
+ tf.setPropertyDataSource(new MethodProperty<Number>(nb, "number"));
+ assertEquals(490, tf.getPropertyDataSource().getValue());
+ assertEquals("490", tf.getValue());
+
+ Converter c1 = tf.getConverter();
+
+ tf.setPropertyDataSource(new MethodProperty<Number>(nb, "number"));
+ Converter c2 = tf.getConverter();
+ assertTrue(
+ "StringToNumber converter is ok for integer types and should stay even though property is changed",
+ c1 == c2);
+ assertEquals(490, tf.getPropertyDataSource().getValue());
+ assertEquals("490", tf.getValue());
+
+ }
+
}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
index 851fece4d1..94385700d8 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import com.vaadin.Application;
import com.vaadin.data.Property;
import com.vaadin.data.util.AbstractProperty;
import com.vaadin.data.util.converter.Converter.ConversionException;
@@ -25,10 +26,13 @@ public class RemoveListenersOnDetach {
}
};
+ private Application application = new Application() {
+
+ };
@Override
public Class<?> getType() {
- return null;
+ return String.class;
}
@Override
@@ -48,6 +52,11 @@ public class RemoveListenersOnDetach {
public com.vaadin.ui.Root getRoot() {
return root;
};
+
+ @Override
+ public Application getApplication() {
+ return application;
+ };
};
Property property = new AbstractProperty() {
@@ -61,7 +70,7 @@ public class RemoveListenersOnDetach {
}
public Class<?> getType() {
- return null;
+ return String.class;
}
};
diff --git a/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java b/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java
new file mode 100644
index 0000000000..e79bd84741
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java
@@ -0,0 +1,59 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.tests.server.component.label;
+
+import junit.framework.TestCase;
+
+import com.vaadin.Application;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.ui.Label;
+
+public class LabelConverters extends TestCase {
+
+ public void testLabelSetDataSourceLaterOn() {
+ Person p = Person.createTestPerson1();
+ Label l = new Label("My label");
+ assertEquals("My label", l.getValue());
+ assertNull(l.getConverter());
+ l.setPropertyDataSource(new MethodProperty<String>(p, "firstName"));
+ assertEquals(p.getFirstName(), l.getValue());
+ p.setFirstName("123");
+ assertEquals("123", l.getValue());
+ }
+
+ public void testIntegerDataSource() {
+ Application.setCurrentApplication(new Application());
+ Label l = new Label("Foo");
+ Property ds = new MethodProperty<Integer>(Person.createTestPerson1(),
+ "age");
+ l.setPropertyDataSource(ds);
+ assertEquals(String.valueOf(Person.createTestPerson1().getAge()),
+ l.getValue());
+ }
+
+ public void testSetValueWithDataSource() {
+ try {
+ MethodProperty<String> property = new MethodProperty<String>(
+ Person.createTestPerson1(), "firstName");
+ Label l = new Label(property);
+ l.setValue("Foo");
+ fail("setValue should throw an exception when a data source is set");
+ } catch (Exception e) {
+ }
+
+ }
+
+ public void testLabelWithoutDataSource() {
+ Label l = new Label("My label");
+ assertEquals("My label", l.getValue());
+ assertNull(l.getConverter());
+ assertNull(l.getPropertyDataSource());
+ l.setValue("New value");
+ assertEquals("New value", l.getValue());
+ assertNull(l.getConverter());
+ assertNull(l.getPropertyDataSource());
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayouts.java b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayouts.java
index e247ce95f7..e247ce95f7 100755..100644
--- a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayouts.java
+++ b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayouts.java
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java
new file mode 100644
index 0000000000..455c16c425
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java
@@ -0,0 +1,140 @@
+package com.vaadin.tests.components.orderedlayout;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.gwt.client.ui.label.ContentMode;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.JavaScript;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.VerticalSplitPanel;
+import com.vaadin.ui.themes.Reindeer;
+
+public class LayoutResizeTest extends TestBase {
+
+ @Override
+ protected void setup() {
+ getLayout().setSizeFull();
+
+ HorizontalSplitPanel split1 = new HorizontalSplitPanel();
+ split1.setSizeFull();
+ addComponent(split1);
+
+ VerticalLayout left = new VerticalLayout();
+ left.setSizeFull();
+ split1.setFirstComponent(left);
+
+ left.setSpacing(true);
+ left.setMargin(true);
+
+ left.addComponent(new Label("<h2>Layout resize test</h2>",
+ ContentMode.XHTML));
+
+ Button resize = new Button("Resize to 700x400",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ JavaScript
+ .getCurrent()
+ .execute(
+ "setTimeout(function() {window.resizeTo(700,400)}, 500)");
+ }
+ });
+ left.addComponent(resize);
+
+ resize = new Button("Resize to 900x600", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ JavaScript
+ .getCurrent()
+ .execute(
+ "setTimeout(function() {window.resizeTo(900,600)}, 500)");
+ }
+ });
+ left.addComponent(resize);
+
+ left.addComponent(new Label(
+ "Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend ut et magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies."));
+
+ Table table1 = new Table();
+ table1.setSizeFull();
+ table1.addContainerProperty("Column", String.class, "");
+ for (int i = 1; i <= 100; i++) {
+ table1.addItem(new Object[] { "Value " + i }, i);
+ }
+ left.addComponent(table1);
+ left.setExpandRatio(table1, 1);
+
+ VerticalSplitPanel split2 = new VerticalSplitPanel();
+ split2.setSizeFull();
+ split1.setSecondComponent(split2);
+
+ Table table2 = new Table();
+ table2.setSizeFull();
+ table2.addContainerProperty("Column 1", String.class, "");
+ table2.addContainerProperty("Column 2", String.class, "");
+ table2.addContainerProperty("Column 3", String.class, "");
+ table2.addContainerProperty("Column 4", String.class, "");
+ for (int i = 1; i <= 100; i++) {
+ table2.addItem(new Object[] { "Value " + i, "Value " + i,
+ "Value " + i, "Value " + i }, i);
+ }
+ split2.setFirstComponent(table2);
+
+ VerticalLayout rows = new VerticalLayout();
+ rows.setWidth("100%");
+ rows.setSpacing(true);
+ rows.setMargin(true);
+ for (int i = 1; i <= 100; i++) {
+ rows.addComponent(getRow(i));
+ }
+ split2.setSecondComponent(rows);
+ }
+
+ private HorizontalLayout getRow(int i) {
+ HorizontalLayout row = new HorizontalLayout();
+ row.setWidth("100%");
+ row.setSpacing(true);
+
+ Embedded icon = new Embedded(null, new ThemeResource(
+ "../runo/icons/32/document.png"));
+ row.addComponent(icon);
+ row.setComponentAlignment(icon, Alignment.MIDDLE_LEFT);
+
+ Label text = new Label(
+ "Row content #"
+ + i
+ + ". In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet.");
+ row.addComponent(text);
+ row.setExpandRatio(text, 1);
+
+ Button button = new Button("Edit");
+ button.addStyleName(Reindeer.BUTTON_SMALL);
+ row.addComponent(button);
+ row.setComponentAlignment(button, Alignment.MIDDLE_LEFT);
+
+ button = new Button("Delete");
+ button.addStyleName(Reindeer.BUTTON_SMALL);
+ row.addComponent(button);
+ row.setComponentAlignment(button, Alignment.MIDDLE_LEFT);
+
+ return row;
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.html b/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.html
new file mode 100644
index 0000000000..9cbcf1d5ea
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.html
@@ -0,0 +1,57 @@
+<?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="http://arturwin.office.itmill.com:8888/" />
+<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.window.RepaintWindowContents?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentswindowRepaintWindowContents::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>Button 1</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentswindowRepaintWindowContents::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentswindowRepaintWindowContents::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>Button 2</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentswindowRepaintWindowContents::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentswindowRepaintWindowContents::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>Button 1</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentswindowRepaintWindowContents::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentswindowRepaintWindowContents::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>Button 2</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java b/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java
new file mode 100644
index 0000000000..353eb535ca
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java
@@ -0,0 +1,56 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.tests.components.AbstractTestRoot;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class RepaintWindowContents extends AbstractTestRoot {
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings("serial")
+ @Override
+ protected void setup(WrappedRequest request) {
+ final Window window = new Window("Test window");
+ addWindow(window);
+
+ final Layout layout1 = new VerticalLayout();
+ Button button1 = new Button("Button 1");
+ layout1.addComponent(button1);
+
+ final Layout layout2 = new VerticalLayout();
+ Button button2 = new Button("Button 2");
+ layout2.addComponent(button2);
+
+ window.setContent(layout1);
+
+ button1.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ window.setContent(layout2);
+ }
+ });
+
+ button2.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ window.setContent(layout1);
+ }
+ });
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Clicking the button switches the content between content1 and content2";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8832;
+ }
+
+} \ No newline at end of file