summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Koskinen <anna@vaadin.com>2014-08-04 16:51:24 +0300
committerVaadin Code Review <review@vaadin.com>2014-08-05 09:19:31 +0000
commit53e65246b66f0478f8313858d86eaeb206d0ed36 (patch)
tree268dbd6763c75ed4b3206d21f67ef6fc59feab33
parent5f0649db3706375131ecb7b5aaef6b3c2c1501af (diff)
downloadvaadin-framework-53e65246b66f0478f8313858d86eaeb206d0ed36.tar.gz
vaadin-framework-53e65246b66f0478f8313858d86eaeb206d0ed36.zip
EditableModeChange test upgrade (#14292)
Change-Id: Ibbd2704dbf97d1b68cbb4937f930242635226c05
-rw-r--r--uitest/src/com/vaadin/tests/components/table/EditableModeChange.html56
-rw-r--r--uitest/src/com/vaadin/tests/components/table/EditableModeChange.java12
-rw-r--r--uitest/src/com/vaadin/tests/components/table/EditableModeChangeTest.java90
3 files changed, 97 insertions, 61 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/EditableModeChange.html b/uitest/src/com/vaadin/tests/components/table/EditableModeChange.html
deleted file mode 100644
index 6414c9bc03..0000000000
--- a/uitest/src/com/vaadin/tests/components/table/EditableModeChange.html
+++ /dev/null
@@ -1,56 +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>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.table.EditableModeChange?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableEditableModeChange::/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>24,8</td>
-</tr>
-<!--Set into editable mode-->
-<tr>
- <td>doubleClick</td>
- <td>vaadin=runcomvaadintestscomponentstableEditableModeChange::/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>24,8</td>
-</tr>
-<!--Update name for selected row-->
-<tr>
- <td>enterCharacter</td>
- <td>vaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]</td>
- <td>baa</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td>
- <td>34,11</td>
-</tr>
-<!--Ensure the name was updated-->
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestscomponentstableEditableModeChange::/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>baa</td>
-</tr>
-<!--Ensure the correct row is selected-->
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>selected-teemu</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/table/EditableModeChange.java b/uitest/src/com/vaadin/tests/components/table/EditableModeChange.java
index fa8ab8f0f5..e792c90af1 100644
--- a/uitest/src/com/vaadin/tests/components/table/EditableModeChange.java
+++ b/uitest/src/com/vaadin/tests/components/table/EditableModeChange.java
@@ -7,22 +7,24 @@ import java.util.Locale;
import com.vaadin.data.Container;
import com.vaadin.event.ItemClickEvent;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Component;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.Table;
import com.vaadin.ui.TableFieldFactory;
-public class EditableModeChange extends TestBase {
+public class EditableModeChange extends AbstractTestUI {
private ItemClickEvent selectionEvent;
private final String[] names = { "Teemu", "Teppo", "Seppo", "Matti",
"Pekka" };
+ @SuppressWarnings("unchecked")
@Override
- public void setup() {
+ public void setup(VaadinRequest request) {
final Table items = new Table("Items - double-click to edit");
items.setSelectable(true);
@@ -42,7 +44,7 @@ public class EditableModeChange extends TestBase {
.setValue(new FormattedDate(cal.getTime().getTime()));
}
- items.addListener(new ItemClickEvent.ItemClickListener() {
+ items.addItemClickListener(new ItemClickEvent.ItemClickListener() {
@Override
public void itemClick(ItemClickEvent event) {
@@ -89,7 +91,7 @@ public class EditableModeChange extends TestBase {
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "Double click a cell to edit, then click on another row to select it (editmode is set to false). The clicked row should now be selected without any flickering.";
}
diff --git a/uitest/src/com/vaadin/tests/components/table/EditableModeChangeTest.java b/uitest/src/com/vaadin/tests/components/table/EditableModeChangeTest.java
new file mode 100644
index 0000000000..56b30dcb7c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/EditableModeChangeTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.io.IOException;
+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.TestBenchElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests that editing and selecting work correctly.
+ *
+ * @author Vaadin Ltd
+ */
+public class EditableModeChangeTest extends MultiBrowserTest {
+
+ @Test
+ public void testNotification() throws IOException, InterruptedException {
+ openTestURL();
+
+ TableElement table = $(TableElement.class).first();
+
+ // check original value
+ TestBenchElement cell_1_0 = table.getCell(1, 0);
+ assertEquals(
+ "original value not found, wrong cell or contents (1st column of the 2nd row expected)",
+ "Teppo", cell_1_0.getText());
+
+ // double-click to edit cell contents
+ cell_1_0.click();
+ new Actions(getDriver()).doubleClick(cell_1_0).build().perform();
+ sleep(100);
+
+ // fetch the updated cell
+ WebElement textField = table.getCell(1, 0).findElement(
+ By.className("v-textfield"));
+ assertEquals(
+ "original value not found, wrong cell or contents (1st column of the 2nd row expected)",
+ "Teppo", textField.getAttribute("value"));
+
+ // update value
+ textField.clear();
+ textField.sendKeys("baa");
+
+ // click on another row
+ table.getCell(0, 1).click();
+
+ // check the value got updated correctly
+ assertEquals(
+ "updated value not found, wrong cell or contents (1st column of the 2nd row expected)",
+ "baa", table.getCell(1, 0).getText());
+
+ // check that selection got updated correctly
+ List<WebElement> selected = table.findElement(
+ By.className("v-table-body")).findElements(
+ By.className("v-selected"));
+ assertEquals(1, selected.size());
+
+ WebElement content = selected.get(0).findElement(
+ By.className("v-table-cell-wrapper"));
+ assertEquals(
+ "expected value not found, wrong cell or contents (1st column of the 1st row expected)",
+ "Teemu", content.getText());
+
+ compareScreen("selection");
+ }
+
+}