+++ /dev/null
-<?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>
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.";
}
return 2688;
}
+ @SuppressWarnings("unchecked")
@Override
- protected void setup() {
+ protected void setup(VaadinRequest request) {
Table table = new Table();
table.setHeight("500px");
table.setSelectable(true);
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) {
--- /dev/null
+/*
+ * 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());
+ }
+
+}