diff options
author | Anna Koskinen <anna@vaadin.com> | 2014-08-01 10:17:25 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-05 10:18:46 +0000 |
commit | dbe24759d5d7e7e3a5f32fa6b0aef629fe9ac331 (patch) | |
tree | a1624c465249015159e1d90a587f93e40ad45b65 /uitest/src/com/vaadin/tests | |
parent | 4b48b027c8672a9589ac77dd5631abde7d12863c (diff) | |
download | vaadin-framework-dbe24759d5d7e7e3a5f32fa6b0aef629fe9ac331.tar.gz vaadin-framework-dbe24759d5d7e7e3a5f32fa6b0aef629fe9ac331.zip |
TableClickAndDragOnIconAndComponents test upgrade (#14292)
Change-Id: I9677d9da361297cf38cadcab043746efd03ff908
Diffstat (limited to 'uitest/src/com/vaadin/tests')
3 files changed, 246 insertions, 137 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html b/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html deleted file mode 100644 index 7ad0873c0f..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html +++ /dev/null @@ -1,132 +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="" /> -<title>TableClickAndDragOnIconAndComponents</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">TableClickAndDragOnIconAndComponents</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.table.TableClickAndDragOnIconAndComponents?restartApplication</td> - <td></td> -</tr> -<tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td> - <td>38,13</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]</td> - <td>1,1</td> -</tr> -<tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VLabel[0]</td> - <td>30,9</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]</td> - <td>71,11</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]/VTextField[1]</td> - <td>34,9</td> -</tr> -<tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VEmbedded[0]/domChild[0]</td> - <td>9,8</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td> - <td>v-selected</td> -</tr> -<tr> - <td>drag</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[1]</td> - <td>2,16</td> -</tr> -<tr> - <td>drop</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[1]/domChild[0]</td> - <td>22,18</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[1]/domChild[0]</td> - <td>foo 4foo</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java b/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java index 62a131cbbf..64f1a64558 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java +++ b/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java @@ -9,29 +9,31 @@ import com.vaadin.event.dd.acceptcriteria.AcceptAll; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.server.Resource; import com.vaadin.server.ThemeResource; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; import com.vaadin.ui.Component; import com.vaadin.ui.Embedded; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.Table.ColumnGenerator; +import com.vaadin.ui.Table.RowHeaderMode; import com.vaadin.ui.Table.TableDragMode; import com.vaadin.ui.TextField; -public class TableClickAndDragOnIconAndComponents extends TestBase { +public class TableClickAndDragOnIconAndComponents extends AbstractTestUI { private static final long serialVersionUID = -2534880024131980135L; private Table table; @Override - protected void setup() { + protected void setup(VaadinRequest request) { table = new Table(); table.addContainerProperty("foo", String.class, "foo"); table.addContainerProperty("red", String.class, "red"); table.addContainerProperty("icon", Resource.class, null); table.setSelectable(true); - table.setRowHeaderMode(Table.ROW_HEADER_MODE_ICON_ONLY); + table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId("icon"); table.setId("testable-table"); addComponent(table); @@ -122,6 +124,7 @@ public class TableClickAndDragOnIconAndComponents extends TestBase { }); } + @SuppressWarnings("unchecked") private void addItemAfter(Object itemId, Object afterItemId) { Item item; if (afterItemId != null) { @@ -136,7 +139,7 @@ public class TableClickAndDragOnIconAndComponents extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "Tests that you can click on a row icon in a table to select the row, or to drag the row. Verifies also that the table doesn't capture the click events meant for components inside the table"; } diff --git a/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponentsTest.java b/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponentsTest.java new file mode 100644 index 0000000000..4a46342cab --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponentsTest.java @@ -0,0 +1,238 @@ +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that clicking on active fields doesn't change Table selection, nor does + * dragging rows. + * + * @author Vaadin Ltd + */ +public class TableClickAndDragOnIconAndComponentsTest extends MultiBrowserTest { + @Test + public void testClickingAndDragging() { + openTestURL(); + + TableElement table = $(TableElement.class).first(); + + // ensure there's no initial selection + List<WebElement> selected = table.findElements(By + .className("v-selected")); + assertTrue("selection found when there should be none", + selected.isEmpty()); + + // click a cell + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 2nd row expected)", + "red 1foo", table.getCell(1, 2).getText()); + table.getCell(1, 2).click(); + + // ensure the correct row and nothing but that got selected + selected = table.findElements(By.className("v-selected")); + assertFalse("no selection found when there should be some", + selected.isEmpty()); + // find cell contents (row header included) + List<WebElement> cellContents = selected.get(0).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 2nd row expected)", + "red 1foo", cellContents.get(2).getText()); + assertEquals("unexpected table selection size", 1, selected.size()); + + List<WebElement> rows = table.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpected table row count", 5, rows.size()); + + // find a row that isn't the one selected + cellContents = rows.get(2).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 3rd row expected)", + "red 2foo", cellContents.get(2).getText()); + + // click on a TextField on that row + WebElement textField = rows.get(2) + .findElements(By.className("v-textfield")).get(0); + assertEquals( + "expected value not found, wrong cell or contents (6th column of the 3rd row expected)", + "foo 2foo", textField.getAttribute("value")); + textField.click(); + + // ensure the focus shifted correctly + List<WebElement> focused = table.findElements(By + .className("v-textfield-focus")); + assertEquals("unexpected amount of focused textfields", 1, + focused.size()); + assertEquals( + "expected value not found, wrong cell or contents (6th column of the 3rd row expected)", + "foo 2foo", focused.get(0).getAttribute("value")); + + // ensure the selection didn't change + selected = table.findElements(By.className("v-selected")); + assertEquals("unexpected table selection size", 1, selected.size()); + cellContents = selected.get(0).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 2nd row expected)", + "red 1foo", cellContents.get(2).getText()); + + // click on a Label on that row + WebElement label = rows.get(2).findElements(By.className("v-label")) + .get(0); + assertEquals( + "expected value not found, wrong cell or contents (5th column of the 3rd row expected)", + "foo 2foo", label.getText()); + label.click(); + + // ensure the focus shifted correctly + focused = table.findElements(By.className("v-textfield-focus")); + assertTrue("focused textfields found when there should be none", + focused.isEmpty()); + + // ensure the selection changed + selected = table.findElements(By.className("v-selected")); + assertEquals("unexpected table selection size", 1, selected.size()); + cellContents = selected.get(0).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 3rd row expected)", + "red 2foo", cellContents.get(2).getText()); + + // click on the selected row's textfield (same as earlier) + textField.click(); + + // ensure the focus shifted correctly + focused = table.findElements(By.className("v-textfield-focus")); + assertEquals("unexpected amount of focused textfields", 1, + focused.size()); + assertEquals( + "expected value not found, wrong cell or contents (6th column of the 3rd row expected)", + "foo 2foo", focused.get(0).getAttribute("value")); + + // ensure the selection didn't change + selected = table.findElements(By.className("v-selected")); + assertEquals("unexpected table selection size", 1, selected.size()); + cellContents = selected.get(0).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 3rd row expected)", + "red 2foo", cellContents.get(2).getText()); + + // find the readOnly TextField of the previously selected row + textField = rows.get(1).findElements(By.className("v-textfield")) + .get(1); + assertEquals( + "expected value not found, wrong cell or contents (7th column of the 2nd row expected)", + "foo 1foo", textField.getAttribute("value")); + assertEquals( + "expected readonly status not found, wrong cell or contents (7th column of the 2nd row expected)", + "true", textField.getAttribute("readonly")); + + // click on that TextField + textField.click(); + + // ensure the focus shifted correctly + focused = table.findElements(By.className("v-textfield-focus")); + assertTrue("focused textfields found when there should be none", + focused.isEmpty()); + + // ensure the selection changed + selected = table.findElements(By.className("v-selected")); + assertEquals("unexpected table selection size", 1, selected.size()); + cellContents = selected.get(0).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 2nd row expected)", + "red 1foo", cellContents.get(2).getText()); + + // click the embedded icon of the other row + WebElement embedded = rows.get(2).findElement( + By.className("v-embedded")); + embedded.click(); + + // ensure the selection changed + selected = table.findElements(By.className("v-selected")); + assertEquals("unexpected table selection size", 1, selected.size()); + cellContents = selected.get(0).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 3rd row expected)", + "red 2foo", cellContents.get(2).getText()); + + // check row you are about to drag + cellContents = rows.get(4).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 5th row expected)", + "red 4foo", cellContents.get(2).getText()); + + // check the row above it + cellContents = rows.get(3).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 4th row expected)", + "red 3foo", cellContents.get(2).getText()); + + // drag the row to the row that's two places above it (gets dropped + // below that) + cellContents = rows.get(4).findElements( + By.className("v-table-cell-content")); + new Actions(getDriver()).moveToElement(cellContents.get(2)) + .clickAndHold().moveToElement(rows.get(2)).release().perform(); + + // find the current order of the rows + rows = table.findElement(By.className("v-table-body")).findElements( + By.tagName("tr")); + assertEquals("unexpected table row count", 5, rows.size()); + + // ensure the row got dragged + cellContents = rows.get(3).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the dragged row expected, should be on 4th row now)", + "red 4foo", cellContents.get(2).getText()); + + cellContents = rows.get(4).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the previous 4th row expected, should be on 5th row now)", + "red 3foo", cellContents.get(2).getText()); + + // ensure the selection didn't change + selected = table.findElements(By.className("v-selected")); + assertEquals("unexpected table selection size", 1, selected.size()); + cellContents = selected.get(0).findElements( + By.className("v-table-cell-content")); + assertEquals( + "expected value not found, wrong cell or contents (3rd column of the 3rd row expected)", + "red 2foo", cellContents.get(2).getText()); + } + +} |