+++ /dev/null
-<?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>TestLayoutClickListeners</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TestLayoutClickListeners</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.layouts.TestLayoutClickListeners?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>initial</td>
-</tr>
-<!--GridLayout-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>43,11</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: left click on This is label 1</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>82,14</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: left click on This is tf5</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VGridLayout[0]</td>
- <td>130,41</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: left click on <none></td>
-</tr>
-<!--VerticalLayout-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
- <td>74,13</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:VerticalLayout: left click on This is tf6</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]</td>
- <td>53,13</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:VerticalLayout: left click on This is label 3</td>
-</tr>
-<!--AbsoluteLayout-->
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:Button A button with its own click listener was clicked</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/VTextField[0]</td>
- <td>101,14</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:AbsoluteLayout: left click on This is its caption</td>
-</tr>
-<!--CssLayout-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]</td>
- <td>108,13</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[3]/VCssLayout[0]/domChild[0]/domChild[0]</td>
- <td>41,7</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_1</td>
- <td>exact:CSSLayout: left click on This is its caption</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:CSSLayout: left click on This is its caption</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:Button A button with its own click listener was clicked</td>
-</tr>
-<!--Drag in GridLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>40,8</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>40,8</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:GridLayout: left click on This is label 1</td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>24,7</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>46,13</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:GridLayout: left click on This is label 1</td>
-</tr>
-<!--Drag in VerticalLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>25,9</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>25,9</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:VerticalLayout: left click on This is tf5</td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[8]/domChild[0]</td>
- <td>28,11</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VTextField[0]</td>
- <td>39,7</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:VerticalLayout: left click on This is tf5</td>
-</tr>
-<!--Drag in AbsoluteLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[2]/VAbsoluteLayout[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]</td>
- <td>21,9</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[2]/VAbsoluteLayout[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]</td>
- <td>21,9</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:AbsoluteLayout: left click on This is its caption</td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/VTextField[0]</td>
- <td>54,7</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[1]/VTextField[0]</td>
- <td>52,10</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:AbsoluteLayout: left click on This is its caption</td>
-</tr>
-<!--Drag in CSSLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]</td>
- <td>51,7</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]</td>
- <td>51,7</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:CSSLayout: left click on This is its caption</td>
-</tr>
-</tbody></table>
-</body>
-</html>
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.tests.util.Log;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
-import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
-public class TestLayoutClickListeners extends AbstractTestCase {
-
- private Log log = new Log(5).setNumberLogRows(false);
+public class TestLayoutClickListeners extends AbstractTestUIWithLog {
@Override
- public void init() {
- LegacyWindow w = new LegacyWindow("main window");
- setMainWindow(w);
- setTheme("tests-tickets");
-
+ protected void setup(VaadinRequest request) {
HorizontalLayout layoutsLayout = new HorizontalLayout();
layoutsLayout.setSpacing(true);
- w.setContent(layoutsLayout);
+ addComponent(layoutsLayout);
layoutsLayout.addComponent(createClickableGridLayout());
layoutsLayout.addComponent(createClickableVerticalLayout());
layoutsLayout.addComponent(createClickableAbsoluteLayout());
layoutsLayout.addComponent(createClickableCSSLayout());
-
- VerticalLayout mainLayout = new VerticalLayout();
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
- w.setContent(mainLayout);
- mainLayout.addComponent(log);
- mainLayout.addComponent(layoutsLayout);
}
private Component createClickableAbsoluteLayout() {
@Override
public void buttonClick(
com.vaadin.ui.Button.ClickEvent event) {
- log.log("Button " + event.getButton().getCaption()
+ log("Button " + event.getButton().getCaption()
+ " was clicked");
}
}));
- al.addListener(new LayoutClickListener() {
+ al.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
@Override
public void buttonClick(
com.vaadin.ui.Button.ClickEvent event) {
- log.log("Button " + event.getButton().getCaption()
+ log("Button " + event.getButton().getCaption()
+ " was clicked");
}
}));
- cl.addListener(new LayoutClickListener() {
+ cl.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
largeTextarea.setHeight("99%");
gl.addComponent(largeTextarea, 0, 3, 3, 3);
- gl.addListener(new LayoutClickListener() {
+ gl.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
if (event.isDoubleClick()) {
type = "double-click";
}
- log.log(layout + ": " + button + " " + type + " on " + target);
- // + ", coordinates relative to the layout ("
- // + event.getRelativeX() + ", " + event.getRelativeY() + ")");
-
+ log(layout + ": " + button + " " + type + " on " + target);
}
private Layout createClickableVerticalLayout() {
VerticalLayout gl = new VerticalLayout();
addContent(gl, 5);
- gl.addListener(new LayoutClickListener() {
+ gl.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "All layouts have click listeners attached and the events are shown in the event log at the top";
}
protected Integer getTicketNumber() {
return 3541;
}
-
}
--- /dev/null
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.layouts;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.AbsoluteLayoutElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.CssLayoutElement;
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.testbench.elements.VerticalLayoutElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests LayoutClickListener on different layouts.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestLayoutClickListenersTest extends MultiBrowserTest {
+
+ @Before
+ public void before() {
+ openTestURL();
+ }
+
+ @Test
+ public void clickInGridLayout() {
+ GridLayoutElement layout = $(GridLayoutElement.class).first();
+
+ // click on a label
+ layout.$(LabelElement.class).first().click();
+ assertLogText("GridLayout 1st child clicked",
+ "1. GridLayout: left click on This is label 1");
+
+ // click on a text field
+ layout.$(TextFieldElement.class).get(1).click();
+ assertLogText("GridLayout 5th child clicked",
+ "2. GridLayout: left click on This is tf5");
+
+ // click on the layout body (not any component inside the layout)
+ layout.click(130, 41);
+ assertLogText("GridLayout body clicked",
+ "3. GridLayout: left click on <none>");
+ }
+
+ @Test
+ public void clickInVerticalLayout() {
+ VerticalLayoutElement layout = $(VerticalLayoutElement.class).get(4);
+
+ // click on a text field
+ layout.$(TextFieldElement.class).get(1).click();
+ assertLogText("VerticalLayout 6th child clicked",
+ "1. VerticalLayout: left click on This is tf6");
+
+ // click on a label
+ layout.$(LabelElement.class).get(3).click();
+ assertLogText("VerticalLayout 4th child clicked",
+ "2. VerticalLayout: left click on This is label 3");
+ }
+
+ @Test
+ public void clickInAbsoluteLayout() {
+ AbsoluteLayoutElement layout = $(AbsoluteLayoutElement.class).first();
+
+ // click on a button that has its own ClickListener (should be ignored
+ // by the LayoutClickListener)
+ layout.$(ButtonElement.class).first().click();
+ assertLogText("A button with a ClickListener clicked",
+ "1. Button A button with its own click listener was clicked");
+
+ // click on a text field's caption
+ layout.$(TextFieldElement.class).first().click();
+ assertLogText("AbsoluteLayout 1st child was clicked",
+ "2. AbsoluteLayout: left click on This is its caption");
+ }
+
+ @Test
+ public void clickInCSSLayout() {
+ CssLayoutElement layout = $(CssLayoutElement.class).first();
+
+ // click on a text field's caption
+ layout.$(TextFieldElement.class).first().click();
+ assertLogText("CSSLayout 1st child clicked",
+ "1. CSSLayout: left click on This is its caption");
+
+ // click on a button that has its own ClickListener (should be ignored
+ // by the LayoutClickListener)
+ layout.$(ButtonElement.class).first().click();
+ assertLogText("Abutton with a ClickListener was clicked",
+ "2. Button A button with its own click listener was clicked");
+ }
+
+ @Test
+ public void dragInGridLayout() {
+ GridLayoutElement layout = $(GridLayoutElement.class).first();
+
+ // Drag inside the first label in this layout
+ new Actions(getDriver())
+ .moveToElement(layout.$(LabelElement.class).first(), 40, 8)
+ .clickAndHold().moveByOffset(-20, 0).release().perform();
+ assertLogText("Mouse dragged in GridLayout",
+ "1. GridLayout: left click on This is label 1");
+
+ // Drag from the third label to a text field in this layout
+ new Actions(getDriver())
+ .moveToElement(layout.$(LabelElement.class).first(), 40, 8)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).get(3), 46, 33)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. GridLayout: left click on This is label 1");
+ }
+
+ @Test
+ public void dragInVerticalLayout() {
+ VerticalLayoutElement layout = $(VerticalLayoutElement.class).get(4);
+
+ // Drag inside the first text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 25, 9)
+ .clickAndHold().moveByOffset(-20, 0).release().perform();
+ assertLogText("Mouse dragged in VerticalLayout",
+ "1. VerticalLayout: left click on This is tf5");
+
+ // Drag from a caption to its text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).get(4), 28, 11)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).get(4), 39, 30)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. VerticalLayout: left click on This is tf5");
+ }
+
+ @Test
+ public void dragInAbsoluteLayout() {
+ AbsoluteLayoutElement layout = $(AbsoluteLayoutElement.class).first();
+
+ // Drag inside the first text field's caption
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 21, 9)
+ .clickAndHold().moveByOffset(-10, 0).release().perform();
+ assertLogText("Mouse dragged in AbsoluteLayout",
+ "1. AbsoluteLayout: left click on This is its caption");
+
+ // Drag from a text field to another text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).get(1), 54, 7)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).first(), 52, 10)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. AbsoluteLayout: left click on This is its caption");
+ }
+
+ @Test
+ public void dragInCSSLayout() {
+ CssLayoutElement layout = $(CssLayoutElement.class).first();
+
+ // Drag inside the first text field's caption
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 51, 7)
+ .clickAndHold().moveByOffset(-20, 0).release().perform();
+ assertLogText("Mouse dragged in CSSLayout",
+ "1. CSSLayout: left click on This is its caption");
+
+ // Drag from the first text field to the second text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 51, 27)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).get(1), 51, 27)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. CSSLayout: left click on This is its caption");
+ }
+
+ private void assertLogText(String message, String expected) {
+ String actual = $(LabelElement.class).first().getText();
+ Assert.assertEquals(message, expected, actual);
+ }
+}