From 0ff4e15b96b91becdd6c8e38ad20d8272c5455b7 Mon Sep 17 00:00:00 2001 From: Dmitrii Rogozin Date: Wed, 18 Jun 2014 11:37:54 +0300 Subject: Fix problem with IntegerValidator test (#14046) Change-Id: Iaff310ccd2f25ca2d9a4a1043403a3aa1bde2e1a --- .../tests/fieldgroup/IntegerRangeValidator.html | 95 ---------------------- .../tests/tooltip/ValidatorCaptionTooltip.java | 62 ++++++++++++++ .../tests/tooltip/ValidatorCaptionTooltipTest.java | 46 +++++++++++ 3 files changed, 108 insertions(+), 95 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html create mode 100644 uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html b/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html deleted file mode 100644 index 48d48ede80..0000000000 --- a/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - -IntegerRangeValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IntegerRangeValidator
open/run/com.vaadin.tests.fieldgroup.BasicPersonForm?restartApplication
mouseClickvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]64,20
enterCharactervaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]64123
showTooltipvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]
waitForElementPresentvaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]
assertTextvaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]Must be between 0 and 150, 64123 is not
assertCSSClassvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]v-errorindicator
showTooltipvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]
enterCharactervaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]10
assertElementNotPresentvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]v-errorindicator
mouseClickvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]69,11
enterCharactervaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]-1
assertCSSClassvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]v-errorindicator
showTooltipvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VTextField[0]
assertTextvaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]Must be between 0 and 150, -1 is not
- - diff --git a/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java new file mode 100644 index 0000000000..20dc514c10 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java @@ -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 index 0000000000..9603b1df36 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java @@ -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); + } +} -- cgit v1.2.3