diff options
author | John Ahlroos <john@vaadin.com> | 2012-08-31 10:10:03 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2012-08-31 10:10:03 +0300 |
commit | 340cd7899812b444941584d383d930fe8155159b (patch) | |
tree | 5989b22f0db52cd578aad087afc9f9fe4d63fb9d /uitest/src/com/vaadin/tests/fieldgroup | |
parent | 8b546f207714a663d4e2996f514cdc077cc9dafc (diff) | |
parent | 7b25b3886ea95bc6495506fbe9472e45fcbde684 (diff) | |
download | vaadin-framework-340cd7899812b444941584d383d930fe8155159b.tar.gz vaadin-framework-340cd7899812b444941584d383d930fe8155159b.zip |
Merge branch 'master' into layoutgraph
Conflicts:
client/src/com/vaadin/client/ComponentLocator.java
client/src/com/vaadin/client/ui/AbstractComponentConnector.java
Diffstat (limited to 'uitest/src/com/vaadin/tests/fieldgroup')
13 files changed, 1404 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java b/uitest/src/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java new file mode 100644 index 0000000000..894944d186 --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java @@ -0,0 +1,99 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.data.fieldgroup.BeanFieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup.CommitException; +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.Notification; + +public abstract class AbstractBeanFieldGroupTest extends TestBase { + + private Button commitButton; + protected Log log = new Log(5); + + private Button discardButton; + private Button showBeanButton; + private BeanFieldGroup fieldBinder; + + @Override + protected void setup() { + addComponent(log); + } + + protected Button getDiscardButton() { + if (discardButton == null) { + discardButton = new Button("Discard", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + getFieldBinder().discard(); + log.log("Discarded changes"); + + } + }); + } + return discardButton; + } + + protected Button getShowBeanButton() { + if (showBeanButton == null) { + showBeanButton = new Button("Show bean values", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log(getFieldBinder().getItemDataSource() + .getBean().toString()); + + } + }); + } + return showBeanButton; + } + + protected Button getCommitButton() { + if (commitButton == null) { + commitButton = new Button("Commit"); + commitButton.addListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + String msg = "Commit succesful"; + try { + getFieldBinder().commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); + } + Notification.show(msg); + log.log(msg); + + } + }); + } + return commitButton; + } + + protected BeanFieldGroup getFieldBinder() { + return fieldBinder; + } + + protected void setFieldBinder(BeanFieldGroup beanFieldBinder) { + fieldBinder = beanFieldBinder; + } + + @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/uitest/src/com/vaadin/tests/fieldgroup/BasicPersonForm.java b/uitest/src/com/vaadin/tests/fieldgroup/BasicPersonForm.java new file mode 100644 index 0000000000..b399857b3b --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/BasicPersonForm.java @@ -0,0 +1,197 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.data.fieldgroup.BeanFieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup.CommitEvent; +import com.vaadin.data.fieldgroup.FieldGroup.CommitException; +import com.vaadin.data.fieldgroup.FieldGroup.CommitHandler; +import com.vaadin.data.util.BeanItem; +import com.vaadin.data.util.converter.StringToBooleanConverter; +import com.vaadin.data.validator.EmailValidator; +import com.vaadin.data.validator.IntegerRangeValidator; +import com.vaadin.data.validator.StringLengthValidator; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.data.bean.Address; +import com.vaadin.tests.data.bean.Country; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.tests.data.bean.Sex; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; + +public class BasicPersonForm extends TestBase { + + private Log log = new Log(5); + private TextField firstName; + private TextArea lastName; + private TextField email; + private TextField age; + private Table sex; + private TextField deceased; + + public class Configuration { + public boolean preCommitFails = false; + public boolean postCommitFails = false; + + public boolean isPreCommitFails() { + return preCommitFails; + } + + public void setPreCommitFails(boolean preCommitFails) { + this.preCommitFails = preCommitFails; + } + + public boolean isPostCommitFails() { + return postCommitFails; + } + + public void setPostCommitFails(boolean postCommitFails) { + this.postCommitFails = postCommitFails; + } + + } + + private Configuration configuration = new Configuration(); + + private class ConfigurationPanel extends Panel { + + public ConfigurationPanel() { + super("Configuration"); + BeanItem<Configuration> bi = new BeanItem<BasicPersonForm.Configuration>( + configuration); + FieldGroup confFieldGroup = new FieldGroup(bi); + confFieldGroup.setItemDataSource(bi); + confFieldGroup.setBuffered(false); + + for (Object propertyId : bi.getItemPropertyIds()) { + addComponent(confFieldGroup.buildAndBind(propertyId)); + } + + } + } + + @Override + protected void setup() { + addComponent(log); + Panel confPanel = new ConfigurationPanel(); + addComponent(confPanel); + + final FieldGroup fieldGroup = new BeanFieldGroup<Person>(Person.class); + fieldGroup.addCommitHandler(new CommitHandler() { + + @Override + public void preCommit(CommitEvent commitEvent) + throws CommitException { + if (configuration.preCommitFails) { + throw new CommitException( + "Error in preCommit because first name is " + + getPerson(commitEvent.getFieldBinder()) + .getFirstName()); + } + + } + + @Override + public void postCommit(CommitEvent commitEvent) + throws CommitException { + if (configuration.postCommitFails) { + throw new CommitException( + "Error in postCommit because first name is " + + getPerson(commitEvent.getFieldBinder()) + .getFirstName()); + } + } + }); + + fieldGroup.setBuffered(true); + + fieldGroup.buildAndBindMemberFields(this); + addComponent(firstName); + addComponent(lastName); + addComponent(email); + addComponent(age); + addComponent(sex); + addComponent(deceased); + + Button commitButton = new Button("Commit", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + String msg = "Commit succesful"; + try { + fieldGroup.commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); + } + Notification.show(msg); + log.log(msg); + + } + }); + Button discardButton = new Button("Discard", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + fieldGroup.discard(); + log.log("Discarded changes"); + + } + }); + Button showBean = new Button("Show bean values", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log(getPerson(fieldGroup).toString()); + + } + }); + addComponent(commitButton); + addComponent(discardButton); + addComponent(showBean); + email.addValidator(new EmailValidator("Must be a valid address")); + lastName.addValidator(new StringLengthValidator("Must be min 5 chars", + 5, null, true)); + + age.addValidator(new IntegerRangeValidator( + "Must be between 0 and 150, {0} is not", 0, 150)); + sex.setPageLength(0); + deceased.setConverter(new StringToBooleanConverter() { + @Override + protected String getTrueString() { + return "YAY!"; + } + + @Override + protected String getFalseString() { + return "NAAAAAH"; + } + }); + Person p = new Person("John", "Doe", "john@doe.com", 64, Sex.MALE, + new Address("John street", 11223, "John's town", Country.USA)); + fieldGroup.setItemDataSource(new BeanItem<Person>(p)); + } + + public static Person getPerson(FieldGroup binder) { + return ((BeanItem<Person>) binder.getItemDataSource()).getBean(); + } + + @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/uitest/src/com/vaadin/tests/fieldgroup/BooleanTextField.html b/uitest/src/com/vaadin/tests/fieldgroup/BooleanTextField.html new file mode 100644 index 0000000000..c2c8842bcb --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/BooleanTextField.html @@ -0,0 +1,141 @@ +<?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.fieldgroup.BasicPersonForm?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>initial</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>90,38</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Dover</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>1. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>108,9</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]</td> + <td>0,587</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>-18,9</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>false</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]</td> + <td>239,14</td> +</tr> +<!--error indicator--> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VBoxLayout[0]/VBoxLayout$Slot[1]/VBoxLayout[0]/domChild[7]/domChild[0]/domChild[0]/domChild[1]</td> + <td>v-errorindicator</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>false</td> +</tr> +<!--show bean values--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>2. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<!--error message in tooltip--> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]</td> + <td>Could not convert value to Boolean</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>66,6</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>YAY!</td> +</tr> +<!--no error indicator--> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[7]/domChild[0]/domChild[1]</td> + <td>v-errorindicator</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> +</tr> +<!--commit last name and new deceased status--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>4. Person [firstName=John, lastName=Dover, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=true, salary=null, salaryDouble=null, rent=null]</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailures.html b/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailures.html new file mode 100644 index 0000000000..2ad104c16c --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailures.html @@ -0,0 +1,220 @@ +package com.vaadin.tests.fieldgroup; + +public class CommitHandlerFailures_html { + <?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.fieldgroup.BasicPersonForm?restartApplication</td> + <td></td> + </tr> + <!--assert we are starting with what we think we are starting with--> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>John</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doe</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>john@doe.com</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64</td> + </tr> + <tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>v-selected</td> + </tr> + <tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> + <td>v-selected</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>NAAAAAH</td> + </tr> + <!--Make changes to fields--> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doeve</td> + </tr> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>Mike</td> + </tr> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>me@me.com</td> + </tr> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>12</td> + </tr> + <tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td> + <td>31,10</td> + </tr> + <!--show bean values--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>1. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> + </tr> + <!--pre commit fails--> + <tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>35,6</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>2. Commit failed: Commit failed</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>3. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> + </tr> + <!--post commit fails--> + <tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>10,7</td> + </tr> + <tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>9,7</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>4. Commit failed: Commit failed</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>5. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> + </tr> + <!--discard and ensure old values are returned as all commits have failed--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>John</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doe</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>john@doe.com</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64</td> + </tr> + <tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>v-selected</td> + </tr> + <tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> + <td>v-selected</td> + </tr> + <tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>NAAAAAH</td> + </tr> + <!--show bean values--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>7. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> + </tr> + + </tbody></table> + </body> + </html> + +} + diff --git a/uitest/src/com/vaadin/tests/fieldgroup/CommitWithValidationOrConversionError.html b/uitest/src/com/vaadin/tests/fieldgroup/CommitWithValidationOrConversionError.html new file mode 100644 index 0000000000..2c88930077 --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/CommitWithValidationOrConversionError.html @@ -0,0 +1,150 @@ + <?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.fieldgroup.BasicPersonForm?restartApplication</td> + <td></td> + </tr> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doev</td> + </tr> + <!--commit with invalid field must fail--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>1. Commit failed: Commit failed</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>2. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> + </tr> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64,2</td> + </tr> + <!--commit with 2 fails--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>3. Commit failed: Commit failed</td> + </tr> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doever</td> + </tr> + <!--1 error fixed, still 1 conversion error--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>4. Commit failed: Commit failed</td> + </tr> + <tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>123</td> + </tr> + <!--all fields ok, commit should be ok--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>5. Commit succesful</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>6. Person [firstName=John, lastName=Doever, email=john@doe.com, age=123, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> + </tr> + <!--discard should now have no effect--> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>7. Discarded changes</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>8. Person [firstName=John, lastName=Doever, email=john@doe.com, age=123, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> + </tr> + + </tbody></table> + </body> + </html> + +} + diff --git a/uitest/src/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java b/uitest/src/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java new file mode 100644 index 0000000000..4f83f5d0fd --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java @@ -0,0 +1,109 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.data.fieldgroup.BeanFieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup.CommitException; +import com.vaadin.data.util.BeanItem; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.data.bean.Address; +import com.vaadin.tests.data.bean.Country; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.tests.data.bean.PersonWithBeanValidationAnnotations; +import com.vaadin.tests.data.bean.Sex; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; + +public class FieldBinderWithBeanValidation extends TestBase { + + private Log log = new Log(5); + private TextField firstName; + private TextArea lastName; + private TextField email; + private TextField age; + private Table sex; + private TextField deceased; + + @Override + protected void setup() { + addComponent(log); + + final BeanFieldGroup<PersonWithBeanValidationAnnotations> fieldGroup = new BeanFieldGroup<PersonWithBeanValidationAnnotations>( + PersonWithBeanValidationAnnotations.class); + + fieldGroup.buildAndBindMemberFields(this); + addComponent(firstName); + addComponent(lastName); + addComponent(email); + addComponent(age); + addComponent(sex); + addComponent(deceased); + + Button commitButton = new Button("Commit", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + String msg = "Commit succesful"; + try { + fieldGroup.commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); + } + Notification.show(msg); + log.log(msg); + + } + }); + Button discardButton = new Button("Discard", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + fieldGroup.discard(); + log.log("Discarded changes"); + + } + }); + Button showBean = new Button("Show bean values", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log(getPerson(fieldGroup).toString()); + + } + }); + addComponent(commitButton); + addComponent(discardButton); + addComponent(showBean); + sex.setPageLength(0); + + PersonWithBeanValidationAnnotations p = new PersonWithBeanValidationAnnotations( + "John", "Doe", "john@doe.com", 64, Sex.MALE, new Address( + "John street", 11223, "John's town", Country.USA)); + fieldGroup + .setItemDataSource(new BeanItem<PersonWithBeanValidationAnnotations>( + p)); + } + + public static Person getPerson(FieldGroup binder) { + return ((BeanItem<Person>) binder.getItemDataSource()).getBean(); + } + + @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/uitest/src/com/vaadin/tests/fieldgroup/FieldGroupDiscard.html b/uitest/src/com/vaadin/tests/fieldgroup/FieldGroupDiscard.html new file mode 100644 index 0000000000..a2ac1b748b --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/FieldGroupDiscard.html @@ -0,0 +1,164 @@ +<?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.fieldgroup.BasicPersonForm?restartApplication</td> + <td></td> +</tr> +<!--assert we are starting with what we think we are starting with--> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>John</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doe</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>john@doe.com</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>NAAAAAH</td> +</tr> +<!--make some changes--> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>John123</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doe123</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>john@doe.com123</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64123</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>33,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>72,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>-18,15</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>YAY!</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>1. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>2. Discarded changes</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>3. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<!--we should still be at the state we started from--> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>John</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doe</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>john@doe.com</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>NAAAAAH</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/fieldgroup/FormBuilderWithNestedProperties.java b/uitest/src/com/vaadin/tests/fieldgroup/FormBuilderWithNestedProperties.java new file mode 100644 index 0000000000..5f25070f2e --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/FormBuilderWithNestedProperties.java @@ -0,0 +1,47 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.data.fieldgroup.BeanFieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.fieldgroup.PropertyId; +import com.vaadin.data.util.BeanItem; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.data.bean.Address; +import com.vaadin.tests.data.bean.Country; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.tests.data.bean.Sex; +import com.vaadin.ui.TextField; + +public class FormBuilderWithNestedProperties extends TestBase { + + private TextField firstName; + private TextField lastName; + @PropertyId("address.streetAddress") + private TextField streetAddress; + + @Override + protected void setup() { + FieldGroup fieldGroup = new BeanFieldGroup<Person>(Person.class); + fieldGroup.buildAndBindMemberFields(this); + + addComponent(firstName); + addComponent(lastName); + addComponent(streetAddress); + + fieldGroup.setItemDataSource(new BeanItem<Person>(new Person("Who", + "me?", "email", 1, Sex.MALE, new Address("street name", 202020, + "City", Country.FINLAND)))); + } + + @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/uitest/src/com/vaadin/tests/fieldgroup/FormManyToMany.java b/uitest/src/com/vaadin/tests/fieldgroup/FormManyToMany.java new file mode 100644 index 0000000000..f4f612503c --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/FormManyToMany.java @@ -0,0 +1,28 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.tests.components.TestBase; + +public class FormManyToMany extends TestBase { + + @Override + protected void setup() { + // TODO implement + + // TODO note that in one direction, a setter is used and automatically + // updates the other direction (setting the Roles of a User updates + // Roles), whereas in the other direction (updating the list of Users + // for a Role), manual updates are needed at commit time to keep the + // Users consistent with Roles + } + + @Override + protected String getDescription() { + return "Forms which allow editing of a many-to-many mapping between users and roles"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/fieldgroup/FormOneToMany.java b/uitest/src/com/vaadin/tests/fieldgroup/FormOneToMany.java new file mode 100644 index 0000000000..e269a39441 --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/FormOneToMany.java @@ -0,0 +1,43 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.data.util.BeanItem; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.Millionaire; +import com.vaadin.ui.Form; + +public class FormOneToMany extends TestBase { + + @Override + protected void setup() { + final Form form = new Form(); + addComponent(form); + form.setItemDataSource(createMillionaireItem()); + + // TODO support adding, editing and removing secondary addresses + } + + protected BeanItem<Millionaire> createMillionaireItem() { + Millionaire person = new Millionaire("First", "Last", "foo@vaadin.com", + "02-111 2222", "Ruukinkatu 2-4", 20540, "Turku"); + + BeanItem<Millionaire> item = new BeanItem<Millionaire>(person); + // add nested properties from address + item.expandProperty("address"); + + // TODO for now, hide secondary residences + item.removeItemProperty("secondaryResidences"); + + return item; + } + + @Override + protected String getDescription() { + return "Form with an editable list of sub-objects."; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/fieldgroup/FormOneToOne.java b/uitest/src/com/vaadin/tests/fieldgroup/FormOneToOne.java new file mode 100644 index 0000000000..b16cb29a8a --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/FormOneToOne.java @@ -0,0 +1,38 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.data.util.BeanItem; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.Person; +import com.vaadin.ui.Form; + +public class FormOneToOne extends TestBase { + + @Override + protected void setup() { + final Form form = new Form(); + addComponent(form); + form.setItemDataSource(createPersonItem()); + } + + protected BeanItem<Person> createPersonItem() { + Person person = new Person("First", "Last", "foo@vaadin.com", + "02-111 2222", "Ruukinkatu 2-4", 20540, "Turku"); + + BeanItem<Person> item = new BeanItem<Person>(person); + // add nested properties from address + item.expandProperty("address"); + + return item; + } + + @Override + protected String getDescription() { + return "Form where some properties come from a sub-object of the bean."; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/fieldgroup/FormWithNestedProperties.java b/uitest/src/com/vaadin/tests/fieldgroup/FormWithNestedProperties.java new file mode 100644 index 0000000000..f66d822495 --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/FormWithNestedProperties.java @@ -0,0 +1,67 @@ +package com.vaadin.tests.fieldgroup; + +import com.vaadin.data.fieldgroup.BeanFieldGroup; +import com.vaadin.data.fieldgroup.PropertyId; +import com.vaadin.tests.data.bean.Address; +import com.vaadin.tests.data.bean.Country; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.tests.data.bean.Sex; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.TextField; + +public class FormWithNestedProperties extends AbstractBeanFieldGroupTest { + + private Log log = new Log(5); + + private TextField firstName = new TextField("First name"); + private TextField lastName = new TextField("Last name"); + private TextField email = new TextField("Email"); + private TextField age = new TextField("Age"); + + @PropertyId("address.streetAddress") + private TextField streetAddress = new TextField("Street address"); + private NativeSelect country; + + private CheckBox deceased = new CheckBox("Deceased"); + + @Override + protected void setup() { + super.setup(); + + setFieldBinder(new BeanFieldGroup<Person>(Person.class)); + country = getFieldBinder().buildAndBind("country", "address.country", + NativeSelect.class); + getFieldBinder().bindMemberFields(this); + addComponent(firstName); + addComponent(lastName); + addComponent(streetAddress); + addComponent(country); + addComponent(email); + addComponent(age); + addComponent(deceased); + addComponent(getCommitButton()); + addComponent(getDiscardButton()); + addComponent(getShowBeanButton()); + + getFieldBinder().setItemDataSource( + new Person("First", "Last", "Email", 52, Sex.FEMALE, + new Address("street address", 01234, "City", + Country.FINLAND))); + + } + + @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/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html b/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html new file mode 100644 index 0000000000..b7c40b4d9e --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html @@ -0,0 +1,101 @@ + <?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.fieldgroup.BasicPersonForm?restartApplication</td> + <td></td> +</tr> +<!--64123 -> age--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64,20</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64123</td> +</tr> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]</td> + <td>Must be between 0 and 150, 64123 is not</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]</td> + <td>v-errorindicator</td> +</tr> +<!--Hide tooltip--> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]</td> + <td></td> +</tr> +<!--10 -> age--> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>10</td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]</td> + <td>v-errorindicator</td> +</tr> +<!---1--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>69,11</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>-1</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]</td> + <td>v-errorindicator</td> +</tr> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]</td> + <td>Must be between 0 and 150, -1 is not</td> +</tr> +</tbody></table> + </body> + </html> + |