* Migrate Grid tests P1. Fixes vaadin/framework8-issues#586tags/8.0.0.beta2
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.v7.tests.components.grid; | |||||
package com.vaadin.tests.components.grid; | |||||
import com.vaadin.tests.components.grid.CustomRendererUI.Data; | |||||
import com.vaadin.tests.widgetset.client.SimpleTestBean; | import com.vaadin.tests.widgetset.client.SimpleTestBean; | ||||
import com.vaadin.v7.ui.Grid.AbstractRenderer; | |||||
import com.vaadin.ui.renderers.AbstractRenderer; | |||||
public class BeanRenderer extends AbstractRenderer<SimpleTestBean> { | |||||
public class BeanRenderer extends AbstractRenderer<Data, SimpleTestBean> { | |||||
public BeanRenderer() { | public BeanRenderer() { | ||||
super(SimpleTestBean.class, ""); | super(SimpleTestBean.class, ""); | ||||
} | } |
/* | |||||
* 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<Data> 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; | |||||
} | |||||
} |
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.v7.tests.components.grid; | |||||
package com.vaadin.tests.components.grid; | |||||
import com.vaadin.v7.ui.Grid.AbstractRenderer; | |||||
import com.vaadin.tests.components.grid.CustomRendererUI.Data; | |||||
import com.vaadin.ui.renderers.AbstractRenderer; | |||||
public class IntArrayRenderer extends AbstractRenderer<int[]> { | |||||
public class IntArrayRenderer extends AbstractRenderer<Data, int[]> { | |||||
public IntArrayRenderer() { | public IntArrayRenderer() { | ||||
super(int[].class, ""); | super(int[].class, ""); | ||||
} | } |
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.v7.tests.components.grid; | |||||
package com.vaadin.tests.components.grid; | |||||
import com.vaadin.tests.widgetset.client.v7.grid.RowAwareRendererConnector.RowAwareRendererRpc; | |||||
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.Label; | ||||
import com.vaadin.v7.ui.Grid.AbstractRenderer; | |||||
import com.vaadin.ui.renderers.AbstractRenderer; | |||||
public class RowAwareRenderer extends AbstractRenderer<Void> { | |||||
public class RowAwareRenderer extends AbstractRenderer<Data, EmptyEnum> { | |||||
public RowAwareRenderer(final Label debugLabel) { | public RowAwareRenderer(final Label debugLabel) { | ||||
super(Void.class, ""); | |||||
super(EmptyEnum.class, ""); | |||||
registerRpc(new RowAwareRendererRpc() { | registerRpc(new RowAwareRendererRpc() { | ||||
@Override | @Override | ||||
public void clicky(String key) { | public void clicky(String key) { | ||||
Object itemId = getItemId(key); | |||||
debugLabel.setValue("key: " + key + ", itemId: " + itemId); | |||||
Data data = getParentGrid().getDataCommunicator().getKeyMapper() | |||||
.get(key); | |||||
debugLabel.setValue("key: " + key + ", itemId: " + data); | |||||
} | } | ||||
}); | }); | ||||
} | } |
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.v7.tests.components.grid; | |||||
package com.vaadin.tests.smoke; | |||||
import com.vaadin.server.VaadinRequest; | import com.vaadin.server.VaadinRequest; | ||||
import com.vaadin.tests.components.AbstractReindeerTestUI; | import com.vaadin.tests.components.AbstractReindeerTestUI; | ||||
import com.vaadin.v7.ui.Grid; | import com.vaadin.v7.ui.Grid; | ||||
import com.vaadin.v7.ui.Grid.SelectionMode; | import com.vaadin.v7.ui.Grid.SelectionMode; | ||||
public class GridAddRow extends AbstractReindeerTestUI { | |||||
public class GridSmoke extends AbstractReindeerTestUI { | |||||
@Override | @Override | ||||
protected void setup(VaadinRequest request) { | protected void setup(VaadinRequest request) { |
/* | |||||
* 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 { | |||||
} | |||||
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.tests.widgetset.client.v7.grid; | |||||
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.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) | |||||
@Connect(com.vaadin.tests.components.grid.IntArrayRenderer.class) | |||||
public class IntArrayRendererConnector | public class IntArrayRendererConnector | ||||
extends AbstractGridRendererConnector<int[]> { | extends AbstractGridRendererConnector<int[]> { | ||||
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.tests.widgetset.client.v7.grid; | |||||
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.shared.ui.Connect; | ||||
import com.vaadin.tests.widgetset.client.SimpleTestBean; | 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) | |||||
@Connect(com.vaadin.tests.components.grid.BeanRenderer.class) | |||||
public class PojoRendererConnector | public class PojoRendererConnector | ||||
extends AbstractGridRendererConnector<SimpleTestBean> { | extends AbstractGridRendererConnector<SimpleTestBean> { | ||||
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.tests.widgetset.client.v7.grid; | |||||
package com.vaadin.tests.widgetset.client.grid; | |||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import com.google.gwt.dom.client.DivElement; | import com.google.gwt.dom.client.DivElement; | ||||
import com.google.gwt.dom.client.NativeEvent; | import com.google.gwt.dom.client.NativeEvent; | ||||
import com.google.gwt.user.client.DOM; | 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.communication.ServerRpc; | ||||
import com.vaadin.shared.ui.Connect; | 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 com.vaadin.tests.widgetset.client.EmptyEnum; | |||||
import elemental.json.JsonObject; | import elemental.json.JsonObject; | ||||
@Connect(com.vaadin.v7.tests.components.grid.RowAwareRenderer.class) | |||||
@Connect(com.vaadin.tests.components.grid.RowAwareRenderer.class) | |||||
public class RowAwareRendererConnector | public class RowAwareRendererConnector | ||||
extends AbstractGridRendererConnector<Void> { | |||||
extends AbstractGridRendererConnector<EmptyEnum> { | |||||
public interface RowAwareRendererRpc extends ServerRpc { | public interface RowAwareRendererRpc extends ServerRpc { | ||||
void clicky(String key); | void clicky(String key); | ||||
} | } | ||||
public class RowAwareRenderer extends ComplexRenderer<Void> { | |||||
public class RowAwareRenderer extends ComplexRenderer<EmptyEnum> { | |||||
@Override | @Override | ||||
public Collection<String> getConsumedEvents() { | public Collection<String> getConsumedEvents() { | ||||
} | } | ||||
@Override | @Override | ||||
public void render(RendererCellReference cell, Void data) { | |||||
public void render(RendererCellReference cell, EmptyEnum data) { | |||||
// NOOP | // NOOP | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
protected Renderer<Void> createRenderer() { | |||||
protected Renderer<EmptyEnum> createRenderer() { | |||||
// cannot use the default createRenderer as RowAwareRenderer needs a | // cannot use the default createRenderer as RowAwareRenderer needs a | ||||
// reference to its connector - it has no "real" no-argument constructor | // reference to its connector - it has no "real" no-argument constructor | ||||
return new RowAwareRenderer(); | return new RowAwareRenderer(); |
/* | |||||
* 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<int[]> propertyIntArray = item | |||||
.getItemProperty(INT_ARRAY_PROPERTY); | |||||
propertyIntArray.setValue(new int[] { 1, 1, 2, 3, 5, 8, 13 }); | |||||
@SuppressWarnings("unchecked") | |||||
Property<SimpleTestBean> 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); | |||||
} | |||||
} |
/* | |||||
* 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; | |||||
} | |||||
} |
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; | |||||
} | |||||
} |
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.v7.tests.components.grid; | |||||
package com.vaadin.tests.components.grid; | |||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
GridElement grid = findGrid(); | GridElement grid = findGrid(); | ||||
assertEquals("Click me!", grid.getCell(0, 1).getText()); | assertEquals("Click me!", grid.getCell(0, 1).getText()); | ||||
assertEquals(CustomRenderer.INIT_DEBUG_LABEL_CAPTION, | |||||
findDebugLabel().getText()); | |||||
assertEquals("Debug label placeholder", findDebugLabel().getText()); | |||||
grid.getCell(0, 1).click(); | grid.getCell(0, 1).click(); | ||||
assertEquals("row: 0, key: 1", grid.getCell(0, 1).getText()); | assertEquals("row: 0, key: 1", grid.getCell(0, 1).getText()); | ||||
assertEquals("key: 1, itemId: " + CustomRenderer.ITEM_ID, | |||||
findDebugLabel().getText()); | |||||
assertEquals("key: 1, itemId: test-data", findDebugLabel().getText()); | |||||
} | } | ||||
@Test | @Test | ||||
} | } | ||||
private LabelElement findDebugLabel() { | private LabelElement findDebugLabel() { | ||||
return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID); | |||||
return $(LabelElement.class).id("debuglabel"); | |||||
} | |||||
@Override | |||||
protected Class<?> getUIClass() { | |||||
return CustomRendererUI.class; | |||||
} | } | ||||
} | } |
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.v7.tests.components.grid; | |||||
package com.vaadin.tests.smoke; | |||||
import org.junit.Assert; | import org.junit.Assert; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import com.vaadin.tests.tb3.MultiBrowserTest; | import com.vaadin.tests.tb3.MultiBrowserTest; | ||||
@TestCategory("grid") | @TestCategory("grid") | ||||
public class GridAddRowTest extends MultiBrowserTest { | |||||
public class GridSmokeTest extends MultiBrowserTest { | |||||
@Test | @Test | ||||
public void testAddRow() { | public void testAddRow() { | ||||
openTestURL(); | openTestURL(); |
/* | |||||
* 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"); | |||||
} | |||||
} | |||||
} |
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<Boolean>() { | |||||
@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); | |||||
} | |||||
} |
import org.junit.Test; | import org.junit.Test; | ||||
import com.vaadin.testbench.customelements.GridElement; | import com.vaadin.testbench.customelements.GridElement; | ||||
import com.vaadin.testbench.elements.LabelElement; | |||||
import com.vaadin.testbench.parallel.TestCategory; | import com.vaadin.testbench.parallel.TestCategory; | ||||
import com.vaadin.tests.tb3.MultiBrowserTest; | import com.vaadin.tests.tb3.MultiBrowserTest; | ||||
return $(GridElement.class).id("test-grid"); | return $(GridElement.class).id("test-grid"); | ||||
} | } | ||||
private LabelElement findDebugLabel() { | |||||
return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID); | |||||
} | |||||
} | } |