From bbbdef8c4fc34e6ad6db3295cf03643de23208f4 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 24 Feb 2011 12:33:29 +0000 Subject: [PATCH] Test for #6494 Making tables invisible and visible again does not work correctly svn changeset:17432/svn branch:6.5 --- .../table/TableToggleVisibility.html | 116 ++++++++++++ .../table/TableToggleVisibility.java | 169 ++++++++++++++++++ 2 files changed, 285 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html create mode 100644 tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java diff --git a/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html new file mode 100644 index 0000000000..e9c57203c0 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html @@ -0,0 +1,116 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.TableToggleVisibility?restartApplication
screenCapturetrucks-trailers-drivers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturedrivers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]
screenCapturetrailers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]
screenCapturetrailers-drivers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
screenCapturetrucks-trailers-drivers-2
+ + diff --git a/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java new file mode 100644 index 0000000000..5c456ab230 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java @@ -0,0 +1,169 @@ +package com.vaadin.tests.components.table; + +import java.text.DecimalFormat; + +import com.vaadin.tests.components.AbstractTestCase; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.HorizontalSplitPanel; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class TableToggleVisibility extends AbstractTestCase { + + private static final int[] LENGTHS = new int[] { 20, 22, 10 }; + + @Override + public void init() { + + DecimalFormat format = new DecimalFormat("000"); + Table[] tables = new Table[3]; + Button[] buttons = new Button[3]; + + VerticalLayout leftComponent = new VerticalLayout(); + leftComponent.setMargin(true); + leftComponent.setSpacing(true); + + // Toolbar with buttons to hide or show lists + + HorizontalLayout toolBar = new HorizontalLayout(); + toolBar.setSpacing(true); + toolBar.setMargin(true); + + leftComponent.addComponent(toolBar); + leftComponent.setExpandRatio(toolBar, 0.0f); + + // List of trucks ----------------------- + + tables[0] = new Table("Trucks"); + tables[0].addContainerProperty("Brand", String.class, null); + tables[0].addContainerProperty("Model", String.class, null); + tables[0].addContainerProperty("License Plate", String.class, null); + + for (int i = 1; i < LENGTHS[0]; i++) { + tables[0].addItem( + new Object[] { "MAN", "XYZ", "1-ABC-" + format.format(i) }, + Integer.valueOf(i)); + } + tables[0].setPageLength(LENGTHS[0]); + + tables[0].setWidth("100%"); + tables[0].setHeight("100%"); + tables[0].setSelectable(true); + + leftComponent.addComponent(tables[0]); + leftComponent.setExpandRatio(tables[0], 1.0f); + + // List of trailers ---------------------- + + tables[1] = new Table("Trailers"); + tables[1].addContainerProperty("Type", String.class, null); + tables[1].addContainerProperty("License Plate", String.class, null); + for (int i = 1; i < LENGTHS[1]; i++) { + tables[1].addItem( + new Object[] { "Cooler", "1-QQQ-" + format.format(i) }, + Integer.valueOf(i)); + } + tables[1].setPageLength(LENGTHS[1]); + + tables[1].setWidth("100%"); + tables[1].setHeight("100%"); + tables[1].setSelectable(true); + + leftComponent.addComponent(tables[1]); + leftComponent.setExpandRatio(tables[1], 1.0f); + + // List of drivers ------------------------ + + tables[2] = new Table("Drivers"); + tables[2].addContainerProperty("First Name", String.class, null); + tables[2].addContainerProperty("Last Name", String.class, null); + tables[2].addContainerProperty("HR ID", String.class, null); + for (int i = 1; i < LENGTHS[2]; i++) { + tables[2].addItem( + new Object[] { "King", "Vabis", "HR-" + format.format(i) }, + Integer.valueOf(i)); + } + tables[2].setPageLength(LENGTHS[2]); + + tables[2].setWidth("100%"); + tables[2].setHeight("100%"); + tables[2].setSelectable(true); + + leftComponent.addComponent(tables[2]); + leftComponent.setExpandRatio(tables[2], 1.0f); + + leftComponent.setWidth("100%"); + + HorizontalSplitPanel split = new HorizontalSplitPanel(); + split.setFirstComponent(leftComponent); + + VerticalLayout rightComponent = new VerticalLayout(); + rightComponent.setMargin(true); + rightComponent.addComponent(new Label("Left blank!")); + split.setSecondComponent(rightComponent); + + split.setSizeFull(); + + VerticalLayout mainLayout = new VerticalLayout(); + mainLayout.setSizeFull(); + mainLayout.addComponent(split); + mainLayout.setExpandRatio(split, 1.0f); + + Window mainWindow = new Window("Visibilitybug Application", mainLayout); + mainWindow.setSizeFull(); + + setMainWindow(mainWindow); + + // complete toolbar + + for (int i = 0; i < buttons.length; i++) { + buttons[i] = new ToggleButton(tables[i]); + toolBar.addComponent(buttons[i]); + } + + } + + // Button to switch the visibility of a table. + + private static class ToggleButton extends Button { + + private Table table; + + private ToggleButton(Table table) { + this.table = table; + + setCaption("- " + table.getCaption()); + + addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + + boolean wasVisible = ToggleButton.this.table.isVisible(); + + ToggleButton.this.table.setVisible(!wasVisible); + setCaption((wasVisible ? "+ " : "- ") + + ToggleButton.this.table.getCaption()); + setDescription((wasVisible ? "Show " : "Hide ") + + "the list with " + + ToggleButton.this.table.getCaption()); + + } + }); + } + + } + + @Override + protected String getDescription() { + return "Test for hiding and showing tables. Click a button to show/hide one of the tables. The tables are all 100% wide and should be rendered the same way after being hidden and shown again."; + } + + @Override + protected Integer getTicketNumber() { + return 6494; + } + +} \ No newline at end of file -- 2.39.5