]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test for how validators work with empty fields
authorArtur Signell <artur.signell@itmill.com>
Thu, 8 Dec 2011 15:37:54 +0000 (15:37 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 8 Dec 2011 15:37:54 +0000 (15:37 +0000)
svn changeset:22329/svn branch:6.7

tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.html [new file with mode: 0644]
tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java [new file with mode: 0644]

diff --git a/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.html b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.html
new file mode 100644 (file)
index 0000000..4b273ca
--- /dev/null
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
+<link rel="selenium.base" href="" />\r
+<title>New Test</title>\r
+</head>\r
+<body>\r
+<table cellpadding="1" cellspacing="1" border="1">\r
+<thead>\r
+<tr><td rowspan="1" colspan="3">New Test</td></tr>\r
+</thead><tbody>\r
+<tr>\r
+       <td>open</td>\r
+       <td>/run/com.vaadin.tests.validation.ValidationOfRequiredFields?restartApplication</td>\r
+       <td></td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td>\r
+       <td>11,8</td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td>\r
+       <td>60,11</td>\r
+</tr>\r
+<tr>\r
+       <td>enterCharacter</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td>\r
+       <td>The field is required</td>\r
+</tr>\r
+<tr>\r
+       <td>showTooltip</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td>0,0</td>\r
+</tr>\r
+<tr>\r
+       <td>screenCapture</td>\r
+       <td></td>\r
+       <td>required-message</td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[0]</td>\r
+       <td>13,5</td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td>28,13</td>\r
+</tr>\r
+<tr>\r
+       <td>enterCharacter</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td>a</td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/domChild[0]/domChild[1]</td>\r
+       <td>34,186</td>\r
+</tr>\r
+<tr>\r
+       <td>showTooltip</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td>0,0</td>\r
+</tr>\r
+<tr>\r
+       <td>screenCapture</td>\r
+       <td></td>\r
+       <td>error-must-be-int</td>\r
+</tr>\r
+<!--  Dummy command to remove the tooltip -->\r
+<tr>\r
+       <td>showTooltip</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>\r
+       <td></td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>\r
+       <td>45,9</td>\r
+</tr>\r
+<tr>\r
+       <td>showTooltip</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td>0,0</td>\r
+</tr>\r
+<tr>\r
+       <td>screenCapture</td>\r
+       <td></td>\r
+       <td>error-must-be-int-and-5-to-10-chars</td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>\r
+       <td>12,7</td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td>124,12</td>\r
+</tr>\r
+<tr>\r
+       <td>type</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td></td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td>\r
+       <td>8,10</td>\r
+</tr>\r
+<tr>\r
+       <td>mouseClick</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>\r
+       <td>13,7</td>\r
+</tr>\r
+<tr>\r
+       <td>showTooltip</td>\r
+       <td>vaadin=runcomvaadintestsvalidationValidationOfRequiredFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>\r
+       <td>0,0</td>\r
+</tr>\r
+<tr>\r
+       <td>screenCapture</td>\r
+       <td></td>\r
+       <td>empty-invalid-not-required</td>\r
+</tr>\r
+\r
+</tbody></table>\r
+</body>\r
+</html>\r
diff --git a/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java
new file mode 100644 (file)
index 0000000..396b244
--- /dev/null
@@ -0,0 +1,94 @@
+package com.vaadin.tests.validation;\r
+\r
+import com.vaadin.data.Property.ValueChangeEvent;\r
+import com.vaadin.data.Property.ValueChangeListener;\r
+import com.vaadin.data.Validator;\r
+import com.vaadin.data.validator.IntegerValidator;\r
+import com.vaadin.data.validator.StringLengthValidator;\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.CheckBox;\r
+import com.vaadin.ui.TextField;\r
+\r
+public class ValidationOfRequiredEmptyFields extends TestBase {\r
+\r
+    private TextField tf;\r
+    private CheckBox requiredInput;\r
+    private TextField requiredErrorInput;\r
+\r
+    private Validator integerValidator = new IntegerValidator(\r
+            "Must be an integer");\r
+    private Validator stringLengthValidator = new StringLengthValidator(\r
+            "Must be 5-10 chars", 5, 10, false);\r
+    private CheckBox integerValidatorInput;\r
+    private CheckBox stringLengthValidatorInput;\r
+\r
+    @Override\r
+    protected void setup() {\r
+        requiredInput = new CheckBox("Field required");\r
+        requiredInput.setImmediate(true);\r
+        requiredInput.addListener(new ValueChangeListener() {\r
+            public void valueChange(ValueChangeEvent event) {\r
+                tf.setRequired((Boolean) requiredInput.getValue());\r
+            }\r
+        });\r
+\r
+        requiredErrorInput = new TextField("Required error message");\r
+        requiredErrorInput.setImmediate(true);\r
+        requiredErrorInput.addListener(new ValueChangeListener() {\r
+            public void valueChange(ValueChangeEvent event) {\r
+                tf.setRequiredError((String) requiredErrorInput.getValue());\r
+            }\r
+        });\r
+\r
+        integerValidatorInput = new CheckBox("Integer.parseInt validator");\r
+        integerValidatorInput.setImmediate(true);\r
+        integerValidatorInput.addListener(new ValueChangeListener() {\r
+\r
+            public void valueChange(ValueChangeEvent event) {\r
+                if ((Boolean) integerValidatorInput.getValue()) {\r
+                    tf.addValidator(integerValidator);\r
+                } else {\r
+                    tf.removeValidator(integerValidator);\r
+                }\r
+            }\r
+        });\r
+        stringLengthValidatorInput = new CheckBox(\r
+                "stringLength.parseInt validator");\r
+        stringLengthValidatorInput.setImmediate(true);\r
+        stringLengthValidatorInput.addListener(new ValueChangeListener() {\r
+\r
+            public void valueChange(ValueChangeEvent event) {\r
+                if ((Boolean) stringLengthValidatorInput.getValue()) {\r
+                    tf.addValidator(stringLengthValidator);\r
+                } else {\r
+                    tf.removeValidator(stringLengthValidator);\r
+                }\r
+            }\r
+        });\r
+\r
+        tf = new TextField();\r
+        tf.setImmediate(true);\r
+\r
+        requiredInput.setValue(false);\r
+        requiredErrorInput.setValue("");\r
+        integerValidatorInput.setValue(false);\r
+        stringLengthValidatorInput.setValue(false);\r
+\r
+        addComponent(requiredInput);\r
+        addComponent(requiredErrorInput);\r
+        addComponent(integerValidatorInput);\r
+        addComponent(stringLengthValidatorInput);\r
+        addComponent(tf);\r
+    }\r
+\r
+    @Override\r
+    protected String getDescription() {\r
+        return null;\r
+    }\r
+\r
+    @Override\r
+    protected Integer getTicketNumber() {\r
+        return 3851;\r
+    }\r
+\r
+}\r