From ce4c938f03684b1d074c8f6163165de2b21dc10c Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Thu, 19 Aug 2010 07:09:58 +0000 Subject: [PATCH] Testcase and fix for #5457 svn changeset:14532/svn branch:6.4 --- .../gwt/client/ui/VAbsoluteLayout.java | 7 + .../layouts/WidgetImplementationSwap.html | 157 +++++++++++++++++ .../layouts/WidgetImplementationSwap.java | 161 ++++++++++++++++++ 3 files changed, 325 insertions(+) create mode 100644 tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.html create mode 100644 tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java index 0b5356a17e..286704a0fe 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java @@ -285,6 +285,13 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { } } + @Override + public void setWidget(Widget w) { + // this fixes #5457 (Widget implementation can change on-the-fly) + paintable = (Paintable) w; + super.setWidget(w); + } + public void destroy() { if (caption != null) { caption.removeFromParent(); diff --git a/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.html b/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.html new file mode 100644 index 0000000000..5ce788213c --- /dev/null +++ b/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.html @@ -0,0 +1,157 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/64/run/com.vaadin.tests.layouts.WidgetImplementationSwap?restartApplication
waitForVaadin
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
assertElementHeightvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextArea[0]66
assertElementHeightvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VHorizontalLayout[0]/ChildComponentContainer[0]/VTextArea[0]66
assertElementHeightvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextArea[0]66
assertElementHeightvaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextArea[0]66
assertElementHeight//input[@type='text']66
+ + diff --git a/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java b/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java new file mode 100644 index 0000000000..b1896091cb --- /dev/null +++ b/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java @@ -0,0 +1,161 @@ +package com.vaadin.tests.layouts; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbsoluteLayout; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class WidgetImplementationSwap extends TestBase { + + @Override + protected void setup() { + setTheme("tests-tickets"); + + { + final AbstractLayout layout = new AbsoluteLayout(); + layout.setCaption(layout.getClass().getSimpleName()); + layout.setStyleName("borders"); + layout.setWidth("500px"); + layout.setHeight("50px"); + addComponent(layout); + final TextField tf = new TextField(); + layout.addComponent(tf); + Button b = new Button("-> TextArea", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + if (tf.getRows() == 0) { + tf.setRows(3); + event.getButton().setCaption("Move"); + } else { + layout.setCaption(layout.getClass().getSimpleName() + + " done"); + event.getButton().setCaption("done"); + } + + } + }); + addComponent(b); + } + { + final AbstractLayout layout = new VerticalLayout(); + layout.setCaption(layout.getClass().getSimpleName()); + layout.setStyleName("borders"); + layout.setWidth("500px"); + layout.setHeight("50px"); + addComponent(layout); + final TextField tf = new TextField(); + layout.addComponent(tf); + Button b = new Button("-> TextArea", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + if (tf.getRows() == 0) { + tf.setRows(3); + event.getButton().setCaption("Move"); + } else { + layout.setCaption(layout.getClass().getSimpleName() + + " done"); + event.getButton().setCaption("done"); + } + + } + }); + addComponent(b); + } + + { + final AbstractLayout layout = new HorizontalLayout(); + layout.setCaption(layout.getClass().getSimpleName()); + layout.setStyleName("borders"); + layout.setWidth("500px"); + layout.setHeight("50px"); + addComponent(layout); + final TextField tf = new TextField(); + layout.addComponent(tf); + Button b = new Button("-> TextArea", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + if (tf.getRows() == 0) { + tf.setRows(3); + event.getButton().setCaption("Move"); + } else { + layout.setCaption(layout.getClass().getSimpleName() + + " done"); + event.getButton().setCaption("done"); + } + + } + }); + addComponent(b); + } + + { + final AbstractLayout layout = new GridLayout(); + layout.setCaption(layout.getClass().getSimpleName()); + layout.setStyleName("borders"); + layout.setWidth("500px"); + layout.setHeight("50px"); + addComponent(layout); + final TextField tf = new TextField(); + layout.addComponent(tf); + Button b = new Button("-> TextArea", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + if (tf.getRows() == 0) { + tf.setRows(3); + event.getButton().setCaption("Move"); + } else { + layout.setCaption(layout.getClass().getSimpleName() + + " done"); + event.getButton().setCaption("done"); + } + + } + }); + addComponent(b); + } + + { + final AbstractLayout layout = new CssLayout(); + layout.setCaption(layout.getClass().getSimpleName()); + layout.setStyleName("borders"); + layout.setWidth("500px"); + layout.setHeight("50px"); + addComponent(layout); + final TextField tf = new TextField(); + layout.addComponent(tf); + Button b = new Button("-> TextArea", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + if (tf.getRows() == 0) { + tf.setRows(3); + event.getButton().setCaption("Move"); + } else { + layout.setCaption(layout.getClass().getSimpleName() + + " done"); + event.getButton().setCaption("done"); + } + + } + }); + addComponent(b); + } + + } + + @Override + protected String getDescription() { + return "First click turns TextField into a TextArea (on the client); second click modifies the layout - widget should still be a TextArea."; + } + + @Override + protected Integer getTicketNumber() { + return 5457; + } + +} -- 2.39.5