diff options
author | Markus Koivisto <markus@vaadin.com> | 2016-04-05 16:08:09 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-05 16:13:17 +0300 |
commit | dffe1597cd97f2bbbd8300773cb99302aa9783e5 (patch) | |
tree | 5d6b7eefa3ba28f009ab2c85b08e813c78847f7c /uitest/src/com/vaadin/tests | |
parent | 4bce5d542c79bc914eb28be3d06678962bc5b744 (diff) | |
download | vaadin-framework-dffe1597cd97f2bbbd8300773cb99302aa9783e5.tar.gz vaadin-framework-dffe1597cd97f2bbbd8300773cb99302aa9783e5.zip |
Refresh grid body after resize (#19664)
Change-Id: I8531f9d39aaa5854108e1bee9db121b0e54be770
Diffstat (limited to 'uitest/src/com/vaadin/tests')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridResizeAndScroll.java | 68 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java | 45 |
2 files changed, 113 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridResizeAndScroll.java b/uitest/src/com/vaadin/tests/components/grid/GridResizeAndScroll.java new file mode 100644 index 0000000000..fe4a9884f5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridResizeAndScroll.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import com.vaadin.data.Item; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.event.SelectionEvent; +import com.vaadin.event.SelectionEvent.SelectionListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.SelectionMode; +import com.vaadin.ui.VerticalLayout; + +public class GridResizeAndScroll extends AbstractTestUI { + + @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/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java b/uitest/src/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java new file mode 100644 index 0000000000..52079c782c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.GridElement.GridCellElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridResizeAndScrollTest extends MultiBrowserTest { + + @Test + public void scrollAndClick() { + openTestURL(); + GridElement grid = $(GridElement.class).first(); + grid.scrollToRow(49); + // select a row (click on checkbox) + grid.getCell(49, 0).click(); + + // verify rows are what they should be + GridCellElement cell = grid.getCell(33, 1); + String textBefore = cell.getText(); + cell.click(); + + Assert.assertEquals("String contents changed on click", textBefore, + cell.getText()); + + } + +} |