summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2014-03-18 15:40:01 +0200
committerLeif Åstrand <leif@vaadin.com>2014-03-18 15:40:50 +0200
commit4420f52578e245045677f88852f1ba3f405e88a3 (patch)
tree5f5c3f6c03326afe580f26eb395963f5c1e50804 /uitest
parent5d0b53bad905a2f77e4e75a3e307a69824c9b87d (diff)
parent796063f898ef34bbbe457164976ae96c802c1bc7 (diff)
downloadvaadin-framework-4420f52578e245045677f88852f1ba3f405e88a3.tar.gz
vaadin-framework-4420f52578e245045677f88852f1ba3f405e88a3.zip
Merge branch 'master' into grid
Change-Id: Ia9d156009a3f1b4e61f12eb415040670a52d7876
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html176
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java312
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java49
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java343
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java373
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java111
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridScrolling.java115
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java48
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java138
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java29
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java220
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java96
12 files changed, 2010 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html b/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html
new file mode 100644
index 0000000000..70aa0fe195
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>BasicEscalator</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">BasicEscalator</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.grid.BasicEscalator?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>Row 0: 0,0 (0)</td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[17]/domChild[9]</td>
+ <td>Cell: 9,17 (179)</td>
+</tr>
+<tr>
+ <td>verifyTextNotPresent</td>
+ <td>Cell: 0,100</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextNotPresent</td>
+ <td>Cell: 0,101</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[18]/domChild[0]</td>
+ <td>Row 0: 0,100 (190)</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
+ <td>11</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[17]/domChild[0]</td>
+ <td>Row 11: 0,101 (200)</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
+ <td>100</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[16]/domChild[0]</td>
+ <td>Row 0: 0,102 (210)</td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td>
+ <td>Row 16: 0,118 (370)</td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[0]</td>
+ <td>1109</td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Row 56: 0,158</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Row 72: 0,174</td>
+ <td></td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[0]</td>
+ <td>3690</td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Row 201: 0,99</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
+ <td>201</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td>
+ <td>Row 200: 0,98 (960)</td>
+</tr>
+<tr>
+ <td>verifyTextNotPresent</td>
+ <td>Row 201:</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
+ <td>2</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VHorizontalLayout[0]/Slot[2]/VButton[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[16]/domChild[0]</td>
+ <td>Row 184: 10,82 (974)</td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td>
+ <td>Row 200: 10,98 (1006)</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java b/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java
new file mode 100644
index 0000000000..61d263f433
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2000-2013 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.Random;
+
+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.server.grid.TestGrid;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.TextField;
+
+/**
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+@Widgetset(TestingWidgetSet.NAME)
+public class BasicEscalator extends AbstractTestUI {
+ public static final String ESCALATOR = "escalator";
+ public static final String INSERT_ROWS_OFFSET = "iro";
+ public static final String INSERT_ROWS_AMOUNT = "ira";
+ public static final String INSERT_ROWS_BUTTON = "irb";
+
+ private final Random random = new Random();
+
+ @Override
+ protected void setup(final VaadinRequest request) {
+ final TestGrid grid = new TestGrid();
+ grid.setId(ESCALATOR);
+ addComponent(grid);
+
+ final Layout insertRowsLayout = new HorizontalLayout();
+ final TextField insertRowsOffset = new TextField();
+ insertRowsOffset.setId(INSERT_ROWS_OFFSET);
+ insertRowsLayout.addComponent(insertRowsOffset);
+ final TextField insertRowsAmount = new TextField();
+ insertRowsAmount.setId(INSERT_ROWS_AMOUNT);
+ insertRowsLayout.addComponent(insertRowsAmount);
+ insertRowsLayout.addComponent(new Button("insert rows",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ final int offset = Integer.parseInt(insertRowsOffset
+ .getValue());
+ final int amount = Integer.parseInt(insertRowsAmount
+ .getValue());
+ grid.insertRows(offset, amount);
+ }
+ }) {
+ {
+ setId(INSERT_ROWS_BUTTON);
+ }
+ });
+ addComponent(insertRowsLayout);
+
+ final Layout removeRowsLayout = new HorizontalLayout();
+ final TextField removeRowsOffset = new TextField();
+ removeRowsLayout.addComponent(removeRowsOffset);
+ final TextField removeRowsAmount = new TextField();
+ removeRowsLayout.addComponent(removeRowsAmount);
+ removeRowsLayout.addComponent(new Button("remove rows",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ final int offset = Integer.parseInt(removeRowsOffset
+ .getValue());
+ final int amount = Integer.parseInt(removeRowsAmount
+ .getValue());
+ grid.removeRows(offset, amount);
+ }
+ }));
+ addComponent(removeRowsLayout);
+
+ final Layout insertColumnsLayout = new HorizontalLayout();
+ final TextField insertColumnsOffset = new TextField();
+ insertColumnsLayout.addComponent(insertColumnsOffset);
+ final TextField insertColumnsAmount = new TextField();
+ insertColumnsLayout.addComponent(insertColumnsAmount);
+ insertColumnsLayout.addComponent(new Button("insert columns",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ final int offset = Integer.parseInt(insertColumnsOffset
+ .getValue());
+ final int amount = Integer.parseInt(insertColumnsAmount
+ .getValue());
+ grid.insertColumns(offset, amount);
+ }
+ }));
+ addComponent(insertColumnsLayout);
+
+ final Layout removeColumnsLayout = new HorizontalLayout();
+ final TextField removeColumnsOffset = new TextField();
+ removeColumnsLayout.addComponent(removeColumnsOffset);
+ final TextField removeColumnsAmount = new TextField();
+ removeColumnsLayout.addComponent(removeColumnsAmount);
+ removeColumnsLayout.addComponent(new Button("remove columns",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ final int offset = Integer.parseInt(removeColumnsOffset
+ .getValue());
+ final int amount = Integer.parseInt(removeColumnsAmount
+ .getValue());
+ grid.removeColumns(offset, amount);
+ }
+ }));
+ addComponent(removeColumnsLayout);
+
+ final HorizontalLayout rowScroll = new HorizontalLayout();
+ final NativeSelect destination = new NativeSelect();
+ destination.setNullSelectionAllowed(false);
+ destination.addItem("any");
+ destination.setValue("any");
+ destination.addItem("start");
+ destination.addItem("end");
+ destination.addItem("middle");
+ rowScroll.addComponent(destination);
+ final TextField rowIndex = new TextField();
+ rowScroll.addComponent(rowIndex);
+ final TextField rowPadding = new TextField();
+ rowScroll.addComponent(rowPadding);
+ rowScroll.addComponent(new Button("scroll to row",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ int index;
+ try {
+ index = Integer.parseInt(rowIndex.getValue());
+ } catch (NumberFormatException e) {
+ index = 0;
+ }
+
+ int padding;
+ try {
+ padding = Integer.parseInt(rowPadding.getValue());
+ } catch (NumberFormatException e) {
+ padding = 0;
+ }
+
+ grid.scrollToRow(index,
+ (String) destination.getValue(), padding);
+ }
+ }));
+ addComponent(rowScroll);
+
+ final HorizontalLayout colScroll = new HorizontalLayout();
+ final NativeSelect colDestination = new NativeSelect();
+ colDestination.setNullSelectionAllowed(false);
+ colDestination.addItem("any");
+ colDestination.setValue("any");
+ colDestination.addItem("start");
+ colDestination.addItem("end");
+ colDestination.addItem("middle");
+ colScroll.addComponent(colDestination);
+ final TextField colIndex = new TextField();
+ colScroll.addComponent(colIndex);
+ final TextField colPadding = new TextField();
+ colScroll.addComponent(colPadding);
+ colScroll.addComponent(new Button("scroll to column",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ int index;
+ try {
+ index = Integer.parseInt(colIndex.getValue());
+ } catch (NumberFormatException e) {
+ index = 0;
+ }
+
+ int padding;
+ try {
+ padding = Integer.parseInt(colPadding.getValue());
+ } catch (NumberFormatException e) {
+ padding = 0;
+ }
+
+ grid.scrollToColumn(index,
+ (String) colDestination.getValue(), padding);
+ }
+ }));
+ addComponent(colScroll);
+
+ final TextField freezeCount = new TextField();
+ freezeCount.setConverter(Integer.class);
+ freezeCount.setNullRepresentation("");
+ addComponent(new HorizontalLayout(freezeCount, new Button(
+ "set frozen columns", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ grid.setFrozenColumns(((Integer) freezeCount
+ .getConvertedValue()).intValue());
+ freezeCount.setValue(null);
+ }
+ })));
+
+ addComponent(new Button("Resize randomly", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ int width = random.nextInt(300) + 500;
+ int height = random.nextInt(300) + 200;
+ grid.setWidth(width + "px");
+ grid.setHeight(height + "px");
+ }
+ }));
+
+ addComponent(new Button("Random headers count",
+ new Button.ClickListener() {
+ private int headers = 1;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ int diff = 0;
+ while (diff == 0) {
+ final int nextHeaders = random.nextInt(4);
+ diff = nextHeaders - headers;
+ headers = nextHeaders;
+ }
+ if (diff > 0) {
+ grid.insertHeaders(0, diff);
+ } else if (diff < 0) {
+ grid.removeHeaders(0, -diff);
+ }
+ }
+ }));
+
+ addComponent(new Button("Random footers count",
+ new Button.ClickListener() {
+ private int footers = 1;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ int diff = 0;
+ while (diff == 0) {
+ final int nextFooters = random.nextInt(4);
+ diff = nextFooters - footers;
+ footers = nextFooters;
+ }
+ if (diff > 0) {
+ grid.insertFooters(0, diff);
+ } else if (diff < 0) {
+ grid.removeFooters(0, -diff);
+ }
+ }
+ }));
+
+ final Layout resizeColumnsLayout = new HorizontalLayout();
+ final TextField resizeColumnIndex = new TextField();
+ resizeColumnsLayout.addComponent(resizeColumnIndex);
+ final TextField resizeColumnPx = new TextField();
+ resizeColumnsLayout.addComponent(resizeColumnPx);
+ resizeColumnsLayout.addComponent(new Button("resize column",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ final int index = Integer.parseInt(resizeColumnIndex
+ .getValue());
+ final int px = Integer.parseInt(resizeColumnPx
+ .getValue());
+ grid.setColumnWidth(index, px);
+ }
+ }));
+ addComponent(resizeColumnsLayout);
+
+ addComponent(new Button("Autoresize columns",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ grid.calculateColumnWidths();
+ }
+ }));
+
+ addComponent(new Button("Randomize row heights",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ grid.randomizeDefaultRowHeight();
+ }
+ }));
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java b/uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java
new file mode 100644
index 0000000000..5afe826196
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2013 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.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class BasicEscalatorTest extends MultiBrowserTest {
+
+ @Test
+ public void testNormalHeight() throws Exception {
+ openTestURL();
+ compareScreen("normalHeight");
+ }
+
+ @Test
+ public void testModifiedHeight() throws Exception {
+ openTestURLWithTheme("reindeer-tests");
+ compareScreen("modifiedHeight");
+ }
+
+ private WebElement getFirstBodyRowCell() {
+ return getDriver().findElement(
+ By.xpath("//tbody/tr[@class='v-escalator-row'][1]/td[1]"));
+ }
+
+ private void openTestURLWithTheme(String themeName) {
+ String testUrl = getTestUrl();
+ testUrl += (testUrl.contains("?")) ? "&" : "?";
+ testUrl += "theme=" + themeName;
+ getDriver().get(testUrl);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java
new file mode 100644
index 0000000000..c28feb8d10
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java
@@ -0,0 +1,343 @@
+/*
+ * Copyright 2000-2013 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.LinkedHashMap;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.AbstractComponentTest;
+import com.vaadin.ui.components.grid.ColumnGroup;
+import com.vaadin.ui.components.grid.ColumnGroupRow;
+import com.vaadin.ui.components.grid.Grid;
+import com.vaadin.ui.components.grid.GridColumn;
+
+/**
+ * Tests the basic features like columns, footers and headers
+ *
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class GridBasicFeatures extends AbstractComponentTest<Grid> {
+
+ private final int COLUMNS = 10;
+
+ private int columnGroupRows = 0;
+
+ private final int ROWS = 1000;
+
+ private IndexedContainer ds;
+
+ @Override
+ protected Grid constructComponent() {
+
+ // Build data source
+ ds = new IndexedContainer();
+
+ for (int col = 0; col < COLUMNS; col++) {
+ ds.addContainerProperty(getColumnProperty(col), String.class, "");
+ }
+
+ for (int row = 0; row < ROWS; row++) {
+ Item item = ds.addItem(Integer.valueOf(row));
+ for (int col = 0; col < COLUMNS; col++) {
+ item.getItemProperty(getColumnProperty(col)).setValue(
+ "(" + row + ", " + col + ")");
+ }
+ }
+
+ // Create grid
+ Grid grid = new Grid(ds);
+
+ // Add footer values (header values are automatically created)
+ for (int col = 0; col < COLUMNS; col++) {
+ grid.getColumn(getColumnProperty(col)).setFooterCaption(
+ "Footer " + col);
+ }
+
+ // Set varying column widths
+ for (int col = 0; col < COLUMNS; col++) {
+ grid.getColumn("Column" + col).setWidth(100 + col * 50);
+ }
+
+ createGridActions();
+
+ createColumnActions();
+
+ createHeaderActions();
+
+ createFooterActions();
+
+ createColumnGroupActions();
+
+ createRowActions();
+
+ return grid;
+ }
+
+ protected void createGridActions() {
+ LinkedHashMap<String, String> primaryStyleNames = new LinkedHashMap<String, String>();
+ primaryStyleNames.put("v-grid", "v-grid");
+ primaryStyleNames.put("v-escalator", "v-escalator");
+ primaryStyleNames.put("my-grid", "my-grid");
+
+ createMultiClickAction("Primary style name", "State",
+ primaryStyleNames, new Command<Grid, String>() {
+
+ @Override
+ public void execute(Grid grid, String value, Object data) {
+ grid.setPrimaryStyleName(value);
+
+ }
+ }, primaryStyleNames.get("v-grid"));
+ }
+
+ protected void createHeaderActions() {
+ createCategory("Headers", null);
+
+ createBooleanAction("Visible", "Headers", true,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid grid, Boolean value, Object data) {
+ grid.setColumnHeadersVisible(value);
+ }
+ });
+ }
+
+ protected void createFooterActions() {
+ createCategory("Footers", null);
+
+ createBooleanAction("Visible", "Footers", false,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid grid, Boolean value, Object data) {
+ grid.setColumnFootersVisible(value);
+ }
+ });
+ }
+
+ protected void createColumnActions() {
+ createCategory("Columns", null);
+
+ for (int c = 0; c < COLUMNS; c++) {
+ createCategory(getColumnProperty(c), "Columns");
+
+ createBooleanAction("Visible", getColumnProperty(c), true,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid grid, Boolean value,
+ Object columnIndex) {
+ Object propertyId = (new ArrayList(grid
+ .getContainerDatasource()
+ .getContainerPropertyIds())
+ .get((Integer) columnIndex));
+ GridColumn column = grid.getColumn(propertyId);
+ column.setVisible(!column.isVisible());
+ }
+ }, c);
+
+ createClickAction("Remove", getColumnProperty(c),
+ new Command<Grid, String>() {
+
+ @Override
+ public void execute(Grid grid, String value, Object data) {
+ grid.getContainerDatasource()
+ .removeContainerProperty("Column" + data);
+ }
+ }, null, c);
+
+ createClickAction("Freeze", getColumnProperty(c),
+ new Command<Grid, String>() {
+
+ @Override
+ public void execute(Grid grid, String value, Object data) {
+ grid.setLastFrozenPropertyId("Column" + data);
+ }
+ }, null, c);
+
+ createCategory("Column" + c + " Width", getColumnProperty(c));
+
+ createClickAction("Auto", "Column" + c + " Width",
+ new Command<Grid, Integer>() {
+
+ @Override
+ public void execute(Grid grid, Integer value,
+ Object columnIndex) {
+ Object propertyId = (new ArrayList(grid
+ .getContainerDatasource()
+ .getContainerPropertyIds())
+ .get((Integer) columnIndex));
+ GridColumn column = grid.getColumn(propertyId);
+ column.setWidthUndefined();
+ }
+ }, -1, c);
+
+ for (int w = 50; w < 300; w += 50) {
+ createClickAction(w + "px", "Column" + c + " Width",
+ new Command<Grid, Integer>() {
+
+ @Override
+ public void execute(Grid grid, Integer value,
+ Object columnIndex) {
+ Object propertyId = (new ArrayList(grid
+ .getContainerDatasource()
+ .getContainerPropertyIds())
+ .get((Integer) columnIndex));
+ GridColumn column = grid.getColumn(propertyId);
+ column.setWidth(value);
+ }
+ }, w, c);
+ }
+ }
+ }
+
+ private static String getColumnProperty(int c) {
+ return "Column" + c;
+ }
+
+ protected void createColumnGroupActions() {
+ createCategory("Column groups", null);
+
+ createClickAction("Add group row", "Column groups",
+ new Command<Grid, String>() {
+
+ @Override
+ public void execute(Grid grid, String value, Object data) {
+ final ColumnGroupRow row = grid.addColumnGroupRow();
+ columnGroupRows++;
+ createCategory("Column group row " + columnGroupRows,
+ "Column groups");
+
+ createBooleanAction("Header Visible",
+ "Column group row " + columnGroupRows, true,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid grid,
+ Boolean value, Object columnIndex) {
+ row.setHeaderVisible(value);
+ }
+ }, row);
+
+ createBooleanAction("Footer Visible",
+ "Column group row " + columnGroupRows, false,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid grid,
+ Boolean value, Object columnIndex) {
+ row.setFooterVisible(value);
+ }
+ }, row);
+
+ for (int i = 0; i < COLUMNS; i++) {
+ final int columnIndex = i;
+ createClickAction("Group Column " + columnIndex
+ + " & " + (columnIndex + 1),
+ "Column group row " + columnGroupRows,
+ new Command<Grid, Integer>() {
+
+ @Override
+ public void execute(Grid c,
+ Integer value, Object data) {
+ final ColumnGroup group = row
+ .addGroup(
+ "Column" + value,
+ "Column"
+ + (value + 1));
+
+ group.setHeaderCaption("Column "
+ + value + " & "
+ + (value + 1));
+
+ group.setFooterCaption("Column "
+ + value + " & "
+ + (value + 1));
+ }
+ }, i, row);
+ }
+ }
+ }, null, null);
+
+ }
+
+ protected void createRowActions() {
+ createCategory("Body rows", null);
+
+ createClickAction("Add first row", "Body rows",
+ new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ Item item = ds.addItemAt(0, new Object());
+ for (int i = 0; i < COLUMNS; i++) {
+ item.getItemProperty(getColumnProperty(i))
+ .setValue("newcell: " + i);
+ }
+ }
+ }, null);
+
+ createClickAction("Remove first row", "Body rows",
+ new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ Object firstItemId = ds.getIdByIndex(0);
+ ds.removeItem(firstItemId);
+ }
+ }, null);
+
+ createClickAction("Modify first row (getItemProperty)", "Body rows",
+ new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ Object firstItemId = ds.getIdByIndex(0);
+ Item item = ds.getItem(firstItemId);
+ for (int i = 0; i < COLUMNS; i++) {
+ item.getItemProperty(getColumnProperty(i))
+ .setValue("modified: " + i);
+ }
+ }
+ }, null);
+
+ createClickAction("Modify first row (getContainerProperty)",
+ "Body rows", new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ Object firstItemId = ds.getIdByIndex(0);
+ for (Object containerPropertyId : ds
+ .getContainerPropertyIds()) {
+ ds.getContainerProperty(firstItemId,
+ containerPropertyId).setValue(
+ "modified: " + containerPropertyId);
+ }
+ }
+ }, null);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12829;
+ }
+
+ @Override
+ protected Class<Grid> getTestClass() {
+ return Grid.class;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java
new file mode 100644
index 0000000000..bc43f2be98
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java
@@ -0,0 +1,373 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class GridBasicFeaturesTest extends MultiBrowserTest {
+
+ @Test
+ public void testColumnHeaderCaptions() throws Exception {
+ openTestURL();
+
+ // Column headers should be visible
+ List<WebElement> cells = getGridHeaderRowCells();
+ assertEquals(10, cells.size());
+ assertEquals("Column0", cells.get(0).getText());
+ assertEquals("Column1", cells.get(1).getText());
+ assertEquals("Column2", cells.get(2).getText());
+ }
+
+ @Test
+ public void testColumnFooterCaptions() throws Exception {
+ openTestURL();
+
+ // footer row should by default be hidden
+ List<WebElement> cells = getGridFooterRowCells();
+ assertEquals(0, cells.size());
+
+ // Open footer row
+ selectMenuPath("Component", "Footers", "Visible");
+
+ // Footers should now be visible
+ cells = getGridFooterRowCells();
+ assertEquals(10, cells.size());
+ assertEquals("Footer 0", cells.get(0).getText());
+ assertEquals("Footer 1", cells.get(1).getText());
+ assertEquals("Footer 2", cells.get(2).getText());
+ }
+
+ @Test
+ public void testColumnGroupHeaders() throws Exception {
+ openTestURL();
+
+ // Hide column headers for this test
+ selectMenuPath("Component", "Headers", "Visible");
+
+ List<WebElement> cells = getGridHeaderRowCells();
+
+ // header row should be empty
+ assertEquals(0, cells.size());
+
+ // add a group row
+ selectMenuPath("Component", "Column groups", "Add group row");
+
+ // Empty group row cells should be present
+ cells = getGridHeaderRowCells();
+ assertEquals(10, cells.size());
+
+ // Group columns 0 & 1
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 0 & 1");
+
+ cells = getGridHeaderRowCells();
+ assertEquals("Column 0 & 1", cells.get(0).getText());
+ }
+
+ @Test
+ public void testColumnGroupFooters() throws Exception {
+ openTestURL();
+
+ // add a group row
+ selectMenuPath("Component", "Column groups", "Add group row");
+
+ // Set footer visible
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Footer Visible");
+
+ // Group columns 0 & 1
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 0 & 1");
+
+ List<WebElement> cells = getGridFooterRowCells();
+ assertEquals("Column 0 & 1", cells.get(0).getText());
+ }
+
+ @Test
+ public void testGroupingSameColumnsOnRowThrowsException() throws Exception {
+ openTestURL();
+
+ // add a group row
+ selectMenuPath("Component", "Column groups", "Add group row");
+
+ // Group columns 0 & 1
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 0 & 1");
+
+ // Group columns 1 & 2 shoud fail
+ selectMenuPath("Component", "Column groups", "Column group row 1",
+ "Group Column 1 & 2");
+
+ assertTrue(getLogRow(0)
+ .contains(
+ "Exception occured, java.lang.IllegalArgumentExceptionColumn Column1 already belongs to another group."));
+ }
+
+ @Test
+ public void testHidingColumn() throws Exception {
+ openTestURL();
+
+ // Column 0 should be visible
+ List<WebElement> cells = getGridHeaderRowCells();
+ assertEquals("Column0", cells.get(0).getText());
+
+ // Hide column 0
+ selectMenuPath("Component", "Columns", "Column0", "Visible");
+
+ // Column 1 should now be the first cell
+ cells = getGridHeaderRowCells();
+ assertEquals("Column1", cells.get(0).getText());
+ }
+
+ @Test
+ public void testRemovingColumn() throws Exception {
+ openTestURL();
+
+ // Column 0 should be visible
+ List<WebElement> cells = getGridHeaderRowCells();
+ assertEquals("Column0", cells.get(0).getText());
+
+ // Hide column 0
+ selectMenuPath("Component", "Columns", "Column0", "Remove");
+
+ // Column 1 should now be the first cell
+ cells = getGridHeaderRowCells();
+ assertEquals("Column1", cells.get(0).getText());
+ }
+
+ @Test
+ public void testFreezingColumn() throws Exception {
+ openTestURL();
+
+ // Freeze column 2
+ selectMenuPath("Component", "Columns", "Column2", "Freeze");
+
+ WebElement cell = getBodyCellByRowAndColumn(1, 1);
+ assertTrue(cell.getAttribute("class").contains("frozen"));
+
+ cell = getBodyCellByRowAndColumn(1, 2);
+ assertTrue(cell.getAttribute("class").contains("frozen"));
+ }
+
+ @Test
+ public void testInitialColumnWidths() throws Exception {
+ openTestURL();
+
+ // Default borders and margins implemented by escalator
+ int cellBorder = 1 + 1;
+ int cellMargin = 2 + 2;
+
+ WebElement cell = getBodyCellByRowAndColumn(1, 1);
+ assertEquals((100 - cellBorder - cellMargin) + "px",
+ cell.getCssValue("width"));
+
+ cell = getBodyCellByRowAndColumn(1, 2);
+ assertEquals((150 - cellBorder - cellMargin) + "px",
+ cell.getCssValue("width"));
+
+ cell = getBodyCellByRowAndColumn(1, 3);
+ assertEquals((200 - cellBorder - cellMargin) + "px",
+ cell.getCssValue("width"));
+ }
+
+ @Test
+ public void testColumnWidths() throws Exception {
+ openTestURL();
+
+ // Default borders and margins implemented by escalator
+ int cellBorder = 1 + 1;
+ int cellMargin = 2 + 2;
+
+ // Default column width is 100px
+ WebElement cell = getBodyCellByRowAndColumn(1, 1);
+ assertEquals((100 - cellBorder - cellMargin) + "px",
+ cell.getCssValue("width"));
+
+ // Set first column to be 200px wide
+ selectMenuPath("Component", "Columns", "Column0", "Column0 Width",
+ "200px");
+
+ cell = getBodyCellByRowAndColumn(1, 1);
+ assertEquals((200 - cellBorder - cellMargin) + "px",
+ cell.getCssValue("width"));
+
+ // Set second column to be 150px wide
+ selectMenuPath("Component", "Columns", "Column1", "Column1 Width",
+ "150px");
+ cell = getBodyCellByRowAndColumn(1, 2);
+ assertEquals((150 - cellBorder - cellMargin) + "px",
+ cell.getCssValue("width"));
+
+ // Set first column to be auto sized (defaults to 100px currently)
+ selectMenuPath("Component", "Columns", "Column0", "Column0 Width",
+ "Auto");
+
+ cell = getBodyCellByRowAndColumn(1, 1);
+ assertEquals((100 - cellBorder - cellMargin) + "px",
+ cell.getCssValue("width"));
+ }
+
+ @Test
+ public void testPrimaryStyleNames() throws Exception {
+ openTestURL();
+
+ // v-grid is default primary style namea
+ assertPrimaryStylename("v-grid");
+
+ selectMenuPath("Component", "State", "Primary style name",
+ "v-escalator");
+ assertPrimaryStylename("v-escalator");
+
+ selectMenuPath("Component", "State", "Primary style name", "my-grid");
+ assertPrimaryStylename("my-grid");
+
+ selectMenuPath("Component", "State", "Primary style name", "v-grid");
+ assertPrimaryStylename("v-grid");
+ }
+
+ /**
+ * Test that the current view is updated when a server-side container change
+ * occurs (without scrolling back and forth)
+ */
+ @Test
+ public void testItemSetChangeEvent() throws Exception {
+ openTestURL();
+
+ final By newRow = By.xpath("//td[text()='newcell: 0']");
+
+ assertTrue("Unexpected initial state", !elementIsFound(newRow));
+
+ selectMenuPath("Component", "Body rows", "Add first row");
+ assertTrue("Add row failed", elementIsFound(newRow));
+
+ selectMenuPath("Component", "Body rows", "Remove first row");
+ assertTrue("Remove row failed", !elementIsFound(newRow));
+ }
+
+ /**
+ * Test that the current view is updated when a property's value is reflect
+ * to the client, when the value is modified server-side.
+ */
+ @Test
+ public void testPropertyValueChangeEvent() throws Exception {
+ openTestURL();
+
+ assertEquals("Unexpected cell initial state", "(0, 0)",
+ getBodyCellByRowAndColumn(1, 1).getText());
+
+ selectMenuPath("Component", "Body rows",
+ "Modify first row (getItemProperty)");
+ assertEquals("(First) modification with getItemProperty failed",
+ "modified: 0", getBodyCellByRowAndColumn(1, 1).getText());
+
+ selectMenuPath("Component", "Body rows",
+ "Modify first row (getContainerProperty)");
+ assertEquals("(Second) modification with getItemProperty failed",
+ "modified: Column0", getBodyCellByRowAndColumn(1, 1).getText());
+ }
+
+ private boolean elementIsFound(By locator) {
+ try {
+ return driver.findElement(locator) != null;
+ } catch (NoSuchElementException e) {
+ return false;
+ }
+ }
+
+ private void assertPrimaryStylename(String stylename) {
+ assertTrue(getGridElement().getAttribute("class").contains(stylename));
+
+ String tableWrapperStyleName = getTableWrapper().getAttribute("class");
+ assertTrue(tableWrapperStyleName.contains(stylename + "-tablewrapper"));
+
+ String hscrollStyleName = getHorizontalScroller().getAttribute("class");
+ assertTrue(hscrollStyleName.contains(stylename + "-scroller"));
+ assertTrue(hscrollStyleName
+ .contains(stylename + "-scroller-horizontal"));
+
+ String vscrollStyleName = getVerticalScroller().getAttribute("class");
+ assertTrue(vscrollStyleName.contains(stylename + "-scroller"));
+ assertTrue(vscrollStyleName.contains(stylename + "-scroller-vertical"));
+ }
+
+ private WebElement getBodyCellByRowAndColumn(int row, int column) {
+ return getDriver().findElement(
+ By.xpath("//div[@id='testComponent']//tbody/tr[" + row
+ + "]/td[" + column + "]"));
+ }
+
+ private void selectSubMenu(String menuCaption) {
+ selectMenu(menuCaption);
+ new Actions(getDriver()).moveByOffset(100, 0).build().perform();
+ }
+
+ private void selectMenu(String menuCaption) {
+ getDriver().findElement(
+ By.xpath("//span[text() = '" + menuCaption + "']")).click();
+ }
+
+ private void selectMenuPath(String... menuCaptions) {
+ selectMenu(menuCaptions[0]);
+ for (int i = 1; i < menuCaptions.length; i++) {
+ selectSubMenu(menuCaptions[i]);
+ }
+ }
+
+ private WebElement getVerticalScroller() {
+ return getDriver().findElement(
+ By.xpath("//div[@id='testComponent']/div[1]"));
+ }
+
+ private WebElement getHorizontalScroller() {
+ return getDriver().findElement(
+ By.xpath("//div[@id='testComponent']/div[2]"));
+ }
+
+ private WebElement getTableWrapper() {
+ return getDriver().findElement(
+ By.xpath("//div[@id='testComponent']/div[3]"));
+ }
+
+ private WebElement getGridElement() {
+ return getDriver().findElement(By.id("testComponent"));
+ }
+
+ private List<WebElement> getGridHeaderRowCells() {
+ return getDriver().findElements(
+ By.xpath("//div[@id='testComponent']//thead//th"));
+ }
+
+ private List<WebElement> getGridFooterRowCells() {
+ return getDriver().findElements(
+ By.xpath("//div[@id='testComponent']//tfoot//td"));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java b/uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java
new file mode 100644
index 0000000000..66e7651f76
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2000-2013 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.util.IndexedContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.components.grid.ColumnGroup;
+import com.vaadin.ui.components.grid.ColumnGroupRow;
+import com.vaadin.ui.components.grid.Grid;
+import com.vaadin.ui.components.grid.GridColumn;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class GridColumnGroups extends AbstractTestUI {
+
+ private final int COLUMNS = 4;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ // Setup grid
+ IndexedContainer ds = new IndexedContainer();
+ for (int col = 0; col < COLUMNS; col++) {
+ ds.addContainerProperty("Column" + col, String.class, "");
+ }
+ Grid grid = new Grid(ds);
+ addComponent(grid);
+
+ /*-
+ * ---------------------------------------------
+ * | Header 1 | <- Auxiliary row 2
+ * |-------------------------------------------|
+ * | Header 2 | Header 3 | <- Auxiliary row 1
+ * |-------------------------------------------|
+ * | Column 1 | Column 2 | Column 3 | Column 4 | <- Column headers
+ * --------------------------------------------|
+ * | ... | ... | ... | ... |
+ * | ... | ... | ... | ... |
+ * --------------------------------------------|
+ * | Column 1 | Column 2 | Column 3 | Column 4 | <- Column footers
+ * --------------------------------------------|
+ * | Footer 2 | Footer 3 | <- Auxiliary row 1
+ * --------------------------------------------|
+ * | Footer 1 | <- Auxiliary row 2
+ * ---------------------------------------------
+ -*/
+
+ // Set column footers (headers are generated automatically)
+ grid.setColumnFootersVisible(true);
+ for (Object propertyId : ds.getContainerPropertyIds()) {
+ GridColumn column = grid.getColumn(propertyId);
+ column.setFooterCaption(String.valueOf(propertyId));
+ }
+
+ // First auxiliary row
+ ColumnGroupRow auxRow1 = grid.addColumnGroupRow();
+
+ // Using property id to create a column group
+ ColumnGroup columns12 = auxRow1.addGroup("Column0", "Column1");
+ columns12.setHeaderCaption("Header 2");
+ columns12.setFooterCaption("Footer 2");
+
+ // Using grid columns to create a column group
+ GridColumn column3 = grid.getColumn("Column2");
+ GridColumn column4 = grid.getColumn("Column3");
+ ColumnGroup columns34 = auxRow1.addGroup(column3, column4);
+ columns34.setHeaderCaption("Header 3");
+ columns34.setFooterCaption("Footer 3");
+
+ // Second auxiliary row
+ ColumnGroupRow auxRow2 = grid.addColumnGroupRow();
+
+ // Using previous groups to create a column group
+ ColumnGroup columns1234 = auxRow2.addGroup(columns12, columns34);
+ columns1234.setHeaderCaption("Header 1");
+ columns1234.setFooterCaption("Footer 1");
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Grid should support headers and footer groups";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12894;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridScrolling.java b/uitest/src/com/vaadin/tests/components/grid/GridScrolling.java
new file mode 100644
index 0000000000..d514fbd0c5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridScrolling.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2000-2013 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.server.VaadinRequest;
+import com.vaadin.shared.ui.grid.ScrollDestination;
+import com.vaadin.tests.components.AbstractTestUI;
+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.ui.components.grid.Grid;
+
+/**
+ *
+ */
+@SuppressWarnings("serial")
+public class GridScrolling extends AbstractTestUI {
+
+ 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.scrollToItem(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/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java
new file mode 100644
index 0000000000..ae2799d228
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2013 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.shared.communication.ClientRpc;
+
+public interface TestGridClientRpc extends ClientRpc {
+ void insertRows(int offset, int amount);
+
+ void removeRows(int offset, int amount);
+
+ void insertColumns(int offset, int amount);
+
+ void removeColumns(int offset, int amount);
+
+ void scrollToRow(int index, String destination, int padding);
+
+ void scrollToColumn(int index, String destination, int padding);
+
+ void setFrozenColumns(int frozenColumns);
+
+ void insertHeaders(int index, int amount);
+
+ void removeHeaders(int index, int amount);
+
+ void insertFooters(int index, int amount);
+
+ void removeFooters(int index, int amount);
+
+ void setColumnWidth(int index, int px);
+
+ void calculateColumnWidths();
+
+ void randomRowHeight();
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java
new file mode 100644
index 0000000000..e2d88c57f2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2000-2013 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.google.gwt.user.client.Random;
+import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.grid.ScrollDestination;
+import com.vaadin.tests.widgetset.server.grid.TestGrid;
+
+/**
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+@Connect(TestGrid.class)
+public class TestGridConnector extends AbstractComponentConnector {
+ @Override
+ protected void init() {
+ super.init();
+ registerRpc(TestGridClientRpc.class, new TestGridClientRpc() {
+ @Override
+ public void insertRows(int offset, int amount) {
+ getWidget().insertRows(offset, amount);
+ }
+
+ @Override
+ public void removeRows(int offset, int amount) {
+ getWidget().removeRows(offset, amount);
+ }
+
+ @Override
+ public void removeColumns(int offset, int amount) {
+ getWidget().removeColumns(offset, amount);
+ }
+
+ @Override
+ public void insertColumns(int offset, int amount) {
+ getWidget().insertColumns(offset, amount);
+ }
+
+ @Override
+ public void scrollToRow(int index, String destination, int padding) {
+ getWidget().scrollToRow(index, getDestination(destination),
+ padding);
+ }
+
+ @Override
+ public void scrollToColumn(int index, String destination,
+ int padding) {
+ getWidget().scrollToColumn(index, getDestination(destination),
+ padding);
+ }
+
+ private ScrollDestination getDestination(String destination) {
+ final ScrollDestination d;
+ if (destination.equals("start")) {
+ d = ScrollDestination.START;
+ } else if (destination.equals("middle")) {
+ d = ScrollDestination.MIDDLE;
+ } else if (destination.equals("end")) {
+ d = ScrollDestination.END;
+ } else {
+ d = ScrollDestination.ANY;
+ }
+ return d;
+ }
+
+ @Override
+ public void setFrozenColumns(int frozenColumns) {
+ getWidget().getColumnConfiguration().setFrozenColumnCount(
+ frozenColumns);
+ }
+
+ @Override
+ public void insertHeaders(int index, int amount) {
+ getWidget().getHeader().insertRows(index, amount);
+ }
+
+ @Override
+ public void removeHeaders(int index, int amount) {
+ getWidget().getHeader().removeRows(index, amount);
+ }
+
+ @Override
+ public void insertFooters(int index, int amount) {
+ getWidget().getFooter().insertRows(index, amount);
+ }
+
+ @Override
+ public void removeFooters(int index, int amount) {
+ getWidget().getFooter().removeRows(index, amount);
+ }
+
+ @Override
+ public void setColumnWidth(int index, int px) {
+ getWidget().getColumnConfiguration().setColumnWidth(index, px);
+ }
+
+ @Override
+ public void calculateColumnWidths() {
+ getWidget().calculateColumnWidths();
+ }
+
+ @Override
+ public void randomRowHeight() {
+ getWidget().getHeader().setDefaultRowHeight(
+ Random.nextInt(20) + 20);
+ getWidget().getBody().setDefaultRowHeight(
+ Random.nextInt(20) + 20);
+ getWidget().getFooter().setDefaultRowHeight(
+ Random.nextInt(20) + 20);
+ }
+ });
+ }
+
+ @Override
+ public VTestGrid getWidget() {
+ return (VTestGrid) super.getWidget();
+ }
+
+ @Override
+ public TestGridState getState() {
+ return (TestGridState) super.getState();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java
new file mode 100644
index 0000000000..73d6ba311c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2013 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.shared.AbstractComponentState;
+
+/**
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class TestGridState extends AbstractComponentState {
+ public static final String DEFAULT_HEIGHT = "400.0px";
+
+ /* TODO: this should be "100%" before setting final. */
+ public static final String DEFAULT_WIDTH = "800.0px";
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
new file mode 100644
index 0000000000..28e650edc1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
@@ -0,0 +1,220 @@
+package com.vaadin.tests.widgetset.client.grid;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.vaadin.client.ui.grid.Cell;
+import com.vaadin.client.ui.grid.ColumnConfiguration;
+import com.vaadin.client.ui.grid.Escalator;
+import com.vaadin.client.ui.grid.EscalatorUpdater;
+import com.vaadin.client.ui.grid.Row;
+import com.vaadin.client.ui.grid.RowContainer;
+import com.vaadin.shared.ui.grid.ScrollDestination;
+
+public class VTestGrid extends Composite {
+
+ private static class Data {
+ private int columnCounter = 0;
+ private int rowCounter = 0;
+ private final List<Integer> columns = new ArrayList<Integer>();
+ private final List<Integer> rows = new ArrayList<Integer>();
+
+ @SuppressWarnings("boxing")
+ public void insertRows(final int offset, final int amount) {
+ final List<Integer> newRows = new ArrayList<Integer>();
+ for (int i = 0; i < amount; i++) {
+ newRows.add(rowCounter++);
+ }
+ rows.addAll(offset, newRows);
+ }
+
+ @SuppressWarnings("boxing")
+ public void insertColumns(final int offset, final int amount) {
+ final List<Integer> newColumns = new ArrayList<Integer>();
+ for (int i = 0; i < amount; i++) {
+ newColumns.add(columnCounter++);
+ }
+ columns.addAll(offset, newColumns);
+ }
+
+ public EscalatorUpdater createHeaderUpdater() {
+ return new EscalatorUpdater() {
+ @Override
+ public void updateCells(final Row row,
+ final Iterable<Cell> cellsToUpdate) {
+ for (final Cell cell : cellsToUpdate) {
+ if (cell.getColumn() % 3 == 0) {
+ cell.setColSpan(2);
+ }
+
+ final Integer columnName = columns
+ .get(cell.getColumn());
+ cell.getElement().setInnerText("Header " + columnName);
+ }
+ }
+ };
+ }
+
+ public EscalatorUpdater createFooterUpdater() {
+ return new EscalatorUpdater() {
+ @Override
+ public void updateCells(final Row row,
+ final Iterable<Cell> cellsToUpdate) {
+ for (final Cell cell : cellsToUpdate) {
+ if (cell.getColumn() % 3 == 1) {
+ cell.setColSpan(2);
+ }
+
+ final Integer columnName = columns
+ .get(cell.getColumn());
+ cell.getElement().setInnerText("Footer " + columnName);
+ }
+ }
+ };
+ }
+
+ public EscalatorUpdater createBodyUpdater() {
+ return new EscalatorUpdater() {
+ private int i = 0;
+
+ public void renderCell(final Cell cell) {
+ final Integer columnName = columns.get(cell.getColumn());
+ final Integer rowName = rows.get(cell.getRow());
+ final String cellInfo = columnName + "," + rowName + " ("
+ + i + ")";
+
+ if (cell.getColumn() > 0) {
+ cell.getElement().setInnerText("Cell: " + cellInfo);
+ } else {
+ cell.getElement().setInnerText(
+ "Row " + cell.getRow() + ": " + cellInfo);
+ }
+
+ if (cell.getColumn() % 3 == cell.getRow() % 3) {
+ cell.setColSpan(3);
+ }
+
+ final double c = i * .1;
+ final int r = (int) ((Math.cos(c) + 1) * 128);
+ final int g = (int) ((Math.cos(c / Math.PI) + 1) * 128);
+ final int b = (int) ((Math.cos(c / (Math.PI * 2)) + 1) * 128);
+ cell.getElement()
+ .getStyle()
+ .setBackgroundColor(
+ "rgb(" + r + "," + g + "," + b + ")");
+ if ((r * .8 + g * 1.3 + b * .9) / 3 < 127) {
+ cell.getElement().getStyle().setColor("white");
+ } else {
+ cell.getElement().getStyle().clearColor();
+ }
+
+ i++;
+ }
+
+ @Override
+ public void updateCells(final Row row,
+ final Iterable<Cell> cellsToUpdate) {
+ for (final Cell cell : cellsToUpdate) {
+ renderCell(cell);
+ }
+ }
+ };
+ }
+
+ public void removeRows(final int offset, final int amount) {
+ for (int i = 0; i < amount; i++) {
+ rows.remove(offset);
+ }
+ }
+
+ public void removeColumns(final int offset, final int amount) {
+ for (int i = 0; i < amount; i++) {
+ columns.remove(offset);
+ }
+ }
+ }
+
+ private final Escalator escalator = new Escalator();
+ private final Data data = new Data();
+
+ public VTestGrid() {
+ initWidget(escalator);
+ final RowContainer header = escalator.getHeader();
+ header.setEscalatorUpdater(data.createHeaderUpdater());
+ header.insertRows(0, 1);
+
+ final RowContainer footer = escalator.getFooter();
+ footer.setEscalatorUpdater(data.createFooterUpdater());
+ footer.insertRows(0, 1);
+
+ escalator.getBody().setEscalatorUpdater(data.createBodyUpdater());
+
+ insertRows(0, 100);
+ insertColumns(0, 10);
+
+ setWidth(TestGridState.DEFAULT_WIDTH);
+ setHeight(TestGridState.DEFAULT_HEIGHT);
+
+ }
+
+ public void insertRows(final int offset, final int number) {
+ data.insertRows(offset, number);
+ escalator.getBody().insertRows(offset, number);
+ }
+
+ public void insertColumns(final int offset, final int number) {
+ data.insertColumns(offset, number);
+ escalator.getColumnConfiguration().insertColumns(offset, number);
+ }
+
+ public ColumnConfiguration getColumnConfiguration() {
+ return escalator.getColumnConfiguration();
+ }
+
+ public void scrollToRow(final int index,
+ final ScrollDestination destination, final int padding) {
+ escalator.scrollToRow(index, destination, padding);
+ }
+
+ public void scrollToColumn(final int index,
+ final ScrollDestination destination, final int padding) {
+ escalator.scrollToColumn(index, destination, padding);
+ }
+
+ public void removeRows(final int offset, final int amount) {
+ data.removeRows(offset, amount);
+ escalator.getBody().removeRows(offset, amount);
+ }
+
+ public void removeColumns(final int offset, final int amount) {
+ data.removeColumns(offset, amount);
+ escalator.getColumnConfiguration().removeColumns(offset, amount);
+ }
+
+ @Override
+ public void setWidth(String width) {
+ escalator.setWidth(width);
+ }
+
+ @Override
+ public void setHeight(String height) {
+ escalator.setHeight(height);
+ }
+
+ public RowContainer getHeader() {
+ return escalator.getHeader();
+ }
+
+ public RowContainer getBody() {
+ return escalator.getBody();
+ }
+
+ public RowContainer getFooter() {
+ return escalator.getFooter();
+ }
+
+ public void calculateColumnWidths() {
+ escalator.calculateColumnWidths();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java b/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java
new file mode 100644
index 0000000000..4e218ebba1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2000-2013 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.server.grid;
+
+import com.vaadin.tests.widgetset.client.grid.TestGridClientRpc;
+import com.vaadin.tests.widgetset.client.grid.TestGridState;
+import com.vaadin.ui.AbstractComponent;
+
+/**
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class TestGrid extends AbstractComponent {
+ public TestGrid() {
+ setWidth(TestGridState.DEFAULT_WIDTH);
+ setHeight(TestGridState.DEFAULT_HEIGHT);
+ }
+
+ @Override
+ protected TestGridState getState() {
+ return (TestGridState) super.getState();
+ }
+
+ public void insertRows(int offset, int amount) {
+ rpc().insertRows(offset, amount);
+ }
+
+ public void removeRows(int offset, int amount) {
+ rpc().removeRows(offset, amount);
+ }
+
+ public void insertColumns(int offset, int amount) {
+ rpc().insertColumns(offset, amount);
+ }
+
+ public void removeColumns(int offset, int amount) {
+ rpc().removeColumns(offset, amount);
+ }
+
+ private TestGridClientRpc rpc() {
+ return getRpcProxy(TestGridClientRpc.class);
+ }
+
+ public void scrollToRow(int index, String destination, int padding) {
+ rpc().scrollToRow(index, destination, padding);
+ }
+
+ public void scrollToColumn(int index, String destination, int padding) {
+ rpc().scrollToColumn(index, destination, padding);
+ }
+
+ public void setFrozenColumns(int frozenColumns) {
+ rpc().setFrozenColumns(frozenColumns);
+ }
+
+ public void insertHeaders(int index, int amount) {
+ rpc().insertHeaders(index, amount);
+ }
+
+ public void removeHeaders(int index, int amount) {
+ rpc().removeHeaders(index, amount);
+ }
+
+ public void insertFooters(int index, int amount) {
+ rpc().insertFooters(index, amount);
+ }
+
+ public void removeFooters(int index, int amount) {
+ rpc().removeFooters(index, amount);
+ }
+
+ public void setColumnWidth(int index, int px) {
+ rpc().setColumnWidth(index, px);
+ }
+
+ public void calculateColumnWidths() {
+ rpc().calculateColumnWidths();
+ }
+
+ public void randomizeDefaultRowHeight() {
+ rpc().randomRowHeight();
+ }
+}