From 9ee0c0d568410fb76b35d8e6f4bbdc910c69759a Mon Sep 17 00:00:00 2001 From: John Alhroos Date: Tue, 21 Dec 2010 13:53:09 +0000 Subject: Fix for #6188 + Testbench tests svn changeset:16608/svn branch:6.5 --- .../tabsheet/TabGetAndReplaceComponent.html | 72 +++++++++++++++++++++ .../tabsheet/TabGetAndReplaceComponent.java | 54 ++++++++++++++++ .../tabsheet/TabSheetIndexOperations.html | 52 +++++++++++++++ .../tabsheet/TabSheetIndexOperations.java | 74 ++++++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.html create mode 100644 tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java create mode 100644 tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.html create mode 100644 tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java (limited to 'tests') diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.html b/tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.html new file mode 100644 index 0000000000..fce39361e1 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.html @@ -0,0 +1,72 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.tabsheet.TabGetAndReplaceComponent?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]18,13
assertTextvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/VTabsheetPanel[0]/VLabel[1]Content 2
clickvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/VTabsheetPanel[0]/VLabel[1]Replacement 2
mouseClickvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]41,13
mouseClickvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]16,11
mouseClickvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]39,11
mouseClickvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]42,12
mouseClickvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]37,10
assertTextvaadin=runcomvaadintestscomponentstabsheetTabGetAndReplaceComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/VTabsheetPanel[0]/VLabel[0]Content 1
+ + diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java b/tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java new file mode 100644 index 0000000000..c49133dd7c --- /dev/null +++ b/tests/src/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java @@ -0,0 +1,54 @@ +package com.vaadin.tests.components.tabsheet; + +import java.util.Iterator; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TabSheet.Tab; + +public class TabGetAndReplaceComponent extends TestBase { + + @Override + protected void setup() { + final TabSheet tabs = new TabSheet(); + + tabs.addTab(new Label("Content 1"), "Content 1", null); + tabs.addTab(new Label("Content 2"), "Content 2", null); + tabs.addTab(new Label("Content 3"), "Content 3", null); + tabs.addTab(new Label("Content 4"), "Content 4", null); + tabs.addTab(new Label("Content 5"), "Content 5", null); + addComponent(tabs); + + Button replace2 = new Button("Replace Content 2", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Iterator iter = tabs.getComponentIterator(); + iter.next(); + + Component content2 = iter.next(); + Tab tab = tabs.getTab(content2); + + // Replace content + tabs.replaceComponent(tab.getComponent(), new Label( + "Replacement 2")); + + } + }); + addComponent(replace2); + } + + @Override + protected String getDescription() { + return "The tab should have a reference to the component it holds"; + } + + @Override + protected Integer getTicketNumber() { + return 6188; + } + +} diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.html b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.html new file mode 100644 index 0000000000..8db5641603 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.html @@ -0,0 +1,52 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.tabsheet.TabSheetIndexOperations?restartApplication
clickvaadin=runcomvaadintestscomponentstabsheetTabSheetIndexOperations::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstabsheetTabSheetIndexOperations::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]Added Tab 1
clickvaadin=runcomvaadintestscomponentstabsheetTabSheetIndexOperations::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstabsheetTabSheetIndexOperations::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]1 baT deddA
clickvaadin=runcomvaadintestscomponentstabsheetTabSheetIndexOperations::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstabsheetTabSheetIndexOperations::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]Tab 1
+ + diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java new file mode 100644 index 0000000000..31bf1f1588 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java @@ -0,0 +1,74 @@ +package com.vaadin.tests.components.tabsheet; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TabSheet.Tab; + +public class TabSheetIndexOperations extends TestBase { + + private int tabCounter = 1; + + @Override + protected void setup() { + final TabSheet tabs = new TabSheet(); + + // Add some tabs + tabs.addTab(new Label("Content 1"), "Tab 1", null); + tabs.addTab(new Label("Content 2"), "Tab 2", null); + tabs.addTab(new Label("Content 3"), "Tab 3", null); + + addComponent(tabs); + + Button addTab = new Button("Add tab at index 2", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tabs.addTab(new Label("Content " + tabCounter), + "Added Tab " + tabCounter, null, 2); + tabCounter++; + } + }); + addComponent(addTab); + + Button setCaption = new Button("Invert tab caption at index 2", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Tab tab = tabs.getTab(2); + tab.setCaption(new StringBuffer(tab.getCaption()) + .reverse().toString()); + } + }); + addComponent(setCaption); + + Button move = new Button("Move selected tab to index 2", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tabs.setTabIndex(tabs.getTab(tabs.getSelectedTab()), 2); + } + }); + addComponent(move); + + Button getIndex = new Button("Get selected tab index", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getMainWindow().showNotification( + "Index: " + + tabs.getTabIndex(tabs.getTab(tabs + .getSelectedTab()))); + + } + }); + addComponent(getIndex); + } + + @Override + protected String getDescription() { + return "You can use indexes to add and reorder the TabSheet"; + } + + @Override + protected Integer getTicketNumber() { + return 6188; + } + +} -- cgit v1.2.3