]> source.dussan.org Git - vaadin-framework.git/commitdiff
Grid UI tests migration P3. (#8121)
authorDenis <denis@vaadin.com>
Wed, 4 Jan 2017 07:56:18 +0000 (09:56 +0200)
committerPekka Hyvönen <pekka@vaadin.com>
Wed, 4 Jan 2017 07:56:18 +0000 (09:56 +0200)
* Grid UI tests migration P2.

Fixes vaadin/framework8-issues#588

* Grid UI tests migration P3.

Fixes vaadin/framework8-issues#589

* Merge branch 'master' into 589-grid-tests-migration

Conflicts:
uitest/src/main/java/com/vaadin/tests/components/grid/GridCellFocusOnResetSize.java
uitest/src/main/java/com/vaadin/tests/components/grid/GridClientDataChangeHandler.java

* Update screenshot submodule reference.

47 files changed:
tests/screenshots
uitest/src/main/java/com/vaadin/tests/components/grid/GridCellFocusOnResetSize.java
uitest/src/main/java/com/vaadin/tests/components/grid/GridClientDataChangeHandler.java
uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoExpand.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoWidth.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoWidthClient.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutData.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridDataSourceReset.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsDetach.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsLayoutExpand.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsWidth.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/widgetset/client/TestWidgetConnector.java
uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridColumnAutoWidthClientWidget.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridColumnAutoWidthClientWidget.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColspans.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoExpand.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidth.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthClient.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnExpand.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnWidthRecalculation.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnWidthsWithoutData.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDataSourceReset.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsDetach.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsLayoutExpand.java [deleted file]
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsLocation.java
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsWidth.java [deleted file]
uitest/src/test/java/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoWidthClientTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoWidthServerTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsDetachTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsWidthTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColspansTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoExpandTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthClientTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthServerTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnWidthRecalculationTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnWidthsWithoutDataTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDataSourceResetTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsDetachTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsLayoutExpandTest.java [deleted file]
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsWidthTest.java [deleted file]

index 2f2e57cf41694f724aaee7a63202d3763b0e55d8..eec6eee6610e80e28736e8a27aaaa2166ea2fa7c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2f2e57cf41694f724aaee7a63202d3763b0e55d8
+Subproject commit eec6eee6610e80e28736e8a27aaaa2166ea2fa7c
index bfe324455447bba6e76a83ca2f98e0313093cc21..9dcabebbf72c6c633c73a9c810edc5cd9b36b94f 100644 (file)
@@ -17,13 +17,13 @@ package com.vaadin.tests.components.grid;
 
 import com.vaadin.annotations.Widgetset;
 import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.tests.widgetset.TestingWidgetSet;
 import com.vaadin.tests.widgetset.client.grid.GridCellFocusOnResetSizeWidget;
 import com.vaadin.tests.widgetset.server.TestWidgetComponent;
 
 @Widgetset(TestingWidgetSet.NAME)
-public class GridCellFocusOnResetSize extends AbstractReindeerTestUI {
+public class GridCellFocusOnResetSize extends AbstractTestUI {
 
     @Override
     protected void setup(VaadinRequest request) {
index 50f7e40837b0b20273cb24b7c2776051703aacce..a9f686b1072fbbcca75818325c22f0e5de3d8df9 100644 (file)
@@ -17,13 +17,13 @@ package com.vaadin.tests.components.grid;
 
 import com.vaadin.annotations.Widgetset;
 import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.tests.widgetset.TestingWidgetSet;
 import com.vaadin.tests.widgetset.client.grid.GridDataChangeHandlerWidget;
 import com.vaadin.tests.widgetset.server.TestWidgetComponent;
 
 @Widgetset(TestingWidgetSet.NAME)
-public class GridClientDataChangeHandler extends AbstractReindeerTestUI {
+public class GridClientDataChangeHandler extends AbstractTestUI {
 
     @Override
     protected void setup(VaadinRequest request) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java
new file mode 100644 (file)
index 0000000..ce29ca3
--- /dev/null
@@ -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.stream.Collectors;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.components.grid.FooterRow;
+import com.vaadin.ui.components.grid.HeaderRow;
+import com.vaadin.ui.renderers.NumberRenderer;
+
+public class GridColspans extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        Person person = new Person();
+        person.setFirstName("Rudolph");
+        person.setLastName("Reindeer");
+        person.setEmail("test@vaadin.com");
+        person.setAge(34);
+        person.setSalary(3210);
+
+        Grid<Person> grid = new Grid<>();
+        grid.setWidth("600px");
+
+        Column<Person, String> firstNameColumn = grid
+                .addColumn(Person::getFirstName);
+        firstNameColumn.setId("firstName").setCaption("First name");
+        Column<Person, String> lastNameColumn = grid
+                .addColumn(Person::getLastName);
+        lastNameColumn.setCaption("Last name");
+        Column<Person, String> emailColumn = grid.addColumn(Person::getEmail);
+        Column<Person, Number> ageColumn = grid.addColumn(Person::getAge,
+                new NumberRenderer());
+        ageColumn.setCaption("Age");
+        ageColumn.setId("ageColumn");
+        Column<Person, Number> salaryColumn = grid.addColumn(Person::getSalary,
+                new NumberRenderer());
+
+        grid.setItems(person);
+
+        grid.setSelectionMode(SelectionMode.MULTI);
+        addComponent(grid);
+
+        HeaderRow row = grid.prependHeaderRow();
+        row.join(row.getCell(firstNameColumn), row.getCell(lastNameColumn))
+                .setText("Full Name");
+        row.join(row.getCell(emailColumn), row.getCell(ageColumn),
+                row.getCell(salaryColumn)).setText("Misc");
+        grid.prependHeaderRow().join(grid.getColumns().stream()
+                .map(row::getCell).collect(Collectors.toSet()))
+                .setText("All the stuff");
+
+        FooterRow footerRow = grid.appendFooterRow();
+        footerRow.join(footerRow.getCell(firstNameColumn),
+                footerRow.getCell(lastNameColumn)).setText("Full Name");
+        footerRow.join(footerRow.getCell(emailColumn),
+                footerRow.getCell(ageColumn), footerRow.getCell(salaryColumn))
+                .setText("Misc");
+        grid.appendFooterRow().join(grid.getColumns().stream()
+                .map(footerRow::getCell).collect(Collectors.toSet()))
+                .setText("All the stuff");
+
+        addComponent(new Button("Show/Hide firstName", event -> {
+            Column<Person, ?> column = grid.getColumn("firstName");
+            if (column != null) {
+                grid.removeColumn(column);
+            } else {
+                grid.addColumn(Person::getFirstName).setId("firstName");
+            }
+        }));
+
+        addComponent(new Button("Change column order", event -> {
+            grid.setColumnOrder(grid.getColumn("ageColumn"),
+                    grid.getColumn("firstName"));
+        }));
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Grid header and footer colspans";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 13334;
+    }
+
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoExpand.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoExpand.java
new file mode 100644 (file)
index 0000000..3daa978
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.data.ValueProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridColumnAutoExpand extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final VerticalLayout layout = new VerticalLayout();
+        layout.setSizeFull();
+        layout.setMargin(true);
+        addComponent(layout);
+
+        Grid<String> grid = new Grid<>();
+        grid.setCaption("Broken Grid with Caption");
+        grid.setWidth("100%");
+        grid.setHeight("100px");
+
+        grid.addColumn(ValueProvider.identity()).setCaption("Col1")
+                .setWidth(100);
+        grid.addColumn(ValueProvider.identity()).setCaption("Col2")
+                .setMinimumWidth(100).setExpandRatio(1);
+
+        layout.addComponent(grid);
+    }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoWidth.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoWidth.java
new file mode 100644 (file)
index 0000000..1434aea
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.renderers.HtmlRenderer;
+
+public class GridColumnAutoWidth extends AbstractReindeerTestUI {
+    @Override
+    protected void setup(VaadinRequest request) {
+        Grid<Object> grid = new Grid<>();
+        grid.addColumn(item -> "<span>equal width</span>", new HtmlRenderer())
+                .setId("equal width");
+        grid.addColumn(item -> "<span>a very long cell content</span>",
+                new HtmlRenderer()).setId("short");
+        grid.addColumn(item -> "<span>short</span>", new HtmlRenderer())
+                .setId("a very long header content");
+
+        grid.addColumn(item -> "<span>fixed width narrow</span>",
+                new HtmlRenderer()).setId("fixed width narrow").setWidth(50);
+        grid.addColumn(item -> "<span>fixed width wide</span>",
+                new HtmlRenderer()).setId("fixed width wide").setWidth(200);
+
+        for (Column<Object, ?> column : grid.getColumns()) {
+            column.setExpandRatio(0);
+            grid.getHeaderRow(0).getCell(column)
+                    .setHtml("<span>" + column.getId() + "</span>");
+        }
+
+        grid.setItems(new Object());
+
+        grid.setSelectionMode(SelectionMode.NONE);
+        grid.setWidth("750px");
+        addComponent(grid);
+    }
+
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoWidthClient.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnAutoWidthClient.java
new file mode 100644 (file)
index 0000000..b26f56b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.tests.widgetset.client.grid.GridColumnAutoWidthClientWidget;
+import com.vaadin.tests.widgetset.server.TestWidgetComponent;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class GridColumnAutoWidthClient extends AbstractReindeerTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        addComponent(
+                new TestWidgetComponent(GridColumnAutoWidthClientWidget.class));
+    }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutData.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutData.java
new file mode 100644 (file)
index 0000000..c184cd7
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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.EnumSet;
+import java.util.List;
+
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.server.SerializablePredicate;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridColumnWidthsWithoutData extends AbstractTestUI {
+
+    private SelectionMode selectionMode = SelectionMode.NONE;
+    private List<Person> items;
+    private DataProvider<Person, SerializablePredicate<Person>> provider;
+    private Grid<Person> grid = createGrid(true);
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        addComponent(grid);
+
+        NativeSelect<SelectionMode> selectionModeSelector = new NativeSelect<>(
+                "Selection mode", EnumSet.allOf(SelectionMode.class));
+        selectionModeSelector.setValue(selectionMode);
+        selectionModeSelector.addValueChangeListener(event -> {
+            selectionMode = selectionModeSelector.getValue();
+            grid.setSelectionMode(selectionMode);
+        });
+
+        addComponent(selectionModeSelector);
+
+        addComponent(new Button("Recreate without data",
+                event -> replaceGrid(createGrid(false))));
+
+        addComponent(new Button("Recreate with data",
+                event -> replaceGrid(createGrid(true))));
+
+        addComponent(new Button("Add data", event -> addDataToGrid()));
+
+        addComponent(new Button("Remove data", event -> {
+            items.clear();
+            provider.refreshAll();
+        }));
+
+    }
+
+    private void replaceGrid(Grid<Person> newGrid) {
+        ((VerticalLayout) grid.getParent()).replaceComponent(grid, newGrid);
+        grid = newGrid;
+    }
+
+    private Grid<Person> createGrid(boolean withData) {
+        Grid<Person> grid = new Grid<>();
+        grid.addColumn(Person::getFirstName);
+        grid.addColumn(Person::getLastName);
+        grid.setWidth("300px");
+        grid.setSelectionMode(selectionMode);
+
+        items = new ArrayList<>();
+        provider = DataProvider.create(items);
+        grid.setDataProvider(provider);
+
+        if (withData) {
+            addDataToGrid();
+        }
+
+        return grid;
+    }
+
+    private void addDataToGrid() {
+        Person person = new Person();
+        person.setFirstName("Some");
+        person.setLastName("Data with more data in one col");
+        items.add(person);
+        provider.refreshAll();
+    }
+
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDataSourceReset.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDataSourceReset.java
new file mode 100644 (file)
index 0000000..b04e004
--- /dev/null
@@ -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.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.data.provider.ListDataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.fieldgroup.ComplexPerson;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+
+public class GridDataSourceReset extends AbstractTestUI {
+
+    private List<ComplexPerson> persons;
+    private Grid<ComplexPerson> grid;
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        persons = createPersons(10, new Random(1));
+
+        grid = new Grid<>();
+        ListDataProvider<ComplexPerson> provider = DataProvider.create(persons);
+        grid.setDataProvider(provider);
+        grid.getSelectionModel().select(persons.get(0));
+        addComponent(new Button("Remove first", event -> {
+            persons.remove(0);
+
+            provider.refreshAll();
+            grid.getSelectionModel().select(persons.get(0));
+        }));
+
+        addComponent(grid);
+    }
+
+    public static List<ComplexPerson> createPersons(int count, Random r) {
+        List<ComplexPerson> c = new ArrayList<>();
+        for (int i = 0; i < count; ++i) {
+            c.add(ComplexPerson.create(r));
+        }
+        return c;
+    }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsDetach.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsDetach.java
new file mode 100644 (file)
index 0000000..b34d0cd
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * 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.List;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.renderers.NumberRenderer;
+
+public class GridDetailsDetach extends AbstractTestUI {
+
+    private Grid currentGrid;
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        VerticalLayout layout = new VerticalLayout();
+        layout.setSpacing(false);
+        layout.setMargin(false);
+        layout.setSizeFull();
+
+        Button button = new Button("Test");
+        layout.addComponent(button);
+        layout.setExpandRatio(button, 0f);
+
+        currentGrid = generateGrid();
+        final VerticalLayout gridContainer = new VerticalLayout();
+        gridContainer.setSpacing(false);
+        gridContainer.setMargin(false);
+        gridContainer.addComponent(currentGrid);
+
+        button.addClickListener(event -> gridContainer
+                .replaceComponent(currentGrid, new Label("Foo")));
+
+        layout.addComponent(new Button("Reattach Grid", event -> {
+            gridContainer.removeAllComponents();
+            gridContainer.addComponent(currentGrid);
+        }));
+
+        layout.addComponent(gridContainer);
+        layout.setExpandRatio(gridContainer, 1f);
+
+        addComponent(layout);
+    }
+
+    private Grid<GridExampleBean> generateGrid() {
+        List<GridExampleBean> items = new ArrayList<>();
+        for (int i = 0; i < 1000; i++) {
+            items.add(new GridExampleBean("Bean " + i, i * i, i / 10d));
+        }
+
+        final Grid<GridExampleBean> grid = new Grid<>();
+        grid.setItems(items);
+        grid.addColumn(GridExampleBean::getName);
+        grid.addColumn(GridExampleBean::getAmount, new NumberRenderer());
+        grid.addColumn(GridExampleBean::getCount, new NumberRenderer());
+        grid.setSizeFull();
+        grid.setSelectionMode(SelectionMode.NONE);
+
+        grid.setDetailsGenerator(item -> {
+            VerticalLayout layout = new VerticalLayout(
+                    new Label("Extra data for " + item.getName()));
+            layout.setMargin(true);
+            return layout;
+        });
+
+        grid.addItemClickListener(event -> {
+            GridExampleBean item = event.getItem();
+            grid.setDetailsVisible(item, !grid.isDetailsVisible(item));
+        });
+        return grid;
+    }
+
+    public class GridExampleBean {
+
+        private String name;
+
+        private int count;
+
+        private double amount;
+
+        public GridExampleBean() {
+        }
+
+        public GridExampleBean(String name, int count, double amount) {
+            this.name = name;
+            this.count = count;
+            this.amount = amount;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public int getCount() {
+            return count;
+        }
+
+        public double getAmount() {
+            return amount;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public void setCount(int count) {
+            this.count = count;
+        }
+
+        public void setAmount(double amount) {
+            this.amount = amount;
+        }
+
+    }
+
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsLayoutExpand.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsLayoutExpand.java
new file mode 100644 (file)
index 0000000..ab8d3d8
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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.List;
+
+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.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.renderers.NumberRenderer;
+
+/**
+ * Tests the layouting of Grid's details row when it contains a HorizontalLayout
+ * with expand ratios.
+ *
+ * @author Vaadin Ltd
+ */
+@SuppressWarnings("serial")
+public class GridDetailsLayoutExpand extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final Grid<Person> grid = new Grid<>();
+        grid.setSizeFull();
+
+        grid.addColumn(Person::getFirstName);
+        grid.addColumn(Person::getAge, new NumberRenderer());
+
+        List<Person> persons = new ArrayList<>();
+        Person person = new Person();
+        person.setFirstName("Nicolaus Copernicus");
+        person.setAge(1543);
+        persons.add(person);
+
+        person = new Person();
+        person.setFirstName("Galileo Galilei");
+        person.setAge(1564);
+        persons.add(person);
+
+        person = new Person();
+        person.setFirstName("Johannes Kepler");
+        person.setAge(1571);
+        persons.add(person);
+
+        grid.setItems(persons);
+        addComponent(grid);
+
+        grid.setDetailsGenerator(item -> {
+            final HorizontalLayout detailsLayout = new HorizontalLayout();
+            detailsLayout.setSizeFull();
+            detailsLayout.setHeightUndefined();
+
+            // Label 1 first element of the detailsLayout, taking 200 pixels
+            final Label lbl1 = new Label("test1");
+            lbl1.setWidth("200px");
+            detailsLayout.addComponent(lbl1);
+
+            // layout2 second element of the detailsLayout, taking the rest
+            // of the available space
+            final HorizontalLayout layout2 = new HorizontalLayout();
+            layout2.setSizeFull();
+            layout2.setHeightUndefined();
+            detailsLayout.addComponent(layout2);
+            detailsLayout.setExpandRatio(layout2, 1);
+
+            // 2 Labels added to the layout2
+            final Label lbl2 = new Label("test2");
+            lbl2.setWidth("100%");
+            lbl2.setId("lbl2");
+            layout2.addComponent(lbl2);
+
+            final Label lbl3 = new Label("test3");
+            lbl3.setWidth("100%");
+            lbl3.setId("lbl3");
+            layout2.addComponent(lbl3);
+
+            return detailsLayout;
+        });
+
+        grid.addItemClickListener(event -> {
+            final Person itemId = event.getItem();
+            grid.setDetailsVisible(itemId, !grid.isDetailsVisible(itemId));
+        });
+
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 18821;
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Details row must be the same after opening another details row";
+    }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsWidth.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsWidth.java
new file mode 100644 (file)
index 0000000..678b4ad
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.stream.IntStream;
+
+import com.vaadin.data.ValueProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridDetailsWidth extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final VerticalLayout layout = new VerticalLayout();
+        layout.setMargin(true);
+
+        final Grid<String> grid = new Grid<>();
+
+        Column<String, String> column = grid.addColumn(ValueProvider.identity())
+                .setCaption("Hello");
+        grid.setItems(IntStream.range(0, 3).mapToObj(i -> "Hello " + i));
+
+        column.setWidth(600);
+        grid.setWidth(400, Unit.PIXELS);
+
+        grid.setDetailsGenerator(item -> {
+            HorizontalLayout myLayout = new HorizontalLayout();
+            TextArea textArea1 = new TextArea();
+            TextArea textArea2 = new TextArea();
+            textArea1.setSizeFull();
+            textArea2.setSizeFull();
+            myLayout.addComponent(textArea1);
+            myLayout.addComponent(textArea2);
+            myLayout.setWidth(100, Unit.PERCENTAGE);
+            myLayout.setHeight(null);
+            myLayout.setMargin(true);
+            return myLayout;
+        });
+
+        grid.addItemClickListener(event -> grid.setDetailsVisible(
+                event.getItem(), !grid.isDetailsVisible(event.getItem())));
+
+        layout.addComponent(grid);
+
+        addComponent(layout);
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 18223;
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Tests that Escalator will not set explicit widths to the TD element in a details row.";
+    }
+
+}
index 7b10fba57979f0dc7b52ba2732fbd1dfed04f616..8498218e88afb0af3adf141fd6fbd00641ac0ba7 100644 (file)
@@ -19,6 +19,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Style.Position;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.SimplePanel;
@@ -35,6 +36,11 @@ import com.vaadin.tests.widgetset.server.TestWidgetComponent;
 public class TestWidgetConnector extends AbstractComponentConnector {
     public static class SubPartAwareSimplePanel extends SimplePanel
             implements SubPartAware {
+
+        public SubPartAwareSimplePanel() {
+            getElement().getStyle().setPosition(Position.ABSOLUTE);
+        }
+
         @Override
         public Element getSubPartElement(String subPart) {
             Widget target = getWidget();
diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridColumnAutoWidthClientWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridColumnAutoWidthClientWidget.java
new file mode 100644 (file)
index 0000000..df20417
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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.widgetset.client.grid;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.vaadin.client.renderers.HtmlRenderer;
+import com.vaadin.client.widget.grid.datasources.ListDataSource;
+import com.vaadin.client.widget.grid.selection.SelectionModel;
+import com.vaadin.client.widgets.Grid;
+
+public class GridColumnAutoWidthClientWidget
+        extends PureGWTTestApplication<Grid<List<String>>> {
+
+    private Grid<List<String>> grid;
+
+    private class Col extends Grid.Column<String, List<String>> {
+        public Col(String header) {
+            super(header, new HtmlRenderer());
+            setExpandRatio(0);
+        }
+
+        @Override
+        public String getValue(List<String> row) {
+            int index = grid.getColumns().indexOf(this);
+            return "<span>" + String.valueOf(row.get(index)) + "</span>";
+        }
+    }
+
+    public GridColumnAutoWidthClientWidget() {
+        super(new Grid<List<String>>());
+        grid = getTestedWidget();
+        grid.setSelectionModel(new SelectionModel.NoSelectionModel<>());
+        grid.setWidth("750px");
+
+        addColumn("equal length");
+        addColumn("short");
+        addColumn("a very long header content");
+        addColumn("fixed width narrow").setWidth(50);
+        addColumn("fixed width wide").setWidth(200);
+
+        List<List<String>> list = new ArrayList<>();
+        list.add(Arrays.asList("equal length", "a very long cell content",
+                "short", "fixed width narrow", "fixed width wide"));
+        grid.setDataSource(new ListDataSource<>(list));
+
+        addNorth(grid, 400);
+    }
+
+    private Col addColumn(String header) {
+        Col column = grid.addColumn(new Col(header));
+        grid.getHeaderRow(0).getCell(column)
+                .setHtml("<span>" + header + "</span>");
+        return column;
+    }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridColumnAutoWidthClientWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridColumnAutoWidthClientWidget.java
deleted file mode 100644 (file)
index 139835b..0000000
+++ /dev/null
@@ -1,71 +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.tests.widgetset.client.v7.grid;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import com.vaadin.v7.client.renderers.HtmlRenderer;
-import com.vaadin.v7.client.widget.grid.datasources.ListDataSource;
-import com.vaadin.v7.client.widgets.Grid;
-import com.vaadin.v7.client.widgets.Grid.SelectionMode;
-
-public class GridColumnAutoWidthClientWidget
-        extends PureGWTTestApplication<Grid<List<String>>> {
-
-    private Grid<List<String>> grid;
-
-    private class Col extends Grid.Column<String, List<String>> {
-        public Col(String header) {
-            super(header, new HtmlRenderer());
-            setExpandRatio(0);
-        }
-
-        @Override
-        public String getValue(List<String> row) {
-            int index = grid.getColumns().indexOf(this);
-            return "<span>" + String.valueOf(row.get(index)) + "</span>";
-        }
-    }
-
-    public GridColumnAutoWidthClientWidget() {
-        super(new Grid<List<String>>());
-        grid = getTestedWidget();
-        grid.setSelectionMode(SelectionMode.NONE);
-        grid.setWidth("750px");
-
-        List<List<String>> list = new ArrayList<>();
-        list.add(Arrays.asList("equal length", "a very long cell content",
-                "short", "fixed width narrow", "fixed width wide"));
-        grid.setDataSource(new ListDataSource<>(list));
-
-        addColumn("equal length");
-        addColumn("short");
-        addColumn("a very long header content");
-        addColumn("fixed width narrow").setWidth(50);
-        addColumn("fixed width wide").setWidth(200);
-
-        addNorth(grid, 400);
-    }
-
-    private Col addColumn(String header) {
-        Col column = grid.addColumn(new Col(header));
-        grid.getHeaderRow(0).getCell(column)
-                .setHtml("<span>" + header + "</span>");
-        return column;
-    }
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColspans.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColspans.java
deleted file mode 100644 (file)
index dc0b84a..0000000
+++ /dev/null
@@ -1,102 +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.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.v7.data.Container.Indexed;
-import com.vaadin.v7.data.Item;
-import com.vaadin.v7.data.util.IndexedContainer;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.FooterRow;
-import com.vaadin.v7.ui.Grid.HeaderRow;
-import com.vaadin.v7.ui.Grid.SelectionMode;
-import com.vaadin.v7.ui.renderers.NumberRenderer;
-
-public class GridColspans extends AbstractReindeerTestUI {
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        Indexed dataSource = new IndexedContainer();
-        final Grid grid;
-
-        dataSource.addContainerProperty("firstName", String.class, "");
-        dataSource.addContainerProperty("lastName", String.class, "");
-        dataSource.addContainerProperty("streetAddress", String.class, "");
-        dataSource.addContainerProperty("zipCode", Integer.class, null);
-        dataSource.addContainerProperty("city", String.class, "");
-        Item i = dataSource.addItem(0);
-        i.getItemProperty("firstName").setValue("Rudolph");
-        i.getItemProperty("lastName").setValue("Reindeer");
-        i.getItemProperty("streetAddress").setValue("Ruukinkatu 2-4");
-        i.getItemProperty("zipCode").setValue(20540);
-        i.getItemProperty("city").setValue("Turku");
-        grid = new Grid(dataSource);
-        grid.setWidth("600px");
-        grid.getColumn("zipCode").setRenderer(new NumberRenderer());
-        grid.setSelectionMode(SelectionMode.MULTI);
-        addComponent(grid);
-
-        HeaderRow row = grid.prependHeaderRow();
-        row.join("firstName", "lastName").setText("Full Name");
-        row.join("streetAddress", "zipCode", "city").setText("Address");
-        grid.prependHeaderRow()
-                .join(dataSource.getContainerPropertyIds().toArray())
-                .setText("All the stuff");
-
-        FooterRow footerRow = grid.appendFooterRow();
-        footerRow.join("firstName", "lastName").setText("Full Name");
-        footerRow.join("streetAddress", "zipCode", "city").setText("Address");
-        grid.appendFooterRow()
-                .join(dataSource.getContainerPropertyIds().toArray())
-                .setText("All the stuff");
-
-        addComponent(
-                new Button("Show/Hide firstName", new Button.ClickListener() {
-
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        if (grid.getColumn("firstName") != null) {
-                            grid.removeColumn("firstName");
-                        } else {
-                            grid.addColumn("firstName");
-                        }
-                    }
-                }));
-
-        addComponent(
-                new Button("Change column order", new Button.ClickListener() {
-
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        grid.setColumnOrder("zipCode", "firstName");
-                    }
-                }));
-    }
-
-    @Override
-    protected String getTestDescription() {
-        return "Grid header and footer colspans";
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return 13334;
-    }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoExpand.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoExpand.java
deleted file mode 100644 (file)
index 269f16e..0000000
+++ /dev/null
@@ -1,46 +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.ui.VerticalLayout;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.Column;
-
-public class GridColumnAutoExpand extends AbstractReindeerTestUI {
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        final VerticalLayout layout = new VerticalLayout();
-        layout.setSizeFull();
-        layout.setMargin(true);
-        addComponent(layout);
-
-        Grid grid = new Grid("Broken Grid with Caption");
-        grid.setWidth("100%");
-        grid.setHeight("100px");
-
-        Column col1 = grid.addColumn("Col1");
-        col1.setWidth(100);
-
-        Column col2 = grid.addColumn("Col2");
-        col2.setMinimumWidth(100);
-        col2.setExpandRatio(1);
-
-        layout.addComponent(grid);
-    }
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidth.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidth.java
deleted file mode 100644 (file)
index c03aa05..0000000
+++ /dev/null
@@ -1,63 +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.data.Container;
-import com.vaadin.v7.data.util.IndexedContainer;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.Column;
-import com.vaadin.v7.ui.Grid.SelectionMode;
-import com.vaadin.v7.ui.renderers.HtmlRenderer;
-
-public class GridColumnAutoWidth extends AbstractReindeerTestUI {
-    @Override
-    protected void setup(VaadinRequest request) {
-        Grid grid = new Grid(createContainer());
-        grid.getColumn("fixed width narrow").setWidth(50);
-        grid.getColumn("fixed width wide").setWidth(200);
-
-        for (Object propertyId : grid.getContainerDataSource()
-                .getContainerPropertyIds()) {
-            Column column = grid.getColumn(propertyId);
-            column.setExpandRatio(0);
-            column.setRenderer(new HtmlRenderer());
-            grid.getHeaderRow(0).getCell(propertyId)
-                    .setHtml("<span>" + column.getHeaderCaption() + "</span>");
-        }
-
-        grid.setSelectionMode(SelectionMode.NONE);
-        grid.setWidth("750px");
-        addComponent(grid);
-    }
-
-    private static Container.Indexed createContainer() {
-        IndexedContainer c = new IndexedContainer();
-        c.addContainerProperty("equal width", String.class,
-                "<span>equal width</span>");
-        c.addContainerProperty("short", String.class,
-                "<span>a very long cell content</span>");
-        c.addContainerProperty("a very long header content", String.class,
-                "<span>short</span>");
-        c.addContainerProperty("fixed width narrow", String.class,
-                "<span>fixed width narrow</span>");
-        c.addContainerProperty("fixed width wide", String.class,
-                "<span>fixed width wide</span>");
-        c.addItem();
-        return c;
-    }
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthClient.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthClient.java
deleted file mode 100644 (file)
index 9991efc..0000000
+++ /dev/null
@@ -1,33 +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.annotations.Widgetset;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.tests.widgetset.TestingWidgetSet;
-import com.vaadin.tests.widgetset.client.v7.grid.GridColumnAutoWidthClientWidget;
-import com.vaadin.tests.widgetset.server.TestWidgetComponent;
-
-@Widgetset(TestingWidgetSet.NAME)
-public class GridColumnAutoWidthClient extends AbstractReindeerTestUI {
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        addComponent(
-                new TestWidgetComponent(GridColumnAutoWidthClientWidget.class));
-    }
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnExpand.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnExpand.java
deleted file mode 100644 (file)
index d3c71ed..0000000
+++ /dev/null
@@ -1,160 +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.annotations.Theme;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.tests.util.PersonContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.Column;
-import com.vaadin.v7.ui.themes.Reindeer;
-
-@Theme(Reindeer.THEME_NAME)
-public class GridColumnExpand extends AbstractReindeerTestUI {
-    private Grid grid;
-    private Label firstInfo = new Label();
-    private Label secondInfo = new Label();
-    private Column firstColumn;
-    private Column secondColumn;
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        grid = new Grid(PersonContainer.createWithTestData());
-        grid.removeAllColumns();
-        grid.addColumn("address.streetAddress");
-        grid.addColumn("lastName");
-        firstColumn = grid.getColumns().get(0);
-        secondColumn = grid.getColumns().get(1);
-
-        updateInfoLabels();
-        addComponent(grid);
-        addComponent(firstInfo);
-        addComponent(secondInfo);
-        addButtons();
-    }
-
-    private void addButtons() {
-        HorizontalLayout layout = new HorizontalLayout();
-        layout.addComponent(createButtons(firstColumn));
-        layout.addComponent(createButtons(secondColumn));
-        layout.setExpandRatio(layout.getComponent(1), 1);
-        addComponent(layout);
-    }
-
-    private Component createButtons(Column column) {
-        CssLayout layout = new CssLayout();
-        layout.addComponent(new Label("Column 1"));
-
-        CssLayout widthLayout = new CssLayout();
-        layout.addComponent(widthLayout);
-        widthLayout.addComponent(new Label("Width"));
-        widthLayout.addComponent(createWidthButton(column, -1));
-        widthLayout.addComponent(createWidthButton(column, 50));
-        widthLayout.addComponent(createWidthButton(column, 200));
-
-        CssLayout minLayout = new CssLayout();
-        layout.addComponent(minLayout);
-        minLayout.addComponent(new Label("Min width"));
-        minLayout.addComponent(createMinButton(column, -1));
-        minLayout.addComponent(createMinButton(column, 50));
-        minLayout.addComponent(createMinButton(column, 200));
-
-        CssLayout maxLayout = new CssLayout();
-        maxLayout.addComponent(new Label("Max width"));
-        maxLayout.addComponent(createMaxButton(column, -1));
-        maxLayout.addComponent(createMaxButton(column, 50));
-        maxLayout.addComponent(createMaxButton(column, 200));
-        layout.addComponent(maxLayout);
-
-        CssLayout expandLayout = new CssLayout();
-        expandLayout.addComponent(new Label("Expand ratio"));
-        expandLayout.addComponent(createExpandButton(column, -1));
-        expandLayout.addComponent(createExpandButton(column, 0));
-        expandLayout.addComponent(createExpandButton(column, 1));
-        expandLayout.addComponent(createExpandButton(column, 2));
-        layout.addComponent(expandLayout);
-
-        return layout;
-    }
-
-    private Component createWidthButton(final Column column,
-            final double width) {
-        return new Button("" + width, new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                if (width >= 0) {
-                    column.setWidth(width);
-                } else {
-                    column.setWidthUndefined();
-                }
-                updateInfoLabels();
-            }
-        });
-    }
-
-    private Component createMinButton(final Column column, final double width) {
-        return new Button("" + width, new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                column.setMinimumWidth(width);
-                updateInfoLabels();
-            }
-        });
-    }
-
-    private Component createMaxButton(final Column column, final double width) {
-        return new Button("" + width, new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                column.setMaximumWidth(width);
-                updateInfoLabels();
-            }
-        });
-    }
-
-    private Component createExpandButton(final Column column, final int ratio) {
-        return new Button("" + ratio, new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                column.setExpandRatio(ratio);
-                updateInfoLabels();
-            }
-        });
-    }
-
-    private void updateInfoLabels() {
-        updateLabel(firstInfo, firstColumn);
-        updateLabel(secondInfo, secondColumn);
-    }
-
-    private void updateLabel(Label label, Column column) {
-        int expandRatio = column.getExpandRatio();
-        double minimumWidth = Math.round(column.getMinimumWidth() * 100) / 100;
-        double maximumWidth = Math.round(column.getMaximumWidth() * 100) / 100;
-        double width = Math.round(column.getWidth() * 100) / 100;
-        Object propertyId = column.getPropertyId();
-        label.setValue(String.format(
-                "[%s] Expand ratio: %s - min: %s - max: %s - width: %s",
-                propertyId, expandRatio, minimumWidth, maximumWidth, width));
-    }
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnWidthRecalculation.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnWidthRecalculation.java
deleted file mode 100644 (file)
index 8045075..0000000
+++ /dev/null
@@ -1,92 +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.ArrayList;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.v7.data.Container.Indexed;
-import com.vaadin.v7.data.Item;
-import com.vaadin.v7.data.Property;
-import com.vaadin.v7.ui.Grid;
-
-public class GridColumnWidthRecalculation extends AbstractTestUI {
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        final Grid grid = new Grid();
-
-        grid.addColumn("Column 1");
-        grid.addColumn("Column 2");
-
-        grid.addRow("Narrow",
-                "Wiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiide");
-        addComponent(grid);
-
-        Button b = new Button("Swap content", new Button.ClickListener() {
-
-            @Override
-            public void buttonClick(ClickEvent event) {
-                swapData(grid);
-            }
-        });
-        addComponent(b);
-
-        b = new Button("Swap content and recalculate columns",
-                new Button.ClickListener() {
-
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        swapData(grid);
-                        grid.recalculateColumnWidths();
-
-                    }
-                });
-        addComponent(b);
-    }
-
-    @SuppressWarnings("unchecked")
-    protected void swapData(Grid grid) {
-        Indexed dataSource = grid.getContainerDataSource();
-        Object itemId = dataSource.getItemIds().iterator().next();
-        Item item = dataSource.getItem(itemId);
-        ArrayList<Object> pIds = new ArrayList<>(item.getItemPropertyIds());
-        for (int i = 0; i < pIds.size() / 2; i++) {
-            int j = pIds.size() - 1 - i;
-            Object pid1 = pIds.get(i);
-            Object pid2 = pIds.get(j);
-
-            Property<Object> property1 = item.getItemProperty(pid1);
-            Property<Object> property2 = item.getItemProperty(pid2);
-            Object tmp = property1.getValue();
-            property1.setValue(property2.getValue());
-            property2.setValue(tmp);
-        }
-    }
-
-    @Override
-    protected String getTestDescription() {
-        return "There should be a way to ask Grid to recalculate column widths from server-side.";
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return 16748;
-    }
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnWidthsWithoutData.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridColumnWidthsWithoutData.java
deleted file mode 100644 (file)
index 011a1ec..0000000
+++ /dev/null
@@ -1,108 +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.EnumSet;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.v7.data.Property.ValueChangeEvent;
-import com.vaadin.v7.data.Property.ValueChangeListener;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.SelectionMode;
-import com.vaadin.v7.ui.NativeSelect;
-
-public class GridColumnWidthsWithoutData extends AbstractReindeerTestUI {
-
-    private SelectionMode selectionMode = SelectionMode.NONE;
-    private Grid grid = createGrid(true);
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        addComponent(grid);
-
-        NativeSelect selectionModeSelector = new NativeSelect("Selection mode",
-                EnumSet.allOf(SelectionMode.class));
-        selectionModeSelector.setValue(selectionMode);
-        selectionModeSelector.setNullSelectionAllowed(false);
-        selectionModeSelector.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                selectionMode = (SelectionMode) event.getProperty().getValue();
-                grid.setSelectionMode(selectionMode);
-            }
-        });
-        addComponent(selectionModeSelector);
-
-        addComponent(
-                new Button("Recreate without data", new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        replaceGrid(createGrid(false));
-                    }
-                }));
-
-        addComponent(
-                new Button("Recreate with data", new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        replaceGrid(createGrid(true));
-                    }
-                }));
-
-        addComponent(new Button("Add data", new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                addDataToGrid(grid);
-            }
-        }));
-
-        addComponent(new Button("Remove data", new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                grid.getContainerDataSource().removeAllItems();
-            }
-        }));
-
-    }
-
-    private void replaceGrid(Grid newGrid) {
-        ((VerticalLayout) grid.getParent()).replaceComponent(grid, newGrid);
-        grid = newGrid;
-    }
-
-    private Grid createGrid(boolean withData) {
-        Grid grid = new Grid();
-        grid.addColumn("foo");
-        grid.addColumn("bar");
-        grid.setWidth("300px");
-        grid.setSelectionMode(selectionMode);
-
-        if (withData) {
-            addDataToGrid(grid);
-        }
-
-        return grid;
-    }
-
-    private void addDataToGrid(Grid grid) {
-        grid.addRow("Some", "Data with more data in one col");
-    }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDataSourceReset.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDataSourceReset.java
deleted file mode 100644 (file)
index f27f985..0000000
+++ /dev/null
@@ -1,65 +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.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.tests.fieldgroup.ComplexPerson;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.v7.data.util.BeanItemContainer;
-import com.vaadin.v7.ui.Grid;
-
-public class GridDataSourceReset extends AbstractReindeerTestUI {
-
-    BeanItemContainer<ComplexPerson> container;
-    List<ComplexPerson> persons;
-    Grid grid;
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        persons = createPersons(10, new Random(1));
-        container = new BeanItemContainer<>(ComplexPerson.class, persons);
-
-        grid = new Grid(container);
-        grid.select(container.firstItemId());
-        addComponent(new Button("Remove first", new ClickListener() {
-
-            @Override
-            public void buttonClick(ClickEvent event) {
-                container.removeAllItems();
-                persons.remove(0);
-
-                container.addAll(persons);
-                grid.select(container.firstItemId());
-            }
-        }));
-        addComponent(grid);
-    }
-
-    public static List<ComplexPerson> createPersons(int count, Random r) {
-        List<ComplexPerson> c = new ArrayList<>();
-        for (int i = 0; i < count; ++i) {
-            c.add(ComplexPerson.create(r));
-        }
-        return c;
-    }
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsDetach.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsDetach.java
deleted file mode 100644 (file)
index d77f493..0000000
+++ /dev/null
@@ -1,150 +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.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.v7.data.util.BeanItemContainer;
-import com.vaadin.v7.event.ItemClickEvent;
-import com.vaadin.v7.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.DetailsGenerator;
-import com.vaadin.v7.ui.Grid.RowReference;
-import com.vaadin.v7.ui.Grid.SelectionMode;
-
-public class GridDetailsDetach extends AbstractReindeerTestUI {
-
-    private Grid currentGrid;
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        VerticalLayout layout = new VerticalLayout();
-        layout.setSizeFull();
-
-        Button button = new Button("Test");
-        layout.addComponent(button);
-        layout.setExpandRatio(button, 0f);
-
-        currentGrid = generateGrid();
-        final VerticalLayout gridContainer = new VerticalLayout();
-        gridContainer.addComponent(currentGrid);
-
-        button.addClickListener(new Button.ClickListener() {
-
-            @Override
-            public void buttonClick(ClickEvent event) {
-                gridContainer.replaceComponent(currentGrid, new Label("Foo"));
-            }
-        });
-
-        layout.addComponent(
-                new Button("Reattach Grid", new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        gridContainer.removeAllComponents();
-                        gridContainer.addComponent(currentGrid);
-                    }
-                }));
-
-        layout.addComponent(gridContainer);
-        layout.setExpandRatio(gridContainer, 1f);
-
-        addComponent(layout);
-    }
-
-    private Grid generateGrid() {
-        BeanItemContainer<GridExampleBean> container = new BeanItemContainer<>(
-                GridExampleBean.class);
-        for (int i = 0; i < 1000; i++) {
-            container.addItem(new GridExampleBean("Bean " + i, i * i, i / 10d));
-        }
-
-        final Grid grid = new Grid(container);
-        grid.setColumnOrder("name", "amount", "count");
-        grid.setSizeFull();
-        grid.setSelectionMode(SelectionMode.NONE);
-
-        grid.setDetailsGenerator(new DetailsGenerator() {
-            @Override
-            public Component getDetails(RowReference rowReference) {
-                final GridExampleBean bean = (GridExampleBean) rowReference
-                        .getItemId();
-                VerticalLayout layout = new VerticalLayout(
-                        new Label("Extra data for " + bean.getName()));
-                layout.setMargin(true);
-                return layout;
-            }
-        });
-
-        grid.addItemClickListener(new ItemClickListener() {
-            @Override
-            public void itemClick(ItemClickEvent event) {
-                Object itemId = event.getItemId();
-                grid.setDetailsVisible(itemId, !grid.isDetailsVisible(itemId));
-            }
-        });
-        return grid;
-    }
-
-    public class GridExampleBean {
-
-        private String name;
-
-        private int count;
-
-        private double amount;
-
-        public GridExampleBean() {
-        }
-
-        public GridExampleBean(String name, int count, double amount) {
-            this.name = name;
-            this.count = count;
-            this.amount = amount;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public int getCount() {
-            return count;
-        }
-
-        public double getAmount() {
-            return amount;
-        }
-
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        public void setCount(int count) {
-            this.count = count;
-        }
-
-        public void setAmount(double amount) {
-            this.amount = amount;
-        }
-
-    }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsLayoutExpand.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsLayoutExpand.java
deleted file mode 100644 (file)
index 21dba5b..0000000
+++ /dev/null
@@ -1,105 +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.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.v7.event.ItemClickEvent;
-import com.vaadin.v7.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.DetailsGenerator;
-import com.vaadin.v7.ui.Grid.RowReference;
-
-/**
- * Tests the layouting of Grid's details row when it contains a HorizontalLayout
- * with expand ratios.
- *
- * @author Vaadin Ltd
- */
-@SuppressWarnings("serial")
-public class GridDetailsLayoutExpand extends AbstractReindeerTestUI {
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        final Grid grid = new Grid();
-        grid.setSizeFull();
-        grid.addColumn("name", String.class);
-        grid.addColumn("born", Integer.class);
-
-        grid.addRow("Nicolaus Copernicus", 1543);
-        grid.addRow("Galileo Galilei", 1564);
-        grid.addRow("Johannes Kepler", 1571);
-
-        addComponent(grid);
-
-        grid.setDetailsGenerator(new DetailsGenerator() {
-            @Override
-            public Component getDetails(final RowReference rowReference) {
-                final HorizontalLayout detailsLayout = new HorizontalLayout();
-                detailsLayout.setSizeFull();
-                detailsLayout.setHeightUndefined();
-
-                // Label 1 first element of the detailsLayout, taking 200 pixels
-                final Label lbl1 = new Label("test1");
-                lbl1.setWidth("200px");
-                detailsLayout.addComponent(lbl1);
-
-                // layout2 second element of the detailsLayout, taking the rest
-                // of the available space
-                final HorizontalLayout layout2 = new HorizontalLayout();
-                layout2.setSizeFull();
-                layout2.setHeightUndefined();
-                detailsLayout.addComponent(layout2);
-                detailsLayout.setExpandRatio(layout2, 1);
-
-                // 2 Labels added to the layout2
-                final Label lbl2 = new Label("test2");
-                lbl2.setWidth("100%");
-                lbl2.setId("lbl2");
-                layout2.addComponent(lbl2);
-
-                final Label lbl3 = new Label("test3");
-                lbl3.setWidth("100%");
-                lbl3.setId("lbl3");
-                layout2.addComponent(lbl3);
-
-                return detailsLayout;
-            }
-        });
-
-        grid.addItemClickListener(new ItemClickListener() {
-            @Override
-            public void itemClick(final ItemClickEvent event) {
-                final Object itemId = event.getItemId();
-                grid.setDetailsVisible(itemId, !grid.isDetailsVisible(itemId));
-            }
-        });
-
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return 18821;
-    }
-
-    @Override
-    protected String getTestDescription() {
-        return "Details row must be the same after opening another details row";
-    }
-}
index 7a88da395b990694ef6a9dfa692827a3373e6b97..bd451e978b13317df3e1e98f5c1424e549f75013 100644 (file)
@@ -32,6 +32,13 @@ import com.vaadin.v7.ui.Grid.DetailsGenerator;
 import com.vaadin.v7.ui.Grid.RowReference;
 import com.vaadin.v7.ui.Grid.SelectionMode;
 
+/**
+ * This test cannot be migrated to V8 since there is no Grid::scrollTo method.
+ * Will it be there in the future ? (may be this test should be just removed).
+ * 
+ * @author Vaadin Ltd
+ *
+ */
 public class GridDetailsLocation extends UI {
 
     private final DetailsGenerator detailsGenerator = new DetailsGenerator() {
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsWidth.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridDetailsWidth.java
deleted file mode 100644 (file)
index 8194cee..0000000
+++ /dev/null
@@ -1,91 +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.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.v7.event.ItemClickEvent;
-import com.vaadin.v7.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.Column;
-import com.vaadin.v7.ui.Grid.DetailsGenerator;
-import com.vaadin.v7.ui.Grid.RowReference;
-import com.vaadin.v7.ui.TextArea;
-
-public class GridDetailsWidth extends AbstractReindeerTestUI {
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        final VerticalLayout layout = new VerticalLayout();
-        layout.setMargin(true);
-
-        final Grid grid = new Grid();
-
-        Column column = grid.addColumn("Hello", String.class);
-        for (int i = 0; i < 3; i++) {
-            grid.addRow("Hello " + i);
-        }
-
-        column.setWidth(600);
-        grid.setWidth(400, Unit.PIXELS);
-
-        grid.setDetailsGenerator(new DetailsGenerator() {
-
-            @Override
-            public Component getDetails(RowReference rowReference) {
-                HorizontalLayout myLayout = new HorizontalLayout();
-                TextArea textArea1 = new TextArea();
-                TextArea textArea2 = new TextArea();
-                textArea1.setSizeFull();
-                textArea2.setSizeFull();
-                myLayout.addComponent(textArea1);
-                myLayout.addComponent(textArea2);
-                myLayout.setWidth(100, Unit.PERCENTAGE);
-                myLayout.setHeight(null);
-                myLayout.setMargin(true);
-                return myLayout;
-            }
-        });
-
-        grid.addItemClickListener(new ItemClickListener() {
-
-            @Override
-            public void itemClick(ItemClickEvent event) {
-                grid.setDetailsVisible(event.getItemId(),
-                        !grid.isDetailsVisible(event.getItemId()));
-
-            }
-        });
-
-        layout.addComponent(grid);
-
-        addComponent(layout);
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return 18223;
-    }
-
-    @Override
-    protected String getTestDescription() {
-        return "Tests that Escalator will not set explicit widths to the TD element in a details row.";
-    }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java
new file mode 100644 (file)
index 0000000..b5ff8a3
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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 java.io.IOException;
+import java.util.regex.Pattern;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.parallel.BrowserUtil;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@SuppressWarnings("boxing")
+@TestCategory("grid")
+public abstract class AbstractGridColumnAutoWidthTest extends MultiBrowserTest {
+
+    public static final int TOTAL_MARGIN_PX = 21;
+
+    @Before
+    public void before() {
+        openTestURL();
+    }
+
+    @Test
+    public void testNarrowHeaderWideBody() {
+        WebElement[] col = getColumn(1);
+        int headerWidth = col[0].getSize().getWidth();
+        int bodyWidth = col[1].getSize().getWidth();
+        int colWidth = col[2].getSize().getWidth() - TOTAL_MARGIN_PX;
+
+        assertLessThan("header should've been narrower than body", headerWidth,
+                bodyWidth);
+        assertEquals("column should've been roughly as wide as the body",
+                bodyWidth, colWidth, 5);
+    }
+
+    @Test
+    public void testWideHeaderNarrowBody() {
+        WebElement[] col = getColumn(2);
+        int headerWidth = col[0].getSize().getWidth();
+        int bodyWidth = col[1].getSize().getWidth();
+        int colWidth = col[2].getSize().getWidth() - TOTAL_MARGIN_PX;
+
+        assertGreater("header should've been wider than body", headerWidth,
+                bodyWidth);
+        assertEquals("column should've been roughly as wide as the header",
+                headerWidth, colWidth, 5);
+
+    }
+
+    @Test
+    public void testTooNarrowColumn() {
+        if (BrowserUtil.isIE(getDesiredCapabilities())) {
+            // IE can't deal with overflow nicely.
+            return;
+        }
+
+        WebElement[] col = getColumn(3);
+        int headerWidth = col[0].getSize().getWidth();
+        int colWidth = col[2].getSize().getWidth() - TOTAL_MARGIN_PX;
+
+        assertLessThan("column should've been narrower than content", colWidth,
+                headerWidth);
+    }
+
+    @Test
+    public void testTooWideColumn() {
+        WebElement[] col = getColumn(4);
+        int headerWidth = col[0].getSize().getWidth();
+        int colWidth = col[2].getSize().getWidth() - TOTAL_MARGIN_PX;
+
+        assertGreater("column should've been wider than content", colWidth,
+                headerWidth);
+    }
+
+    @Test
+    public void testColumnsRenderCorrectly() throws IOException {
+        WebElement loadingIndicator = findElement(
+                By.className("v-loading-indicator"));
+        Pattern pattern = Pattern.compile("display: *none;");
+        waitUntil(driver -> {
+            return pattern.matcher(loadingIndicator.getAttribute("style"))
+                    .find();
+        });
+        compareScreen("grid-v8-initialRender");
+    }
+
+    private WebElement[] getColumn(int i) {
+        WebElement[] col = new WebElement[3];
+        col[0] = getDriver().findElement(
+                By.xpath("//thead//th[" + (i + 1) + "]/div[1]/span"));
+        col[1] = getDriver()
+                .findElement(By.xpath("//tbody//td[" + (i + 1) + "]//span"));
+        col[2] = getDriver()
+                .findElement(By.xpath("//tbody//td[" + (i + 1) + "]"));
+        return col;
+    }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java
new file mode 100644 (file)
index 0000000..bd1cf1a
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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 static org.junit.Assert.assertFalse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridColspansTest extends MultiBrowserTest {
+
+    @Before
+    public void setUp() {
+        setDebug(true);
+    }
+
+    @Test
+    public void testColSpans() {
+        openTestURL();
+
+        GridElement grid = $(GridElement.class).first();
+        assertEquals("5", grid.getHeaderCell(0, 1).getAttribute("colspan"));
+        assertEquals("2", grid.getHeaderCell(1, 1).getAttribute("colspan"));
+        assertEquals("3", grid.getHeaderCell(1, 3).getAttribute("colspan"));
+
+        assertEquals("5", grid.getFooterCell(1, 1).getAttribute("colspan"));
+        assertEquals("2", grid.getFooterCell(0, 1).getAttribute("colspan"));
+        assertEquals("3", grid.getFooterCell(0, 3).getAttribute("colspan"));
+    }
+
+    @Test
+    public void testHideFirstColumnOfColspan() {
+        openTestURL();
+
+        GridElement grid = $(GridElement.class).first();
+        assertEquals("Failed initial condition.", "all the stuff",
+                grid.getHeaderCell(0, 1).getText().toLowerCase());
+        assertEquals("Failed initial condition.", "first name",
+                grid.getHeaderCell(2, 1).getText().toLowerCase());
+        $(ButtonElement.class).caption("Show/Hide firstName").first().click();
+        assertEquals("Header text changed on column hide.", "all the stuff",
+                grid.getHeaderCell(0, 1).getText().toLowerCase());
+        assertEquals("Failed initial condition.", "last name",
+                grid.getHeaderCell(2, 1).getText().toLowerCase());
+    }
+
+    @Test
+    public void testSplittingMergedHeaders() {
+        openTestURL();
+
+        GridElement grid = $(GridElement.class).first();
+        GridCellElement headerCell = grid.getHeaderCell(1, 1);
+        assertEquals("Failed initial condition.", "full name",
+                headerCell.getText().toLowerCase());
+        assertEquals("Failed initial condition.", "first name",
+                grid.getHeaderCell(2, 1).getText().toLowerCase());
+        $(ButtonElement.class).get(1).click();
+        headerCell = grid.getHeaderCell(1, 1);
+        assertEquals("Joined Header text not changed on column reorder.",
+                "misc", headerCell.getText().toLowerCase());
+        assertEquals("Unexpected colspan", "1",
+                headerCell.getAttribute("colspan"));
+        headerCell = grid.getHeaderCell(1, 2);
+        assertEquals("Header text not changed on column reorder", "full name",
+                headerCell.getText().toLowerCase());
+        assertEquals("Unexpected colspan", "2",
+                headerCell.getAttribute("colspan"));
+
+        assertFalse("Error indicator not present",
+                isElementPresent(By.className("v-errorindicator")));
+
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java
new file mode 100644 (file)
index 0000000..be8f122
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.assertTrue;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class GridColumnAutoExpandTest extends MultiBrowserTest {
+
+    @Override
+    public List<DesiredCapabilities> getBrowsersToTest() {
+        // The functionality doesn't work for PHJS_1. And the test fails. It
+        // works for PHJS_2.
+        return getBrowsersExcludingPhantomJS();
+    }
+
+    @Test
+    public void testSecondColumnHasExpanded() {
+        openTestURL();
+
+        GridCellElement headerCell = $(GridElement.class).first()
+                .getHeaderCell(0, 1);
+
+        assertTrue("Column did not expand as expected",
+                headerCell.getSize().getWidth() > 400);
+    }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoWidthClientTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoWidthClientTest.java
new file mode 100644 (file)
index 0000000..8b1745d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.testbench.parallel.TestCategory;
+
+@TestCategory("grid")
+public class GridColumnAutoWidthClientTest
+        extends AbstractGridColumnAutoWidthTest {
+    @Override
+    protected Class<?> getUIClass() {
+        return GridColumnAutoWidthClient.class;
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoWidthServerTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoWidthServerTest.java
new file mode 100644 (file)
index 0000000..b41c626
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.testbench.parallel.TestCategory;
+
+@TestCategory("grid")
+public class GridColumnAutoWidthServerTest
+        extends AbstractGridColumnAutoWidthTest {
+    @Override
+    protected Class<?> getUIClass() {
+        return GridColumnAutoWidth.class;
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java
new file mode 100644 (file)
index 0000000..6797353
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * 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.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.testbench.elements.NativeSelectElement;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+@TestCategory("grid")
+public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest {
+
+    @Test
+    public void testWidthsWhenAddingDataBack() {
+        openTestURL();
+        GridElement grid = $(GridElement.class).first();
+
+        int[] baseWidths = getColWidths(grid);
+        Assert.assertEquals("Sanity check", 2, baseWidths.length);
+
+        Assert.assertTrue("Columns should not have equal width",
+                Math.abs(baseWidths[0] - baseWidths[1]) > 2);
+
+        removeData();
+
+        assertSameWidths(baseWidths, getColWidths(grid));
+
+        addData();
+
+        assertSameWidths(baseWidths, getColWidths(grid));
+    }
+
+    @Test
+    public void testWidthsWhenInitiallyEmpty() {
+        setDebug(true);
+        openTestURL();
+        $(ButtonElement.class).caption("Recreate without data").first().click();
+
+        GridElement grid = $(GridElement.class).first();
+
+        int[] baseWidths = getColWidths(grid);
+        Assert.assertEquals("Sanity check", 2, baseWidths.length);
+
+        Assert.assertTrue("Columns should have roughly equal width",
+                Math.abs(baseWidths[0] - baseWidths[1]) < 10);
+        Assert.assertTrue("Columns should not have default widths",
+                baseWidths[0] > 140);
+        Assert.assertTrue("Columns should not have default widths",
+                baseWidths[1] > 140);
+
+        addData();
+
+        assertSameWidths(baseWidths, getColWidths(grid));
+
+        Assert.assertFalse("Notification was present",
+                isElementPresent(NotificationElement.class));
+    }
+
+    @Test
+    public void testMultiSelectWidths() {
+        setDebug(true);
+        openTestURL();
+        $(NativeSelectElement.class).caption("Selection mode").first()
+                .selectByText("MULTI");
+
+        GridElement grid = $(GridElement.class).first();
+
+        int sum = sumUsedWidths(grid);
+
+        // 295 instead of 300 to avoid rounding issues
+        Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
+
+        $(ButtonElement.class).caption("Recreate without data").first().click();
+
+        grid = $(GridElement.class).first();
+        sum = sumUsedWidths(grid);
+
+        // 295 instead of 300 to avoid rounding issues
+        Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
+    }
+
+    private int sumUsedWidths(GridElement grid) {
+        int sum = 0;
+        for (int i : getColWidths(grid)) {
+            sum += i;
+        }
+        return sum;
+    }
+
+    private static void assertSameWidths(int[] expected, int[] actual) {
+        Assert.assertEquals("Arrays have differing lengths", expected.length,
+                actual.length);
+
+        for (int i = 0; i < expected.length; i++) {
+            if (Math.abs(expected[i] - actual[i]) > 1) {
+                Assert.fail("Differing sizes at index " + i + ". Expected "
+                        + expected[i] + " but got " + actual[i]);
+            }
+        }
+    }
+
+    private void removeData() {
+        $(ButtonElement.class).caption("Remove data").first().click();
+    }
+
+    private void addData() {
+        $(ButtonElement.class).caption("Add data").first().click();
+    }
+
+    private int[] getColWidths(GridElement grid) {
+        List<GridCellElement> headerCells = grid.getHeaderCells(0);
+        int[] widths = new int[headerCells.size()];
+        for (int i = 0; i < widths.length; i++) {
+            widths[i] = headerCells.get(i).getSize().getWidth();
+        }
+        return widths;
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java
new file mode 100644 (file)
index 0000000..4e3ce3e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class GridDataSourceResetTest extends SingleBrowserTest {
+
+    @Test
+    public void testRemoveWithSelectUpdatesRowsCorrectly() {
+        openTestURL();
+
+        GridElement grid = $(GridElement.class).first();
+
+        assertTrue("First row was not selected", grid.getRow(0).isSelected());
+        for (int i = 1; i < 10; ++i) {
+            assertFalse("Only first row should be selected",
+                    grid.getRow(i).isSelected());
+        }
+
+        $(ButtonElement.class).first().click();
+
+        assertTrue("First row was not selected after remove",
+                grid.getRow(0).isSelected());
+        for (int i = 1; i < 9; ++i) {
+            assertFalse("Only first row should be selected after remove",
+                    grid.getRow(i).isSelected());
+        }
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsDetachTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsDetachTest.java
new file mode 100644 (file)
index 0000000..5ede362
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridDetailsDetachTest extends MultiBrowserTest {
+
+    @Test
+    public void testDetachGridWithDetailsOpen() {
+        setDebug(true);
+        openTestURL();
+
+        $(GridElement.class).first().getCell(3, 0).click();
+        $(GridElement.class).first().getCell(5, 0).click();
+
+        assertNoErrorNotifications();
+
+        $(ButtonElement.class).first().click();
+
+        assertNoErrorNotifications();
+    }
+
+    @Test
+    public void testDetachAndReattachGridWithDetailsOpen() {
+        setDebug(true);
+        openTestURL();
+
+        $(GridElement.class).first().getCell(1, 0).click();
+        $(GridElement.class).first().getCell(3, 0).click();
+
+        assertNoErrorNotifications();
+
+        $(ButtonElement.class).first().click();
+
+        assertNoErrorNotifications();
+
+        $(ButtonElement.class).get(1).click();
+
+        assertNoErrorNotifications();
+
+        List<WebElement> spacers = findElements(By.className("v-grid-spacer"));
+        Assert.assertEquals("Not enough spacers in DOM", 2, spacers.size());
+        Assert.assertEquals("Spacer content not visible",
+                "Extra data for Bean 1", spacers.get(0).getText());
+        Assert.assertEquals("Spacer content not visible",
+                "Extra data for Bean 3", spacers.get(1).getText());
+    }
+
+    @Test
+    public void testDetachAndImmediateReattach() {
+        setDebug(true);
+        openTestURL();
+
+        $(GridElement.class).first().getCell(1, 0).click();
+        $(GridElement.class).first().getCell(3, 0).click();
+
+        assertNoErrorNotifications();
+
+        // Detach and Re-attach Grid
+        $(ButtonElement.class).get(1).click();
+
+        assertNoErrorNotifications();
+
+        List<WebElement> spacers = findElements(By.className("v-grid-spacer"));
+        Assert.assertEquals("Not enough spacers in DOM", 2, spacers.size());
+        Assert.assertEquals("Spacer content not visible",
+                "Extra data for Bean 1", spacers.get(0).getText());
+        Assert.assertEquals("Spacer content not visible",
+                "Extra data for Bean 3", spacers.get(1).getText());
+    }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java
new file mode 100644 (file)
index 0000000..c1f4ee7
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.number.IsCloseTo.closeTo;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.parallel.Browser;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests the layouting of Grid's details row when it contains a HorizontalLayout
+ * with expand ratios.
+ *
+ * @author Vaadin Ltd
+ */
+@TestCategory("grid")
+public class GridDetailsLayoutExpandTest extends MultiBrowserTest {
+
+    @Override
+    public List<DesiredCapabilities> getBrowsersToTest() {
+        List<DesiredCapabilities> browsersToTest = super.getBrowsersToTest();
+        // for some reason PhantomJS doesn't find the label even if it detects
+        // the presence
+        browsersToTest.remove(Browser.PHANTOMJS.getDesiredCapabilities());
+        return browsersToTest;
+    }
+
+    @Test
+    public void testLabelWidths() {
+        openTestURL();
+        waitForElementPresent(By.className("v-grid"));
+
+        GridElement grid = $(GridElement.class).first();
+        int gridWidth = grid.getSize().width;
+
+        grid.getRow(2).click();
+        waitForElementPresent(By.id("lbl2"));
+
+        // space left over from first label should be divided equally
+        double expectedWidth = (double) (gridWidth - 200) / 2;
+        assertLabelWidth("lbl2", expectedWidth);
+        assertLabelWidth("lbl3", expectedWidth);
+    }
+
+    private void assertLabelWidth(String id, double expectedWidth) {
+        // 1px leeway for calculations
+        assertThat("Unexpected label width.",
+                (double) $(LabelElement.class).id(id).getSize().width,
+                closeTo(expectedWidth, 1d));
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsWidthTest.java
new file mode 100644 (file)
index 0000000..7c4ebb5
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.customelements.GridElement;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+@TestCategory("grid")
+public class GridDetailsWidthTest extends SingleBrowserTest {
+
+    @Test
+    public void testSpacerTDsHaveNoWidth() {
+        openTestURL();
+        GridElement grid = $(GridElement.class).first();
+
+        // Open all details rows
+        grid.getCell(0, 0).click();
+        checkSpacersHaveNoWidths(1);
+
+        grid.getCell(1, 0).click();
+        checkSpacersHaveNoWidths(2);
+
+        grid.getCell(2, 0).click();
+        checkSpacersHaveNoWidths(3);
+
+        // Close all details rows
+        grid.getCell(2, 0).click();
+        checkSpacersHaveNoWidths(2);
+
+        grid.getCell(1, 0).click();
+        checkSpacersHaveNoWidths(1);
+
+        grid.getCell(0, 0).click();
+        checkSpacersHaveNoWidths(0);
+    }
+
+    private void checkSpacersHaveNoWidths(int expectedCount) {
+        List<WebElement> spacers = findElements(By.className("v-grid-spacer"));
+        Assert.assertEquals("Wrong amount of spacers visible.", expectedCount,
+                spacers.size());
+        for (WebElement spacer : spacers) {
+            Assert.assertFalse("Spacer element had an unexpected width set.",
+                    spacer.findElement(By.tagName("td")).getAttribute("style")
+                            .contains("width"));
+        }
+    }
+
+    @Test
+    public void testDetailsOnSort() {
+        openTestURL();
+        GridElement grid = $(GridElement.class).first();
+
+        // Open a details rows
+        grid.getCell(0, 0).click();
+
+        GridCellElement cell = grid.getHeaderCell(0, 0);
+        cell.click();
+        cell.click();
+
+        cell = grid.getCell(2, 0);
+        WebElement spacer = findElement(By.className("v-grid-spacer"));
+        Assert.assertEquals("Grid was not sorted correctly", "Hello 0",
+                cell.getText());
+        Assert.assertEquals("Details row was not in correct location",
+                cell.getLocation().getY() + cell.getSize().getHeight(),
+                spacer.getLocation().getY(), 2);
+
+    }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColspansTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColspansTest.java
deleted file mode 100644 (file)
index b50c5a2..0000000
+++ /dev/null
@@ -1,101 +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 static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openqa.selenium.By;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.GridElement.GridCellElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-@TestCategory("grid")
-public class GridColspansTest extends MultiBrowserTest {
-
-    @Before
-    public void setUp() {
-        setDebug(true);
-    }
-
-    @Test
-    public void testHeaderColSpans() {
-        openTestURL();
-
-        GridElement grid = $(GridElement.class).first();
-        assertEquals("5", grid.getHeaderCell(0, 1).getAttribute("colspan"));
-        assertEquals("2", grid.getHeaderCell(1, 1).getAttribute("colspan"));
-        assertEquals("3", grid.getHeaderCell(1, 3).getAttribute("colspan"));
-    }
-
-    @Test
-    public void testFooterColSpans() {
-        openTestURL();
-
-        GridElement grid = $(GridElement.class).first();
-        assertEquals("5", grid.getFooterCell(1, 1).getAttribute("colspan"));
-        assertEquals("2", grid.getFooterCell(0, 1).getAttribute("colspan"));
-        assertEquals("3", grid.getFooterCell(0, 3).getAttribute("colspan"));
-    }
-
-    @Test
-    public void testHideFirstColumnOfColspan() {
-        openTestURL();
-
-        GridElement grid = $(GridElement.class).first();
-        assertEquals("Failed initial condition.", "all the stuff",
-                grid.getHeaderCell(0, 1).getText().toLowerCase());
-        assertEquals("Failed initial condition.", "first name",
-                grid.getHeaderCell(2, 1).getText().toLowerCase());
-        $(ButtonElement.class).caption("Show/Hide firstName").first().click();
-        assertEquals("Header text changed on column hide.", "all the stuff",
-                grid.getHeaderCell(0, 1).getText().toLowerCase());
-        assertEquals("Failed initial condition.", "last name",
-                grid.getHeaderCell(2, 1).getText().toLowerCase());
-    }
-
-    @Test
-    public void testSplittingMergedHeaders() {
-        openTestURL();
-
-        GridElement grid = $(GridElement.class).first();
-        GridCellElement headerCell = grid.getHeaderCell(1, 1);
-        assertEquals("Failed initial condition.", "full name",
-                headerCell.getText().toLowerCase());
-        assertEquals("Failed initial condition.", "first name",
-                grid.getHeaderCell(2, 1).getText().toLowerCase());
-        $(ButtonElement.class).get(1).click();
-        headerCell = grid.getHeaderCell(1, 1);
-        assertEquals("Header text not changed on column reorder.", "address",
-                headerCell.getText().toLowerCase());
-        assertEquals("Unexpected colspan", "1",
-                headerCell.getAttribute("colspan"));
-        headerCell = grid.getHeaderCell(1, 2);
-        assertEquals("Header text not changed on column reorder", "full name",
-                headerCell.getText().toLowerCase());
-        assertEquals("Unexpected colspan", "2",
-                headerCell.getAttribute("colspan"));
-
-        assertTrue("Error indicator not present",
-                isElementPresent(By.className("v-errorindicator")));
-
-    }
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoExpandTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoExpandTest.java
deleted file mode 100644 (file)
index cd77084..0000000
+++ /dev/null
@@ -1,39 +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.assertTrue;
-
-import org.junit.Test;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.GridElement.GridCellElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class GridColumnAutoExpandTest extends MultiBrowserTest {
-
-    @Test
-    public void testSecondColumnHasExpanded() {
-        openTestURL();
-
-        GridCellElement headerCell = $(GridElement.class).first()
-                .getHeaderCell(0, 1);
-
-        assertTrue("Column did not expand as expected",
-                headerCell.getSize().getWidth() > 400);
-    }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthClientTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthClientTest.java
deleted file mode 100644 (file)
index a0567bb..0000000
+++ /dev/null
@@ -1,27 +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.testbench.parallel.TestCategory;
-
-@TestCategory("grid")
-public class GridColumnAutoWidthClientTest
-        extends AbstractGridColumnAutoWidthTest {
-    @Override
-    protected Class<?> getUIClass() {
-        return GridColumnAutoWidthClient.class;
-    }
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthServerTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnAutoWidthServerTest.java
deleted file mode 100644 (file)
index 0a0f823..0000000
+++ /dev/null
@@ -1,27 +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.testbench.parallel.TestCategory;
-
-@TestCategory("grid")
-public class GridColumnAutoWidthServerTest
-        extends AbstractGridColumnAutoWidthTest {
-    @Override
-    protected Class<?> getUIClass() {
-        return GridColumnAutoWidth.class;
-    }
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnWidthRecalculationTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnWidthRecalculationTest.java
deleted file mode 100644 (file)
index 6bad840..0000000
+++ /dev/null
@@ -1,82 +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 org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openqa.selenium.Dimension;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.GridElement.GridCellElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.SingleBrowserTest;
-
-@TestCategory("grid")
-public class GridColumnWidthRecalculationTest extends SingleBrowserTest {
-
-    private GridElement grid;
-
-    @Before
-    public void open() {
-        openTestURL();
-        grid = $(GridElement.class).first();
-    }
-
-    @Test
-    public void columnWidthAfterSwap() {
-        int column0Width = getColumnWidth(0);
-        int column1Width = getColumnWidth(1);
-        Assert.assertTrue("Column 0 should be narrower than column 1 initially",
-                column0Width < column1Width);
-
-        $(ButtonElement.class).caption("Swap content").first().click();
-
-        Assert.assertEquals(
-                "Column 0 width should not change when swapping contents only",
-                column0Width, getColumnWidth(0));
-        Assert.assertEquals(
-                "Column 1 width should not change when swapping contents only",
-                column1Width, getColumnWidth(1));
-    }
-
-    @Test
-    public void columnWidthAfterSwapAndRecalculate() {
-        int column0Width = getColumnWidth(0);
-        int column1Width = getColumnWidth(1);
-        Assert.assertTrue("Column 0 should be narrower than column 1 initially",
-                column0Width < column1Width);
-
-        $(ButtonElement.class).caption("Swap content and recalculate columns")
-                .first().click();
-
-        column0Width = getColumnWidth(0);
-        column1Width = getColumnWidth(1);
-
-        Assert.assertTrue(
-                "Column 1 should be narrower than column 0 after resize",
-                column1Width < column0Width);
-    }
-
-    private int getColumnWidth(int columnIndex) {
-        GridCellElement headerColumn = grid.getHeaderCells(0).get(columnIndex);
-        Dimension column1Size = headerColumn.getSize();
-        int columnWidth = column1Size.getWidth();
-        return columnWidth;
-    }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnWidthsWithoutDataTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridColumnWidthsWithoutDataTest.java
deleted file mode 100644 (file)
index 81f0a83..0000000
+++ /dev/null
@@ -1,139 +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.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.GridElement.GridCellElement;
-import com.vaadin.testbench.elements.NativeSelectElement;
-import com.vaadin.testbench.elements.NotificationElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.SingleBrowserTest;
-
-@TestCategory("grid")
-public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest {
-
-    @Test
-    public void testWidthsWhenAddingDataBack() {
-        openTestURL();
-        GridElement grid = $(GridElement.class).first();
-
-        int[] baseWidths = getColWidths(grid);
-        Assert.assertEquals("Sanity check", 2, baseWidths.length);
-
-        Assert.assertTrue("Columns should not have equal width",
-                Math.abs(baseWidths[0] - baseWidths[1]) > 2);
-
-        removeData();
-
-        assertSameWidths(baseWidths, getColWidths(grid));
-
-        addData();
-
-        assertSameWidths(baseWidths, getColWidths(grid));
-    }
-
-    @Test
-    public void testWidthsWhenInitiallyEmpty() {
-        setDebug(true);
-        openTestURL();
-        $(ButtonElement.class).caption("Recreate without data").first().click();
-
-        GridElement grid = $(GridElement.class).first();
-
-        int[] baseWidths = getColWidths(grid);
-        Assert.assertEquals("Sanity check", 2, baseWidths.length);
-
-        Assert.assertTrue("Columns should have roughly equal width",
-                Math.abs(baseWidths[0] - baseWidths[1]) < 10);
-        Assert.assertTrue("Columns should not have default widths",
-                baseWidths[0] > 140);
-        Assert.assertTrue("Columns should not have default widths",
-                baseWidths[1] > 140);
-
-        addData();
-
-        assertSameWidths(baseWidths, getColWidths(grid));
-
-        Assert.assertFalse("Notification was present",
-                isElementPresent(NotificationElement.class));
-    }
-
-    @Test
-    public void testMultiSelectWidths() {
-        setDebug(true);
-        openTestURL();
-        $(NativeSelectElement.class).caption("Selection mode").first()
-                .selectByText("Multi");
-
-        GridElement grid = $(GridElement.class).first();
-
-        int sum = sumUsedWidths(grid);
-
-        // 295 instead of 300 to avoid rounding issues
-        Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
-
-        $(ButtonElement.class).caption("Recreate without data").first().click();
-
-        grid = $(GridElement.class).first();
-        sum = sumUsedWidths(grid);
-
-        // 295 instead of 300 to avoid rounding issues
-        Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
-    }
-
-    private int sumUsedWidths(GridElement grid) {
-        int sum = 0;
-        for (int i : getColWidths(grid)) {
-            sum += i;
-        }
-        return sum;
-    }
-
-    private static void assertSameWidths(int[] expected, int[] actual) {
-        Assert.assertEquals("Arrays have differing lengths", expected.length,
-                actual.length);
-
-        for (int i = 0; i < expected.length; i++) {
-            if (Math.abs(expected[i] - actual[i]) > 1) {
-                Assert.fail("Differing sizes at index " + i + ". Expected "
-                        + expected[i] + " but got " + actual[i]);
-            }
-        }
-    }
-
-    private void removeData() {
-        $(ButtonElement.class).caption("Remove data").first().click();
-    }
-
-    private void addData() {
-        $(ButtonElement.class).caption("Add data").first().click();
-    }
-
-    private int[] getColWidths(GridElement grid) {
-        List<GridCellElement> headerCells = grid.getHeaderCells(0);
-        int[] widths = new int[headerCells.size()];
-        for (int i = 0; i < widths.length; i++) {
-            widths[i] = headerCells.get(i).getSize().getWidth();
-        }
-        return widths;
-    }
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDataSourceResetTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDataSourceResetTest.java
deleted file mode 100644 (file)
index 3405d81..0000000
+++ /dev/null
@@ -1,50 +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.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.tests.tb3.SingleBrowserTest;
-
-public class GridDataSourceResetTest extends SingleBrowserTest {
-
-    @Test
-    public void testRemoveWithSelectUpdatesRowsCorrectly() {
-        openTestURL();
-
-        GridElement grid = $(GridElement.class).first();
-
-        assertTrue("First row was not selected", grid.getRow(0).isSelected());
-        for (int i = 1; i < 10; ++i) {
-            assertFalse("Only first row should be selected",
-                    grid.getRow(i).isSelected());
-        }
-
-        $(ButtonElement.class).first().click();
-
-        assertTrue("First row was not selected after remove",
-                grid.getRow(0).isSelected());
-        for (int i = 1; i < 9; ++i) {
-            assertFalse("Only first row should be selected after remove",
-                    grid.getRow(i).isSelected());
-        }
-    }
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsDetachTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsDetachTest.java
deleted file mode 100644 (file)
index fe700a1..0000000
+++ /dev/null
@@ -1,97 +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.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-@TestCategory("grid")
-public class GridDetailsDetachTest extends MultiBrowserTest {
-
-    @Test
-    public void testDetachGridWithDetailsOpen() {
-        setDebug(true);
-        openTestURL();
-
-        $(GridElement.class).first().getCell(3, 0).click();
-        $(GridElement.class).first().getCell(5, 0).click();
-
-        assertNoErrorNotifications();
-
-        $(ButtonElement.class).first().click();
-
-        assertNoErrorNotifications();
-    }
-
-    @Test
-    public void testDetachAndReattachGridWithDetailsOpen() {
-        setDebug(true);
-        openTestURL();
-
-        $(GridElement.class).first().getCell(3, 0).click();
-        $(GridElement.class).first().getCell(5, 0).click();
-
-        assertNoErrorNotifications();
-
-        $(ButtonElement.class).first().click();
-
-        assertNoErrorNotifications();
-
-        $(ButtonElement.class).get(1).click();
-
-        assertNoErrorNotifications();
-
-        List<WebElement> spacers = findElements(By.className("v-grid-spacer"));
-        Assert.assertEquals("Not enough spacers in DOM", 2, spacers.size());
-        Assert.assertEquals("Spacer content not visible",
-                "Extra data for Bean 3", spacers.get(0).getText());
-        Assert.assertEquals("Spacer content not visible",
-                "Extra data for Bean 5", spacers.get(1).getText());
-    }
-
-    @Test
-    public void testDetachAndImmediateReattach() {
-        setDebug(true);
-        openTestURL();
-
-        $(GridElement.class).first().getCell(3, 0).click();
-        $(GridElement.class).first().getCell(5, 0).click();
-
-        assertNoErrorNotifications();
-
-        // Detach and Re-attach Grid
-        $(ButtonElement.class).get(1).click();
-
-        assertNoErrorNotifications();
-
-        List<WebElement> spacers = findElements(By.className("v-grid-spacer"));
-        Assert.assertEquals("Not enough spacers in DOM", 2, spacers.size());
-        Assert.assertEquals("Spacer content not visible",
-                "Extra data for Bean 3", spacers.get(0).getText());
-        Assert.assertEquals("Spacer content not visible",
-                "Extra data for Bean 5", spacers.get(1).getText());
-    }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsLayoutExpandTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsLayoutExpandTest.java
deleted file mode 100644 (file)
index 67daf06..0000000
+++ /dev/null
@@ -1,74 +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.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.number.IsCloseTo.closeTo;
-
-import java.util.List;
-
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.LabelElement;
-import com.vaadin.testbench.parallel.Browser;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests the layouting of Grid's details row when it contains a HorizontalLayout
- * with expand ratios.
- *
- * @author Vaadin Ltd
- */
-@TestCategory("grid")
-public class GridDetailsLayoutExpandTest extends MultiBrowserTest {
-
-    @Override
-    public List<DesiredCapabilities> getBrowsersToTest() {
-        List<DesiredCapabilities> browsersToTest = super.getBrowsersToTest();
-        // for some reason PhantomJS doesn't find the label even if it detects
-        // the presence
-        browsersToTest.remove(Browser.PHANTOMJS.getDesiredCapabilities());
-        return browsersToTest;
-    }
-
-    @Test
-    public void testLabelWidths() {
-        openTestURL();
-        waitForElementPresent(By.className("v-grid"));
-
-        GridElement grid = $(GridElement.class).first();
-        int gridWidth = grid.getSize().width;
-
-        grid.getRow(2).click();
-        waitForElementPresent(By.id("lbl2"));
-
-        // space left over from first label should be divided equally
-        double expectedWidth = (double) (gridWidth - 200) / 2;
-        assertLabelWidth("lbl2", expectedWidth);
-        assertLabelWidth("lbl3", expectedWidth);
-    }
-
-    private void assertLabelWidth(String id, double expectedWidth) {
-        // 1px leeway for calculations
-        assertThat("Unexpected label width.",
-                (double) $(LabelElement.class).id(id).getSize().width,
-                closeTo(expectedWidth, 1d));
-    }
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsWidthTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsWidthTest.java
deleted file mode 100644 (file)
index 055f447..0000000
+++ /dev/null
@@ -1,92 +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.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.customelements.GridElement;
-import com.vaadin.testbench.elements.GridElement.GridCellElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.SingleBrowserTest;
-
-@TestCategory("grid")
-public class GridDetailsWidthTest extends SingleBrowserTest {
-
-    @Test
-    public void testSpacerTDsHaveNoWidth() {
-        openTestURL();
-        GridElement grid = $(GridElement.class).first();
-
-        // Open all details rows
-        grid.getCell(0, 0).click();
-        checkSpacersHaveNoWidths(1);
-
-        grid.getCell(1, 0).click();
-        checkSpacersHaveNoWidths(2);
-
-        grid.getCell(2, 0).click();
-        checkSpacersHaveNoWidths(3);
-
-        // Close all details rows
-        grid.getCell(2, 0).click();
-        checkSpacersHaveNoWidths(2);
-
-        grid.getCell(1, 0).click();
-        checkSpacersHaveNoWidths(1);
-
-        grid.getCell(0, 0).click();
-        checkSpacersHaveNoWidths(0);
-    }
-
-    private void checkSpacersHaveNoWidths(int expectedCount) {
-        List<WebElement> spacers = findElements(By.className("v-grid-spacer"));
-        Assert.assertEquals("Wrong amount of spacers visible.", expectedCount,
-                spacers.size());
-        for (WebElement spacer : spacers) {
-            Assert.assertFalse("Spacer element had an unexpected width set.",
-                    spacer.findElement(By.tagName("td")).getAttribute("style")
-                            .contains("width"));
-        }
-    }
-
-    @Test
-    public void testDetailsOnSort() {
-        openTestURL();
-        GridElement grid = $(GridElement.class).first();
-
-        // Open a details rows
-        grid.getCell(0, 0).click();
-
-        GridCellElement cell = grid.getHeaderCell(0, 0);
-        cell.click();
-        cell.click();
-
-        cell = grid.getCell(2, 0);
-        WebElement spacer = findElement(By.className("v-grid-spacer"));
-        Assert.assertEquals("Grid was not sorted correctly", "Hello 0",
-                cell.getText());
-        Assert.assertEquals("Details row was not in correct location",
-                cell.getLocation().getY() + cell.getSize().getHeight(),
-                spacer.getLocation().getY());
-
-    }
-
-}