From: Artur Signell Date: Thu, 26 Nov 2009 08:20:13 +0000 (+0000) Subject: Split test case into Layout click test and textfield focus/blur test + auto test... X-Git-Tag: 6.7.0.beta1~2241^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6bbd59bf720d8e71154e5741f54be2e1f8d9c15d;p=vaadin-framework.git Split test case into Layout click test and textfield focus/blur test + auto test for layout click. Simplified ClickEventHandler/LayoutClickEventHandler and made them public so they are available to other components. svn changeset:10054/svn branch:event-framework-3234 --- diff --git a/src/TestListeners.java b/src/TestListeners.java deleted file mode 100644 index 87255b4eac..0000000000 --- a/src/TestListeners.java +++ /dev/null @@ -1,198 +0,0 @@ -import com.vaadin.Application; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.event.LayoutEvents.LayoutClickEvent; -import com.vaadin.event.LayoutEvents.LayoutClickListener; -import com.vaadin.event.MouseEvents.ClickEvent; -import com.vaadin.event.MouseEvents.ClickListener; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.terminal.gwt.client.MouseEventDetails; -import com.vaadin.ui.AbsoluteLayout; -import com.vaadin.ui.Component; -import com.vaadin.ui.Embedded; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window; - -public class TestListeners extends Application implements LayoutClickListener, - ClickListener, FocusListener { - - @Override - public void init() { - Window w = new Window("main window"); - setMainWindow(w); - HorizontalLayout hl = new HorizontalLayout(); - w.setContent(hl); - - final AbsoluteLayout al = new AbsoluteLayout(); - al.setWidth("200px"); - al.setHeight("200px"); - al.addComponent(new TextField("This is its caption", - "This is a textfield"), "top: 20px; left: 0px; width: 100px;"); - al.addComponent(new TextField("Antoerh caption", - "This is another textfield"), - "top: 120px; left: 0px; width: 100px;"); - - final LayoutClickListener lcl = new LayoutClickListener() { - - public void layoutClick(LayoutClickEvent event) { - System.out.println("AL: Click on " + event.getChildComponent()); - // al.removeListener(this); - - } - }; - al.addListener(lcl); - - final GridLayout vl = new GridLayout(); - vl.addComponent(al); - vl.setSpacing(true); - for (int i = 0; i < 10; i++) { - vl.addComponent(new Label("Component " + i)); - ExternalResource res = new ExternalResource( - "http://vaadin.com/image/image_gallery?uuid=07c1f6d5-2e94-4f4d-a707-b548bf22279d&groupId=10919&t=1241012632062"); - Embedded e = new Embedded("an image", res); - e.setType(Embedded.TYPE_IMAGE); - e.addListener(new ClickListener() { - - public void click(ClickEvent event) { - TestListeners.this.click(event); - - } - }); - // e.addListener(this); - vl.addComponent(e); - TextField tf = new TextField("tf"); - tf.setInputPrompt("Please enter a value"); - - // tf.addListener(this); - tf.addListener(new BlurListener() { - - public void blur(BlurEvent event) { - getMainWindow().showNotification( - "Blurred " + event.getComponent()); - - } - }); - tf.addListener(new FocusListener() { - - public void focus(FocusEvent event) { - getMainWindow().showNotification( - "Focused " + event.getComponent()); - - } - }); - vl.addComponent(tf); - } - - // vl.addListener(this); - vl.addListener(new LayoutClickListener() { - - public void layoutClick(LayoutClickEvent event) { - TestListeners.this.layoutClick(event); - vl.removeListener(this); - } - }); - vl.setMargin(true); - - hl.addComponent(vl); - hl.addComponent(createClickableGridLayout()); - hl.addComponent(createClickableVerticalLayout()); - } - - private Layout createClickableGridLayout() { - - GridLayout gl = new GridLayout(3, 3); - addContent(gl, 5); - - gl.addListener(new LayoutClickListener() { - - public void layoutClick(LayoutClickEvent event) { - getMainWindow().showNotification( - "GL-click on " + event.getChildComponent()); - - } - }); - - return wrap(gl, "Clickable GridLayout"); - } - - private Layout createClickableVerticalLayout() { - - VerticalLayout gl = new VerticalLayout(); - addContent(gl, 5); - - gl.addListener(new LayoutClickListener() { - - public void layoutClick(LayoutClickEvent event) { - getMainWindow().showNotification( - "VL-click on " + event.getChildComponent()); - - } - }); - - return wrap(gl, "Clickable VerticalLayout"); - } - - private void addContent(Layout gl, int nr) { - for (int i = 1; i < nr; i++) { - Label l = new Label("This is label " + i); - l.setWidth(null); - gl.addComponent(l); - } - for (int i = nr; i < nr * 2; i++) { - gl.addComponent(new TextField("This is tf" + i, "this is tf " + i)); - } - } - - private Layout wrap(Component c, String caption) { - VerticalLayout vl = new VerticalLayout(); - Label l = new Label(caption); - l.setWidth(null); - vl.addComponent(l); - vl.addComponent(c); - - return vl; - } - - public void layoutClick(LayoutClickEvent event) { - if (event.getChildComponent() == null) { - getMainWindow().showNotification("You missed!"); - } else { - getMainWindow().showNotification( - "Clicked on " + event.getChildComponent() + "!"); - // getMainWindow().removeComponent(event.getChildComponent()); - } - - } - - public void click(ClickEvent event) { - getMainWindow().showNotification( - "Clicked on " + event.getComponent() + " using " - + getButton(event)); - } - - private String getButton(ClickEvent event) { - if (event.getButton() == MouseEventDetails.BUTTON_LEFT) { - return "left"; - } else if (event.getButton() == MouseEventDetails.BUTTON_RIGHT) { - return "right"; - } else { - return "middle"; - } - } - - public void focus(FocusEvent event) { - TextField tf = (TextField) event.getComponent(); - // tf.addStyleName("a"); - // tf.setValue(""); - getMainWindow().requestRepaintAll(); - - } - -} diff --git a/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java b/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java index 3a9a64657c..0a20b112d3 100644 --- a/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java +++ b/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java @@ -90,6 +90,18 @@ public class MouseEventDetails { return instance; } + public String getButtonName() { + if (button == BUTTON_LEFT) { + return "left"; + } else if (button == BUTTON_RIGHT) { + return "right"; + } else if (button == BUTTON_MIDDLE) { + return "middle"; + } + + return ""; + } + public Class getType() { return MouseEventDetails.class; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/ClickEventHandler.java b/src/com/vaadin/terminal/gwt/client/ui/ClickEventHandler.java index aae416ba6a..0e60246d48 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/ClickEventHandler.java +++ b/src/com/vaadin/terminal/gwt/client/ui/ClickEventHandler.java @@ -19,8 +19,8 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.Paintable; -abstract class ClickEventHandler implements ClickHandler, DoubleClickHandler, - ContextMenuHandler, MouseUpHandler { +public abstract class ClickEventHandler implements ClickHandler, + DoubleClickHandler, ContextMenuHandler, MouseUpHandler { private HandlerRegistration clickHandlerRegistration; private HandlerRegistration doubleClickHandlerRegistration; @@ -29,13 +29,15 @@ abstract class ClickEventHandler implements ClickHandler, DoubleClickHandler, protected String clickEventIdentifier; protected Paintable paintable; + private ApplicationConnection client; - ClickEventHandler(Paintable paintable, String clickEventIdentifier) { + public ClickEventHandler(Paintable paintable, String clickEventIdentifier) { this.paintable = paintable; this.clickEventIdentifier = clickEventIdentifier; } - public void handleHandlerRegistration() { + public void handleEventHandlerRegistration(ApplicationConnection client) { + this.client = client; // Handle registering/unregistering of click handler depending on if // server side listeners have been added or removed. if (hasEventListener()) { @@ -70,7 +72,9 @@ abstract class ClickEventHandler implements ClickHandler, DoubleClickHandler, protected abstract HandlerRegistration registerHandler( final H handler, DomEvent.Type type); - public abstract ApplicationConnection getApplicationConnection(); + protected ApplicationConnection getApplicationConnection() { + return client; + } public boolean hasEventListener() { return getApplicationConnection().hasEventListeners(paintable, diff --git a/src/com/vaadin/terminal/gwt/client/ui/LayoutClickEventHandler.java b/src/com/vaadin/terminal/gwt/client/ui/LayoutClickEventHandler.java index c19d0b1c7d..8cf55ca952 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/LayoutClickEventHandler.java +++ b/src/com/vaadin/terminal/gwt/client/ui/LayoutClickEventHandler.java @@ -9,7 +9,7 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.Paintable; -abstract class LayoutClickEventHandler extends ClickEventHandler { +public abstract class LayoutClickEventHandler extends ClickEventHandler { LayoutClickEventHandler(Paintable paintable, String clickEventIdentifier) { super(paintable, clickEventIdentifier); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java index a83df137f4..63f865082b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java @@ -55,11 +55,6 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( this, CLICK_EVENT_IDENTIFIER) { - @Override - public ApplicationConnection getApplicationConnection() { - return client; - } - @Override protected Paintable getChildComponent(Element element) { return getComponent(element); @@ -154,7 +149,7 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { return; } - clickEventHandler.handleHandlerRegistration(); + clickEventHandler.handleEventHandlerRegistration(client); HashSet unrenderedPids = new HashSet( pidToComponentWrappper.keySet()); @@ -417,7 +412,6 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { } } - private Paintable getComponent(Element target) { while (target != null && target != canvas) { Paintable paintable = client.getPaintable(target); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java index adf8d7c354..871e2ae35f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java @@ -39,11 +39,6 @@ public class VEmbedded extends HTML implements Paintable { private ClickEventHandler clickEventHandler = new ClickEventHandler(this, CLICK_EVENT_IDENTIFIER) { - @Override - public ApplicationConnection getApplicationConnection() { - return client; - } - @Override protected HandlerRegistration registerHandler( H handler, Type type) { @@ -64,7 +59,7 @@ public class VEmbedded extends HTML implements Paintable { boolean clearBrowserElement = true; - clickEventHandler.handleHandlerRegistration(); + clickEventHandler.handleEventHandlerRegistration(client); if (uidl.hasAttribute("type")) { final String type = uidl.getStringAttribute("type"); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java index c057135862..2dae5626d6 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java @@ -75,11 +75,6 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( this, CLICK_EVENT_IDENTIFIER) { - @Override - public ApplicationConnection getApplicationConnection() { - return client; - } - @Override protected Paintable getChildComponent(Element element) { return getComponent(element); @@ -112,7 +107,7 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { rendering = false; return; } - clickEventHandler.handleHandlerRegistration(); + clickEventHandler.handleEventHandlerRegistration(client); canvas.setWidth("0px"); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java index 0f548680a1..cb5624142f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java @@ -55,11 +55,6 @@ public class VOrderedLayout extends CellBasedLayout { private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( this, CLICK_EVENT_IDENTIFIER) { - @Override - public ApplicationConnection getApplicationConnection() { - return client; - } - @Override protected Paintable getChildComponent(Element element) { return getComponent(element); @@ -100,7 +95,7 @@ public class VOrderedLayout extends CellBasedLayout { return; } - clickEventHandler.handleHandlerRegistration(); + clickEventHandler.handleEventHandlerRegistration(client); if (allowOrientationUpdate) { handleOrientationUpdate(uidl); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java index e6386e7a7c..8b054160a8 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java @@ -79,11 +79,6 @@ public class VPanel extends SimplePanel implements Container { private ClickEventHandler clickEventHandler = new ClickEventHandler(this, CLICK_EVENT_IDENTIFIER) { - @Override - public ApplicationConnection getApplicationConnection() { - return client; - } - @Override protected HandlerRegistration registerHandler( H handler, Type type) { @@ -126,7 +121,7 @@ public class VPanel extends SimplePanel implements Container { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { rendering = true; if (!uidl.hasAttribute("cached")) { - clickEventHandler.handleHandlerRegistration(); + clickEventHandler.handleEventHandlerRegistration(client); // Handle caption displaying and style names, prior generics. // Affects size diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java index 5e5d0bf687..fe2c03496c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java @@ -169,13 +169,39 @@ public class VTextField extends TextBoxBase implements Paintable, Field, } public void onChange(ChangeEvent event) { + valueChange(false); + } + + /** + * Called when the field value might have changed and/or the field was + * blurred. These are combined so the blur event is sent in the same batch + * as a possible value change event (these are often connected). + * + * @param blurred + * true if the field was blurred + */ + public void valueChange(boolean blurred) { if (client != null && id != null) { + boolean sendBlurEvent = false; + boolean sendValueChange = false; + + if (blurred + && client.hasEventListeners(this, BLUR_EVENT_IDENTIFIER)) { + sendBlurEvent = true; + client.updateVariable(id, BLUR_EVENT_IDENTIFIER, "", false); + } + String newText = getText(); if (!prompting && newText != null && !newText.equals(valueBeforeEdit)) { - client.updateVariable(id, "text", getText(), immediate); + sendValueChange = immediate; + client.updateVariable(id, "text", getText(), false); valueBeforeEdit = newText; } + + if (sendBlurEvent || sendValueChange) { + client.sendPendingVariableChanges(); + } } } @@ -213,11 +239,8 @@ public class VTextField extends TextBoxBase implements Paintable, Field, setText(inputPrompt); addStyleDependentName(CLASSNAME_PROMPT); } - onChange(null); - if (client.hasEventListeners(this, BLUR_EVENT_IDENTIFIER)) { - client.updateVariable(client.getPid(this), BLUR_EVENT_IDENTIFIER, - "", true); - } + + valueChange(true); } private void setPrompting(boolean prompting) { diff --git a/src/com/vaadin/ui/TextField.java b/src/com/vaadin/ui/TextField.java index ee2f1097f3..59cf6640ce 100644 --- a/src/com/vaadin/ui/TextField.java +++ b/src/com/vaadin/ui/TextField.java @@ -248,13 +248,6 @@ public class TextField extends AbstractField { super.changeVariables(source, variables); - if (variables.containsKey(FOCUS_EVENT)) { - fireFocus(variables.get(FOCUS_EVENT)); - } - if (variables.containsKey(BLUR_EVENT)) { - fireBlur(variables.get(BLUR_EVENT)); - } - // Sets the text if (variables.containsKey("text") && !isReadOnly()) { @@ -285,6 +278,13 @@ public class TextField extends AbstractField { } } + if (variables.containsKey(FOCUS_EVENT)) { + fireFocus(variables.get(FOCUS_EVENT)); + } + if (variables.containsKey(BLUR_EVENT)) { + fireBlur(variables.get(BLUR_EVENT)); + } + } /* Text field configuration */ diff --git a/tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java b/tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java new file mode 100644 index 0000000000..77cc587915 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java @@ -0,0 +1,95 @@ +package com.vaadin.tests.components.textfield; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.layouts.TestLayoutClickListeners.Log; +import com.vaadin.ui.TextField; + +public class TextFieldFocusAndBlurListeners extends TestBase implements + FocusListener, BlurListener, ValueChangeListener { + private Log log = new Log(5); + + @Override + protected String getDescription() { + return "Tests the focus and blur functionality of TextField"; + } + + @Override + protected Integer getTicketNumber() { + return 3544; + } + + @Override + public void setup() { + addComponent(log); + TextField tf1 = new TextField("TextField 1", + "Has focus and blur listeners"); + tf1.setWidth("300px"); + tf1.addListener((FocusListener) this); + tf1.addListener((BlurListener) this); + + addComponent(tf1); + + TextField tf2 = new TextField("TextField 2", + "Has focus, blur and valuechange listeners"); + tf2.setWidth("300px"); + tf2.addListener(new ValueChangeListener() { + + public void valueChange(ValueChangeEvent event) { + TextFieldFocusAndBlurListeners.this.valueChange(event); + } + }); + tf2.addListener(new FocusListener() { + + public void focus(FocusEvent event) { + TextFieldFocusAndBlurListeners.this.focus(event); + } + + }); + tf2.addListener(new BlurListener() { + + public void blur(BlurEvent event) { + TextFieldFocusAndBlurListeners.this.blur(event); + } + }); + + addComponent(tf2); + + TextField tf3 = new TextField("TextField 3", + "Has non-immediate valuechange listener"); + tf3.setWidth("300px"); + tf3.addListener((ValueChangeListener) this); + + addComponent(tf3); + + TextField tf4 = new TextField("TextField 4", + "Has immediate valuechange listener"); + tf4.setWidth("300px"); + tf4.setImmediate(true); + tf4.addListener((ValueChangeListener) this); + + addComponent(tf4); + } + + public void focus(FocusEvent event) { + log.log(event.getComponent().getCaption() + ": Focus"); + + } + + public void blur(BlurEvent event) { + TextField tf = (TextField) event.getComponent(); + log.log(tf.getCaption() + ": Blur. Value is: " + + tf.getValue().toString()); + + } + + public void valueChange(ValueChangeEvent event) { + TextField tf = (TextField) event.getProperty(); + log.log(tf.getCaption() + ": ValueChange: " + tf.getValue().toString()); + } +} diff --git a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html new file mode 100644 index 0000000000..aa2e923ffa --- /dev/null +++ b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html @@ -0,0 +1,142 @@ + + + + + + +TestLayoutClickListeners + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestLayoutClickListeners
open/run/com.vaadin.tests.layouts.TestLayoutClickListeners
waitForVaadin
screenCaptureinitial
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]43,11
waitForVaadin
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:GridLayout: Click on This is label 1
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VTextField[0]82,14
waitForVaadin
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:GridLayout: Click on This is tf5
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]74,13
waitForVaadin
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:VerticalLayout: Click on This is tf6
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]53,13
waitForVaadin
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:VerticalLayout: Click on This is label 3
clickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[2]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0]Button A button with its own click listener was clicked
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:AbsoluteLayout: Click on A button with its own click listener
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/VTextField[0]101,14
waitForVaadin
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:AbsoluteLayout: Click on This is its caption
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/domChild[0]/domChild[0]/domChild[1]87,42
waitForVaadin
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:GridLayout: Click on <none>
+ + diff --git a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java new file mode 100644 index 0000000000..a96404e4f6 --- /dev/null +++ b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java @@ -0,0 +1,195 @@ +package com.vaadin.tests.layouts; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.event.LayoutEvents.LayoutClickEvent; +import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.tests.components.AbstractTestCase; +import com.vaadin.ui.AbsoluteLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Component; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class TestLayoutClickListeners extends AbstractTestCase { + + private Log log = new Log(5); + + public static class Log extends VerticalLayout { + List