From 6adc887b7f94f5fb6e83c34822358e2240018147 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 2 Jan 2017 13:04:26 +0200 Subject: Migrate Grid tests P1. (#8108) * Migrate Grid tests P1. Fixes vaadin/framework8-issues#586 --- .../vaadin/tests/components/grid/BeanRenderer.java | 26 +++++ .../tests/components/grid/CustomRendererUI.java | 111 +++++++++++++++++++++ .../tests/components/grid/IntArrayRenderer.java | 25 +++++ .../tests/components/grid/RowAwareRenderer.java | 36 +++++++ .../java/com/vaadin/tests/smoke/GridSmoke.java | 49 +++++++++ .../vaadin/tests/widgetset/client/EmptyEnum.java | 25 +++++ .../client/grid/IntArrayRendererConnector.java | 47 +++++++++ .../client/grid/PojoRendererConnector.java | 39 ++++++++ .../client/grid/RowAwareRendererConnector.java | 81 +++++++++++++++ .../client/v7/grid/IntArrayRendererConnector.java | 47 --------- .../client/v7/grid/PojoRendererConnector.java | 39 -------- .../client/v7/grid/RowAwareRendererConnector.java | 80 --------------- .../v7/tests/components/grid/BeanRenderer.java | 25 ----- .../v7/tests/components/grid/CustomRenderer.java | 91 ----------------- .../grid/GridAddAndRemoveDataOnInit.java | 62 ------------ .../v7/tests/components/grid/GridAddRow.java | 49 --------- .../grid/GridApplyFilterWhenScrolledDown.java | 62 ------------ .../v7/tests/components/grid/IntArrayRenderer.java | 24 ----- .../v7/tests/components/grid/RowAwareRenderer.java | 33 ------ .../tests/components/grid/CustomRendererTest.java | 73 ++++++++++++++ .../java/com/vaadin/tests/smoke/GridSmokeTest.java | 50 ++++++++++ .../tests/components/grid/CustomRendererTest.java | 70 ------------- .../grid/GridAddAndRemoveDataOnInitTest.java | 46 --------- .../v7/tests/components/grid/GridAddRowTest.java | 50 ---------- .../grid/GridApplyFilterWhenScrolledDownTest.java | 44 -------- .../tests/components/grid/NullRenderersTest.java | 4 - 26 files changed, 562 insertions(+), 726 deletions(-) create mode 100644 uitest/src/main/java/com/vaadin/tests/components/grid/BeanRenderer.java create mode 100644 uitest/src/main/java/com/vaadin/tests/components/grid/CustomRendererUI.java create mode 100644 uitest/src/main/java/com/vaadin/tests/components/grid/IntArrayRenderer.java create mode 100644 uitest/src/main/java/com/vaadin/tests/components/grid/RowAwareRenderer.java create mode 100644 uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java create mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/EmptyEnum.java create mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/IntArrayRendererConnector.java create mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/PojoRendererConnector.java create mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/RowAwareRendererConnector.java delete mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/IntArrayRendererConnector.java delete mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/PojoRendererConnector.java delete mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/RowAwareRendererConnector.java delete mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/grid/BeanRenderer.java delete mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/grid/CustomRenderer.java delete mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInit.java delete mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddRow.java delete mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDown.java delete mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/grid/IntArrayRenderer.java delete mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/grid/RowAwareRenderer.java create mode 100644 uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java create mode 100644 uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java delete mode 100644 uitest/src/test/java/com/vaadin/v7/tests/components/grid/CustomRendererTest.java delete mode 100644 uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInitTest.java delete mode 100644 uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddRowTest.java delete mode 100644 uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/BeanRenderer.java b/uitest/src/main/java/com/vaadin/tests/components/grid/BeanRenderer.java new file mode 100644 index 0000000000..09d793588e --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/BeanRenderer.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import com.vaadin.tests.components.grid.CustomRendererUI.Data; +import com.vaadin.tests.widgetset.client.SimpleTestBean; +import com.vaadin.ui.renderers.AbstractRenderer; + +public class BeanRenderer extends AbstractRenderer { + public BeanRenderer() { + super(SimpleTestBean.class, ""); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/CustomRendererUI.java b/uitest/src/main/java/com/vaadin/tests/components/grid/CustomRendererUI.java new file mode 100644 index 0000000000..980a635cd4 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/CustomRendererUI.java @@ -0,0 +1,111 @@ +/* + * 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.AbstractTestUI; +import com.vaadin.tests.widgetset.TestingWidgetSet; +import com.vaadin.tests.widgetset.client.EmptyEnum; +import com.vaadin.tests.widgetset.client.SimpleTestBean; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.SelectionMode; +import com.vaadin.ui.Label; + +@Widgetset(TestingWidgetSet.NAME) +public class CustomRendererUI extends AbstractTestUI { + + public static class Data { + private int[] array; + + private EmptyEnum emptyProperty; + + private SimpleTestBean bean; + + private final String id; + + public Data(String id) { + this.id = id; + } + + public int[] getArray() { + return array; + } + + public void setArray(int[] array) { + this.array = array; + } + + public EmptyEnum getEmptyProperty() { + return emptyProperty; + } + + public void setEmptyProperty(EmptyEnum emptyProperty) { + this.emptyProperty = emptyProperty; + } + + public SimpleTestBean getBean() { + return bean; + } + + public void setBean(SimpleTestBean bean) { + this.bean = bean; + } + + @Override + public String toString() { + return id; + } + } + + @Override + protected void setup(VaadinRequest request) { + Data data = new Data("test-data"); + data.setArray(new int[] { 1, 1, 2, 3, 5, 8, 13 }); + + SimpleTestBean bean = new SimpleTestBean(); + bean.setValue(42); + data.setBean(bean); + + Grid grid = new Grid<>(); + + Label debugLabel = new Label("Debug label placeholder"); + debugLabel.setId("debuglabel"); + grid.addColumn(Data::getArray, new IntArrayRenderer()); + grid.addColumn(Data::getEmptyProperty, + new RowAwareRenderer(debugLabel)); + grid.addColumn(Data::getBean, new BeanRenderer()); + + grid.setSelectionMode(SelectionMode.NONE); + + grid.setItems(data); + + addComponent(grid); + addComponent(debugLabel); + } + + @Override + protected String getTestDescription() { + return "Verifies that renderers operating on other data than " + + "just Strings also work "; + } + + @Override + protected Integer getTicketNumber() { + return 13334; + } + +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/IntArrayRenderer.java b/uitest/src/main/java/com/vaadin/tests/components/grid/IntArrayRenderer.java new file mode 100644 index 0000000000..effdc832ac --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/IntArrayRenderer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import com.vaadin.tests.components.grid.CustomRendererUI.Data; +import com.vaadin.ui.renderers.AbstractRenderer; + +public class IntArrayRenderer extends AbstractRenderer { + public IntArrayRenderer() { + super(int[].class, ""); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/RowAwareRenderer.java b/uitest/src/main/java/com/vaadin/tests/components/grid/RowAwareRenderer.java new file mode 100644 index 0000000000..49b7808291 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/RowAwareRenderer.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import com.vaadin.tests.components.grid.CustomRendererUI.Data; +import com.vaadin.tests.widgetset.client.EmptyEnum; +import com.vaadin.tests.widgetset.client.grid.RowAwareRendererConnector.RowAwareRendererRpc; +import com.vaadin.ui.Label; +import com.vaadin.ui.renderers.AbstractRenderer; + +public class RowAwareRenderer extends AbstractRenderer { + public RowAwareRenderer(final Label debugLabel) { + super(EmptyEnum.class, ""); + registerRpc(new RowAwareRendererRpc() { + @Override + public void clicky(String key) { + Data data = getParentGrid().getDataCommunicator().getKeyMapper() + .get(key); + debugLabel.setValue("key: " + key + ", itemId: " + data); + } + }); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java b/uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java new file mode 100644 index 0000000000..ebca101d08 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java @@ -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.smoke; + +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.ui.Grid; +import com.vaadin.v7.ui.Grid.SelectionMode; + +public class GridSmoke extends AbstractReindeerTestUI { + + @Override + protected void setup(VaadinRequest request) { + + final Grid grid = new Grid(); + grid.setSelectionMode(SelectionMode.MULTI); + grid.addColumn("firstName"); + grid.addColumn("age", Integer.class); + + grid.addRow("Lorem", Integer.valueOf(1)); + grid.addRow("Ipsum", Integer.valueOf(2)); + + addComponent(grid); + + addComponent(new Button("Add new row", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + grid.addRow("Dolor", Integer.valueOf(3)); + } + })); + + } + +} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/EmptyEnum.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/EmptyEnum.java new file mode 100644 index 0000000000..6e0b97eea7 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/EmptyEnum.java @@ -0,0 +1,25 @@ +/* + * 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; + +/** + * @author Vaadin Ltd + * + */ +public enum EmptyEnum { + +} + diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/IntArrayRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/IntArrayRendererConnector.java new file mode 100644 index 0000000000..face2a95e0 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/IntArrayRendererConnector.java @@ -0,0 +1,47 @@ +/* + * 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 com.vaadin.client.connectors.grid.AbstractGridRendererConnector; +import com.vaadin.client.renderers.Renderer; +import com.vaadin.client.widget.grid.RendererCellReference; +import com.vaadin.shared.ui.Connect; + +@Connect(com.vaadin.tests.components.grid.IntArrayRenderer.class) +public class IntArrayRendererConnector + extends AbstractGridRendererConnector { + + public static class IntArrayRenderer implements Renderer { + private static final String JOINER = " :: "; + + @Override + public void render(RendererCellReference cell, int[] data) { + String text = ""; + for (int i : data) { + text += i + JOINER; + } + if (!text.isEmpty()) { + text = text.substring(0, text.length() - JOINER.length()); + } + cell.getElement().setInnerText(text); + } + } + + @Override + public IntArrayRenderer getRenderer() { + return (IntArrayRenderer) super.getRenderer(); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/PojoRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/PojoRendererConnector.java new file mode 100644 index 0000000000..a74db261eb --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/PojoRendererConnector.java @@ -0,0 +1,39 @@ +/* + * 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 com.vaadin.client.connectors.grid.AbstractGridRendererConnector; +import com.vaadin.client.renderers.Renderer; +import com.vaadin.client.widget.grid.RendererCellReference; +import com.vaadin.shared.ui.Connect; +import com.vaadin.tests.widgetset.client.SimpleTestBean; + +@Connect(com.vaadin.tests.components.grid.BeanRenderer.class) +public class PojoRendererConnector + extends AbstractGridRendererConnector { + + public static class BeanRenderer implements Renderer { + @Override + public void render(RendererCellReference cell, SimpleTestBean bean) { + cell.getElement().setInnerText(bean.toString()); + } + } + + @Override + public BeanRenderer getRenderer() { + return (BeanRenderer) super.getRenderer(); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/RowAwareRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/RowAwareRendererConnector.java new file mode 100644 index 0000000000..dd06c005a4 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/RowAwareRendererConnector.java @@ -0,0 +1,81 @@ +/* + * 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.Arrays; +import java.util.Collection; + +import com.google.gwt.dom.client.BrowserEvents; +import com.google.gwt.dom.client.DivElement; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.user.client.DOM; +import com.vaadin.client.connectors.grid.AbstractGridRendererConnector; +import com.vaadin.client.renderers.ComplexRenderer; +import com.vaadin.client.renderers.Renderer; +import com.vaadin.client.widget.grid.CellReference; +import com.vaadin.client.widget.grid.RendererCellReference; +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.Connect; +import com.vaadin.tests.widgetset.client.EmptyEnum; + +import elemental.json.JsonObject; + +@Connect(com.vaadin.tests.components.grid.RowAwareRenderer.class) +public class RowAwareRendererConnector + extends AbstractGridRendererConnector { + public interface RowAwareRendererRpc extends ServerRpc { + void clicky(String key); + } + + public class RowAwareRenderer extends ComplexRenderer { + + @Override + public Collection getConsumedEvents() { + return Arrays.asList(BrowserEvents.CLICK); + } + + @Override + public void init(RendererCellReference cell) { + DivElement div = DivElement.as(DOM.createDiv()); + div.setAttribute("style", + "border: 1px solid red; background: pink;"); + div.setInnerText("Click me!"); + cell.getElement().appendChild(div); + } + + @Override + public void render(RendererCellReference cell, EmptyEnum data) { + // NOOP + } + + @Override + public boolean onBrowserEvent(CellReference cell, + NativeEvent event) { + String key = getRowKey((JsonObject) cell.getRow()); + getRpcProxy(RowAwareRendererRpc.class).clicky(key); + cell.getElement().setInnerText( + "row: " + cell.getRowIndex() + ", key: " + key); + return true; + } + } + + @Override + protected Renderer createRenderer() { + // cannot use the default createRenderer as RowAwareRenderer needs a + // reference to its connector - it has no "real" no-argument constructor + return new RowAwareRenderer(); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/IntArrayRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/IntArrayRendererConnector.java deleted file mode 100644 index 28056c4b47..0000000000 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/IntArrayRendererConnector.java +++ /dev/null @@ -1,47 +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 com.vaadin.shared.ui.Connect; -import com.vaadin.v7.client.connectors.AbstractGridRendererConnector; -import com.vaadin.v7.client.renderers.Renderer; -import com.vaadin.v7.client.widget.grid.RendererCellReference; - -@Connect(com.vaadin.v7.tests.components.grid.IntArrayRenderer.class) -public class IntArrayRendererConnector - extends AbstractGridRendererConnector { - - public static class IntArrayRenderer implements Renderer { - private static final String JOINER = " :: "; - - @Override - public void render(RendererCellReference cell, int[] data) { - String text = ""; - for (int i : data) { - text += i + JOINER; - } - if (!text.isEmpty()) { - text = text.substring(0, text.length() - JOINER.length()); - } - cell.getElement().setInnerText(text); - } - } - - @Override - public IntArrayRenderer getRenderer() { - return (IntArrayRenderer) super.getRenderer(); - } -} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/PojoRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/PojoRendererConnector.java deleted file mode 100644 index fdbdd324a7..0000000000 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/PojoRendererConnector.java +++ /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.tests.widgetset.client.v7.grid; - -import com.vaadin.shared.ui.Connect; -import com.vaadin.tests.widgetset.client.SimpleTestBean; -import com.vaadin.v7.client.connectors.AbstractGridRendererConnector; -import com.vaadin.v7.client.renderers.Renderer; -import com.vaadin.v7.client.widget.grid.RendererCellReference; - -@Connect(com.vaadin.v7.tests.components.grid.BeanRenderer.class) -public class PojoRendererConnector - extends AbstractGridRendererConnector { - - public static class BeanRenderer implements Renderer { - @Override - public void render(RendererCellReference cell, SimpleTestBean bean) { - cell.getElement().setInnerText(bean.toString()); - } - } - - @Override - public BeanRenderer getRenderer() { - return (BeanRenderer) super.getRenderer(); - } -} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/RowAwareRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/RowAwareRendererConnector.java deleted file mode 100644 index ff541b8741..0000000000 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/RowAwareRendererConnector.java +++ /dev/null @@ -1,80 +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.Arrays; -import java.util.Collection; - -import com.google.gwt.dom.client.BrowserEvents; -import com.google.gwt.dom.client.DivElement; -import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.user.client.DOM; -import com.vaadin.shared.communication.ServerRpc; -import com.vaadin.shared.ui.Connect; -import com.vaadin.v7.client.connectors.AbstractGridRendererConnector; -import com.vaadin.v7.client.renderers.ComplexRenderer; -import com.vaadin.v7.client.renderers.Renderer; -import com.vaadin.v7.client.widget.grid.CellReference; -import com.vaadin.v7.client.widget.grid.RendererCellReference; - -import elemental.json.JsonObject; - -@Connect(com.vaadin.v7.tests.components.grid.RowAwareRenderer.class) -public class RowAwareRendererConnector - extends AbstractGridRendererConnector { - public interface RowAwareRendererRpc extends ServerRpc { - void clicky(String key); - } - - public class RowAwareRenderer extends ComplexRenderer { - - @Override - public Collection getConsumedEvents() { - return Arrays.asList(BrowserEvents.CLICK); - } - - @Override - public void init(RendererCellReference cell) { - DivElement div = DivElement.as(DOM.createDiv()); - div.setAttribute("style", - "border: 1px solid red; background: pink;"); - div.setInnerText("Click me!"); - cell.getElement().appendChild(div); - } - - @Override - public void render(RendererCellReference cell, Void data) { - // NOOP - } - - @Override - public boolean onBrowserEvent(CellReference cell, - NativeEvent event) { - String key = getRowKey((JsonObject) cell.getRow()); - getRpcProxy(RowAwareRendererRpc.class).clicky(key); - cell.getElement().setInnerText( - "row: " + cell.getRowIndex() + ", key: " + key); - return true; - } - } - - @Override - protected Renderer createRenderer() { - // cannot use the default createRenderer as RowAwareRenderer needs a - // reference to its connector - it has no "real" no-argument constructor - return new RowAwareRenderer(); - } -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/BeanRenderer.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/BeanRenderer.java deleted file mode 100644 index c3036e93b4..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/BeanRenderer.java +++ /dev/null @@ -1,25 +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.tests.widgetset.client.SimpleTestBean; -import com.vaadin.v7.ui.Grid.AbstractRenderer; - -public class BeanRenderer extends AbstractRenderer { - public BeanRenderer() { - super(SimpleTestBean.class, ""); - } -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/CustomRenderer.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/CustomRenderer.java deleted file mode 100644 index 5c7d1deb1b..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/CustomRenderer.java +++ /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.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.SimpleTestBean; -import com.vaadin.ui.Label; -import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.util.IndexedContainer; -import com.vaadin.v7.ui.Grid; -import com.vaadin.v7.ui.Grid.SelectionMode; - -@Widgetset(TestingWidgetSet.NAME) -public class CustomRenderer extends AbstractReindeerTestUI { - - private static final Object INT_ARRAY_PROPERTY = "int array"; - private static final Object VOID_PROPERTY = "void"; - private static final Object BEAN_PROPERTY = "pojo"; - - static final Object ITEM_ID = "itemId1"; - static final String DEBUG_LABEL_ID = "debuglabel"; - static final String INIT_DEBUG_LABEL_CAPTION = "Debug label placeholder"; - - @Override - protected void setup(VaadinRequest request) { - IndexedContainer container = new IndexedContainer(); - container.addContainerProperty(INT_ARRAY_PROPERTY, int[].class, - new int[] {}); - container.addContainerProperty(VOID_PROPERTY, Void.class, null); - container.addContainerProperty(BEAN_PROPERTY, SimpleTestBean.class, - null); - - Item item = container.addItem(ITEM_ID); - - @SuppressWarnings("unchecked") - Property propertyIntArray = item - .getItemProperty(INT_ARRAY_PROPERTY); - propertyIntArray.setValue(new int[] { 1, 1, 2, 3, 5, 8, 13 }); - - @SuppressWarnings("unchecked") - Property propertyPojo = item - .getItemProperty(BEAN_PROPERTY); - SimpleTestBean bean = new SimpleTestBean(); - bean.setValue(42); - propertyPojo.setValue(bean); - - Label debugLabel = new Label(INIT_DEBUG_LABEL_CAPTION); - debugLabel.setId(DEBUG_LABEL_ID); - - Grid grid = new Grid(container); - - grid.getColumn(INT_ARRAY_PROPERTY).setRenderer(new IntArrayRenderer()); - grid.getColumn(VOID_PROPERTY) - .setRenderer(new RowAwareRenderer(debugLabel)); - grid.getColumn(BEAN_PROPERTY).setRenderer(new BeanRenderer()); - - grid.setSelectionMode(SelectionMode.NONE); - - addComponent(grid); - addComponent(debugLabel); - } - - @Override - protected String getTestDescription() { - return "Verifies that renderers operating on other data than " - + "just Strings also work "; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(13334); - } - -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInit.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInit.java deleted file mode 100644 index d759bb27ad..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInit.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.v7.tests.components.grid; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.v7.data.Container.Indexed; -import com.vaadin.v7.data.util.IndexedContainer; -import com.vaadin.v7.ui.Grid; - -public class GridAddAndRemoveDataOnInit extends AbstractReindeerTestUI { - - @Override - protected void setup(VaadinRequest request) { - Grid gridAdd = new Grid(); - gridAdd.setHeight("240px"); - gridAdd.setWidth("140px"); - addComponent(gridAdd); - Indexed dataSource = gridAdd.getContainerDataSource(); - dataSource.addContainerProperty("foo", Integer.class, 0); - for (int i = 0; i < 10; ++i) { - Object id = dataSource.addItem(); - dataSource.getItem(id).getItemProperty("foo").setValue(i); - } - dataSource = new IndexedContainer(); - dataSource.addContainerProperty("bar", Integer.class, 0); - for (int i = 0; i < 10; ++i) { - Object id = dataSource.addItem(); - dataSource.getItem(id).getItemProperty("bar").setValue(i); - } - Grid gridRemove = new Grid(dataSource); - gridRemove.setHeight("150px"); - gridRemove.setWidth("140px"); - addComponent(gridRemove); - for (int i = 0; i < 5; ++i) { - dataSource.removeItem(dataSource.getIdByIndex(i)); - } - } - - @Override - protected String getTestDescription() { - return "Foo"; - } - - @Override - protected Integer getTicketNumber() { - return 13334; - } -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddRow.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddRow.java deleted file mode 100644 index 3ee500d78a..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridAddRow.java +++ /dev/null @@ -1,49 +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.ui.Grid; -import com.vaadin.v7.ui.Grid.SelectionMode; - -public class GridAddRow extends AbstractReindeerTestUI { - - @Override - protected void setup(VaadinRequest request) { - - final Grid grid = new Grid(); - grid.setSelectionMode(SelectionMode.MULTI); - grid.addColumn("firstName"); - grid.addColumn("age", Integer.class); - - grid.addRow("Lorem", Integer.valueOf(1)); - grid.addRow("Ipsum", Integer.valueOf(2)); - - addComponent(grid); - - addComponent(new Button("Add new row", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - grid.addRow("Dolor", Integer.valueOf(3)); - } - })); - - } - -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDown.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDown.java deleted file mode 100644 index f2255389c2..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDown.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.vaadin.v7.tests.components.grid; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.ui.UI; -import com.vaadin.ui.themes.ValoTheme; -import com.vaadin.v7.data.Container.Filterable; -import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.util.filter.SimpleStringFilter; -import com.vaadin.v7.event.FieldEvents.TextChangeEvent; -import com.vaadin.v7.event.FieldEvents.TextChangeListener; -import com.vaadin.v7.ui.Grid; -import com.vaadin.v7.ui.Grid.HeaderRow; -import com.vaadin.v7.ui.TextField; - -public class GridApplyFilterWhenScrolledDown extends UI { - - private Grid grid = new Grid(); - - @Override - protected void init(VaadinRequest vaadinRequest) { - - grid.addColumn("Name", String.class); - - HeaderRow appendHeaderRow = grid.appendHeaderRow(); - TextField filter = getColumnFilter("Name"); - appendHeaderRow.getCell("Name").setComponent(filter); - - for (int i = 0; i < 1000; i++) { - Item addItem = grid.getContainerDataSource().addItem(i); - addItem.getItemProperty("Name").setValue("Name " + i); - - } - - Item addItem = grid.getContainerDataSource().addItem(1000); - addItem.getItemProperty("Name").setValue("Test"); - - // grid.scrollToStart(); - setContent(grid); - } - - private TextField getColumnFilter(final Object columnId) { - TextField filter = new TextField(); - filter.setWidth("100%"); - filter.addStyleName(ValoTheme.TEXTFIELD_TINY); - filter.addTextChangeListener(new TextChangeListener() { - SimpleStringFilter filter = null; - - @Override - public void textChange(TextChangeEvent event) { - Filterable f = (Filterable) grid.getContainerDataSource(); - if (filter != null) { - f.removeContainerFilter(filter); - } - filter = new SimpleStringFilter(columnId, event.getText(), true, - true); - f.addContainerFilter(filter); - } - }); - return filter; - } - -} \ No newline at end of file diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/IntArrayRenderer.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/IntArrayRenderer.java deleted file mode 100644 index a50d7dd251..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/IntArrayRenderer.java +++ /dev/null @@ -1,24 +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.v7.ui.Grid.AbstractRenderer; - -public class IntArrayRenderer extends AbstractRenderer { - public IntArrayRenderer() { - super(int[].class, ""); - } -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/RowAwareRenderer.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/RowAwareRenderer.java deleted file mode 100644 index 288116b630..0000000000 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/RowAwareRenderer.java +++ /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.tests.widgetset.client.v7.grid.RowAwareRendererConnector.RowAwareRendererRpc; -import com.vaadin.ui.Label; -import com.vaadin.v7.ui.Grid.AbstractRenderer; - -public class RowAwareRenderer extends AbstractRenderer { - public RowAwareRenderer(final Label debugLabel) { - super(Void.class, ""); - registerRpc(new RowAwareRendererRpc() { - @Override - public void clicky(String key) { - Object itemId = getItemId(key); - debugLabel.setValue("key: " + key + ", itemId: " + itemId); - } - }); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java new file mode 100644 index 0000000000..4e79de561e --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java @@ -0,0 +1,73 @@ +/* + * 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.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.customelements.GridElement; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +@TestCategory("grid") +public class CustomRendererTest extends MultiBrowserTest { + @Test + public void testIntArrayIsRendered() throws Exception { + openTestURL(); + + GridElement grid = findGrid(); + assertEquals("1 :: 1 :: 2 :: 3 :: 5 :: 8 :: 13", + grid.getCell(0, 0).getText()); + } + + @Test + public void testRowAwareRenderer() throws Exception { + openTestURL(); + + GridElement grid = findGrid(); + assertEquals("Click me!", grid.getCell(0, 1).getText()); + assertEquals("Debug label placeholder", findDebugLabel().getText()); + + grid.getCell(0, 1).click(); + assertEquals("row: 0, key: 1", grid.getCell(0, 1).getText()); + assertEquals("key: 1, itemId: test-data", findDebugLabel().getText()); + } + + @Test + public void testBeanRenderer() throws Exception { + openTestURL(); + + assertEquals("SimpleTestBean(42)", findGrid().getCell(0, 2).getText()); + } + + private GridElement findGrid() { + List elements = $(GridElement.class).all(); + return elements.get(0); + } + + private LabelElement findDebugLabel() { + return $(LabelElement.class).id("debuglabel"); + } + + @Override + protected Class getUIClass() { + return CustomRendererUI.class; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java new file mode 100644 index 0000000000..495919f00b --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java @@ -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.smoke; + +import org.junit.Assert; +import org.junit.Test; + +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 GridSmokeTest extends MultiBrowserTest { + @Test + public void testAddRow() { + openTestURL(); + + GridElement grid = $(GridElement.class).first(); + + Assert.assertEquals("Lorem", grid.getCell(0, 1).getText()); + Assert.assertEquals("2", grid.getCell(1, 2).getText()); + + addRow(); + + Assert.assertEquals("Dolor", grid.getCell(2, 1).getText()); + + addRow(); + + Assert.assertEquals("Dolor", grid.getCell(3, 1).getText()); + } + + private void addRow() { + $(ButtonElement.class).caption("Add new row").first().click(); + } + +} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/CustomRendererTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/CustomRendererTest.java deleted file mode 100644 index c812e4a942..0000000000 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/CustomRendererTest.java +++ /dev/null @@ -1,70 +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 java.util.List; - -import org.junit.Test; - -import com.vaadin.testbench.customelements.GridElement; -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.testbench.parallel.TestCategory; -import com.vaadin.tests.tb3.MultiBrowserTest; - -@TestCategory("grid") -public class CustomRendererTest extends MultiBrowserTest { - @Test - public void testIntArrayIsRendered() throws Exception { - openTestURL(); - - GridElement grid = findGrid(); - assertEquals("1 :: 1 :: 2 :: 3 :: 5 :: 8 :: 13", - grid.getCell(0, 0).getText()); - } - - @Test - public void testRowAwareRenderer() throws Exception { - openTestURL(); - - GridElement grid = findGrid(); - assertEquals("Click me!", grid.getCell(0, 1).getText()); - assertEquals(CustomRenderer.INIT_DEBUG_LABEL_CAPTION, - findDebugLabel().getText()); - - grid.getCell(0, 1).click(); - assertEquals("row: 0, key: 1", grid.getCell(0, 1).getText()); - assertEquals("key: 1, itemId: " + CustomRenderer.ITEM_ID, - findDebugLabel().getText()); - } - - @Test - public void testBeanRenderer() throws Exception { - openTestURL(); - - assertEquals("SimpleTestBean(42)", findGrid().getCell(0, 2).getText()); - } - - private GridElement findGrid() { - List elements = $(GridElement.class).all(); - return elements.get(0); - } - - private LabelElement findDebugLabel() { - return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID); - } -} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInitTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInitTest.java deleted file mode 100644 index 0ea6f78c95..0000000000 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddAndRemoveDataOnInitTest.java +++ /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 org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.By; -import com.vaadin.testbench.customelements.GridElement; -import com.vaadin.testbench.parallel.TestCategory; -import com.vaadin.tests.tb3.MultiBrowserTest; - -@TestCategory("grid") -public class GridAddAndRemoveDataOnInitTest extends MultiBrowserTest { - - @Test - public void verifyGridSizes() { - openTestURL(); - - GridElement gridAdd = $(GridElement.class).first(); - if (!gridAdd.isElementPresent(By.vaadin("#cell[9][0]")) - || gridAdd.isElementPresent(By.vaadin("#cell[10][0]"))) { - Assert.fail("Grid with added data contained incorrect rows"); - } - - GridElement gridRemove = $(GridElement.class).get(1); - if (!gridRemove.isElementPresent(By.vaadin("#cell[4][0]")) - || gridRemove.isElementPresent(By.vaadin("#cell[5][0]"))) { - Assert.fail("Grid with removed data contained incorrect rows"); - } - } - -} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddRowTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddRowTest.java deleted file mode 100644 index 928aa9334a..0000000000 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridAddRowTest.java +++ /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 org.junit.Assert; -import org.junit.Test; - -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 GridAddRowTest extends MultiBrowserTest { - @Test - public void testAddRow() { - openTestURL(); - - GridElement grid = $(GridElement.class).first(); - - Assert.assertEquals("Lorem", grid.getCell(0, 1).getText()); - Assert.assertEquals("2", grid.getCell(1, 2).getText()); - - addRow(); - - Assert.assertEquals("Dolor", grid.getCell(2, 1).getText()); - - addRow(); - - Assert.assertEquals("Dolor", grid.getCell(3, 1).getText()); - } - - private void addRow() { - $(ButtonElement.class).caption("Add new row").first().click(); - } - -} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java deleted file mode 100644 index 9a14c01146..0000000000 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.vaadin.v7.tests.components.grid; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -import com.vaadin.testbench.By; -import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.GridElement; -import com.vaadin.testbench.elements.TextFieldElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class GridApplyFilterWhenScrolledDownTest extends MultiBrowserTest { - - @Test - public void scrolledCorrectly() throws InterruptedException { - openTestURL(); - final GridElement grid = $(GridElement.class).first(); - grid.scrollToRow(50); - $(TextFieldElement.class).first().setValue("Test"); - final TestBenchElement gridBody = grid.getBody(); - // Can't use element API because it scrolls - waitUntil(new ExpectedCondition() { - - @Override - public Boolean apply(WebDriver input) { - return gridBody.findElements(By.className("v-grid-row")) - .size() == 1; - } - }); - WebElement cell = gridBody.findElements(By.className("v-grid-cell")) - .get(0); - Assert.assertEquals("Test", cell.getText()); - - int gridHeight = grid.getSize().getHeight(); - int scrollerHeight = grid.getVerticalScroller().getSize().getHeight(); - Assert.assertTrue( - "Scroller height is " + scrollerHeight - + ", should be smaller than grid height: " + gridHeight, - scrollerHeight < gridHeight); - } -} \ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullRenderersTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullRenderersTest.java index c0f74de039..036e56ea4d 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullRenderersTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullRenderersTest.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import com.vaadin.testbench.customelements.GridElement; -import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -58,7 +57,4 @@ public class NullRenderersTest extends MultiBrowserTest { return $(GridElement.class).id("test-grid"); } - private LabelElement findDebugLabel() { - return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID); - } } -- cgit v1.2.3