]> source.dussan.org Git - vaadin-framework.git/commitdiff
Properly encode special UTF-8 characters (#19928)
authorArtur Signell <artur@vaadin.com>
Wed, 24 Aug 2016 11:03:42 +0000 (14:03 +0300)
committerArtur Signell <artur@vaadin.com>
Wed, 24 Aug 2016 11:24:59 +0000 (14:24 +0300)
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

build.properties
pom.xml
uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java [new file with mode: 0644]

index 2148fc00e6d6c910f466478b4a8e86fb3373a89b..846e0698988a32559a4868d8056e7bc564a00203 100644 (file)
@@ -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
diff --git a/pom.xml b/pom.xml
index 5f5eac095dc8296b11071b6c4dd7e97b67c328d6..6f1d59a2ee769c70aab18a6d3adfe025ec456ff7 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -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 (file)
index 0000000..9dc3351
--- /dev/null
@@ -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 (file)
index 0000000..f92e6cb
--- /dev/null
@@ -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");
+    }
+}