Browse Source

Convert TableDragColumn tests from TB2 to TB4

Change-Id: I16127f7b86bedc7603f5319dcc482c9b53e93a46
tags/7.5.0.beta1
Teemu Suo-Anttila 9 years ago
parent
commit
f9dc7d3370

+ 122
- 0
uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java View File

@@ -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]);
}
}
}

+ 0
- 80
uitest/tb2/com/vaadin/tests/components/table/TableDragColumn.html View File

@@ -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>

+ 0
- 124
uitest/tb2/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html View File

@@ -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>

Loading…
Cancel
Save