summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-03-24 10:34:05 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-24 10:34:05 +0200
commit8fcb2da138eced17f0a6105ae39122a9d096ef0b (patch)
tree8e72ba50f792d85fe7e22e710cbe972c7a5091fb /uitest
parentb32d7b0e45ddc9d7b720bc603ce5374404381a81 (diff)
downloadvaadin-framework-8fcb2da138eced17f0a6105ae39122a9d096ef0b.tar.gz
vaadin-framework-8fcb2da138eced17f0a6105ae39122a9d096ef0b.zip
Add possibility to configure the content mode of TabSheet tabs (#8920)
Fixes #8590
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentMode.java44
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentModeTest.java53
2 files changed, 97 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentMode.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentMode.java
new file mode 100644
index 0000000000..e398532f3e
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentMode.java
@@ -0,0 +1,44 @@
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ContentMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+public class TabDescriptionContentMode extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TabSheet tabSheet = new TabSheet();
+
+ Tab firstTab = tabSheet.addTab(new Label());
+ firstTab.setCaption("First tab");
+ firstTab.setDescription("First tab description", ContentMode.TEXT);
+
+ Tab secondTab = tabSheet.addTab(new Label());
+ secondTab.setCaption("Second tab");
+ secondTab.setDescription("Second tab\ndescription",
+ ContentMode.PREFORMATTED);
+
+ Tab thirdTab = tabSheet.addTab(new Label());
+ thirdTab.setCaption("Third tab");
+ thirdTab.setDescription("<b>Third tab description</b>",
+ ContentMode.HTML);
+
+ Tab fourthTab = tabSheet.addTab(new Label());
+ fourthTab.setCaption("Fourth tab");
+ fourthTab.setDescription("Fourth tab description");
+
+ Button changeFourthTabDescription = new Button(
+ "Change fourth tab description");
+ changeFourthTabDescription.addClickListener(
+ event -> fourthTab.setDescription(
+ "Fourth tab description, changed",
+ ContentMode.TEXT));
+
+ addComponents(tabSheet, changeFourthTabDescription);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentModeTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentModeTest.java
new file mode 100644
index 0000000000..a3de6ab147
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentModeTest.java
@@ -0,0 +1,53 @@
+package com.vaadin.tests.components.tabsheet;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class TabDescriptionContentModeTest extends SingleBrowserTest {
+
+ @Test
+ public void tab_description_content_modes() {
+ openTestURL();
+ List<WebElement> tabCaptions = findElements(
+ By.className("v-captiontext"));
+
+ hoverCaption(tabCaptions.get(0));
+ waitUntil(driver -> "First tab description"
+ .equals(getDescriptionElement().getText()));
+
+ hoverCaption(tabCaptions.get(1));
+ waitUntil(driver -> "Second tab\ndescription"
+ .equals(getDescriptionElement().findElement(By.tagName("pre"))
+ .getText()));
+
+ hoverCaption(tabCaptions.get(2));
+ waitUntil(
+ driver -> "Third tab description".equals(getDescriptionElement()
+ .findElement(By.tagName("b")).getText()));
+
+ hoverCaption(tabCaptions.get(3));
+ waitUntil(driver -> "Fourth tab description"
+ .equals(getDescriptionElement().findElement(By.tagName("pre"))
+ .getText()));
+
+ $(ButtonElement.class).first().click();
+ hoverCaption(tabCaptions.get(3));
+ waitUntil(driver -> "Fourth tab description, changed"
+ .equals(getDescriptionElement().getText()));
+ }
+
+ private void hoverCaption(WebElement captionElement) {
+ new Actions(getDriver()).moveToElement(captionElement, 1, 1).perform();
+ }
+
+ private WebElement getDescriptionElement() {
+ return findElement(By.className("v-tooltip-text"));
+ }
+}