From 53e65246b66f0478f8313858d86eaeb206d0ed36 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Mon, 4 Aug 2014 16:51:24 +0300 Subject: EditableModeChange test upgrade (#14292) Change-Id: Ibbd2704dbf97d1b68cbb4937f930242635226c05 --- .../tests/components/table/EditableModeChange.html | 56 -------------- .../tests/components/table/EditableModeChange.java | 12 +-- .../components/table/EditableModeChangeTest.java | 90 ++++++++++++++++++++++ 3 files changed, 97 insertions(+), 61 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/EditableModeChange.html create mode 100644 uitest/src/com/vaadin/tests/components/table/EditableModeChangeTest.java 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 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.table.EditableModeChange?restartApplication
mouseClickvaadin=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]24,8
doubleClickvaadin=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]24,8
enterCharactervaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]baa
mouseClickvaadin=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]34,11
assertTextvaadin=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]baa
screenCaptureselected-teemu
- - 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 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"); + } + +} -- cgit v1.2.3