diff options
-rw-r--r-- | uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java | 64 | ||||
-rw-r--r-- | uitest/tb2/com/vaadin/tests/components/checkbox/CheckBoxNullValue.html | 77 |
2 files changed, 64 insertions, 77 deletions
diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java new file mode 100644 index 0000000000..63e5c3f080 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java @@ -0,0 +1,64 @@ +package com.vaadin.tests.components.checkbox; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class CheckBoxNullValueTest extends MultiBrowserTest { + @Test + public void testValidation() throws Exception { + openTestURL(); + CheckBoxElement checkbox = $(CheckBoxElement.class).first(); + CheckBoxElement requiredCheckbox = $(CheckBoxElement.class).caption( + "A required checkbox").first(); + + assertValid(checkbox, true); + assertValid(requiredCheckbox, true); + ButtonElement validate = $(ButtonElement.class).caption("Validate") + .first(); + validate.click(); + + assertValid(checkbox, true); + assertValid(requiredCheckbox, false); + + click(checkbox); + click(requiredCheckbox); + validate.click(); + + assertValid(checkbox, true); + assertValid(requiredCheckbox, true); + + click(checkbox); + click(requiredCheckbox); + validate.click(); + assertValid(checkbox, true); + assertValid(requiredCheckbox, false); + + } + + private void click(CheckBoxElement checkbox) { + checkbox.findElement(By.xpath("input")).click(); + + } + + private void assertValid(CheckBoxElement checkbox, boolean valid) { + boolean hasIndicator = false; + List<WebElement> e = checkbox.findElements(By + .className("v-errorindicator")); + if (e.size() != 0) { + hasIndicator = e.get(0).isDisplayed(); + } + + Assert.assertEquals("Checkbox state should be " + + (valid ? "valid" : "invalid"), valid, !hasIndicator); + + } + +} diff --git a/uitest/tb2/com/vaadin/tests/components/checkbox/CheckBoxNullValue.html b/uitest/tb2/com/vaadin/tests/components/checkbox/CheckBoxNullValue.html deleted file mode 100644 index 9717ccec78..0000000000 --- a/uitest/tb2/com/vaadin/tests/components/checkbox/CheckBoxNullValue.html +++ /dev/null @@ -1,77 +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>CheckBoxNullValue</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">CheckBoxNullValue</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.checkbox.CheckBoxNullValue?restartApplication</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>initial</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>bothnull</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> - <td>6,5</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> - <td>7,4</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>bothtrue</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> - <td>6,6</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> - <td>9,9</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>bothfalse</td> -</tr> - -</tbody></table> -</body> -</html> |