diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-01-18 13:52:14 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-02-15 17:11:33 +0200 |
commit | ccde161e56b586d6ab55fd15f08ab4fd5965e4d3 (patch) | |
tree | dbf013b3ddeeec21b54fc69a73c6ab513142369a /uitest/src/com | |
parent | 3824db71f4d6f3b51d95d5a60f7362de60977768 (diff) | |
download | vaadin-framework-ccde161e56b586d6ab55fd15f08ab4fd5965e4d3.tar.gz vaadin-framework-ccde161e56b586d6ab55fd15f08ab4fd5965e4d3.zip |
Fix NPE on column width detection in TreeTable and RowGenerator (#19437)
Change-Id: Icaf037a045d75e0b93781abcc80f7137f6a4d306
Diffstat (limited to 'uitest/src/com')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGenerator.java | 65 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGeneratorTest.java | 31 |
2 files changed, 96 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGenerator.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGenerator.java new file mode 100644 index 0000000000..e8da4abbec --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGenerator.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2014 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.treetable; + +import com.vaadin.data.Item; +import com.vaadin.data.util.HierarchicalContainer; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Table; +import com.vaadin.ui.TreeTable; + +public class TreeTableRowGenerator extends AbstractTestUI { + public static final String COLUMN_A = "first"; + public static final String COLUMN_B = "second"; + + @Override + protected void setup(VaadinRequest request) { + TreeTable treeTable = new TreeTable(); + + final HierarchicalContainer hierarchicalContainer = new HierarchicalContainer(); + hierarchicalContainer.addContainerProperty(COLUMN_A, String.class, ""); + hierarchicalContainer.addContainerProperty(COLUMN_B, String.class, ""); + + Item it = hierarchicalContainer.addItem(0); + it.getItemProperty(COLUMN_A).setValue("row 1 column a"); + it.getItemProperty(COLUMN_B).setValue("row 1 column b"); + hierarchicalContainer.setChildrenAllowed(0, true); + + Item it2 = hierarchicalContainer.addItem(1); + it2.getItemProperty(COLUMN_A).setValue("row 2 column a"); + it2.getItemProperty(COLUMN_B).setValue("row 2 column b"); + hierarchicalContainer.setChildrenAllowed(1, false); + + hierarchicalContainer.setParent(1, 0); + + treeTable.setRowGenerator(new Table.RowGenerator() { + @Override + public Table.GeneratedRow generateRow(Table table, Object itemId) { + if (table instanceof TreeTable + && ((TreeTable) table).areChildrenAllowed(itemId)) { + return new Table.GeneratedRow("Spanned Row"); + } else { + return null; + } + } + }); + + treeTable.setContainerDataSource(hierarchicalContainer); + treeTable.setSizeFull(); + addComponent(treeTable); + } +} diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGeneratorTest.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGeneratorTest.java new file mode 100644 index 0000000000..84a2f7bbb3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowGeneratorTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2014 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.treetable; + +import org.junit.Test; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class TreeTableRowGeneratorTest extends SingleBrowserTest { + + @Test + public void testNoExceptionOnRender() { + setDebug(true); + openTestURL(); + + assertNoErrorNotifications(); + } +} |