diff options
author | Henrik Paul <henrik@vaadin.com> | 2013-11-18 14:50:18 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-11-21 14:33:29 +0000 |
commit | c2b988781045d1e6723b8159ca34d6c0afcdcde8 (patch) | |
tree | 5974f71475e21c7f46a890a8e367558eac950968 /uitest | |
parent | e3b1e6be389cbe48d1782723adf1595edbd10ea2 (diff) | |
download | vaadin-framework-c2b988781045d1e6723b8159ca34d6c0afcdcde8.tar.gz vaadin-framework-c2b988781045d1e6723b8159ca34d6c0afcdcde8.zip |
Fixes Escalator resize issues (#12645)
Change-Id: I34273d35338568833b179b61294de7462abe78f1
Diffstat (limited to 'uitest')
6 files changed, 118 insertions, 7 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java b/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java index a9cd22365e..2431fc815c 100644 --- a/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java +++ b/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.java @@ -16,6 +16,8 @@ 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; @@ -39,6 +41,8 @@ public class BasicEscalator extends AbstractTestUI { 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(); @@ -55,7 +59,6 @@ public class BasicEscalator extends AbstractTestUI { insertRowsLayout.addComponent(new Button("insert rows", new Button.ClickListener() { @Override - @SuppressWarnings("boxing") public void buttonClick(final ClickEvent event) { final int offset = Integer.parseInt(insertRowsOffset .getValue()); @@ -78,7 +81,6 @@ public class BasicEscalator extends AbstractTestUI { removeRowsLayout.addComponent(new Button("remove rows", new Button.ClickListener() { @Override - @SuppressWarnings("boxing") public void buttonClick(final ClickEvent event) { final int offset = Integer.parseInt(removeRowsOffset .getValue()); @@ -97,7 +99,6 @@ public class BasicEscalator extends AbstractTestUI { insertColumnsLayout.addComponent(new Button("insert columns", new Button.ClickListener() { @Override - @SuppressWarnings("boxing") public void buttonClick(final ClickEvent event) { final int offset = Integer.parseInt(insertColumnsOffset .getValue()); @@ -116,7 +117,6 @@ public class BasicEscalator extends AbstractTestUI { removeColumnsLayout.addComponent(new Button("remove columns", new Button.ClickListener() { @Override - @SuppressWarnings("boxing") public void buttonClick(final ClickEvent event) { final int offset = Integer.parseInt(removeColumnsOffset .getValue()); @@ -214,6 +214,56 @@ public class BasicEscalator extends AbstractTestUI { } }))); + 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); + } + } + })); + } @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 index 71fcd63086..225cc34147 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridClientRpc.java @@ -31,4 +31,12 @@ public interface TestGridClientRpc extends ClientRpc { 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); } 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 7b722e03c0..b355c9e79c 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java @@ -82,6 +82,26 @@ public class TestGridConnector extends AbstractComponentConnector { 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); + } }); } 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 8f9cd3c371..73d6ba311c 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java @@ -22,9 +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 = "405px"; + public static final String DEFAULT_HEIGHT = "400.0px"; /* TODO: this should be "100%" before setting final. */ - public static final String DEFAULT_WIDTH = "800px"; + 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 index 5edc2ab0a0..e9ee461fb9 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java @@ -187,4 +187,22 @@ public class VTestGrid extends Composite { 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 getFooter() { + return escalator.getFooter(); + } } 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 e37d9ccee0..2f14f21f0e 100644 --- a/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java +++ b/uitest/src/com/vaadin/tests/widgetset/server/grid/TestGrid.java @@ -65,4 +65,20 @@ public class TestGrid extends AbstractComponent { 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); + } } |