]> source.dussan.org Git - vaadin-framework.git/commitdiff
Testcase and fix for #5457
authorMarc Englund <marc.englund@itmill.com>
Thu, 19 Aug 2010 07:09:58 +0000 (07:09 +0000)
committerMarc Englund <marc.englund@itmill.com>
Thu, 19 Aug 2010 07:09:58 +0000 (07:09 +0000)
svn changeset:14532/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java
tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.html [new file with mode: 0644]
tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java [new file with mode: 0644]

index 0b5356a17ea24c7fcafca61c5cd7e89e60ff36e9..286704a0fed7dc3da1d627d5bd46f871890381df 100644 (file)
@@ -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 (file)
index 0000000..5ce7882
--- /dev/null
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8080/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/64/run/com.vaadin.tests.layouts.WidgetImplementationSwap?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertElementHeight</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextArea[0]</td>
+       <td>66</td>
+</tr>
+<tr>
+       <td>assertElementHeight</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VHorizontalLayout[0]/ChildComponentContainer[0]/VTextArea[0]</td>
+       <td>66</td>
+</tr>
+<tr>
+       <td>assertElementHeight</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextArea[0]</td>
+       <td>66</td>
+</tr>
+<tr>
+       <td>assertElementHeight</td>
+       <td>vaadin=64runcomvaadintestslayoutsWidgetImplementationSwap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextArea[0]</td>
+       <td>66</td>
+</tr>
+<tr>
+       <td>assertElementHeight</td>
+       <td>//input[@type='text']</td>
+       <td>66</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java b/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java
new file mode 100644 (file)
index 0000000..b189609
--- /dev/null
@@ -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;
+    }
+
+}