summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorMatti Tahvonen <matti@vaadin.com>2015-07-16 18:12:57 +0300
committerVaadin Code Review <review@vaadin.com>2016-05-02 08:38:24 +0000
commit85870ccd9f93cebd839d22d2bd63ec817bb90a3d (patch)
treea1397563807e3468429878d520874bbc8cc92d33 /uitest
parent29a6ed998041be42e2c4e986d9702fa2e798f1be (diff)
downloadvaadin-framework-85870ccd9f93cebd839d22d2bd63ec817bb90a3d.tar.gz
vaadin-framework-85870ccd9f93cebd839d22d2bd63ec817bb90a3d.zip
Better default for nullRepresentation (#13221, #12877)
Change-Id: Ia4662c79b20ee699b3a9741ffa24c4de6645b775
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyMode.java84
-rw-r--r--uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java10
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyModeTest.java21
3 files changed, 114 insertions, 1 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyMode.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyMode.java
new file mode 100644
index 0000000000..ab0bc6e534
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyMode.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.tests.components.textfield;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.data.fieldgroup.BeanFieldGroup;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+@SuppressWarnings("serial")
+@Theme("valo")
+public class NullRepresentationLegacyMode extends AbstractTestUI {
+
+ public static class Entity {
+
+ private String value;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ }
+
+ public static class Form extends VerticalLayout {
+ TextField value = new TextField();
+
+ public Form() {
+ setMargin(true);
+ setSpacing(true);
+ addComponent(value);
+ }
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Form formWithoutNulls = new Form();
+ formWithoutNulls.setCaption("No 'null's here please");
+ formWithoutNulls.setId("without");
+ BeanFieldGroup.bindFieldsUnbuffered(new Entity(), formWithoutNulls);
+
+ // Use the legacy default
+ AbstractTextField.setNullRepresentationDefault("null");
+
+ Form formWithNulls = new Form();
+ formWithNulls.setCaption("'null's please");
+ formWithNulls.setId("with");
+ BeanFieldGroup.bindFieldsUnbuffered(new Entity(), formWithNulls);
+ AbstractTextField.setNullRepresentationDefault("");
+
+ addComponents(formWithoutNulls, formWithNulls);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Text field must not truncate underscores in modal dialogs.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12974;
+ }
+
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java
index 58f2292f84..f09b32d5c7 100644
--- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java
+++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java
@@ -1,5 +1,7 @@
package com.vaadin.tests.fieldgroup;
+import org.apache.commons.lang.StringEscapeUtils;
+
import com.vaadin.data.Validator;
import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.data.util.BeanItem;
@@ -7,10 +9,10 @@ import com.vaadin.data.validator.BeanValidator;
import com.vaadin.server.AbstractErrorMessage;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.AbstractTextField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
-import org.apache.commons.lang.StringEscapeUtils;
public class MultipleValidationErrors extends AbstractTestUI {
@@ -25,9 +27,15 @@ public class MultipleValidationErrors extends AbstractTestUI {
new PersonBeanWithValidationAnnotations());
final FieldGroup fieldGroup = new FieldGroup(item);
+ // use old default that this test depends on
+ AbstractTextField.setNullRepresentationDefault("null");
+
bindTextField(item, fieldGroup, "First Name", "firstName");
bindTextField(item, fieldGroup, "Last Name", "lastName");
+ // Revert to new
+ AbstractTextField.setNullRepresentationDefault("");
+
final Label validationErrors = new Label();
validationErrors.setId("validationErrors");
addComponent(validationErrors);
diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyModeTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyModeTest.java
new file mode 100644
index 0000000000..c303e8e9f1
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/NullRepresentationLegacyModeTest.java
@@ -0,0 +1,21 @@
+package com.vaadin.tests.components.textfield;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class NullRepresentationLegacyModeTest extends MultiBrowserTest {
+
+ @Test
+ public void testWindowRepositioning() throws Exception {
+ openTestURL();
+ String without = getDriver().findElement(
+ By.xpath("//div[@id='without']//input")).getAttribute("value");
+ String with = getDriver().findElement(
+ By.xpath("//div[@id='with']//input")).getAttribute("value");
+ Assert.assertEquals("null", with);
+ Assert.assertEquals("", without);
+ }
+}