summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-10-11 16:04:58 +0300
committerHenri Sara <henri.sara@gmail.com>2017-10-11 16:04:58 +0300
commitd0b5741b81d214491c93d4d042c79e10bb4f192e (patch)
treeea36411bfcf99c456e2e590782a51d0882ae0315 /uitest
parentdd806e8bb31ecc7bce50f3aed5ed3fab48364895 (diff)
downloadvaadin-framework-d0b5741b81d214491c93d4d042c79e10bb4f192e.tar.gz
vaadin-framework-d0b5741b81d214491c93d4d042c79e10bb4f192e.zip
Add ErrorLevel to Validators and results (#10099)
Fixes #9792
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/binder/BinderValidatorErrorLevel.java29
-rw-r--r--uitest/src/test/java/com/vaadin/tests/binder/BinderValidatorErrorLevelTest.java41
2 files changed, 70 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/binder/BinderValidatorErrorLevel.java b/uitest/src/main/java/com/vaadin/tests/binder/BinderValidatorErrorLevel.java
new file mode 100644
index 0000000000..03a20bbe1f
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/binder/BinderValidatorErrorLevel.java
@@ -0,0 +1,29 @@
+package com.vaadin.tests.binder;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.data.Binder;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ErrorLevel;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.TextField;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class BinderValidatorErrorLevel extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Binder<Object> binder = new Binder<>();
+
+ for (ErrorLevel l : ErrorLevel.values()) {
+ TextField field = new TextField(l.name());
+ binder.forField(field)
+ .withValidator(s -> s.length() > 3,
+ "ErrorLevel: " + l.name(), l)
+ .bind(t -> "", (t, s) -> {
+ });
+ addComponent(field);
+ }
+ binder.validate();
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/binder/BinderValidatorErrorLevelTest.java b/uitest/src/test/java/com/vaadin/tests/binder/BinderValidatorErrorLevelTest.java
new file mode 100644
index 0000000000..4be9f9a49e
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/binder/BinderValidatorErrorLevelTest.java
@@ -0,0 +1,41 @@
+package com.vaadin.tests.binder;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.shared.ui.ErrorLevel;
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class BinderValidatorErrorLevelTest extends SingleBrowserTest {
+
+ @Test
+ public void testErrorLevelStyleNames() throws IOException {
+ openTestURL();
+
+ for (ErrorLevel l : ErrorLevel.values()) {
+ TextFieldElement textField = $(TextFieldElement.class)
+ .caption(l.name()).first();
+
+ // Screenshot the whole slot
+ compareScreen(textField.findElement(By.xpath("..")),
+ l.name().toLowerCase());
+
+ Assert.assertTrue("Error style for " + l.name() + " not present",
+ textField.getAttribute("class").contains(
+ "v-textfield-error-" + l.name().toLowerCase()));
+ textField.setValue("long enough text");
+ Assert.assertFalse("Error style for " + l.name() + " still present",
+ textField.getAttribute("class").contains(
+ "v-textfield-error-" + l.name().toLowerCase()));
+ textField.setValue("foo");
+ Assert.assertTrue(
+ "Error style for " + l.name() + " should be present again.",
+ textField.getAttribute("class").contains(
+ "v-textfield-error-" + l.name().toLowerCase()));
+ }
+ }
+}