summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2013-10-09 14:35:10 +0300
committerHenrik Paul <henrik@vaadin.com>2013-11-08 15:36:52 +0200
commitecb954092f2bb3e3b2c5b1acfc7447993ed84468 (patch)
tree6e5a0dd24470865960fbc7bd78b4f93bbfe530fe /uitest
parentb29caad20c1d14a655f546493f6c5507a0a6f856 (diff)
downloadvaadin-framework-ecb954092f2bb3e3b2c5b1acfc7447993ed84468.tar.gz
vaadin-framework-ecb954092f2bb3e3b2c5b1acfc7447993ed84468.zip
Implement escalator pattern for widget (#12645)
Change-Id: Ibdc5a5162ae88e886e74d93f3f75f4ea3c6dab89
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridTest.html151
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridTest.java86
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java28
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java23
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java3
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java58
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java21
7 files changed, 325 insertions, 45 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridTest.html b/uitest/src/com/vaadin/tests/components/grid/GridTest.html
new file mode 100644
index 0000000000..76ebbf1807
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridTest.html
@@ -0,0 +1,151 @@
+<?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>GridTest</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">GridTest</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.grid.GridTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>Logical row 0/0</td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[9]/domChild[0]</td>
+ <td>Logical row 9/9</td>
+</tr>
+<tr>
+ <td>verifyTextNotPresent</td>
+ <td>Logical row 0/10</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextNotPresent</td>
+ <td>Logical row 11/11</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>Logical row 0/10</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[11]/domChild[0]</td>
+ <td>Logical row 11/11</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>Logical row 0/12</td>
+</tr>
+<tr>
+ <td>verifyText</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[10]/domChild[0]</td>
+ <td>Logical row 17/29</td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[0]</td>
+ <td>1109</td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Logical row 56/68</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Logical row 72/84</td>
+ <td></td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[0]</td>
+ <td>1875</td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Logical row 111/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
+ <td>111</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/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=runcomvaadintestscomponentsgridGridTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[17]/domChild[0]</td>
+ <td>Logical row 110/144</td>
+</tr>
+<tr>
+ <td>verifyTextNotPresent</td>
+ <td>Logical row 111/</td>
+ <td></td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridTest.java b/uitest/src/com/vaadin/tests/components/grid/GridTest.java
index cd8a13423c..aab3c66acf 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridTest.java
@@ -21,6 +21,11 @@ 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.TextField;
/**
* @since 7.2
@@ -29,8 +34,85 @@ import com.vaadin.tests.widgetset.server.grid.TestGrid;
@Widgetset(TestingWidgetSet.NAME)
public class GridTest extends AbstractTestUI {
@Override
- protected void setup(VaadinRequest request) {
- addComponent(new TestGrid());
+ protected void setup(final VaadinRequest request) {
+ final TestGrid grid = new TestGrid();
+ addComponent(grid);
+
+ final Layout insertRowsLayout = new HorizontalLayout();
+ final TextField insertRowsOffset = new TextField();
+ insertRowsLayout.addComponent(insertRowsOffset);
+ final TextField insertRowsAmount = new TextField();
+ insertRowsLayout.addComponent(insertRowsAmount);
+ insertRowsLayout.addComponent(new Button("insert rows",
+ new Button.ClickListener() {
+ @Override
+ @SuppressWarnings("boxing")
+ public void buttonClick(final ClickEvent event) {
+ int offset = Integer.valueOf(insertRowsOffset
+ .getValue());
+ int amount = Integer.valueOf(insertRowsAmount
+ .getValue());
+ grid.insertRows(offset, amount);
+ }
+ }));
+ 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
+ @SuppressWarnings("boxing")
+ public void buttonClick(final ClickEvent event) {
+ int offset = Integer.valueOf(removeRowsOffset
+ .getValue());
+ int amount = Integer.valueOf(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
+ @SuppressWarnings("boxing")
+ public void buttonClick(final ClickEvent event) {
+ int offset = Integer.valueOf(insertColumnsOffset
+ .getValue());
+ int amount = Integer.valueOf(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
+ @SuppressWarnings("boxing")
+ public void buttonClick(final ClickEvent event) {
+ int offset = Integer.valueOf(removeColumnsOffset
+ .getValue());
+ int amount = Integer.valueOf(removeColumnsAmount
+ .getValue());
+ grid.removeColumns(offset, amount);
+ }
+ }));
+ addComponent(removeColumnsLayout);
}
@Override
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..878e04ef39
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java
@@ -0,0 +1,28 @@
+/*
+ * 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);
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java
index ef624d6fc8..382d01e04e 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java
@@ -28,6 +28,29 @@ 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().getBody().insertRows(offset, amount);
+ }
+
+ @Override
+ public void removeRows(int offset, int amount) {
+ getWidget().getBody().removeRows(offset, amount);
+ }
+
+ @Override
+ public void removeColumns(int offset, int amount) {
+ getWidget().getColumnConfiguration().removeColumns(offset,
+ amount);
+ }
+
+ @Override
+ public void insertColumns(int offset, int amount) {
+ getWidget().getColumnConfiguration().insertColumns(offset,
+ amount);
+ }
+ });
}
@Override
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java
index 9aeca0bdbe..8f9cd3c371 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java
@@ -22,7 +22,8 @@ import com.vaadin.shared.AbstractComponentState;
* @author Vaadin Ltd
*/
public class TestGridState extends AbstractComponentState {
- public static final String DEFAULT_HEIGHT = "400px";
+ // public static final String DEFAULT_HEIGHT = "400px";
+ public static final String DEFAULT_HEIGHT = "405px";
/* TODO: this should be "100%" before setting final. */
public static final String DEFAULT_WIDTH = "800px";
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
index 274b01b166..b3dff67338 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
@@ -19,10 +19,16 @@ public class VTestGrid extends Composite {
public static class BodyRenderer implements CellRenderer {
private int i = 0;
+ private int ri = 0;
@Override
public void renderCell(final Cell cell) {
- cell.getElement().setInnerText("Cell #" + (i++));
+ if (cell.getColumn() != 0) {
+ cell.getElement().setInnerText("Cell #" + (i++));
+ } else {
+ cell.getElement().setInnerText(
+ "Logical row " + cell.getRow() + "/" + (ri++));
+ }
double c = i * .1;
int r = (int) ((Math.cos(c) + 1) * 128);
@@ -30,8 +36,10 @@ public class VTestGrid extends Composite {
int b = (int) ((Math.cos(c / (Math.PI * 2)) + 1) * 128);
cell.getElement().getStyle()
.setBackgroundColor("rgb(" + r + "," + g + "," + b + ")");
- if ((r + g + b) / 3 < 127) {
+ if ((r * .8 + g * 1.3 + b * .9) / 3 < 127) {
cell.getElement().getStyle().setColor("white");
+ } else {
+ cell.getElement().getStyle().clearColor();
}
}
}
@@ -49,12 +57,8 @@ public class VTestGrid extends Composite {
public VTestGrid() {
initWidget(escalator);
-
final ColumnConfiguration cConf = escalator.getColumnConfiguration();
- cConf.insertColumns(0, 1);
- cConf.insertColumns(0, 1); // prepend one column
- cConf.insertColumns(cConf.getColumnCount(), 1); // append one column
- // cConf.insertColumns(cConf.getColumnCount(), 10); // append 10 columns
+ cConf.insertColumns(cConf.getColumnCount(), 5);
final RowContainer h = escalator.getHeader();
h.setCellRenderer(new HeaderRenderer());
@@ -62,52 +66,22 @@ public class VTestGrid extends Composite {
final RowContainer b = escalator.getBody();
b.setCellRenderer(new BodyRenderer());
- b.insertRows(0, 5);
+ b.insertRows(0, 10);
final RowContainer f = escalator.getFooter();
f.setCellRenderer(new FooterRenderer());
f.insertRows(0, 1);
- b.removeRows(3, 2);
- // iterative transformations for testing.
- // step2();
- // step3();
- // step4();
- // step5();
- // step6();
-
setWidth(TestGridState.DEFAULT_WIDTH);
setHeight(TestGridState.DEFAULT_HEIGHT);
- }
- private void step2() {
- RowContainer b = escalator.getBody();
- b.insertRows(0, 5); // prepend five rows
- b.insertRows(b.getRowCount(), 5); // append five rows
}
- private void step3() {
- ColumnConfiguration cConf = escalator.getColumnConfiguration();
- cConf.insertColumns(0, 1); // prepend one column
- cConf.insertColumns(cConf.getColumnCount(), 1); // append one column
+ public RowContainer getBody() {
+ return escalator.getBody();
}
- private void step4() {
- final ColumnConfiguration cConf = escalator.getColumnConfiguration();
- cConf.removeColumns(0, 1);
- cConf.removeColumns(1, 1);
- cConf.removeColumns(cConf.getColumnCount() - 1, 1);
+ public ColumnConfiguration getColumnConfiguration() {
+ return escalator.getColumnConfiguration();
}
-
- private void step5() {
- final RowContainer b = escalator.getBody();
- b.removeRows(0, 1);
- b.removeRows(b.getRowCount() - 1, 1);
- }
-
- private void step6() {
- RowContainer b = escalator.getBody();
- b.refreshRows(0, b.getRowCount());
- }
-
}
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java b/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java
index 7ae7e03193..7fc20420d2 100644
--- a/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java
+++ b/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java
@@ -15,6 +15,7 @@
*/
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;
@@ -32,4 +33,24 @@ public class TestGrid extends AbstractComponent {
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);
+ }
}