diff options
author | Anna Koskinen <anna@vaadin.com> | 2014-08-08 17:22:56 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-19 14:00:17 +0000 |
commit | bb3d7a233163a2a7dfb268198fa8a0e4b8bde3a5 (patch) | |
tree | 56d0edbf3323c238c35daf0ca3a099156865fd32 | |
parent | 5ae6f5b1d0f362c5893fa61730841b2a6bcb6e2d (diff) | |
download | vaadin-framework-bb3d7a233163a2a7dfb268198fa8a0e4b8bde3a5.tar.gz vaadin-framework-bb3d7a233163a2a7dfb268198fa8a0e4b8bde3a5.zip |
TableWithContainerRequiringEqualsForItemId test upgrade (#14292)
Change-Id: I08da5a69e11f625d3d34f26dbd097d7a0973a541
3 files changed, 98 insertions, 104 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html b/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html deleted file mode 100644 index 0fb4648387..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html +++ /dev/null @@ -1,97 +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="http://arturwin.office.itmill.com:9999/" /> -<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.TableWithContainerRequiringEqualsForItemId?debug&restartApplication</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[0]</td> - <td>523,81</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> - <td>1. Button Button999 clicked</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> - <td>2. Button Button985 clicked</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> - <td>19,7</td> -</tr> -<tr> - <td>contextmenu</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/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></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/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>0</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> - <td>3. Button Button0 clicked</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> - <td>8,15</td> -</tr> -<tr> - <td>contextmenu</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/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></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/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>999</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> - <td>4. Button Button999 clicked</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java b/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java index ae16eff2dd..4ca83b22bd 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java +++ b/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java @@ -4,7 +4,8 @@ import java.util.Date; import com.vaadin.data.util.BeanContainer; import com.vaadin.data.util.BeanItem; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -12,7 +13,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Table; import com.vaadin.ui.themes.Reindeer; -public class TableWithContainerRequiringEqualsForItemId extends TestBase { +public class TableWithContainerRequiringEqualsForItemId extends AbstractTestUI { private MyEntityContainer container = new MyEntityContainer(); private Log log = new Log(10); @@ -44,14 +45,14 @@ public class TableWithContainerRequiringEqualsForItemId extends TestBase { } @Override - protected void setup() { + protected void setup(VaadinRequest request) { Table t = new Table("Table with 1000 item"); t.addGeneratedColumn("Actions", new Table.ColumnGenerator() { @Override public Component generateCell(final Table source, final Object itemId, final Object columnId) { Button tripFolderLink = new Button("Button" + itemId); - tripFolderLink.addListener(new Button.ClickListener() { + tripFolderLink.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { log.log("Button " + event.getButton().getCaption() @@ -69,11 +70,10 @@ public class TableWithContainerRequiringEqualsForItemId extends TestBase { * 1000L)); myEntity.setId(i); container.addBean(myEntity); - // entityProvider.addEntity(myEntity); } t.setContainerDataSource(container); - t.setVisibleColumns(new String[] { "id", "created", "name", "Actions" }); + t.setVisibleColumns(new Object[] { "id", "created", "name", "Actions" }); addComponent(t); addComponent(log); @@ -83,7 +83,7 @@ public class TableWithContainerRequiringEqualsForItemId extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "Test that verifies that Table works correctly with containers which do not return the same instance of the itemId object but instead requires an itemId.equals(otherItemId) check"; } diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemIdTest.java b/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemIdTest.java new file mode 100644 index 0000000000..1eb5cad821 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemIdTest.java @@ -0,0 +1,91 @@ +/* + * 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.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for a Table with a customised BeanItemContainer. + * + * @author Vaadin Ltd + */ +public class TableWithContainerRequiringEqualsForItemIdTest extends + MultiBrowserTest { + + @Test + public void testSorting() { + openTestURL(); + + TableElement table = $(TableElement.class).first(); + List<WebElement> rows = table.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpect amount of rows", 46, rows.size()); + + // click the button on the first visible row + clickButton(table, 0, 3, "1. Button Button999 clicked"); + + // click the button on the last visible row + clickButton(table, 14, 3, "2. Button Button985 clicked"); + + clickTableHeaderToSort(table); + + // check the first cell of the new first visible row + checkFirstCell(table, "0"); + + // click the button on the first visible row + clickButton(table, 0, 3, "3. Button Button0 clicked"); + + // sort by the first column (descending) + clickTableHeaderToSort(table); + + // check the first cell of the new first visible row + checkFirstCell(table, "999"); + + // click the button on the first visible row + clickButton(table, 0, 3, "4. Button Button999 clicked"); + } + + private void checkFirstCell(TableElement table, String expected) { + assertEquals("unexpected contents", expected, table.getCell(0, 0) + .getText()); + } + + private void clickTableHeaderToSort(TableElement table) { + table.findElement(By.className("v-table-header")) + .findElement(By.tagName("tr")) + .findElement(By.className("v-table-caption-container")).click(); + } + + private void clickButton(TableElement table, int row, int column, + String expectedLog) { + table.getCell(row, column).findElement(By.className("v-button")) + .click(); + + // check the new log row + assertEquals("unexpected log row", expectedLog, + findElement(By.id("Log_row_0")).getText()); + } + +} |