123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- package com.vaadin.v7.tests.components.tree;
-
- import static org.junit.Assert.assertEquals;
-
- import org.junit.Test;
- import org.openqa.selenium.Dimension;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.interactions.Actions;
-
- import com.vaadin.testbench.By;
- import com.vaadin.tests.tb3.MultiBrowserTest;
-
- public class TreeContextMenuAndIconsTest extends MultiBrowserTest {
-
- @Override
- protected Class<?> getUIClass() {
- return Trees.class;
- }
-
- @Test
- public void testSimpleContextMenu() throws Exception {
- openTestURL();
-
- selectMenuPath("Settings", "Show event log");
- selectMenuPath("Component", "Features", "Context menu",
- "Item without icon");
-
- openContextMenu(getTreeNodeByCaption("Item 1"));
-
- compareScreen("contextmenu-noicon");
-
- closeContextMenu();
- }
-
- @Test
- public void testContextMenuWithAndWithoutIcon() throws Exception {
- openTestURL();
-
- selectMenuPath("Settings", "Show event log");
- selectMenuPath("Component", "Features", "Context menu",
- "With and without icon");
-
- openContextMenu(getTreeNodeByCaption("Item 1"));
-
- compareScreen("caption-only-and-has-icon");
-
- closeContextMenu();
- }
-
- @Test
- public void testContextLargeIcon() throws Exception {
- openTestURL();
-
- selectMenuPath("Settings", "Show event log");
- selectMenuPath("Component", "Features", "Context menu",
- "Only one large icon");
-
- WebElement menu = openContextMenu(getTreeNodeByCaption("Item 1"));
-
- // reindeer doesn't support menu with larger row height, so the
- // background image contains parts of other sprites =>
- // just check that the menu is of correct size
- Dimension size = menu.getSize();
- assertEquals("Menu height with large icons", 74, size.height);
-
- closeContextMenu();
- }
-
- @Test
- public void testContextRemoveIcon() throws Exception {
- openTestURL();
-
- selectMenuPath("Settings", "Show event log");
- selectMenuPath("Component", "Features", "Context menu",
- "Only one large icon");
-
- openContextMenu(getTreeNodeByCaption("Item 1"));
- closeContextMenu();
-
- selectMenuPath("Component", "Features", "Context menu",
- "Item without icon");
-
- openContextMenu(getTreeNodeByCaption("Item 1"));
-
- compareScreen("contextmenu-noicon");
-
- closeContextMenu();
- }
-
- private WebElement openContextMenu(WebElement element) {
- Actions actions = new Actions(getDriver());
- // Note: on Firefox, the first menu item does not get focus; on other
- // browsers it does
- actions.contextClick(element);
- actions.perform();
- return findElement(By.className("v-contextmenu"));
- }
-
- private void closeContextMenu() {
- findElement(By.className("v-app")).click();
- }
-
- private WebElement getTreeNodeByCaption(String caption) {
- return getDriver()
- .findElement(By.xpath("//span[text() = '" + caption + "']"));
- }
-
- }
|