diff options
author | Leif Åstrand <leif@vaadin.com> | 2011-09-27 09:43:44 +0000 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2011-09-27 09:43:44 +0000 |
commit | 849d5041e4d0de462058227f23a4d3ca6d54db2a (patch) | |
tree | 4ec7c8a78ea235e9914909577f52b2e22007039a /tests | |
parent | b112e78d96dd343095f6322a9923da726851b233 (diff) | |
download | vaadin-framework-849d5041e4d0de462058227f23a4d3ca6d54db2a.tar.gz vaadin-framework-849d5041e4d0de462058227f23a4d3ca6d54db2a.zip |
#6588 Repainting in TextChangeListener will send wrong value to client
svn changeset:21332/svn branch:6.7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.html | 81 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.java | 53 |
2 files changed, 134 insertions, 0 deletions
diff --git a/tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.html b/tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.html new file mode 100644 index 0000000000..ecd0467fb2 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.html @@ -0,0 +1,81 @@ +<?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.textfield.TextFieldEagerRepaint?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]</td> + <td>78,8</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]</td> + <td>abCDef</td> +</tr> +<tr> + <td>pause</td> + <td></td> + <td>100</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]</td> + <td>abef</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td> + <td>73,15</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td> + <td>a</td> +</tr> +<tr> + <td>pause</td> + <td></td> + <td>100</td> +</tr> +<tr> + <td>assertElementWidth</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td> + <td>150</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td> + <td>aB</td> +</tr> +<tr> + <td>pause</td> + <td></td> + <td>100</td> +</tr> +<tr> + <td>assertElementWidth</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td> + <td>100</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldEagerRepaint::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td> + <td>aB</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.java b/tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.java new file mode 100644 index 0000000000..08751a59fd --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textfield/TextFieldEagerRepaint.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.textfield; + +import com.vaadin.event.FieldEvents.TextChangeEvent; +import com.vaadin.event.FieldEvents.TextChangeListener; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractTextField.TextChangeEventMode; +import com.vaadin.ui.TextField; + +public class TextFieldEagerRepaint extends TestBase { + + @Override + protected void setup() { + + final TextField tf1 = new TextField("Updates value"); + tf1.setTextChangeEventMode(TextChangeEventMode.EAGER); + tf1.addListener(new TextChangeListener() { + public void textChange(TextChangeEvent event) { + String text = event.getText(); + if (!text.matches("[a-z]*")) { + String newValue = text.replaceAll("[^a-z]", ""); + tf1.setValue(newValue); + } + } + }); + + final TextField tf2 = new TextField("Updates width"); + tf2.setTextChangeEventMode(TextChangeEventMode.EAGER); + tf2.addListener(new TextChangeListener() { + public void textChange(TextChangeEvent event) { + String text = event.getText(); + if (!text.matches("[a-z]*")) { + tf2.setWidth("100px"); + } else { + tf2.setWidth("150px"); + } + } + }); + + addComponent(tf1); + addComponent(tf2); + } + + @Override + protected String getDescription() { + return "Updating the value in an EAGER TextChangeListener should send the new value to the client while updating something else (e.g. the width) should preserve the text in the field. Both fields react when the field contains anything else than lower case letters a-z"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(6588); + } + +} |