diff options
author | John Alhroos <john.ahlroos@itmill.com> | 2010-04-16 06:11:27 +0000 |
---|---|---|
committer | John Alhroos <john.ahlroos@itmill.com> | 2010-04-16 06:11:27 +0000 |
commit | ab798fddd8df7ae3d0e8f31691088914b26889a1 (patch) | |
tree | 8d6bddfed61423f89b30e37f491c6d9b6df28b71 | |
parent | 1e59ab1a22b651811b4474531cfb1b27d26b97d8 (diff) | |
download | vaadin-framework-ab798fddd8df7ae3d0e8f31691088914b26889a1.tar.gz vaadin-framework-ab798fddd8df7ae3d0e8f31691088914b26889a1.zip |
Added JUnit testcases for #3520
svn changeset:12583/svn branch:6.4
-rw-r--r-- | tests/src/com/vaadin/tests/server/component/table/TestMultipleSelection.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/src/com/vaadin/tests/server/component/table/TestMultipleSelection.java b/tests/src/com/vaadin/tests/server/component/table/TestMultipleSelection.java new file mode 100644 index 0000000000..ff31e20a3e --- /dev/null +++ b/tests/src/com/vaadin/tests/server/component/table/TestMultipleSelection.java @@ -0,0 +1,56 @@ +package com.vaadin.tests.server.component.table; + +import java.util.Set; + +import junit.framework.TestCase; + +import com.google.appengine.repackaged.com.google.common.collect.Lists; +import com.vaadin.data.Container; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.MultiSelectMode; + +public class TestMultipleSelection extends TestCase { + + /** + * Tests weather the multiple select mode is set when using Table.set + */ + @SuppressWarnings("unchecked") + public void testSetMultipleItems() { + Table table = new Table("", createTestContainer()); + + // Tests if multiple selection is set + table.setMultiSelect(true); + assertTrue(table.isMultiSelect()); + + // Test multiselect by setting several items at once + table.setValue(Lists.asList("1", new String[] { "3" })); + assertEquals(2, ((Set<String>) table.getValue()).size()); + } + + /** + * Tests setting the multiselect mode of the Table. The multiselect mode + * affects how mouse selection is made in the table by the user. + */ + public void testSetMultiSelectMode() { + Table table = new Table("", createTestContainer()); + + // Default multiselect mode should be MultiSelectMode.DEFAULT + assertEquals(MultiSelectMode.DEFAULT, table.getMultiSelectMode()); + + // Tests if multiselectmode is set + table.setMultiSelectMode(MultiSelectMode.SIMPLE); + assertEquals(MultiSelectMode.SIMPLE, table.getMultiSelectMode()); + } + + /** + * Creates a testing container for the tests + * + * @return A new container with test items + */ + private Container createTestContainer() { + IndexedContainer container = new IndexedContainer(Lists.asList("1", + new String[] { "2", "3", "4" })); + return container; + } +} |