From 87fab219d406ea24867dc5e5a501539adda80546 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Mon, 6 Jul 2015 08:11:14 +0300 Subject: Convert TB2 test TreeContextMenuAndIcons to TB4 Change-Id: I09751846794f4d1a16a3edd5ab09579da2f7ffa2 --- .../components/table/ContextMenuSizeTest.java | 6 +- .../tree/TreeContextMenuAndIconsTest.java | 130 +++++++++++++++++ .../src/com/vaadin/tests/tb3/MultiBrowserTest.java | 7 + .../components/tree/TreeContextMenuAndIcons.html | 156 --------------------- 4 files changed, 138 insertions(+), 161 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java delete mode 100644 uitest/tb2/com/vaadin/tests/components/tree/TreeContextMenuAndIcons.html diff --git a/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java b/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java index e6b3ca2af4..e5e5163442 100644 --- a/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java +++ b/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java @@ -27,7 +27,6 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; -import com.vaadin.testbench.parallel.Browser; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -39,10 +38,7 @@ public class ContextMenuSizeTest extends MultiBrowserTest { @Override public List getBrowsersToTest() { - // context menu doesn't work in phantom JS and works weirdly with IE8 - // and selenium. - return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11, - Browser.FIREFOX, Browser.CHROME); + return getBrowsersSupportingContextMenu(); } @Override diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java new file mode 100644 index 0000000000..81d906bec3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java @@ -0,0 +1,130 @@ +/* + * Copyright 2000-2014 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.tree; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TreeContextMenuAndIconsTest extends MultiBrowserTest { + + @Override + protected Class getUIClass() { + return Trees.class; + } + + @Override + public List getBrowsersToTest() { + return getBrowsersSupportingContextMenu(); + } + + @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(); + Assert.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 + "']")); + } + +} diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index 678b38c4f1..a678009d85 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -80,6 +80,13 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration { Browser.IE11); } + protected List getBrowsersSupportingContextMenu() { + // context menu doesn't work in phantom JS and works weirdly with IE8 + // and selenium. + return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11, + Browser.FIREFOX, Browser.CHROME); + } + @Override public void setDesiredCapabilities(DesiredCapabilities desiredCapabilities) { if (BrowserUtil.isIE(desiredCapabilities)) { diff --git a/uitest/tb2/com/vaadin/tests/components/tree/TreeContextMenuAndIcons.html b/uitest/tb2/com/vaadin/tests/components/tree/TreeContextMenuAndIcons.html deleted file mode 100644 index 6f9b5e81c3..0000000000 --- a/uitest/tb2/com/vaadin/tests/components/tree/TreeContextMenuAndIcons.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.tree.Trees?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item119,7
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item032,7
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item028,7
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item657,11
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item468,4
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item169,7
contextMenuAtvaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]
screenCapturecontextmenu-noicon
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item042,7
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item652,6
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item453,3
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item231,4
contextMenuAtvaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]
screenCapturecaption-only-and-has-icon
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item042,7
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item652,6
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item453,3
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item331,4
contextMenuAtvaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]
screenCapturelarge-icon
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item028,7
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item657,11
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item468,4
mouseClickvaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item169,7
contextMenuAtvaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]
screenCapturecontextmenu-noicon
- - -- cgit v1.2.3