diff options
author | John Alhroos <john.ahlroos@itmill.com> | 2010-05-19 10:37:24 +0000 |
---|---|---|
committer | John Alhroos <john.ahlroos@itmill.com> | 2010-05-19 10:37:24 +0000 |
commit | cea1358018fc4c51cbbf1fbe3b66a013874ecb27 (patch) | |
tree | 094d87bf3fd5f05cc9b0e56913f17b3aaa52a5ca /tests | |
parent | df71308570f37117d0b1f05043729ecf6db881ee (diff) | |
download | vaadin-framework-cea1358018fc4c51cbbf1fbe3b66a013874ecb27.tar.gz vaadin-framework-cea1358018fc4c51cbbf1fbe3b66a013874ecb27.zip |
Fix for #4542 + JUnit test + Test Application
svn changeset:13251/svn branch:6.3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java | 46 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java | 32 |
2 files changed, 78 insertions, 0 deletions
diff --git a/tests/src/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java b/tests/src/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java new file mode 100644 index 0000000000..db765e0636 --- /dev/null +++ b/tests/src/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java @@ -0,0 +1,46 @@ +package com.vaadin.tests.layouts; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Button.ClickEvent; + +/** + * Tests removing rows from a GridLayout + */ +@SuppressWarnings("serial") +public class GridLayoutRemoveFinalRow extends TestBase { + + @Override + protected void setup() { + getLayout().setSpacing(true); + + final GridLayout layout = new GridLayout(2, 2); + layout.setSpacing(true); + layout.addComponent(new Label("Label1")); + layout.addComponent(new Label("Label2")); + layout.addComponent(new Label("Label3")); + layout.addComponent(new Label("Label4")); + addComponent(layout); + + Button removeRowBtn = new Button("Remove row", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + layout.removeRow(0); + } + }); + addComponent(removeRowBtn); + } + + @Override + protected String getDescription() { + return "Removing last row of a GridLayout throws a IllegalArgumentException"; + } + + @Override + protected Integer getTicketNumber() { + return 4542; + } + +} diff --git a/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java b/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java new file mode 100644 index 0000000000..8881b9e273 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.server.components; + +import junit.framework.TestCase; + +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; + +public class TestGridLayoutLastRowRemoval extends TestCase { + + public void testRemovingLastRow() { + GridLayout grid = new GridLayout(2, 1); + grid.addComponent(new Label("Col1")); + grid.addComponent(new Label("Col2")); + + try { + // Removing the last row in the grid + grid.removeRow(0); + } catch (IllegalArgumentException iae) { + // Removing the last row should not throw an + // IllegalArgumentException + fail("removeRow(0) threw an IllegalArgumentExcetion when removing the last row"); + } + + // The grid should now be empty with one row and one column + assertEquals(1, grid.getColumns()); + assertEquals(1, grid.getRows()); + + // There should be no component left in the grid layout + assertNull("A component should not be left in the layout", grid + .getComponent(0, 0)); + } +} |