From c75cf3956abddcf71ec72e0743eae1cdd52aa661 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Mon, 3 Sep 2012 12:31:35 +0000 Subject: [PATCH] TestBench test case for #8291 svn changeset:24289/svn branch:6.8 --- .../table/TableReduceContainerSize.html | 67 +++++++++++++++++++ .../table/TableReduceContainerSize.java} | 56 +++++++++++----- 2 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.html rename tests/testbench/com/vaadin/tests/{tickets/Ticket8291.java => components/table/TableReduceContainerSize.java} (63%) diff --git a/tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.html b/tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.html new file mode 100644 index 0000000000..9bd0149bdb --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.html @@ -0,0 +1,67 @@ + + + + + + +TableReduceContainerSize + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TableReduceContainerSize
open/run/TableReduceContainerSize?restartApplication
scrollvaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]19700
pause300
clickvaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VLabel[0]Index: *
clickvaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
scrollvaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]19700
pause300
clickvaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VLabel[0]Index: *
+ + diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket8291.java b/tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.java similarity index 63% rename from tests/testbench/com/vaadin/tests/tickets/Ticket8291.java rename to tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.java index 86b5db953b..bc729ef042 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket8291.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.java @@ -1,28 +1,28 @@ -package com.vaadin.tests.tickets; +package com.vaadin.tests.components.table; import java.util.ArrayList; import java.util.Date; import java.util.List; -import com.vaadin.Application; import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; import com.vaadin.ui.Table; -import com.vaadin.ui.Window; /** * Test for #8291 and #7666: NegativeArraySizeException when Table scrolled to * the end and its size reduced. */ -public class Ticket8291 extends Application { +public class TableReduceContainerSize extends TestBase { @Override - public void init() { - setMainWindow(new Window("", new TestView())); + protected void setup() { + addComponent(new TestView()); } private static class DecimateFilter implements Filter { @@ -59,25 +59,41 @@ public class Ticket8291 extends Application { }; table.setContainerDataSource(container); addComponent(table); + final Label label = new Label(); + addComponent(label); Button button = new Button("Click"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { - reduceData = !reduceData; - table.refreshRowCache(); + try { + reduceData = !reduceData; + table.refreshRowCache(); + label.setValue("Index: " + + table.getCurrentPageFirstItemIndex()); + } catch (Exception e) { + label.setValue("Exception: " + + e.getClass().getSimpleName()); + } } }); addComponent(button); Button button2 = new Button("Filter"); button2.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { - if (filter != null) { - container.removeAllContainerFilters(); - filter = null; - } else { - filter = new DecimateFilter(); - container.addContainerFilter(filter); + try { + if (filter != null) { + container.removeAllContainerFilters(); + filter = null; + } else { + filter = new DecimateFilter(); + container.addContainerFilter(filter); + } + table.refreshRowCache(); + label.setValue("Index: " + + table.getCurrentPageFirstItemIndex()); + } catch (Exception e) { + label.setValue("Exception: " + + e.getClass().getSimpleName()); } - table.refreshRowCache(); } }); addComponent(button2); @@ -118,4 +134,14 @@ public class Ticket8291 extends Application { } + @Override + protected String getDescription() { + return "Table throws NegativeArraySizeException if container size is reduced to less than current scroll position"; + } + + @Override + protected Integer getTicketNumber() { + return 8291; + } + } -- 2.39.5