-Subproject commit eec6eee6610e80e28736e8a27aaaa2166ea2fa7c
+Subproject commit 203312a80a5f76d48fc36ef8d215f8b70b8e7545
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 com.vaadin.tests.util.Person;
+import com.vaadin.ui.Grid;
+
+public class GridEditorFrozenColumnsUI extends GridEditorUI {
+
+ @Override
+ protected Grid<Person> createGrid() {
+ Grid<Person> grid = super.createGrid();
+
+ grid.setFrozenColumnCount(2);
+
+ grid.setWidth("600px");
+ grid.setHeight("100%");
+
+ return grid;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 16727;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Frozen columns should also freeze cells in editor.";
+ }
+}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-
-}
+++ /dev/null
-/*
- * 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";
- }
-}
+++ /dev/null
-/*
- * 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.tests.util.PersonContainer;
-import com.vaadin.v7.ui.Grid;
-
-public class GridEditorFrozenColumnsUI extends GridEditorUI {
-
- @Override
- protected Grid createGrid(PersonContainer container) {
- Grid grid = super.createGrid(container);
-
- grid.setFrozenColumnCount(2);
-
- grid.setWidth("600px");
-
- return grid;
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 16727;
- }
-
- @Override
- protected String getTestDescription() {
- return "Frozen columns should also freeze cells in editor.";
- }
-}
+++ /dev/null
-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";
- }
-}
--- /dev/null
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridEditingWithNoScrollBarsTest extends MultiBrowserTest {
+
+ @Test
+ public void testEditorWideEnough() {
+ openTestURL();
+
+ GridElement grid = $(GridElement.class).first();
+ grid.getCell(1, 1).doubleClick();
+ assertEquals(grid.getEditor().getSize().width,
+ grid.getTableWrapper().getSize().width);
+ }
+}
--- /dev/null
+/*
+ * 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.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridEditorFrozenColumnsUITest extends MultiBrowserTest {
+
+ @Test
+ public void testEditorWithFrozenColumns() throws IOException {
+ openTestURL();
+
+ openEditor(10);
+
+ compareScreen("noscroll");
+
+ scrollGridHorizontallyTo(100);
+
+ compareScreen("scrolled");
+ }
+
+ private void openEditor(int rowIndex) {
+ GridElement grid = $(GridElement.class).first();
+
+ GridCellElement cell = grid.getCell(rowIndex, 1);
+
+ new Actions(driver).moveToElement(cell).doubleClick().build().perform();
+ }
+
+ private void scrollGridHorizontallyTo(double px) {
+ executeScript("arguments[0].scrollLeft = " + px,
+ getGridHorizontalScrollbar());
+ }
+
+ private Object executeScript(String script, WebElement element) {
+ final WebDriver driver = getDriver();
+ if (driver instanceof JavascriptExecutor) {
+ final JavascriptExecutor je = (JavascriptExecutor) driver;
+ return je.executeScript(script, element);
+ } else {
+ throw new IllegalStateException("current driver "
+ + getDriver().getClass().getName() + " is not a "
+ + JavascriptExecutor.class.getSimpleName());
+ }
+ }
+
+ private WebElement getGridHorizontalScrollbar() {
+ return getDriver().findElement(By.xpath(
+ "//div[contains(@class, \"v-grid-scroller-horizontal\")]"));
+ }
+}
--- /dev/null
+package com.vaadin.tests.components.grid;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridEditorMultiselectTest extends MultiBrowserTest {
+
+ @Test
+ public void testSelectCheckboxesDisabled() {
+ openTestURL();
+ GridElement grid = openEditor();
+ assertCheckboxesEnabled(grid, false);
+ }
+
+ @Test
+ public void testSelectCheckboxesEnabledBackOnSave() {
+ openTestURL();
+ GridElement grid = openEditor();
+ grid.getEditor().save();
+ waitForElementNotPresent(By.className("v-grid-editor-cells"));
+ assertCheckboxesEnabled(grid, true);
+ }
+
+ @Test
+ public void testSelectCheckboxesEnabledBackOnCancel() {
+ openTestURL();
+ GridElement grid = openEditor();
+ grid.getEditor().cancel();
+ assertCheckboxesEnabled(grid, true);
+ }
+
+ private GridElement openEditor() {
+ GridElement grid = $(GridElement.class).first();
+ grid.getRow(0).doubleClick();
+ Assert.assertTrue("Grid editor should be displayed.",
+ grid.getEditor().isDisplayed());
+ return grid;
+ }
+
+ private void assertCheckboxesEnabled(GridElement grid, boolean isEnabled) {
+ List<WebElement> checkboxes = grid
+ .findElements(By.xpath("//input[@type='checkbox']"));
+ for (WebElement checkbox : checkboxes) {
+ Assert.assertEquals(
+ "Select checkboxes should be "
+ + (isEnabled ? "enabled" : "disabled"),
+ isEnabled, checkbox.isEnabled());
+ }
+ }
+}
+++ /dev/null
-/*
- * 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.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-@TestCategory("grid")
-public class GridEditingWithNoScrollBarsTest extends MultiBrowserTest {
-
- @Test
- public void testEditorWideEnough() {
- openTestURL();
-
- GridElement grid = $(GridElement.class).first();
- grid.getCell(1, 1).doubleClick();
- assertEquals(grid.getEditor().getSize().width,
- grid.getTableWrapper().getSize().width);
- }
-}
+++ /dev/null
-/*
- * 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));
- }
-}
+++ /dev/null
-/*
- * 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.io.IOException;
-
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.GridElement.GridCellElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-@TestCategory("grid")
-public class GridEditorFrozenColumnsUITest extends MultiBrowserTest {
-
- @Test
- public void testEditorWithFrozenColumns() throws IOException {
- openTestURL();
-
- openEditor(10);
-
- compareScreen("noscroll");
-
- scrollGridHorizontallyTo(100);
-
- compareScreen("scrolled");
- }
-
- private void openEditor(int rowIndex) {
- GridElement grid = $(GridElement.class).first();
-
- GridCellElement cell = grid.getCell(rowIndex, 1);
-
- new Actions(driver).moveToElement(cell).doubleClick().build().perform();
- }
-
- private void scrollGridHorizontallyTo(double px) {
- executeScript("arguments[0].scrollLeft = " + px,
- getGridHorizontalScrollbar());
- }
-
- private Object executeScript(String script, WebElement element) {
- final WebDriver driver = getDriver();
- if (driver instanceof JavascriptExecutor) {
- final JavascriptExecutor je = (JavascriptExecutor) driver;
- return je.executeScript(script, element);
- } else {
- throw new IllegalStateException("current driver "
- + getDriver().getClass().getName() + " is not a "
- + JavascriptExecutor.class.getSimpleName());
- }
- }
-
- private WebElement getGridHorizontalScrollbar() {
- return getDriver().findElement(By.xpath(
- "//div[contains(@class, \"v-grid-scroller-horizontal\")]"));
- }
-}
+++ /dev/null
-package com.vaadin.v7.tests.components.grid;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-@TestCategory("grid")
-public class GridEditorMultiselectTest extends MultiBrowserTest {
-
- @Test
- public void testSelectCheckboxesDisabled() {
- openTestURL();
- GridElement grid = openEditor();
- assertCheckboxesEnabled(grid, false);
- }
-
- @Test
- public void testSelectCheckboxesEnabledBackOnSave() {
- openTestURL();
- GridElement grid = openEditor();
- grid.getEditor().save();
- assertCheckboxesEnabled(grid, true);
- }
-
- @Test
- public void testSelectCheckboxesEnabledBackOnCancel() {
- openTestURL();
- GridElement grid = openEditor();
- grid.getEditor().cancel();
- assertCheckboxesEnabled(grid, true);
- }
-
- private GridElement openEditor() {
- GridElement grid = $(GridElement.class).first();
- grid.getRow(0).doubleClick();
- Assert.assertTrue("Grid editor should be displayed.",
- grid.getEditor().isDisplayed());
- return grid;
- }
-
- private void assertCheckboxesEnabled(GridElement grid, boolean isEnabled) {
- List<WebElement> checkboxes = grid
- .findElements(By.xpath("//input[@type='checkbox']"));
- for (WebElement checkbox : checkboxes) {
- Assert.assertEquals(
- "Select checkboxes should be "
- + (isEnabled ? "enabled" : "disabled"),
- isEnabled, checkbox.isEnabled());
- }
- }
-}