diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-04-19 13:42:28 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-04-19 13:42:28 +0000 |
commit | 15bac5d7815a2fd4eec7155e5c119ba8dab58fc7 (patch) | |
tree | 41a7bb97fe543c0e6ea876343a14dfcb2a874796 /tests/src/com/vaadin | |
parent | fa9c9283c25d2407af4554d6d1b3663b165edf85 (diff) | |
download | vaadin-framework-15bac5d7815a2fd4eec7155e5c119ba8dab58fc7.tar.gz vaadin-framework-15bac5d7815a2fd4eec7155e5c119ba8dab58fc7.zip |
Merged fixes from 6.3:
* Build updates
* Fixes for #4418,#4562,#4514,#4536,#4533
* Test case updates
* DevelopmentServerLauncher fix
svn changeset:12649/svn branch:6.4
Diffstat (limited to 'tests/src/com/vaadin')
6 files changed, 478 insertions, 3 deletions
diff --git a/tests/src/com/vaadin/tests/components/select/MultiSelect.java b/tests/src/com/vaadin/tests/components/select/MultiSelect.java new file mode 100644 index 0000000000..66ca41d829 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/select/MultiSelect.java @@ -0,0 +1,31 @@ +package com.vaadin.tests.components.select;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Select;
+
+public class MultiSelect extends TestBase {
+
+ @Override
+ protected void setup() {
+ Select selectComponent = new Select();
+ selectComponent.setMultiSelect(true);
+
+ String[] selection = { "One", "Hund", "Three" };
+ for (String word : selection) {
+ selectComponent.addItem(word);
+ }
+
+ addComponent(selectComponent);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The select is in multi select mode and should be rendered as such";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4553;
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/select/NativeSelects.html b/tests/src/com/vaadin/tests/components/select/NativeSelects.html new file mode 100644 index 0000000000..caff14b5b4 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/select/NativeSelects.html @@ -0,0 +1,177 @@ +<?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.select.NativeSelects?restartApplication</td> + <td></td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VNativeSelect[0]/domChild[0]</td> + <td>label=The second item</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VNativeSelect[0]/domChild[0]</td> + <td>label=an item 1</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VNativeSelect[0]/domChild[0]</td> + <td>label=The second item</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VNativeSelect[0]/domChild[0]</td> + <td>label=an item 1</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>enabled-readwrite-noerror</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>enabled-readonly-noerror</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>31,6</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>enabled-readonly-error</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>3,9</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>enabled-readwrite-error</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[0]</td> + <td>32,6</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>disabled-readwrite-error</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>47,6</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>disabled-readwrite-noerror</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>31,11</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>disabled-readonly-noerror</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>42,4</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>disabled-readonly-error</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/select/NativeSelects.java b/tests/src/com/vaadin/tests/components/select/NativeSelects.java new file mode 100644 index 0000000000..46b5267e28 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/select/NativeSelects.java @@ -0,0 +1,153 @@ +package com.vaadin.tests.components.select; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.Button.ClickEvent; + +public class NativeSelects extends ComponentTestCase { + + private static final Object CAPTION = "caption"; + NativeSelect label[] = new NativeSelect[20]; + + @Override + protected void setup() { + super.setup(); + + NativeSelect s; + + s = createNativeSelect(null); + s.setWidth(null); + addTestComponent(s); + + s = createNativeSelect("Undefined wide, empty select"); + s.setWidth(null); + addTestComponent(s); + + s = createNativeSelect("Undefined wide select with 5 items"); + s.setWidth(null); + addItem(s, "The first item"); + addItem(s, "The second item"); + addItem(s, "The third item"); + addItem(s, "The fourth item"); + addItem(s, "The fifth item"); + addTestComponent(s); + + s = createNativeSelect("Undefined wide select with 50 items"); + s.setWidth(null); + populate(s, 50); + addTestComponent(s); + + s = createNativeSelect(null); + s.setWidth("100px"); + addTestComponent(s); + + s = createNativeSelect("100px wide, empty select"); + s.setWidth("100px"); + addTestComponent(s); + + s = createNativeSelect("150px wide select with 5 items"); + s.setWidth("150px"); + addItem(s, "The first item"); + addItem(s, "The second item"); + addItem(s, "The third item"); + addItem(s, "The fourth item"); + addItem(s, "The fifth item"); + addTestComponent(s); + + s = createNativeSelect("200px wide select with 50 items"); + s.setWidth("200px"); + populate(s, 50); + addTestComponent(s); + + } + + private void populate(NativeSelect s, int nr) { + String text = " an item "; + + String caption = ""; + for (int i = 0; i < nr; i++) { + if (i % 2 == 0) { + caption += text; + } else { + caption += i; + } + + addItem(s, caption); + } + + } + + private void addItem(NativeSelect s, String string) { + Object id = s.addItem(); + s.getItem(id).getItemProperty(CAPTION).setValue(string); + + } + + private NativeSelect createNativeSelect(String caption) { + NativeSelect s = new NativeSelect(); + + s.addContainerProperty(CAPTION, String.class, ""); + s.setItemCaptionPropertyId(CAPTION); + s.setCaption(caption); + + return s; + } + + @Override + protected String getDescription() { + return "A generic test for Labels in different configurations"; + } + + @Override + protected List<Component> createActions() { + ArrayList<Component> actions = new ArrayList<Component>(); + + CheckBox errorIndicators = new CheckBox("Error indicators", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setErrorIndicators(enabled); + + } + }); + + CheckBox enabled = new CheckBox("Enabled", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setEnabled(enabled); + } + }); + + CheckBox readonly = new CheckBox("Readonly", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setReadOnly(enabled); + } + }); + + errorIndicators.setValue(new Boolean(false)); + readonly.setValue(new Boolean(false)); + enabled.setValue(new Boolean(true)); + + errorIndicators.setImmediate(true); + readonly.setImmediate(true); + enabled.setImmediate(true); + + actions.add(errorIndicators); + actions.add(readonly); + actions.add(enabled); + + return actions; + } + +} diff --git a/tests/src/com/vaadin/tests/components/table/TableSorting.java b/tests/src/com/vaadin/tests/components/table/TableSorting.java new file mode 100644 index 0000000000..4cbb1934e4 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableSorting.java @@ -0,0 +1,67 @@ +package com.vaadin.tests.components.table;
+
+import java.io.Serializable;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+
+public class TableSorting extends TestBase {
+
+ @Override
+ public void setup() {
+ final Label showID = new Label("");
+ final Table testTable = new Table();
+
+ BeanItemContainer<TestItem> cont = new BeanItemContainer<TestItem>(
+ TestItem.class);
+
+ for (int i = 0; i < 20; i++) {
+ TestItem ti = new TestItem();
+ ti.setTestName("Name_" + i);
+ cont.addBean(ti);
+ }
+ testTable.setContainerDataSource(cont);
+ testTable.setImmediate(true);
+ testTable.setSelectable(true);
+ testTable.setMultiSelect(false);
+ testTable.setVisibleColumns(new Object[] { "testName" });
+
+ // Handle selection change.
+ testTable.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ System.out.println("ValueChanged: "
+ + testTable.getValue().toString());
+ showID.setCaption("ID: " + testTable.getValue().toString());
+ }
+ });
+ addComponent(testTable);
+ addComponent(showID);
+ }
+
+ public class TestItem implements Serializable {
+ private static final long serialVersionUID = -745849615488792221L;
+ private String testName;
+
+ public String getTestName() {
+ return testName;
+ }
+
+ public void setTestName(String testName) {
+ this.testName = testName;
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the header to sort the table, then click on \"Name_10\". This should show ID: com.vaadin.tests.components.table.TableSorting$TestItem@<hex id> below the table";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4537;
+ }
+}
\ No newline at end of file diff --git a/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java b/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java index 168b99a19b..c1fa4e82f6 100644 --- a/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java +++ b/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java @@ -11,6 +11,8 @@ public class BrowserUserAgentParser extends TestCase { private static final String FIREFOX35_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729) FirePHP/0.4";
private static final String FIREFOX36_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)";
private static final String FIREFOX36B_MAC = "UAString mozilla/5.0 (macintosh; u; intel mac os x 10.6; en-us; rv:1.9.2) gecko/20100115 firefox/3.6";
+ private static final String FIREFOX_30B5_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5";
+ private static final String KONQUEROR_LINUX = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Exabot-Thumbnails)";
private static final String IE6_WINDOWS = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
private static final String IE7_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
@@ -106,6 +108,22 @@ public class BrowserUserAgentParser extends TestCase { assertWindows(bd);
}
+ public void testFirefox30b5() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX_30B5_MAC);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 1.9f);
+ assertMacOSX(bd);
+ }
+
+ public void testKonquerorLinux() {
+ // Just ensure detection does not crash
+ VBrowserDetails bd = new VBrowserDetails(KONQUEROR_LINUX);
+ assertLinux(bd);
+ }
+
public void testFirefox36b() {
VBrowserDetails bd = new VBrowserDetails(FIREFOX36B_MAC);
assertGecko(bd);
diff --git a/tests/src/com/vaadin/tests/server/container/BeanItemContainerSortTest.java b/tests/src/com/vaadin/tests/server/container/BeanItemContainerSortTest.java index eb46da776f..1320d57653 100644 --- a/tests/src/com/vaadin/tests/server/container/BeanItemContainerSortTest.java +++ b/tests/src/com/vaadin/tests/server/container/BeanItemContainerSortTest.java @@ -14,6 +14,16 @@ public class BeanItemContainerSortTest { public class Person { private String name; + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + private int age; + public void setName(String name) { this.name = name; } @@ -23,14 +33,19 @@ public class BeanItemContainerSortTest { } } - String[] names = new String[] { "Antti", "Ville", "Sirkka", "Jaakko" }; + String[] names = new String[] { "Antti", "Ville", "Sirkka", "Jaakko", + "Pekka", "John" }; + int[] ages = new int[] { 10, 20, 50, 12, 64, 67 }; + String[] sortedByAge = new String[] { names[0], names[3], names[1], + names[2], names[4], names[5] }; public BeanItemContainer<Person> getContainer() { BeanItemContainer<Person> bc = new BeanItemContainer<Person>( Person.class); - for (String name : names) { + for (int i = 0; i < names.length; i++) { Person p = new Person(); - p.setName(name); + p.setName(names[i]); + p.setAge(ages[i]); bc.addBean(p); } return bc; @@ -55,6 +70,7 @@ public class BeanItemContainerSortTest { int i = 0; for (String string : asList) { Person idByIndex = container.getIdByIndex(i++); + Assert.assertTrue(container.containsId(idByIndex)); Assert.assertEquals(string, idByIndex.getName()); } } @@ -64,4 +80,17 @@ public class BeanItemContainerSortTest { testSort(false); } + @Test + public void primitiveSorting() { + BeanItemContainer<Person> container = getContainer(); + container.sort(new Object[] { "age" }, new boolean[] { true }); + + int i = 0; + for (String string : sortedByAge) { + Person idByIndex = container.getIdByIndex(i++); + Assert.assertTrue(container.containsId(idByIndex)); + Assert.assertEquals(string, idByIndex.getName()); + } + + } } |