]> source.dussan.org Git - vaadin-framework.git/commitdiff
Update broken TB2 test to valid TB3 test (#14755)
authorArtur Signell <artur@vaadin.com>
Thu, 18 Dec 2014 15:25:15 +0000 (17:25 +0200)
committerVaadin Code Review <review@vaadin.com>
Thu, 18 Dec 2014 16:13:59 +0000 (16:13 +0000)
Change-Id: Idc26ac1fee3edd36646b7a6bd84424d0caa37e63

uitest/src/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java [new file with mode: 0644]
uitest/tb2/com/vaadin/tests/components/checkbox/CheckBoxNullValue.html [deleted file]

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 (file)
index 0000000..63e5c3f
--- /dev/null
@@ -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 (file)
index 9717cce..0000000
+++ /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>