diff options
author | Artur Signell <artur@vaadin.com> | 2016-08-24 14:03:42 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-08-24 14:24:59 +0300 |
commit | 11c3f8bd9ea65f7a7b8da9a282c31a127bd475a6 (patch) | |
tree | 1cba2461fd063e46056b51177fb0747b1ad49424 | |
parent | fb5220ab9b818ee6287467b068371624f73fbbeb (diff) | |
download | vaadin-framework-11c3f8bd9ea65f7a7b8da9a282c31a127bd475a6.tar.gz vaadin-framework-11c3f8bd9ea65f7a7b8da9a282c31a127bd475a6.zip |
Properly encode special UTF-8 characters (#19928)
The main encoding problem was fixed in GWT 2.7.0.vaadin4.
Vaadin 8 is already fixed as it uses GWT 2.8
Change-Id: I78ea30c1ff81d44432cd82ecd23eda8eb86e6efb
-rw-r--r-- | build.properties | 2 | ||||
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java | 32 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java | 44 |
4 files changed, 78 insertions, 2 deletions
diff --git a/build.properties b/build.properties index 2148fc00e6..846e069898 100644 --- a/build.properties +++ b/build.properties @@ -6,5 +6,5 @@ vaadin.url=http://vaadin.com vaadin.java.version=1.6 vaadin.version=7.7.0-SNAPSHOT vaadin.sass.version=0.9.13 -gwt.version=2.7.0.vaadin3 +gwt.version=2.7.0.vaadin4 commons-io.version=2.4 @@ -29,7 +29,7 @@ <liferay.portal.version>6.0.2</liferay.portal.version> <vaadin.sass.version>0.9.13</vaadin.sass.version> - <vaadin.gwt.version>2.7.0.vaadin3</vaadin.gwt.version> + <vaadin.gwt.version>2.7.0.vaadin4</vaadin.gwt.version> <vaadin.plugin.version>7.7.0.alpha1</vaadin.plugin.version> <javax.portlet.version>2.0</javax.portlet.version> diff --git a/uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java b/uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java new file mode 100644 index 0000000000..9dc3351083 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.core; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.MenuItem; +import com.vaadin.ui.TextField; + +public class SpecialCharactersEncodingUI extends AbstractTestUI { + + public static String textWithZwnj = "\ufeffछुट्याउनेछन् क्ष क्ष क्ष"; + + @Override + protected void setup(VaadinRequest request) { + MenuBar menubar = new MenuBar(); + menubar.setId("menubar"); + addComponent(menubar); + menubar.addItem(textWithZwnj, null); + + Label label = new Label(textWithZwnj); + label.setId("label"); + addComponent(label); + + TextField f = new TextField("Textfield", textWithZwnj); + f.setId("textfield"); + addComponent(f); + + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java b/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java new file mode 100644 index 0000000000..f92e6cbcf5 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java @@ -0,0 +1,44 @@ +package com.vaadin.tests.core; + +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.SingleBrowserTest; +import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; + +public class SpecialCharactersEncodingUITest extends SingleBrowserTest { + + @Test + public void checkEncoding() { + openTestURL(); + String textFieldValue = $(TextFieldElement.class).id("textfield") + .getValue(); + Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + textFieldValue); + LabelElement label = $(LabelElement.class).id("label"); + String labelValue = getHtml(label); // getText() strips some characters + Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + labelValue); + + MenuBarElement menubar = $(MenuBarElement.class).first(); + WebElement menuItem = menubar + .findElement(By.className("v-menubar-menuitem-caption")); + Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + getHtml(menuItem)); + } + + private String getHtml(WebElement element) { + return element.getAttribute("innerHTML"); + } +} |