diff options
author | Artur Signell <artur.signell@itmill.com> | 2011-12-08 15:39:10 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2011-12-08 15:39:10 +0000 |
commit | ccdef3ddfd79938215cadc947b08a73faf5d0788 (patch) | |
tree | 6227c897ada088712ae1d2fb2fbfe966439604f9 /tests | |
parent | 15ef15afd31e9ddb7363fb4c47b142aa0f9623a0 (diff) | |
parent | fc4ff50b2bdc3c7dc5197d15d6696b661838e2cf (diff) | |
download | vaadin-framework-ccdef3ddfd79938215cadc947b08a73faf5d0788.tar.gz vaadin-framework-ccdef3ddfd79938215cadc947b08a73faf5d0788.zip |
Merged fixes from 6.7
svn changeset:22331/svn branch:6.8
Diffstat (limited to 'tests')
3 files changed, 260 insertions, 1 deletions
diff --git a/tests/server-side/com/vaadin/data/util/BeanContainerTest.java b/tests/server-side/com/vaadin/data/util/BeanContainerTest.java index 5a753e19d0..d9fa8d896e 100644 --- a/tests/server-side/com/vaadin/data/util/BeanContainerTest.java +++ b/tests/server-side/com/vaadin/data/util/BeanContainerTest.java @@ -1,7 +1,9 @@ package com.vaadin.data.util; +import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -10,7 +12,6 @@ import junit.framework.Assert; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.util.AbstractBeanContainer.BeanIdResolver; -import com.vaadin.data.util.BeanContainer; public class BeanContainerTest extends AbstractBeanContainerTest { @@ -324,6 +325,37 @@ public class BeanContainerTest extends AbstractBeanContainerTest { assertEquals(0, container.size()); } + public void testAddAllWithNullItemId() { + BeanContainer<String, Person> container = new BeanContainer<String, Person>( + Person.class); + // resolver that returns null as item id + container + .setBeanIdResolver(new BeanIdResolver<String, AbstractBeanContainerTest.Person>() { + + public String getIdForBean(Person bean) { + return bean.getName(); + } + }); + + List<Person> persons = new ArrayList<Person>(); + persons.add(new Person("John")); + persons.add(new Person("Marc")); + persons.add(new Person(null)); + persons.add(new Person("foo")); + + try { + container.addAll(persons); + fail(); + } catch (IllegalArgumentException e) { + // should get exception + } + + container.removeAllItems(); + persons.remove(2); + container.addAll(persons); + assertEquals(3, container.size()); + } + public void testAddBeanWithNullResolver() { BeanContainer<String, Person> container = new BeanContainer<String, Person>( Person.class); diff --git a/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.html b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.html new file mode 100644 index 0000000000..4b273ca260 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.html @@ -0,0 +1,133 @@ +<?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.validation.ValidationOfRequiredFields?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td>
+ <td>11,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td>
+ <td>60,11</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td>
+ <td>The field is required</td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>required-message</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[0]</td>
+ <td>13,5</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td>28,13</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td>a</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/domChild[0]/domChild[1]</td>
+ <td>34,186</td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>error-must-be-int</td>
+</tr>
+<!-- Dummy command to remove the tooltip -->
+<tr>
+ <td>showTooltip</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>
+ <td>45,9</td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>error-must-be-int-and-5-to-10-chars</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>
+ <td>12,7</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td>124,12</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td>
+ <td>8,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>
+ <td>13,7</td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>empty-invalid-not-required</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java new file mode 100644 index 0000000000..396b244758 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java @@ -0,0 +1,94 @@ +package com.vaadin.tests.validation;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator;
+import com.vaadin.data.validator.IntegerValidator;
+import com.vaadin.data.validator.StringLengthValidator;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.TextField;
+
+public class ValidationOfRequiredEmptyFields extends TestBase {
+
+ private TextField tf;
+ private CheckBox requiredInput;
+ private TextField requiredErrorInput;
+
+ private Validator integerValidator = new IntegerValidator(
+ "Must be an integer");
+ private Validator stringLengthValidator = new StringLengthValidator(
+ "Must be 5-10 chars", 5, 10, false);
+ private CheckBox integerValidatorInput;
+ private CheckBox stringLengthValidatorInput;
+
+ @Override
+ protected void setup() {
+ requiredInput = new CheckBox("Field required");
+ requiredInput.setImmediate(true);
+ requiredInput.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ tf.setRequired((Boolean) requiredInput.getValue());
+ }
+ });
+
+ requiredErrorInput = new TextField("Required error message");
+ requiredErrorInput.setImmediate(true);
+ requiredErrorInput.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ tf.setRequiredError((String) requiredErrorInput.getValue());
+ }
+ });
+
+ integerValidatorInput = new CheckBox("Integer.parseInt validator");
+ integerValidatorInput.setImmediate(true);
+ integerValidatorInput.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ if ((Boolean) integerValidatorInput.getValue()) {
+ tf.addValidator(integerValidator);
+ } else {
+ tf.removeValidator(integerValidator);
+ }
+ }
+ });
+ stringLengthValidatorInput = new CheckBox(
+ "stringLength.parseInt validator");
+ stringLengthValidatorInput.setImmediate(true);
+ stringLengthValidatorInput.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ if ((Boolean) stringLengthValidatorInput.getValue()) {
+ tf.addValidator(stringLengthValidator);
+ } else {
+ tf.removeValidator(stringLengthValidator);
+ }
+ }
+ });
+
+ tf = new TextField();
+ tf.setImmediate(true);
+
+ requiredInput.setValue(false);
+ requiredErrorInput.setValue("");
+ integerValidatorInput.setValue(false);
+ stringLengthValidatorInput.setValue(false);
+
+ addComponent(requiredInput);
+ addComponent(requiredErrorInput);
+ addComponent(integerValidatorInput);
+ addComponent(stringLengthValidatorInput);
+ addComponent(tf);
+ }
+
+ @Override
+ protected String getDescription() {
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3851;
+ }
+
+}
|