From c521f6ed4c40eeee5f4a9fa1628aff711e37bb7d Mon Sep 17 00:00:00 2001 From: Automerge Date: Wed, 18 Apr 2012 13:21:15 +0000 Subject: [PATCH] [merge from 6.7] Test for #8662: Improved old #2864 test case and added a TestBench script svn changeset:23572/svn branch:6.8 --- .../table/TestCurrentPageFirstItem.html | 42 ++++++++++ .../table/TestCurrentPageFirstItem.java | 83 +++++++++++-------- 2 files changed, 91 insertions(+), 34 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html diff --git a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html new file mode 100644 index 0000000000..ac06706aa5 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html @@ -0,0 +1,42 @@ + + + + + + +TestCurrentPageFirstItem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestCurrentPageFirstItem
open/run/TestCurrentPageFirstItem?restartApplication
clickvaadin=runTestCurrentPageFirstItem::/VHorizontalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runTestCurrentPageFirstItem::/VHorizontalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]
clickvaadin=runTestCurrentPageFirstItem::/VHorizontalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]
screenCapture
+ + diff --git a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java index 1733b15e80..6e38f2a156 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java +++ b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java @@ -1,60 +1,75 @@ package com.vaadin.tests.components.table; -import com.vaadin.Application; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; +import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Table; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window; -public class TestCurrentPageFirstItem extends Application implements - ClickListener { +public class TestCurrentPageFirstItem extends TestBase implements ClickListener { private Button buttonIndex; private Button buttonItem; - private Table table; + private Table[] tables = new Table[4]; private int counter = 0; IndexedContainer container = new IndexedContainer(); @Override - public void init() { - try { - Window main = new Window("Table header Test"); - setMainWindow(main); - main.setSizeFull(); - // setTheme("testtheme"); - VerticalLayout baseLayout = new VerticalLayout(); - main.setContent(baseLayout); - - table = new Table(); - container.addContainerProperty("row", String.class, ""); - table.setContainerDataSource(container); - table.setWidth("100%"); - table.setPageLength(3); - buttonIndex = new Button("Add row and select last index", this); - buttonItem = new Button("Add row and select last item", this); - - baseLayout.addComponent(table); - baseLayout.addComponent(buttonIndex); - baseLayout.addComponent(buttonItem); - } catch (Exception e) { - e.printStackTrace(); + public void setup() { + container.addContainerProperty("row", String.class, ""); + + HorizontalLayout baseLayout = new HorizontalLayout(); + baseLayout.setHeight("115px"); + addComponent(baseLayout); + + for (int i = 0; i < tables.length; ++i) { + Table t = new Table(); + t.setContainerDataSource(container); + t.setWidth("100px"); + baseLayout.addComponent(t); + tables[i] = t; } + tables[0].setSizeFull(); + tables[0].setCaption("Full"); + tables[1].setHeight("100px"); + tables[1].setCaption("100px"); + tables[2].setHeight("95%"); + tables[2].setCaption("95%"); + tables[3].setPageLength(3); + tables[3].setCaption("3 rows"); + + buttonIndex = new Button("Add row and select last index", this); + buttonItem = new Button("Add row and select last item", this); + baseLayout.addComponent(buttonIndex); + baseLayout.addComponent(buttonItem); } public void buttonClick(ClickEvent event) { Item item = container.addItem(++counter); item.getItemProperty("row").setValue(counter + ""); - table.select(counter); - if (event.getButton() == buttonIndex) { - table.setCurrentPageFirstItemIndex(((Container.Indexed) table - .getContainerDataSource()).indexOfId(counter)); - } else { - table.setCurrentPageFirstItemId(counter); + for (int i = 0; i < tables.length; ++i) { + Table t = tables[i]; + t.select(counter); + if (event.getButton() == buttonIndex) { + t.setCurrentPageFirstItemIndex(((Container.Indexed) t + .getContainerDataSource()).indexOfId(counter)); + } else { + t.setCurrentPageFirstItemId(counter); + } } } + + @Override + protected String getDescription() { + return "Table height changes when using setCurrentPageFirstItemId"; + } + + @Override + protected Integer getTicketNumber() { + return 2864; + } } -- 2.39.5