diff options
author | Anna Koskinen <anna@vaadin.com> | 2014-08-05 13:49:57 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-19 10:19:34 +0000 |
commit | a3fdfaee6b9ef45c84bc586c5dd88c7ae7b2e0bb (patch) | |
tree | c1bb28db621ab7abf79332dc2799e294e2126af5 /uitest | |
parent | 1b12dca6368939236ccce69ccba39be453740e52 (diff) | |
download | vaadin-framework-a3fdfaee6b9ef45c84bc586c5dd88c7ae7b2e0bb.tar.gz vaadin-framework-a3fdfaee6b9ef45c84bc586c5dd88c7ae7b2e0bb.zip |
LabelEmbeddedClickThroughForTable test upgrade (#14292)
Change-Id: Ic9799343357735580976687ee02afb3bec142861
Diffstat (limited to 'uitest')
3 files changed, 113 insertions, 135 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.html b/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.html deleted file mode 100644 index 88ff0c01e7..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.html +++ /dev/null @@ -1,129 +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>LabelEmbeddedClickThroughForTable</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">LabelEmbeddedClickThroughForTable</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.table.LabelEmbeddedClickThroughForTable?restartApplication</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td>32,13</td> -</tr> -<!-- Work around for Opera issue #5597 --> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>30,12</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td>32,13</td> -</tr> -<!-- Work around done --> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>30,12</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>row-2-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VLabel[0]</td> - <td>32,9</td> -</tr> -<!-- Moved here to avoid Opera issue #5588 --> -<tr> - <td>screenCapture</td> - <td></td> - <td>row-1-selected</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VLabel[0]</td> - <td>22,6</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>row-2-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VLabel[1]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VLabel[0]</td> - <td>22,6</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VEmbedded[0]/domChild[0]</td> - <td>19,14</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>v-selected</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VEmbedded[0]/domChild[0]</td> - <td>16,15</td> -</tr> -<tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentstableLabelEmbeddedClickThroughForTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]</td> - <td>v-selected</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java b/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java index a90de777cd..b9062236de 100644 --- a/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java +++ b/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java @@ -4,17 +4,18 @@ import com.vaadin.data.Item; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; import com.vaadin.server.ThemeResource; +import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Component; import com.vaadin.ui.Embedded; import com.vaadin.ui.Label; import com.vaadin.ui.Table; -public class LabelEmbeddedClickThroughForTable extends TestBase { +public class LabelEmbeddedClickThroughForTable extends AbstractTestUI { @Override - protected String getDescription() { + protected String getTestDescription() { return "Clicking on a Label or Embedded inside a Table should select the row in the same way that clicking on a text selects the row."; } @@ -23,8 +24,9 @@ public class LabelEmbeddedClickThroughForTable extends TestBase { return 2688; } + @SuppressWarnings("unchecked") @Override - protected void setup() { + protected void setup(VaadinRequest request) { Table table = new Table(); table.setHeight("500px"); table.setSelectable(true); @@ -48,13 +50,13 @@ public class LabelEmbeddedClickThroughForTable extends TestBase { item.getItemProperty("Column 3") .setValue( new Label( - "<a style=\"color: blue\" href=\"javascript:false\">Label A</a>", + "<a style=\"color: blue\" href=\"javascript:false\">Label B</a>", ContentMode.HTML)); item.getItemProperty("Column 4").setValue( new Embedded("", new ThemeResource( "../runo/icons/32/cancel.png"))); - table.addListener(new ItemClickListener() { + table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { diff --git a/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTableTest.java b/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTableTest.java new file mode 100644 index 0000000000..25a3139489 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTableTest.java @@ -0,0 +1,105 @@ +/* + * 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 java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests clicks on different types of Table contents. + * + * @author Vaadin Ltd + */ +public class LabelEmbeddedClickThroughForTableTest extends MultiBrowserTest { + + @Test + public void testNotification() { + openTestURL(); + + TableElement table = $(TableElement.class).first(); + + // click first cell of first row + clickCell(table, 0, 0); + + // click first cell of second row + clickCell(table, 1, 0); + + // click the ordinary label component on first row + clickLabel(table, 0, 1); + + // click the ordinary label component on second row + clickLabel(table, 1, 1); + + // click the html-content label component on first row + clickBoldTag(table, 0, 2); + + // click the ordinary label component on second row (some browsers + // navigate away from the page if you try to click the link in the + // html-content label) + clickLabel(table, 1, 1); + + // click the embedded image on first row + clickImageTag(table, 0, 3); + + // click the embedded image on second row + clickImageTag(table, 1, 3); + } + + private void clickImageTag(TableElement table, int row, int column) { + table.getCell(row, column).findElement(By.className("v-embedded")) + .findElement(By.tagName("img")).click(); + checkRowSelected(table, row); + } + + private void clickBoldTag(TableElement table, int row, int column) { + table.getCell(row, column).findElement(By.className("v-label")) + .findElement(By.tagName("b")).click(); + checkRowSelected(table, row); + } + + private void clickLabel(TableElement table, int row, int column) { + table.getCell(row, column).findElement(By.className("v-label")).click(); + checkRowSelected(table, row); + } + + private void clickCell(TableElement table, int row, int column) { + table.getCell(row, column).click(); + checkRowSelected(table, row); + } + + private void checkRowSelected(TableElement table, int rowIndex) { + List<WebElement> selectedRows = table.findElement( + By.className("v-table-body")).findElements( + By.className("v-selected")); + assertEquals("unexpected table selection size", 1, selectedRows.size()); + assertEquals( + "contents of the selected row don't match contents of the row #" + + rowIndex, + table.getCell(rowIndex, 0).getText(), + selectedRows.get(0) + .findElement(By.className("v-table-cell-wrapper")) + .getText()); + } + +} |