From 68eec666b55c42b4a55235c00bc78f6212eb2062 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 18 Dec 2014 17:25:15 +0200 Subject: [PATCH] Update broken TB2 test to valid TB3 test (#14755) Change-Id: Idc26ac1fee3edd36646b7a6bd84424d0caa37e63 --- .../checkbox/CheckBoxNullValueTest.java | 64 +++++++++++++++ .../checkbox/CheckBoxNullValue.html | 77 ------------------- 2 files changed, 64 insertions(+), 77 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java delete mode 100644 uitest/tb2/com/vaadin/tests/components/checkbox/CheckBoxNullValue.html 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 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 @@ - - - - - - -CheckBoxNullValue - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheckBoxNullValue
open/run/com.vaadin.tests.components.checkbox.CheckBoxNullValue?restartApplication
screenCaptureinitial
clickvaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
screenCapturebothnull
mouseClickvaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]6,5
mouseClickvaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]7,4
clickvaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
screenCapturebothtrue
mouseClickvaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]6,6
mouseClickvaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]9,9
clickvaadin=runcomvaadintestscomponentscheckboxCheckBoxNullValue::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
screenCapturebothfalse
- - -- 2.39.5