diff options
author | Denis <denis@vaadin.com> | 2017-01-05 15:47:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-05 15:47:23 +0200 |
commit | b74e08cfe8a849a8f74e6f9f0a3d7c0475ce196d (patch) | |
tree | 344578116082d6b8e812cc901f6fb654afa7a22f | |
parent | 3fb1d75e2bf4772bcd4edeb5f9b36a6747fd776b (diff) | |
download | vaadin-framework-b74e08cfe8a849a8f74e6f9f0a3d7c0475ce196d.tar.gz vaadin-framework-b74e08cfe8a849a8f74e6f9f0a3d7c0475ce196d.zip |
Migrate Grid UI tests P4 (#8133)
Fixes vaadin/framework8-issues#592
13 files changed, 241 insertions, 256 deletions
diff --git a/tests/screenshots b/tests/screenshots -Subproject eec6eee6610e80e28736e8a27aaaa2166ea2fa7 +Subproject 203312a80a5f76d48fc36ef8d215f8b70b8e754 diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBars.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBars.java new file mode 100644 index 0000000000..203a69b1f0 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBars.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2016 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.grid; + +import java.util.Arrays; +import java.util.stream.IntStream; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.Column; +import com.vaadin.ui.Grid.SelectionMode; + +public class GridEditingWithNoScrollBars extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid<Person> grid = new Grid<>(); + grid.addColumn(Person::getFirstName); + Column<Person, String> column = grid.addColumn(Person::getLastName); + + grid.setItems(IntStream.range(0, 10).mapToObj(this::createPerson)); + + ComboBox<String> stCombo = new ComboBox<>(); + stCombo.setItems(Arrays.asList("1", "2", "3")); + stCombo.setEmptySelectionAllowed(false); + stCombo.setSizeFull(); + + column.setEditorComponent(stCombo); + + grid.setSelectionMode(SelectionMode.SINGLE); + grid.getEditor().setEnabled(true); + grid.setSizeFull(); + + addComponent(grid); + } + + private Person createPerson(int i) { + Person person = new Person(); + person.setFirstName("foo"); + person.setLastName(String.valueOf(i % 3 + 1)); + return person; + } + +} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorFrozenColumnsUI.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUI.java index 3732e70a6f..94d5c13b50 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorFrozenColumnsUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUI.java @@ -13,20 +13,21 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.v7.tests.components.grid; +package com.vaadin.tests.components.grid; -import com.vaadin.tests.util.PersonContainer; -import com.vaadin.v7.ui.Grid; +import com.vaadin.tests.util.Person; +import com.vaadin.ui.Grid; public class GridEditorFrozenColumnsUI extends GridEditorUI { @Override - protected Grid createGrid(PersonContainer container) { - Grid grid = super.createGrid(container); + protected Grid<Person> createGrid() { + Grid<Person> grid = super.createGrid(); grid.setFrozenColumnCount(2); grid.setWidth("600px"); + grid.setHeight("100%"); return grid; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorMultiselect.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorMultiselect.java new file mode 100644 index 0000000000..dbeb1bbc8a --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorMultiselect.java @@ -0,0 +1,63 @@ +package com.vaadin.tests.components.grid; + +import java.util.stream.IntStream; + +import com.vaadin.data.Binder; +import com.vaadin.data.converter.StringToIntegerConverter; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.Column; +import com.vaadin.ui.TextField; +import com.vaadin.ui.renderers.NumberRenderer; + +public class GridEditorMultiselect extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid<Person> grid = new Grid<>(); + + Column<Person, String> nameColumn = grid.addColumn(Person::getFirstName) + .setCaption("name"); + Column<Person, Number> ageColumn = grid + .addColumn(Person::getAge, new NumberRenderer()) + .setCaption("age"); + + Binder<Person> binder = new Binder<>(); + grid.getEditor().setBinder(binder); + + TextField name = new TextField(); + nameColumn.setEditorComponent(name); + binder.bind(name, Person::getFirstName, Person::setFirstName); + + TextField age = new TextField(); + ageColumn.setEditorComponent(age); + binder.forField(age).withConverter(new StringToIntegerConverter("")) + .bind(Person::getAge, Person::setAge); + + grid.setItems(IntStream.range(0, 30).mapToObj(this::createPerson)); + + grid.getEditor().setEnabled(true); + grid.setSelectionMode(Grid.SelectionMode.MULTI); + + addComponent(grid); + } + + @Override + protected Integer getTicketNumber() { + return 17132; + } + + @Override + protected String getTestDescription() { + return "Grid Multiselect: Edit mode allows invalid selection"; + } + + private Person createPerson(int i) { + Person person = new Person(); + person.setFirstName("name" + i); + person.setAge(i); + return person; + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java new file mode 100644 index 0000000000..bf8b997f80 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2016 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.grid; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Random; + +import com.vaadin.data.Binder; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.Person; +import com.vaadin.tests.util.TestDataGenerator; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.Column; +import com.vaadin.ui.PasswordField; +import com.vaadin.ui.TextField; +import com.vaadin.ui.renderers.NumberRenderer; + +public class GridEditorUI extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid<Person> grid = createGrid(); + grid.setItems(createTestData()); + addComponent(grid); + } + + protected Collection<Person> createTestData() { + return createTestData(100); + } + + protected Collection<Person> createTestData(int size) { + Random r = new Random(0); + ArrayList<Person> testData = new ArrayList<>(); + for (int i = 0; i < size; i++) { + Person person = new Person(); + person.setFirstName(TestDataGenerator.getFirstName(r)); + person.setLastName(TestDataGenerator.getLastName(r)); + person.getAddress().setCity(TestDataGenerator.getCity(r)); + person.setEmail(person.getFirstName().toLowerCase() + "." + + person.getLastName().toLowerCase() + "@vaadin.com"); + person.setPhoneNumber(TestDataGenerator.getPhoneNumber(r)); + + person.getAddress() + .setPostalCode(TestDataGenerator.getPostalCode(r)); + person.getAddress() + .setStreetAddress(TestDataGenerator.getStreetAddress(r)); + testData.add(person); + } + return testData; + } + + protected Grid<Person> createGrid() { + Grid<Person> grid = new Grid<>(); + + Binder<Person> binder = new Binder<>(); + grid.getEditor().setBinder(binder); + + grid.addColumn(Person::getEmail).setCaption("Email"); + Column<Person, String> fistNameColumn = grid + .addColumn(Person::getFirstName).setCaption("First Name"); + Column<Person, String> lastNameColumn = grid + .addColumn(Person::getLastName).setCaption("Last Name"); + + Column<Person, String> phoneColumn = grid + .addColumn(Person::getPhoneNumber).setCaption("Phone Number"); + grid.addColumn(person -> person.getAddress().getStreetAddress()) + .setCaption("Street Address"); + grid.addColumn(person -> person.getAddress().getPostalCode(), + new NumberRenderer()).setCaption("Postal Code"); + grid.addColumn(person -> person.getAddress().getCity()) + .setCaption("City"); + + grid.getEditor().setEnabled(true); + + PasswordField passwordField = new PasswordField(); + fistNameColumn.setEditorComponent(passwordField); + binder.bind(passwordField, Person::getFirstName, Person::setFirstName); + + TextField lastNameEditor = new TextField(); + lastNameColumn.setEditorComponent(lastNameEditor); + lastNameEditor.setMaxLength(50); + binder.bind(lastNameEditor, Person::getLastName, Person::setLastName); + + TextField phoneEditor = new TextField(); + phoneEditor.setReadOnly(true); + phoneColumn.setEditorComponent(phoneEditor); + binder.bind(phoneEditor, Person::getPhoneNumber, + Person::setPhoneNumber); + + return grid; + } + +} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDragAndDrop.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDragAndDrop.java deleted file mode 100644 index 5a29717239..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDragAndDrop.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2000-2016 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.v7.tests.components.grid; - -import java.util.Arrays; -import java.util.List; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.v7.ui.Grid; - -@SuppressWarnings("serial") -public class GridDragAndDrop extends AbstractReindeerTestUI { - - @Override - protected void setup(VaadinRequest request) { - - List<String> columnIds = Arrays.asList("Hello", "this", "are", - "multiple", "columns", "plus", "these", "resemble", "a", - "group", "here", "no", "more"); - - Grid grid = new Grid(); - - for (String columnId : columnIds) { - grid.addColumn(columnId); - } - - for (int i = 0; i < 100; i++) { - grid.addRow(columnIds.toArray()); - } - - grid.setColumnReorderingAllowed(true); - - grid.setFrozenColumnCount(1); - grid.setSelectionMode(Grid.SelectionMode.MULTI); - - addComponent(grid); - } - - @Override - protected String getTestDescription() { - return "Start dragging a column header and move left and right.<br> The drop indicator should appear exactly on the lines between column headers."; - } - - @Override - protected Integer getTicketNumber() { - return 18925; - } -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditingWithNoScrollBars.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditingWithNoScrollBars.java deleted file mode 100644 index 78523f362c..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditingWithNoScrollBars.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2016 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.v7.tests.components.grid; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.v7.ui.ComboBox; -import com.vaadin.v7.ui.Grid; -import com.vaadin.v7.ui.Grid.Column; -import com.vaadin.v7.ui.Grid.SelectionMode; - -public class GridEditingWithNoScrollBars extends AbstractReindeerTestUI { - - @Override - protected void setup(VaadinRequest request) { - Grid grid = new Grid(); - grid.addColumn("foo", String.class); - grid.addColumn("bar", String.class); - for (int i = 0; i < 10; ++i) { - grid.addRow("foo", "" + (i % 3 + 1)); - } - - ComboBox stCombo = new ComboBox(); - stCombo.addItem("" + 1); - stCombo.addItem("" + 2); - stCombo.addItem("" + 3); - stCombo.setNullSelectionAllowed(false); - stCombo.setSizeFull(); - - Column stCol = grid.getColumn("bar"); - stCol.setEditorField(stCombo); - - grid.setSelectionMode(SelectionMode.SINGLE); - grid.setEditorEnabled(true); - grid.setSizeFull(); - - addComponent(grid); - } - -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorConverterNotFound.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorConverterNotFound.java deleted file mode 100644 index d224583c26..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorConverterNotFound.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2000-2016 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.v7.tests.components.grid; - -import com.vaadin.server.ErrorHandler; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.v7.ui.Grid; - -public class GridEditorConverterNotFound extends AbstractTestUIWithLog { - - class Foo { - } - - @Override - protected void setup(VaadinRequest request) { - - Grid grid = new Grid(); - - grid.addColumn("foo", Foo.class); - grid.addRow(new Foo()); - grid.setEditorEnabled(true); - grid.setErrorHandler(new ErrorHandler() { - - @Override - public void error(com.vaadin.server.ErrorEvent event) { - log(event.getThrowable().toString()); - } - }); - - addComponent(grid); - } - - @Override - protected Integer getTicketNumber() { - return 17935; - } - - @Override - protected String getTestDescription() { - return "Grid should gracefully handle bind failures when opening editor"; - } -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorMultiselect.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorMultiselect.java deleted file mode 100644 index 086aa8dd9f..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridEditorMultiselect.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.vaadin.v7.tests.components.grid; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.v7.ui.Grid; - -public class GridEditorMultiselect extends AbstractReindeerTestUI { - - @Override - protected void setup(VaadinRequest request) { - Grid grid = new Grid(); - - grid.addColumn("name"); - grid.addColumn("age", Integer.class); - - for (int i = 0; i < 30; i++) { - grid.addRow("name " + i, i); - } - - grid.setEditorEnabled(true); - grid.setSelectionMode(Grid.SelectionMode.MULTI); - - addComponent(grid); - } - - @Override - protected Integer getTicketNumber() { - return 17132; - } - - @Override - protected String getTestDescription() { - return "Grid Multiselect: Edit mode allows invalid selection"; - } -} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditingWithNoScrollBarsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBarsTest.java index d7d59552eb..c0db4f0d35 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditingWithNoScrollBarsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBarsTest.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.v7.tests.components.grid; +package com.vaadin.tests.components.grid; import static org.junit.Assert.assertEquals; diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditorFrozenColumnsUITest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java index 9a451362fd..e2a932f452 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditorFrozenColumnsUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.v7.tests.components.grid; +package com.vaadin.tests.components.grid; import java.io.IOException; diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditorMultiselectTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java index ec15e0368c..1034012311 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditorMultiselectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java @@ -1,4 +1,4 @@ -package com.vaadin.v7.tests.components.grid; +package com.vaadin.tests.components.grid; import java.util.List; @@ -26,6 +26,7 @@ public class GridEditorMultiselectTest extends MultiBrowserTest { openTestURL(); GridElement grid = openEditor(); grid.getEditor().save(); + waitForElementNotPresent(By.className("v-grid-editor-cells")); assertCheckboxesEnabled(grid, true); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditorConverterNotFoundTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditorConverterNotFoundTest.java deleted file mode 100644 index c0d2a83558..0000000000 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridEditorConverterNotFoundTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2016 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.v7.tests.components.grid; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import com.vaadin.testbench.customelements.GridElement; -import com.vaadin.v7.tests.components.grid.basicfeatures.GridBasicFeaturesTest; - -public class GridEditorConverterNotFoundTest extends GridBasicFeaturesTest { - - @Override - protected Class<?> getUIClass() { - // Use the correct UI with helpers from GridBasicFeatures - return GridEditorConverterNotFound.class; - } - - @Test - public void testConverterNotFound() { - openTestURL(); - - $(GridElement.class).first().getCell(0, 0).doubleClick(); - - assertEquals("1. com.vaadin.v7.data.Buffered$SourceException", - getLogRow(0)); - } -} |