]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case for #5038
authorArtur Signell <artur.signell@itmill.com>
Wed, 7 Jul 2010 11:02:10 +0000 (11:02 +0000)
committerArtur Signell <artur.signell@itmill.com>
Wed, 7 Jul 2010 11:02:10 +0000 (11:02 +0000)
svn changeset:14133/svn branch:6.4

tests/src/com/vaadin/tests/components/window/WindowClickEvents.java [new file with mode: 0644]

diff --git a/tests/src/com/vaadin/tests/components/window/WindowClickEvents.java b/tests/src/com/vaadin/tests/components/window/WindowClickEvents.java
new file mode 100644 (file)
index 0000000..4748111
--- /dev/null
@@ -0,0 +1,80 @@
+package com.vaadin.tests.components.window;
+
+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.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class WindowClickEvents extends TestBase {
+
+    private Log log;
+
+    @Override
+    protected String getDescription() {
+        return "Both the sub window and the main window has a click listener. Clicking produces a row in the log below.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 5038;
+    }
+
+    @Override
+    protected void setup() {
+        VerticalLayout layout = new VerticalLayout();
+        layout.addListener(new LayoutClickListener() {
+            public void layoutClick(LayoutClickEvent event) {
+                WindowClickEvents.this.click("Sub window layout", event);
+            }
+        });
+
+        ((VerticalLayout) getMainWindow().getContent())
+                .addListener(new LayoutClickListener() {
+                    public void layoutClick(LayoutClickEvent event) {
+                        WindowClickEvents.this.click("Main window layout",
+                                event);
+                    }
+                });
+        layout.setMargin(true);
+        Window centered = new Window("A window with a click listener", layout);
+        centered.addListener(new ClickListener() {
+
+            public void click(ClickEvent event) {
+                WindowClickEvents.this.click("Sub window", event);
+            }
+
+        });
+        centered.setSizeUndefined();
+        centered.getContent().setSizeUndefined();
+        centered.center();
+
+        Label l = new Label("This window is centered");
+        l.setSizeUndefined();
+        Button b = new Button("Clicking here should not produce an event");
+        centered.addComponent(l);
+        centered.addComponent(b);
+
+        getMainWindow().addWindow(centered);
+        log = new Log(5);
+        addComponent(log);
+        getMainWindow().addListener(new ClickListener() {
+
+            public void click(ClickEvent event) {
+                WindowClickEvents.this.click("Main window", event);
+            }
+        });
+
+    }
+
+    private void click(String target, ClickEvent event) {
+        log.log("Click using " + event.getButtonName() + " on " + target);
+        // + " at " + event.getClientX() + "," + event.getClientY());
+
+    }
+}