summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------tests/screenshots0
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUI.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeAndScroll.java64
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeHiddenColumn.java (renamed from uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeHiddenColumn.java)33
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeTerror.java (renamed from uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeTerror.java)18
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridRowHeightChange.java (renamed from uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridRowHeightChange.java)38
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizing.java (renamed from uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridScrollToLineWhileResizing.java)35
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridSidebarPosition.java (renamed from uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSidebarPosition.java)24
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridSingleColumn.java (renamed from uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSingleColumn.java)31
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridSortIndicator.java98
-rw-r--r--uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeAndScroll.java68
-rw-r--r--uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridScrolling.java112
-rw-r--r--uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSortIndicator.java96
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridResizeAndScrollTest.java)2
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridResizeHiddenColumnTest.java)26
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridRowHeightChangeTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridRowHeightChangeTest.java)2
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridScrollToLineWhileResizingTest.java)2
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSidebarPositionTest.java)2
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSingleColumnTest.java)2
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java (renamed from uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSortIndicatorTest.java)7
21 files changed, 268 insertions, 398 deletions
diff --git a/tests/screenshots b/tests/screenshots
-Subproject 9a77b414d2eed1d74c559916d81df9b92ce680e
+Subproject c87c64ec9448df91164efd72cfe62791c148e0c
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUI.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUI.java
index 94d5c13b50..8810d31a2e 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUI.java
@@ -15,9 +15,11 @@
*/
package com.vaadin.tests.components.grid;
+import com.vaadin.annotations.Theme;
import com.vaadin.tests.util.Person;
import com.vaadin.ui.Grid;
+@Theme("valo")
public class GridEditorFrozenColumnsUI extends GridEditorUI {
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java
index 9efa5c1e11..48f8f814d3 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorUI.java
@@ -20,7 +20,7 @@ import java.util.Collection;
import java.util.Random;
import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.components.AbstractReindeerTestUIWithLog;
import com.vaadin.tests.util.Person;
import com.vaadin.tests.util.TestDataGenerator;
import com.vaadin.ui.Grid;
@@ -29,7 +29,7 @@ import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.renderers.NumberRenderer;
-public class GridEditorUI extends AbstractTestUI {
+public class GridEditorUI extends AbstractReindeerTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeAndScroll.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeAndScroll.java
new file mode 100644
index 0000000000..969ad9e5cf
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeAndScroll.java
@@ -0,0 +1,64 @@
+/*
+ * 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.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridResizeAndScroll extends AbstractReindeerTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ VerticalLayout content = new VerticalLayout();
+ addComponent(content);
+
+ final Grid<Person> grid = new Grid<>();
+ content.setHeight("500px");
+ content.addComponent(grid);
+
+ grid.addColumn(Person::getFirstName);
+ grid.addColumn(Person::getLastName);
+ grid.addColumn(Person::getEmail);
+
+ grid.setItems(IntStream.range(0, 50).mapToObj(this::createPerson));
+
+ grid.setSizeFull();
+
+ grid.setSelectionMode(SelectionMode.MULTI);
+
+ grid.addSelectionListener(event -> {
+ if (event.getAllSelectedItems().isEmpty()) {
+ grid.setHeight("100%");
+ } else {
+ grid.setHeight("50%");
+ }
+ });
+ }
+
+ private Person createPerson(int index) {
+ Person person = new Person();
+ person.setFirstName("cell " + index + " 0");
+ person.setLastName("cell " + index + " 1");
+ person.setEmail("cell " + index + " 2");
+ return person;
+ }
+}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeHiddenColumn.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeHiddenColumn.java
index 20fad06c1f..2c6a2cda1d 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeHiddenColumn.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeHiddenColumn.java
@@ -13,37 +13,32 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.tests.fieldgroup.ComplexPerson;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.ColumnResizeEvent;
-import com.vaadin.v7.ui.Grid.ColumnResizeListener;
+import com.vaadin.tests.util.Person;
+import com.vaadin.ui.Grid;
@SuppressWarnings("serial")
-public class GridResizeHiddenColumn extends AbstractTestUIWithLog {
+public class GridResizeHiddenColumn extends GridEditorUI {
@Override
protected void setup(VaadinRequest request) {
- Grid grid = new Grid();
- grid.setContainerDataSource(ComplexPerson.createContainer(100));
- grid.setColumns("firstName", "lastName", "gender", "birthDate");
+ Grid<Person> grid = createGrid();
+ grid.setItems(createTestData());
+ addComponent(grid);
+
+ grid.setColumns("firstName", "phone", "lastName", "zip");
grid.getColumn("firstName").setHidable(true);
+ grid.getColumn("phone").setHidable(true).setHidden(true);
grid.getColumn("lastName").setHidable(true).setHidden(true);
- grid.getColumn("gender").setHidable(true).setHidden(true);
- grid.getColumn("birthDate").setHidable(true);
+ grid.getColumn("zip").setHidable(true);
addComponent(grid);
- grid.addColumnResizeListener(new ColumnResizeListener() {
- @Override
- public void columnResize(ColumnResizeEvent event) {
- log(String.format("Column resized: id=%s, width=%s",
- event.getColumn().getPropertyId(),
- event.getColumn().getWidth()));
- }
+ grid.addColumnResizeListener(event -> {
+ log(String.format("Column resized: id=%s, width=%s",
+ event.getColumn().getId(), event.getColumn().getWidth()));
});
}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeTerror.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeTerror.java
index 41a1081113..c960d2363a 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeTerror.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridResizeTerror.java
@@ -13,32 +13,28 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
+
+import java.util.stream.IntStream;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.util.ResizeTerrorizer;
import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.ui.Grid;
import com.vaadin.ui.UI;
-import com.vaadin.v7.ui.Grid;
@Widgetset(TestingWidgetSet.NAME)
public class GridResizeTerror extends UI {
@Override
protected void init(VaadinRequest request) {
- Grid grid = new Grid();
+ Grid<Integer> grid = new Grid<>();
int cols = 10;
- Object[] data = new Object[cols];
- for (int i = 0; i < cols; i++) {
- grid.addColumn("Col " + i);
- data[i] = "Data " + i;
- }
+ IntStream.range(0, 10).forEach(i -> grid.addColumn(item -> "Data" + i));
- for (int i = 0; i < 500; i++) {
- grid.addRow(data);
- }
+ grid.setItems(IntStream.range(0, 500).boxed());
ResizeTerrorizer terrorizer = new ResizeTerrorizer(grid);
setContent(terrorizer);
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridRowHeightChange.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridRowHeightChange.java
index fd5b9b7665..34fc2048be 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridRowHeightChange.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridRowHeightChange.java
@@ -1,16 +1,16 @@
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.IntStream;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.grid.HeightMode;
import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
-import com.vaadin.v7.data.Property;
-import com.vaadin.v7.shared.ui.grid.HeightMode;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.NativeSelect;
public class GridRowHeightChange extends AbstractReindeerTestUI {
@@ -19,13 +19,12 @@ public class GridRowHeightChange extends AbstractReindeerTestUI {
@Override
protected void setup(VaadinRequest request) {
- Grid grid = new Grid();
+ Grid<Integer> grid = new Grid<>();
// create column and fill rows
- grid.addColumn("Header");
- for (int i = 1; i <= 10; i++) {
- grid.addRow("row_" + i);
- }
+ grid.addColumn(item -> "row_" + item).setCaption("Header");
+
+ grid.setItems(IntStream.range(1, 11).boxed());
// set height mode and height
grid.setHeightMode(HeightMode.ROW);
@@ -33,22 +32,21 @@ public class GridRowHeightChange extends AbstractReindeerTestUI {
// create a tabsheet with one tab and place grid inside
VerticalLayout tab = new VerticalLayout();
+ tab.setSpacing(false);
+ tab.setMargin(false);
TabSheet tabSheet = new TabSheet();
tabSheet.setWidthUndefined();
tabSheet.addTab(tab, "Tab");
tab.addComponent(grid);
// Theme selector
- NativeSelect themeSelector = new NativeSelect("Theme selector", themes);
- themeSelector.select("reindeer");
- themeSelector.setNullSelectionAllowed(false);
- themeSelector
- .addValueChangeListener(new Property.ValueChangeListener() {
- @Override
- public void valueChange(Property.ValueChangeEvent event) {
- setTheme((String) event.getProperty().getValue());
- }
- });
+ NativeSelect<String> themeSelector = new NativeSelect<>(
+ "Theme selector", themes);
+ themeSelector.setSelectedItem("reindeer");
+ themeSelector.setEmptySelectionAllowed(false);
+ themeSelector.addValueChangeListener(event -> {
+ setTheme(event.getValue());
+ });
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridScrollToLineWhileResizing.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizing.java
index 0806ced163..76ece763d2 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridScrollToLineWhileResizing.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizing.java
@@ -13,17 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
+
+import java.util.stream.IntStream;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.VerticalSplitPanel;
-import com.vaadin.v7.data.Item;
-import com.vaadin.v7.data.util.IndexedContainer;
-import com.vaadin.v7.event.SelectionEvent;
-import com.vaadin.v7.event.SelectionEvent.SelectionListener;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.SelectionMode;
public class GridScrollToLineWhileResizing extends AbstractReindeerTestUI {
@@ -36,28 +34,19 @@ public class GridScrollToLineWhileResizing extends AbstractReindeerTestUI {
vsp.setSplitPosition(100, Unit.PERCENTAGE);
addComponent(vsp);
- IndexedContainer indexedContainer = new IndexedContainer();
- indexedContainer.addContainerProperty("column1", String.class, "");
-
- for (int i = 0; i < 100; i++) {
- Item addItem = indexedContainer.addItem(i);
- addItem.getItemProperty("column1").setValue("cell" + i);
- }
-
- final Grid grid = new Grid(indexedContainer);
+ Grid<Integer> grid = new Grid<>();
+ grid.addColumn(item -> "cell" + item);
+ grid.setItems(IntStream.range(0, 100).boxed());
grid.setSizeFull();
grid.setSelectionMode(SelectionMode.SINGLE);
- grid.addSelectionListener(new SelectionListener() {
-
- @Override
- public void select(SelectionEvent event) {
- vsp.setSplitPosition(50, Unit.PERCENTAGE);
- grid.scrollTo(event.getSelected().iterator().next());
- }
+ grid.addSelectionListener(event -> {
+ vsp.setSplitPosition(50, Unit.PERCENTAGE);
+ grid.scrollTo(event.getFirstSelectedItem().get());
});
vsp.setFirstComponent(grid);
+
}
@Override
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSidebarPosition.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridSidebarPosition.java
index b8a3f8c58f..5dfe9bade3 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSidebarPosition.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridSidebarPosition.java
@@ -13,13 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
+import com.vaadin.data.ValueProvider;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Grid;
import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.v7.ui.Grid;
public class GridSidebarPosition extends AbstractTestUI {
@@ -33,33 +34,36 @@ public class GridSidebarPosition extends AbstractTestUI {
hl.setSpacing(true);
hl.setHeight("100%");
setContent(hl);
- Grid grid = new Grid("Popup window height");
+ Grid<String> grid = new Grid<>("Popup window height");
grid.setId(POPUP_WINDOW_HEIGHT);
grid.setWidth("100px");
for (int i = 0; i < 30; i++) {
- grid.addColumn(
- "This is a really really really really long column name "
- + i)
+ grid.addColumn(ValueProvider.identity())
+ .setCaption(
+ "This is a really really really really long column name "
+ + i)
.setHidable(true);
}
hl.addComponent(grid);
- grid = new Grid("Popup moved up");
+ grid = new Grid<>("Popup moved up");
grid.setId(POPUP_WINDOW_MOVED_UP);
grid.setWidth("100px");
grid.setHeight("400px");
for (int i = 0; i < 15; i++) {
- grid.addColumn("Column " + i).setHidable(true);
+ grid.addColumn(ValueProvider.identity()).setCaption("Column " + i)
+ .setHidable(true);
}
hl.addComponent(grid);
hl.setComponentAlignment(grid, Alignment.BOTTOM_LEFT);
- grid = new Grid("Popup above");
+ grid = new Grid<>("Popup above");
grid.setId(POPUP_ABOVE);
grid.setWidth("100px");
grid.setHeight("200px");
for (int i = 0; i < 10; i++) {
- grid.addColumn("Column " + i).setHidable(true);
+ grid.addColumn(ValueProvider.identity()).setCaption("Column " + i)
+ .setHidable(true);
}
hl.addComponent(grid);
hl.setComponentAlignment(grid, Alignment.BOTTOM_LEFT);
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSingleColumn.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridSingleColumn.java
index 12ba530d25..105da4f96f 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSingleColumn.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridSingleColumn.java
@@ -13,38 +13,31 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
+import java.util.stream.IntStream;
+
+import com.vaadin.data.ValueProvider;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
-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.Column;
-import com.vaadin.v7.ui.Grid.SelectionMode;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
+import com.vaadin.ui.Grid.SelectionMode;
public class GridSingleColumn extends AbstractReindeerTestUI {
@Override
protected void setup(VaadinRequest request) {
-
- IndexedContainer indexedContainer = new IndexedContainer();
- indexedContainer.addContainerProperty("column1", String.class, "");
-
- for (int i = 0; i < 100; i++) {
- Item addItem = indexedContainer.addItem(i);
- addItem.getItemProperty("column1").setValue("cell");
- }
-
- Grid grid = new Grid(indexedContainer);
+ Grid<String> grid = new Grid<>();
grid.setSelectionMode(SelectionMode.NONE);
- Column column = grid.getColumn("column1");
+ grid.setItems(IntStream.range(0, 100).mapToObj(indx -> "cell"));
- column.setHeaderCaption("Header");
+ Column<String, String> column = grid.addColumn(ValueProvider.identity())
+ .setCaption("Header");
addComponent(grid);
- grid.scrollTo(grid.getContainerDataSource().getIdByIndex(50));
+ grid.scrollTo(50);
}
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridSortIndicator.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridSortIndicator.java
new file mode 100644
index 0000000000..5176b25fbd
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridSortIndicator.java
@@ -0,0 +1,98 @@
+/*
+ * 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.data.provider.GridSortOrder;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.data.sort.SortDirection;
+import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.renderers.NumberRenderer;
+
+/*
+ * Test UI for checking that sort indicators of a Grid are updated when the sort order is changed by a
+ * SortListener.
+ */
+public class GridSortIndicator extends AbstractReindeerTestUI {
+
+ private SortDirection oldSortDirection = null;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Grid<Person> grid = getGrid();
+ addComponent(grid);
+ grid.addSortListener(order -> {
+ ArrayList<GridSortOrder<Person>> currentSortOrder = new ArrayList<>(
+ order.getSortOrder());
+ if (currentSortOrder.size() == 1) {
+ // If the name column was clicked, set a new sort order for
+ // both columns. Otherwise, revert to oldSortDirection if it
+ // is not null.
+ List<GridSortOrder<Person>> newSortOrder = new ArrayList<>();
+ SortDirection newSortDirection = oldSortDirection;
+ if (currentSortOrder.get(0).getSorted().getId()
+ .equals("name")) {
+ newSortDirection = SortDirection.ASCENDING
+ .equals(oldSortDirection) ? SortDirection.DESCENDING
+ : SortDirection.ASCENDING;
+ }
+ if (newSortDirection != null) {
+ newSortOrder.add(new GridSortOrder<>(grid.getColumn("name"),
+ newSortDirection));
+ newSortOrder.add(new GridSortOrder<>(grid.getColumn("age"),
+ newSortDirection));
+ grid.setSortOrder(newSortOrder);
+ }
+ oldSortDirection = newSortDirection;
+ }
+ });
+ }
+
+ private final Grid<Person> getGrid() {
+ Grid<Person> grid = new Grid<>();
+ grid.addColumn(Person::getFirstName).setId("name");
+ grid.addColumn(Person::getAge, new NumberRenderer()).setId("age");
+
+ grid.setItems(createPerson("a", 4), createPerson("b", 5),
+ createPerson("c", 3), createPerson("a", 6),
+ createPerson("a", 2), createPerson("c", 7),
+ createPerson("b", 1));
+ return grid;
+ }
+
+ private Person createPerson(String name, int age) {
+ Person person = new Person();
+ person.setFirstName(name);
+ person.setAge(age);
+ return person;
+ }
+
+ @Override
+ public String getTestDescription() {
+ return "When the first column is the primary sort column, both columns should have "
+ + "a sort indicator with the same sort direction. Clicking on the right column "
+ + "in that state should have no effect.";
+ }
+
+ @Override
+ public Integer getTicketNumber() {
+ return 17440;
+ }
+}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeAndScroll.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeAndScroll.java
deleted file mode 100644
index 70e3158a7f..0000000000
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridResizeAndScroll.java
+++ /dev/null
@@ -1,68 +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.data.Item;
-import com.vaadin.v7.data.util.IndexedContainer;
-import com.vaadin.v7.event.SelectionEvent;
-import com.vaadin.v7.event.SelectionEvent.SelectionListener;
-import com.vaadin.v7.ui.Grid;
-import com.vaadin.v7.ui.Grid.SelectionMode;
-
-public class GridResizeAndScroll extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- VerticalLayout content = new VerticalLayout();
- addComponent(content);
-
- final Grid g = new Grid();
- content.setHeight("500px");
- content.addComponent(g);
-
- IndexedContainer cont = new IndexedContainer();
- for (int j = 0; j < 3; j++) {
- cont.addContainerProperty("" + j, String.class, "");
- }
-
- for (int k = 0; k < 50; k++) {
- Item addItem = cont.addItem(k);
- for (int j = 0; j < 3; j++) {
- addItem.getItemProperty("" + j).setValue("cell " + k + " " + j);
- }
- }
- g.setContainerDataSource(cont);
- g.setSizeFull();
-
- g.setSelectionMode(SelectionMode.MULTI);
-
- g.addSelectionListener(new SelectionListener() {
-
- @Override
- public void select(SelectionEvent event) {
- if (g.getSelectedRows().isEmpty()) {
- g.setHeight("100%");
- } else {
- g.setHeight("50%");
- }
- }
- });
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridScrolling.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridScrolling.java
deleted file mode 100644
index 1287c74895..0000000000
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridScrolling.java
+++ /dev/null
@@ -1,112 +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.Button.ClickListener;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.v7.data.Item;
-import com.vaadin.v7.data.util.IndexedContainer;
-import com.vaadin.v7.shared.ui.grid.ScrollDestination;
-import com.vaadin.v7.ui.Grid;
-
-@SuppressWarnings("serial")
-public class GridScrolling extends AbstractReindeerTestUI {
-
- private Grid grid;
-
- private IndexedContainer ds;
-
- @Override
- @SuppressWarnings("unchecked")
- protected void setup(VaadinRequest request) {
- // Build data source
- ds = new IndexedContainer();
-
- for (int col = 0; col < 5; col++) {
- ds.addContainerProperty("col" + col, String.class, "");
- }
-
- for (int row = 0; row < 65536; row++) {
- Item item = ds.addItem(Integer.valueOf(row));
- for (int col = 0; col < 5; col++) {
- item.getItemProperty("col" + col)
- .setValue("(" + row + ", " + col + ")");
- }
- }
-
- grid = new Grid(ds);
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.addComponent(grid);
- hl.setMargin(true);
- hl.setSpacing(true);
-
- VerticalLayout vl = new VerticalLayout();
- vl.setSpacing(true);
-
- // Add scroll buttons
- Button scrollUpButton = new Button("Top", new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- grid.scrollToStart();
- }
- });
- scrollUpButton.setSizeFull();
- vl.addComponent(scrollUpButton);
-
- for (int i = 1; i < 7; ++i) {
- final int row = (ds.size() / 7) * i;
- Button scrollButton = new Button("Scroll to row " + row,
- new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- grid.scrollTo(Integer.valueOf(row),
- ScrollDestination.MIDDLE);
- }
- });
- scrollButton.setSizeFull();
- vl.addComponent(scrollButton);
- }
-
- Button scrollDownButton = new Button("Bottom", new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- grid.scrollToEnd();
- }
- });
- scrollDownButton.setSizeFull();
- vl.addComponent(scrollDownButton);
-
- hl.addComponent(vl);
- addComponent(hl);
- }
-
- @Override
- protected String getTestDescription() {
- return "Test Grid programmatic scrolling features";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 13327;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSortIndicator.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSortIndicator.java
deleted file mode 100644
index dac2939997..0000000000
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridSortIndicator.java
+++ /dev/null
@@ -1,96 +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 com.vaadin.server.VaadinRequest;
-import com.vaadin.shared.data.sort.SortDirection;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.data.sort.SortOrder;
-import com.vaadin.v7.event.SortEvent;
-import com.vaadin.v7.event.SortEvent.SortListener;
-import com.vaadin.v7.ui.Grid;
-
-/*
- * Test UI for checking that sort indicators of a Grid are updated when the sort order is changed by a
- * SortListener.
- */
-public class GridSortIndicator extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- final Grid g = getGrid();
- addComponent(g);
- g.addSortListener(new SortListener() {
- private SortDirection oldSortDirection = null;
-
- @Override
- public void sort(SortEvent event) {
- List<SortOrder> currentSortOrder = new ArrayList<>(
- event.getSortOrder());
- if (currentSortOrder.size() == 1) {
- // If the name column was clicked, set a new sort order for
- // both columns. Otherwise, revert to oldSortDirection if it
- // is not null.
- List<SortOrder> newSortOrder = new ArrayList<>();
- SortDirection newSortDirection = oldSortDirection;
- if (currentSortOrder.get(0).getPropertyId()
- .equals("Name")) {
- newSortDirection = SortDirection.ASCENDING.equals(
- oldSortDirection) ? SortDirection.DESCENDING
- : SortDirection.ASCENDING;
- }
- if (newSortDirection != null) {
- newSortOrder
- .add(new SortOrder("Name", newSortDirection));
- newSortOrder
- .add(new SortOrder("Value", newSortDirection));
- g.setSortOrder(newSortOrder);
- }
- oldSortDirection = newSortDirection;
- }
- }
- });
- }
-
- private final Grid getGrid() {
- Grid g = new Grid();
- g.addColumn("Name");
- g.addColumn("Value", Integer.class);
- g.addRow(new Object[] { "a", 4 });
- g.addRow(new Object[] { "b", 5 });
- g.addRow(new Object[] { "c", 3 });
- g.addRow(new Object[] { "a", 6 });
- g.addRow(new Object[] { "a", 2 });
- g.addRow(new Object[] { "c", 7 });
- g.addRow(new Object[] { "b", 1 });
- return g;
- }
-
- @Override
- public String getTestDescription() {
- return "When the first column is the primary sort column, both columns should have "
- + "a sort indicator with the same sort direction. Clicking on the right column "
- + "in that state should have no effect.";
- }
-
- @Override
- public Integer getTicketNumber() {
- return 17440;
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridResizeAndScrollTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java
index fc854b9b96..f226710313 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridResizeAndScrollTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridResizeHiddenColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java
index c300fdfdf2..3e28c846de 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridResizeHiddenColumnTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import java.util.List;
@@ -42,12 +42,12 @@ public class GridResizeHiddenColumnTest extends MultiBrowserTest {
GridElement grid = $(GridElement.class).first();
Actions action = new Actions(getDriver());
- // Check if column 'Gender' hidden
+ // Check if column 'Last Name' hidden
List<GridCellElement> headerCells = grid.getHeaderCells(0);
Assert.assertEquals("There should be two visible columns", 2,
headerCells.size());
- Assert.assertFalse("Gender column should be hidden",
- containsText("Gender", headerCells));
+ Assert.assertFalse("'Last Name' column should be hidden",
+ containsText("Last Name", headerCells));
// Resize first column
int dragOffset = -100;
@@ -63,30 +63,32 @@ public class GridResizeHiddenColumnTest extends MultiBrowserTest {
headerCellWidth + dragOffset,
headerCells.get(0).getSize().getWidth(), delta);
- // Make column 'Gender' visible
+ // Make column 'Last Name' visible
WebElement menuButton = grid.findElement(By.className("v-contextmenu"))
.findElement(By.tagName("button"));
action.click(menuButton).perform(); // Click on menu button
WebElement sidebarPopup = findElement(
By.className("v-grid-sidebar-popup"));
- WebElement visibilityToggle = findElementByText("Gender",
+ WebElement visibilityToggle = findElementByText("Last Name",
sidebarPopup.findElements(By.className("gwt-MenuItem")));
- action.click(visibilityToggle).perform(); // Click on 'Gender' menu item
+ action.click(visibilityToggle).perform(); // Click on "Last Name"
+ // menu item
- // Check if column 'Gender' is visible
+ // Check if column "Last Name" is visible
headerCells = grid.getHeaderCells(0);
Assert.assertEquals("There should be three visible columns", 3,
headerCells.size());
- Assert.assertTrue("Gender column should be visible",
- containsText("Gender", headerCells));
+ Assert.assertTrue("'Last Name' column should be visible",
+ containsText("Last Name", headerCells));
- // Check if column 'Gender' has expanded width
+ // Check if column "Last Name" has expanded width
int widthSum = 0;
for (GridCellElement e : headerCells) {
widthSum += e.getSize().getWidth();
}
- Assert.assertEquals("Gender column should take up the remaining space",
+ Assert.assertEquals(
+ "'Last Name' column should take up the remaining space",
grid.getHeader().getSize().getWidth(), widthSum, 1d);
}
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridRowHeightChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridRowHeightChangeTest.java
index 043151705e..18ecba5696 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridRowHeightChangeTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridRowHeightChangeTest.java
@@ -1,4 +1,4 @@
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridScrollToLineWhileResizingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java
index f410a2b260..2f614302c3 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridScrollToLineWhileResizingTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSidebarPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java
index 6fc42609f8..4b3fe2057a 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSidebarPositionTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import java.util.List;
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSingleColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java
index 7938aab220..01355e8801 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSingleColumnTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSortIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java
index be419828cf..3fc50223b1 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSortIndicatorTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java
@@ -13,10 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.v7.tests.components.grid;
+package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
+import org.junit.Ignore;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
@@ -27,6 +28,10 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridSortIndicatorTest extends MultiBrowserTest {
@Test
+ @Ignore
+ /*
+ * Should be enabled once #8316 is fixed.
+ */
public void testIndicators() throws InterruptedException {
openTestURL();
GridElement grid = $(GridElement.class).first();