summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java6
-rw-r--r--uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java130
-rw-r--r--uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java7
-rw-r--r--uitest/tb2/com/vaadin/tests/components/tree/TreeContextMenuAndIcons.html156
4 files changed, 138 insertions, 161 deletions
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<DesiredCapabilities> 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<DesiredCapabilities> 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<DesiredCapabilities> 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 @@
-<?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>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.tree.Trees?restartApplication</td>
- <td></td>
-</tr>
-<!--Hide event log-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item1</td>
- <td>19,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item0</td>
- <td>32,7</td>
-</tr>
-<!--Simple context menu-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item0</td>
- <td>28,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item6</td>
- <td>57,11</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item4</td>
- <td>68,4</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item1</td>
- <td>69,7</td>
-</tr>
-<tr>
- <td>contextMenuAt</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>contextmenu-noicon</td>
-</tr>
-<!--Two actions, without and with icon-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item0</td>
- <td>42,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item6</td>
- <td>52,6</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item4</td>
- <td>53,3</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item2</td>
- <td>31,4</td>
-</tr>
-<tr>
- <td>contextMenuAt</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>caption-only-and-has-icon</td>
-</tr>
-<!--Large icon-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item0</td>
- <td>42,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item6</td>
- <td>52,6</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item4</td>
- <td>53,3</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item3</td>
- <td>31,4</td>
-</tr>
-<tr>
- <td>contextMenuAt</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>large-icon</td>
-</tr>
-<!--Simple context menu again to ensure it is properly updated (icons removed)-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_Smenu#item0</td>
- <td>28,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[0]/VMenuBar[0]#item6</td>
- <td>57,11</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[1]/VMenuBar[0]#item4</td>
- <td>68,4</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::Root/VOverlay[2]/VMenuBar[0]#item1</td>
- <td>69,7</td>
-</tr>
-<tr>
- <td>contextMenuAt</td>
- <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>contextmenu-noicon</td>
-</tr>
-</tbody></table>
-</body>
-</html>