]> source.dussan.org Git - vaadin-framework.git/commitdiff
Convert TB2 test TreeContextMenuAndIcons to TB4
authorHenri Sara <hesara@vaadin.com>
Mon, 6 Jul 2015 05:11:14 +0000 (08:11 +0300)
committerVaadin Code Review <review@vaadin.com>
Mon, 13 Jul 2015 08:59:54 +0000 (08:59 +0000)
Change-Id: I109ecbfad6e385f98e6475eefd7823efa754fcb9

uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java
uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
uitest/tb2/com/vaadin/tests/components/tree/TreeContextMenuAndIcons.html [deleted file]

index e6b3ca2af49c844765ca5855cf405726f90975a0..e5e51634423c8f24d460eb23d837f0d3b0241f99 100644 (file)
@@ -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 (file)
index 0000000..81d906b
--- /dev/null
@@ -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 + "']"));
+    }
+
+}
index 678b38c4f1aea0ac6e90c3a98679d16f00a11b8a..a678009d8530f765d3cdb168ddd69e0e55c43928 100644 (file)
@@ -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 (file)
index 6f9b5e8..0000000
+++ /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>