summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--uitest/src/com/vaadin/tests/components/form/FormTooltips.html148
-rw-r--r--uitest/src/com/vaadin/tests/components/form/FormTooltips.java1
-rw-r--r--uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java65
-rw-r--r--uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java81
-rw-r--r--uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java53
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html146
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java34
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java106
-rw-r--r--uitest/src/com/vaadin/tests/tb3/TooltipTest.java94
9 files changed, 424 insertions, 304 deletions
diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html b/uitest/src/com/vaadin/tests/components/form/FormTooltips.html
deleted file mode 100644
index 5e412c3aad..0000000000
--- a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html
+++ /dev/null
@@ -1,148 +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="http://localhost:8888" />
-<title>FormTooltips</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">FormTooltips</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.form.FormTooltips?restartApplication</td>
- <td></td>
-</tr>
-<!--first name tooltip-->
-<tr>
- <td>showTooltip</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>Fields own tooltip</td>
-</tr>
-<tr>
- <td>showTooltip</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPositionLeft</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>-1000</td>
-</tr>
-<!--first name caption tooltip-->
-<tr>
- <td>showTooltip</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>Fields own tooltip</td>
-</tr>
-<tr>
- <td>mouseMove</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPositionLeft</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>-1000</td>
-</tr>
-<!--Form should not have a description tooltip-->
-<tr>
- <td>showTooltip</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPositionLeft</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td>
- <td>-1000</td>
-</tr>
-<!--Form error message should not have a tooltip-->
-<tr>
- <td>showTooltip</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPositionLeft</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td>
- <td>-1000</td>
-</tr>
-<!--last name should have no tooltip-->
-<tr>
- <td>mouseMove</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPositionLeft</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>-1000</td>
-</tr>
-<!--last name caption should have no tooltip-->
-<tr>
- <td>mouseMove</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPositionLeft</td>
- <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>-1000</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.java b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java
index b70f66c710..6e823204e9 100644
--- a/uitest/src/com/vaadin/tests/components/form/FormTooltips.java
+++ b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java
@@ -31,6 +31,7 @@ public class FormTooltips extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
final Form form = new Form();
+ form.setId("tooltipForm");
form.setDescription("Some description");
form.setItemDataSource(new BeanItem<Person>(new Person("foo", "bar",
"baz", 12, Sex.MALE, null)), Arrays.asList(new String[] {
diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java
new file mode 100644
index 0000000000..df18d4082d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2000-2013 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.components.form;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.FormElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.TooltipTest;
+
+public class FormTooltipsTest extends TooltipTest {
+
+ @Test
+ public void testTooltipConfiguration() throws Exception {
+ openTestURL();
+ // first name tooltip
+
+ WebElement fieldElement = $(FormElement.class).first()
+ .$(TextFieldElement.class).first();
+ checkTooltip(fieldElement, "Fields own tooltip");
+
+ moveToRoot();
+ Thread.sleep(1000);
+ checkTooltipNotPresent();
+
+ // first name caption tooltip
+ checkTooltip(
+ $(FormElement.class).first().findElement(
+ By.className("v-caption")), "Fields own tooltip");
+
+ moveToRoot();
+ Thread.sleep(1000);
+ checkTooltipNotPresent();
+
+ // Form should not have a description tooltip
+ checkTooltip($(FormElement.class).first(), null);
+
+ // Form error message should not have a tooltip
+ checkTooltip(By.className("v-form-errormessage"), null);
+
+ // last name should have no tooltip
+ checkTooltip($(TextFieldElement.class).get(1), null);
+
+ // last name caption should have no tooltip
+ checkTooltip(
+ $(FormElement.class).first()
+ .findElements(By.className("v-caption")).get(1), null);
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java
new file mode 100644
index 0000000000..233049b0ba
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2013 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.components.orderedlayout;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class TooltipOnRequiredIndicator extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ VerticalLayout layout = new VerticalLayout();
+
+ TextField inVertical = new TextField();
+ inVertical.setRequired(true);
+ inVertical.setRequiredError("Vertical layout tooltip");
+ inVertical.setCaption("Vertical layout caption");
+ inVertical.setId("verticalField");
+
+ layout.addComponent(inVertical);
+ addComponent(layout);
+
+ HorizontalLayout horizontalLayout = new HorizontalLayout();
+
+ TextField inHorizontal = new TextField();
+ inHorizontal.setRequired(true);
+ inHorizontal.setRequiredError("Horizontal layout tooltip");
+ inHorizontal.setCaption("Horizontal layout caption");
+ inHorizontal.setId("horizontalField");
+
+ horizontalLayout.addComponent(inHorizontal);
+ layout.addComponent(horizontalLayout);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Show tooltip for caption and required indicator";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 10046;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java
new file mode 100644
index 0000000000..815c00bfac
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2013 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.components.orderedlayout;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.elements.HorizontalLayoutElement;
+import com.vaadin.testbench.elements.VerticalLayoutElement;
+import com.vaadin.tests.tb3.TooltipTest;
+
+public class TooltipOnRequiredIndicatorTest extends TooltipTest {
+
+ @Test
+ public void testTooltipOnRequiredIndicator() throws Exception {
+ openTestURL();
+
+ // gwt-uid-* are not stable across browsers etc. so need to look them up
+
+ // caption
+ checkTooltip(
+ $(VerticalLayoutElement.class).get(1).findElement(
+ By.className("v-captiontext")),
+ "Vertical layout tooltip");
+ // required indicator
+ checkTooltip(By.className("v-required-field-indicator"),
+ "Vertical layout tooltip");
+
+ // caption
+ checkTooltip(
+ $(HorizontalLayoutElement.class).first().findElement(
+ By.className("v-captiontext")),
+ "Horizontal layout tooltip");
+ // required indicator
+ checkTooltip(
+ $(HorizontalLayoutElement.class).first().findElement(
+ By.className("v-required-field-indicator")),
+ "Horizontal layout tooltip");
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html
deleted file mode 100644
index 338e4a2c5b..0000000000
--- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html
+++ /dev/null
@@ -1,146 +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="http://localhost:8888/" />
-<title>TooltipConfiguration</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TooltipConfiguration</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.ui.TooltipConfiguration?restartApplication</td>
- <td></td>
-</tr>
-<!--Short close delay-->
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
- <td>0</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td>
- <td>0,0</td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>This is a short tooltip</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPositionLeft</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>-1000</td>
-</tr>
-<!--Long close delay-->
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
- <td>3000</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
- <td>0,0</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td>
- <td>0,0</td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>This is a short tooltip</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPresent</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
- <td>60,9</td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
- <td>0</td>
-</tr>
-<!--Max width 500-->
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td>
- <td>0,0</td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementWidth</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>500</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
- <td></td>
-</tr>
-<!--Max width 100-->
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SMax width</td>
- <td>100</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
- <td>0,0</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td>
- <td>0,0</td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementWidth</td>
- <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
- <td>100</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java
index 4d201d2a1a..eeea91b638 100644
--- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java
+++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java
@@ -32,8 +32,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog {
closeTimeout.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
- getTooltipConfiguration().setCloseTimeout(
- (Integer) closeTimeout.getConvertedValue());
+ if (closeTimeout.getConvertedValue() != null) {
+ getTooltipConfiguration().setCloseTimeout(
+ (Integer) closeTimeout.getConvertedValue());
+ }
}
});
maxWidth = createIntegerTextField("Max width",
@@ -41,8 +43,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog {
maxWidth.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
- getTooltipConfiguration().setMaxWidth(
- (Integer) maxWidth.getConvertedValue());
+ if (maxWidth.getConvertedValue() != null) {
+ getTooltipConfiguration().setMaxWidth(
+ (Integer) maxWidth.getConvertedValue());
+ }
}
});
openDelay = createIntegerTextField("Open delay",
@@ -50,8 +54,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog {
openDelay.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
- getTooltipConfiguration().setOpenDelay(
- (Integer) openDelay.getConvertedValue());
+ if (openDelay.getConvertedValue() != null) {
+ getTooltipConfiguration().setOpenDelay(
+ (Integer) openDelay.getConvertedValue());
+ }
}
});
@@ -61,8 +67,11 @@ public class TooltipConfiguration extends AbstractTestUIWithLog {
.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
- getTooltipConfiguration().setQuickOpenDelay(
- (Integer) quickOpenDelay.getConvertedValue());
+ if (quickOpenDelay.getConvertedValue() != null) {
+ getTooltipConfiguration().setQuickOpenDelay(
+ (Integer) quickOpenDelay
+ .getConvertedValue());
+ }
}
});
@@ -72,8 +81,11 @@ public class TooltipConfiguration extends AbstractTestUIWithLog {
.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
- getTooltipConfiguration().setQuickOpenTimeout(
- (Integer) quickOpenTimeout.getConvertedValue());
+ if (quickOpenTimeout.getConvertedValue() != null) {
+ getTooltipConfiguration().setQuickOpenTimeout(
+ (Integer) quickOpenTimeout
+ .getConvertedValue());
+ }
}
});
@@ -91,6 +103,8 @@ public class TooltipConfiguration extends AbstractTestUIWithLog {
tf.setConverter(Integer.class);
tf.setImmediate(true);
tf.setConvertedValue(initialValue);
+ // makes TB3 tests simpler - no "null" added when clearing a field
+ tf.setNullRepresentation("");
return tf;
}
diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java
new file mode 100644
index 0000000000..f3e7554579
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2000-2013 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.components.ui;
+
+import java.util.NoSuchElementException;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TooltipConfigurationTest extends MultiBrowserTest {
+
+ private org.openqa.selenium.By tooltipBy = By
+ .vaadin("Root/VTooltip[0]/FlowPanel[0]/domChild[1]");
+
+ @Test
+ public void testTooltipConfiguration() throws Exception {
+ openTestURL();
+
+ WebElement uiRoot = getDriver().findElement(By.vaadin("Root"));
+ WebElement closeTimeout = vaadinElementById("Close timeout");
+ WebElement shortTooltip = vaadinElementById("shortTooltip");
+ WebElement longTooltip = vaadinElementById("longTooltip");
+ WebElement maxWidth = vaadinElementById("Max width");
+
+ selectAndType(closeTimeout, "0");
+ testBenchElement(shortTooltip).showTooltip();
+ waitForElementToBePresent(tooltipBy);
+ Assert.assertEquals("This is a short tooltip", getTooltip().getText());
+
+ new Actions(getDriver()).moveToElement(uiRoot, 0, 0).click().perform();
+ // uiRoot.click();
+ checkTooltipNotPresent();
+
+ selectAndType(closeTimeout, "3000");
+ moveMouseToTopLeft(uiRoot);
+ testBenchElement(shortTooltip).showTooltip();
+ waitForElementToBePresent(tooltipBy);
+ WebElement tooltip2 = getTooltip();
+ Assert.assertEquals("This is a short tooltip", tooltip2.getText());
+
+ uiRoot.click();
+ // assert that tooltip is present
+ getTooltip();
+ selectAndType(closeTimeout, "0");
+ testBenchElement(longTooltip).showTooltip();
+ waitForElementToBePresent(tooltipBy);
+ Assert.assertEquals(500, getTooltip().getSize().getWidth());
+
+ uiRoot.click();
+ selectAndType(maxWidth, "100");
+ moveMouseToTopLeft(uiRoot);
+ testBenchElement(longTooltip).showTooltip();
+ Assert.assertEquals(100, getTooltip().getSize().getWidth());
+ }
+
+ private WebElement getTooltip() {
+ return getDriver().findElement(tooltipBy);
+ }
+
+ private void checkTooltipNotPresent() {
+ try {
+ WebElement tooltip = getTooltip();
+ if (!"".equals(tooltip.getText())
+ || tooltip.getLocation().getX() > -999) {
+ Assert.fail("Found tooltip that shouldn't be visible: "
+ + tooltip.getText() + " at " + tooltip.getLocation());
+ }
+ } catch (NoSuchElementException e) {
+ Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools");
+ }
+ }
+
+ private void selectAndType(WebElement element, String value) {
+ // select and replace text
+ element.clear();
+ // if null representation not set as "", need to move cursor to end and
+ // remove text "null"
+ // element.sendKeys("" + Keys.BACK_SPACE + Keys.BACK_SPACE
+ // + Keys.BACK_SPACE + Keys.BACK_SPACE);
+ element.sendKeys(value + Keys.ENTER);
+ }
+
+ private void moveMouseToTopLeft(WebElement element) {
+ new Actions(getDriver()).moveToElement(element, 0, 0).perform();
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/tb3/TooltipTest.java b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java
new file mode 100644
index 0000000000..86ac8c1f12
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2000-2013 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.tb3;
+
+import java.util.NoSuchElementException;
+
+import org.junit.Assert;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.By;
+
+/**
+ * Base class for TestBench 3+ tests that use tooltips. This class contains
+ * utility methods for testing tooltip use.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class TooltipTest extends MultiBrowserTest {
+
+ protected void clearTooltip() throws Exception {
+ moveToRoot();
+ Thread.sleep(500);
+ checkTooltipNotPresent();
+ }
+
+ protected void checkTooltip(String locator, String value) throws Exception {
+ checkTooltip(By.vaadin(locator), value);
+ }
+
+ protected void checkTooltip(org.openqa.selenium.By by, String value)
+ throws Exception {
+ checkTooltip(getDriver().findElement(by), value);
+ }
+
+ protected void checkTooltip(WebElement element, String value)
+ throws Exception {
+ testBenchElement(element).showTooltip();
+ if (null != value) {
+ checkTooltip(value);
+ } else {
+ checkTooltipNotPresent();
+ }
+ }
+
+ protected void checkTooltip(String value) throws Exception {
+ WebElement tooltip = getTooltip();
+ Assert.assertEquals(value, tooltip.getText());
+ Assert.assertTrue("Tooltip should be in viewport", tooltip
+ .getLocation().getX() >= 0);
+ }
+
+ protected void moveToRoot() {
+ WebElement uiRoot = getDriver().findElement(By.vaadin("Root"));
+ moveMouseToTopLeft(uiRoot);
+ }
+
+ protected WebElement getTooltip() throws InterruptedException {
+ org.openqa.selenium.By tooltipBy = By.vaadin("Root/VTooltip[0]");
+ return getDriver().findElement(tooltipBy);
+ }
+
+ protected void checkTooltipNotPresent() throws Exception {
+ try {
+ WebElement tooltip = getTooltip();
+ if (!"".equals(tooltip.getText())
+ || tooltip.getLocation().getX() > -999) {
+ Assert.fail("Found tooltip that shouldn't be visible: "
+ + tooltip.getText() + " at " + tooltip.getLocation());
+ }
+ } catch (NoSuchElementException e) {
+ Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools");
+ }
+ }
+
+ protected void moveMouseToTopLeft(WebElement element) {
+ new Actions(getDriver()).moveToElement(element, 0, 0).perform();
+ }
+
+}