]> source.dussan.org Git - vaadin-framework.git/commitdiff
#6493 layout click listener test
authorHenri Sara <henri.sara@itmill.com>
Wed, 23 Feb 2011 11:52:49 +0000 (11:52 +0000)
committerHenri Sara <henri.sara@itmill.com>
Wed, 23 Feb 2011 11:52:49 +0000 (11:52 +0000)
svn changeset:17391/svn branch:6.5

tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.html [new file with mode: 0644]
tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java [new file with mode: 0644]

diff --git a/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.html b/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.html
new file mode 100644 (file)
index 0000000..7fefe93
--- /dev/null
@@ -0,0 +1,92 @@
+<?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="" />
+<title>LayoutClickListenerTest</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">LayoutClickListenerTest</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/LayoutClickListenerTest?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VLink[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VLink[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/domChild[0]/domChild[1]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[2]/VLink[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[3]/VHorizontalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>everything_clicked</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java b/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java
new file mode 100644 (file)
index 0000000..4f4faf1
--- /dev/null
@@ -0,0 +1,97 @@
+package com.vaadin.tests.components.orderedlayout;
+
+import java.util.Arrays;
+
+import com.vaadin.event.LayoutEvents.LayoutClickEvent;
+import com.vaadin.event.LayoutEvents.LayoutClickListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class LayoutClickListenerTest extends TestBase {
+
+    @Override
+    protected void setup() {
+
+        // Create a grid layout with click events
+        final GridLayout layout = new GridLayout(3, 2);
+        layout.addStyleName("border");
+        layout.setSpacing(true);
+        layout.setSizeFull();
+
+        // Add some components to the layout
+        layout.addComponent(new TextField(null, "Click here"));
+        layout.addComponent(new Link("Click here", null));
+
+        Select select = new Select(null, Arrays.asList("Click here"));
+        select.select("Click here");
+        layout.addComponent(select);
+
+        // Tab content
+        VerticalLayout l1 = new VerticalLayout();
+        l1.setMargin(true);
+        l1.addComponent(new Label("This is a label."));
+        l1.addComponent(new TextField(null, "Click here"));
+        l1.addComponent(new Link("Click here", null));
+
+        TabSheet t = new TabSheet();
+        t.setHeight("200px");
+        t.addTab(l1, "Tab", null);
+        layout.addComponent(t);
+
+        VerticalLayout nestedLayout = new VerticalLayout();
+        nestedLayout.addComponent(new Label("This is a label."));
+        nestedLayout.addComponent(new TextField(null, "Click here"));
+        nestedLayout.addComponent(new Link("Click here", null));
+
+        HorizontalLayout nestedLayout2 = new HorizontalLayout();
+        nestedLayout2.addComponent(new Label("Deeply nested label"));
+        nestedLayout.addComponent(nestedLayout2);
+
+        layout.addComponent(nestedLayout);
+
+        // Listen for layout click events
+        layout.addListener(new LayoutClickListener() {
+            public void layoutClick(LayoutClickEvent event) {
+
+                // Get the deepest nested component which was clicked
+                Component clickedComponent = event.getClickedComponent();
+
+                if (clickedComponent == null) {
+                    // Not over any child component
+                    LayoutClickListenerTest.this.addComponent(new Label(
+                            "The click was not over any component."));
+                } else {
+                    // Over a child component
+                    String message = "The click was over a "
+                            + clickedComponent.getClass().getCanonicalName()
+                            + " in an immediate child component of type "
+                            + event.getChildComponent().getClass()
+                                    .getCanonicalName();
+                    LayoutClickListenerTest.this
+                            .addComponent(new Label(message));
+                }
+            }
+        });
+
+        addComponent(layout);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Layout click listeners should provide access to the deepest nested component clicked - click anywhere in the layout.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 6493;
+    }
+
+}