]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix problem with IntegerValidator test (#14046)
authorDmitrii Rogozin <dmitrii@vaadin.com>
Wed, 18 Jun 2014 08:37:54 +0000 (11:37 +0300)
committerSauli Tähkäpää <sauli@vaadin.com>
Tue, 1 Jul 2014 13:10:02 +0000 (16:10 +0300)
Change-Id: Iaff310ccd2f25ca2d9a4a1043403a3aa1bde2e1a

uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html [deleted file]
uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java [new file with mode: 0644]

diff --git a/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html b/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html
deleted file mode 100644 (file)
index 48d48ed..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>IntegerRangeValidator</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">IntegerRangeValidator</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.fieldgroup.BasicPersonForm?restartApplication</td>
-       <td></td>
-</tr>
-<!--64123 -> age-->
-<tr>
-       <td>mouseClick</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
-       <td>64,20</td>
-</tr>
-<tr>
-       <td>enterCharacter</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
-       <td>64123</td>
-</tr>
-<tr>
-       <td>showTooltip</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>waitForElementPresent</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]</td>
-       <td>Must be between 0 and 150, 64123 is not</td>
-</tr>
-<tr>
-       <td>assertCSSClass</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]</td>
-       <td>v-errorindicator</td>
-</tr>
-<!--Hide tooltip-->
-<tr>
-       <td>showTooltip</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]</td>
-       <td></td>
-</tr>
-<!--10 -> age-->
-<tr>
-       <td>enterCharacter</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
-       <td>10</td>
-</tr>
-<tr>
-       <td>assertElementNotPresent</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]</td>
-       <td>v-errorindicator</td>
-</tr>
-<!---1-->
-<tr>
-       <td>mouseClick</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
-       <td>69,11</td>
-</tr>
-<tr>
-       <td>enterCharacter</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
-       <td>-1</td>
-</tr>
-<tr>
-       <td>assertCSSClass</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]</td>
-       <td>v-errorindicator</td>
-</tr>
-<tr>
-       <td>showTooltip</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VTextField[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]</td>
-       <td>Must be between 0 and 150, -1 is not</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java
new file mode 100644 (file)
index 0000000..20dc514
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.tooltip;
+
+import com.vaadin.data.validator.IntegerRangeValidator;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.TextField;
+
+/**
+ *
+ * UI test class for Tooltip with integer range validator.
+ */
+public class ValidatorCaptionTooltip extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        TextField fieldWithError = new TextField();
+        int min = 0;
+        int max = 100;
+        String errorMessage = "Valid value is between " + min + " and " + max
+                + ". {0} is not.";
+        IntegerRangeValidator validator = new IntegerRangeValidator(
+                errorMessage, min, max);
+        fieldWithError.setValue("142");
+
+        fieldWithError.addValidator(validator);
+        fieldWithError.setConverter(Integer.class);
+        fieldWithError.setImmediate(true);
+
+        TextField fieldWithoutError = new TextField();
+        fieldWithoutError.addValidator(validator);
+        fieldWithoutError.setConverter(Integer.class);
+        fieldWithoutError.setValue("42");
+        addComponent(fieldWithError);
+        addComponent(fieldWithoutError);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Valid value is from 0 to 100.When the value is not valid. An error tooltip should appear";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 14046;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java
new file mode 100644 (file)
index 0000000..9603b1d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.tooltip;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.TooltipTest;
+
+/**
+ * Test to see if validators create error tooltips correctly.
+ * 
+ * @author Vaadin Ltd
+ */
+public class ValidatorCaptionTooltipTest extends TooltipTest {
+    @Test
+    public void validatorWithError() throws Exception {
+        openTestURL();
+
+        TextFieldElement field = $(TextFieldElement.class).get(0);
+        String fieldValue = field.getAttribute("value");
+        String expected = "Valid value is between 0 and 100. " + fieldValue
+                + " is not.";
+        checkTooltip(field, expected);
+    }
+
+    @Test
+    public void validatorWithoutError() throws Exception {
+        openTestURL();
+        TextFieldElement field = $(TextFieldElement.class).get(1);
+        checkTooltip(field, null);
+    }
+}