Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to configure the content mode of TabSheet tabs (#8920)
Fixes #8590
- Loading branch information
Showing
5 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabDescriptionContentModeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); | ||
} | ||
} |