aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-05-05 15:45:11 +0300
committerHenri Sara <hesara@vaadin.com>2015-05-15 08:49:33 +0300
commitfd30b439ec3b0bd70e46a70c9152949bbfce7ebc (patch)
tree2d63125090490d04a313cce0c95d3bf5f2908844
parent61c3f455df27e7360db78517bfa5989c260d070b (diff)
downloadvaadin-framework-fd30b439ec3b0bd70e46a70c9152949bbfce7ebc.tar.gz
vaadin-framework-fd30b439ec3b0bd70e46a70c9152949bbfce7ebc.zip
Convert TableDragColumn tests from TB2 to TB4
Change-Id: I9dde8a72ca1f9d3fa2d0c4e740bb2eff278dac7a
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java122
-rw-r--r--uitest/tb2/com/vaadin/tests/components/table/TableDragColumn.html80
-rw-r--r--uitest/tb2/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html124
3 files changed, 122 insertions, 204 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java b/uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java
new file mode 100644
index 0000000000..cb7c6a070e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.table;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.testbench.elements.TableHeaderElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TableDragColumnTest extends MultiBrowserTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return Tables.class;
+ }
+
+ @Test
+ public void testDragColumn() {
+ openTestURL();
+
+ selectMenuPath("Component", "Columns", "Property 1", "Icon", "ok 16x16");
+
+ TableElement table = $(TableElement.class).first();
+ TableHeaderElement dragged = table.getHeaderCell(0);
+ String imgSrc = dragged.findElement(By.tagName("img")).getAttribute(
+ "src");
+ new Actions(getDriver()).moveToElement(dragged).clickAndHold()
+ .moveByOffset(-6, 0).perform();
+
+ Assert.assertTrue("No drag element visible",
+ isElementPresent(By.className("v-table-header-drag")));
+
+ WebElement dragImage = findElement(By.className("v-table-header-drag"));
+ String cellContent = dragged.getText();
+ Assert.assertEquals(
+ "Drag image had different content than header cell",
+ cellContent, dragImage.getText());
+ Assert.assertEquals("Drag image had different icon", imgSrc, dragImage
+ .findElement(By.tagName("img")).getAttribute("src"));
+
+ TableHeaderElement target = table.getHeaderCell(3);
+ new Actions(getDriver())
+ .moveToElement(target, target.getSize().width - 5, 10)
+ .release().perform();
+
+ dragged = table.getHeaderCell(3);
+ Assert.assertEquals("Column was not dropped where expected.",
+ cellContent, dragged.getText());
+ Assert.assertEquals("Drag image had different icon", imgSrc, dragged
+ .findElement(By.tagName("img")).getAttribute("src"));
+ }
+
+ @Test
+ public void testDragColumnFloatingElementStyle() {
+ openTestURL();
+
+ dragAndAssertStyleName("v-table-header-drag");
+
+ selectMenuPath("Component", "Decorations", "Style name",
+ "1px red border (border-red-1px)");
+ dragAndAssertStyleName("border-red-1px");
+
+ selectMenuPath("Component", "Decorations", "Style name",
+ "2px blue border (border-blue-2px)");
+ dragAndAssertStyleName("border-blue-2px");
+ }
+
+ private void dragAndAssertStyleName(String styleName) {
+ TableHeaderElement dragged = $(TableElement.class).first()
+ .getHeaderCell(0);
+ new Actions(getDriver()).moveToElement(dragged).clickAndHold()
+ .moveByOffset(-6, 0).perform();
+
+ Assert.assertTrue("No drag element visible",
+ isElementPresent(By.className("v-table-header-drag")));
+
+ WebElement dragImage = findElement(By.className("v-table-header-drag"));
+ String cellContent = dragged.getText();
+ Assert.assertEquals(
+ "Drag image had different content than header cell",
+ cellContent, dragImage.getText());
+ Assert.assertTrue("Missing CSS class " + styleName,
+ hasCssClass(dragImage, styleName));
+
+ new Actions(getDriver()).release().perform();
+ }
+
+ protected void selectSubMenu(String menuCaption) {
+ selectMenu(menuCaption);
+ new Actions(getDriver()).moveByOffset(100, 0).build().perform();
+ }
+
+ protected void selectMenu(String menuCaption) {
+ getDriver().findElement(
+ By.xpath("//span[text() = '" + menuCaption + "']")).click();
+ }
+
+ protected void selectMenuPath(String... menuCaptions) {
+ selectMenu(menuCaptions[0]);
+ for (int i = 1; i < menuCaptions.length; i++) {
+ selectSubMenu(menuCaptions[i]);
+ }
+ }
+}
diff --git a/uitest/tb2/com/vaadin/tests/components/table/TableDragColumn.html b/uitest/tb2/com/vaadin/tests/components/table/TableDragColumn.html
deleted file mode 100644
index 5d0ba160fe..0000000000
--- a/uitest/tb2/com/vaadin/tests/components/table/TableDragColumn.html
+++ /dev/null
@@ -1,80 +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>TableDragColumn</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TableDragColumn</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.table.Tables?restartApplication</td>
- <td></td>
-</tr>
-<!--Hide log to allow screenshots to be consistent-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item1</td>
- <td>23,10</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item0</td>
- <td>58,13</td>
-</tr>
-<!-- Icon for first column -->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td>
- <td>43,4</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item9</td>
- <td>42,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item0</td>
- <td>24,3</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item4</td>
- <td>58,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item1</td>
- <td>37,8</td>
-</tr>
-<!-- Drag and drop column 1 to the left of column 4 -->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>51,6</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>dragging_column</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[2]</td>
- <td>70,10</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>moved_column</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/tb2/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html b/uitest/tb2/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html
deleted file mode 100644
index e225091b5f..0000000000
--- a/uitest/tb2/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html
+++ /dev/null
@@ -1,124 +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>TableDragColumn</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TableDragColumn</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.table.Tables?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>51,6</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td>
- <td>70,10</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>1 basic ghost element</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>10,10</td>
-</tr>
-<!--Add style name "red-border-1px" to table-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td>
- <td>24,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td>
- <td>18,10</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item4</td>
- <td>19,8</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item2</td>
- <td>75,7</td>
-</tr>
-<!-- Drag and drop column 1 to the left of column 4 -->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>51,6</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td>
- <td>70,10</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>2 themed ghost element should have red borders</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>10,10</td>
-</tr>
-<!--Add style name "red-border-1px" to table-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td>
- <td>24,7</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td>
- <td>18,10</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item4</td>
- <td>19,8</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item3</td>
- <td>164,10</td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>51,6</td>
-</tr>
-<tr>
- <td>mouseMoveAt</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td>
- <td>70,10</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>3 themed ghost element should have 2px blue borders</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>10,10</td>
-</tr>
-</tbody></table>
-</body>
-</html> \ No newline at end of file