From e039dd6989024c4dda14b2a993bacff9d7ce360e Mon Sep 17 00:00:00 2001 From: Heikki Ohinmaa Date: Mon, 25 Aug 2014 17:28:51 +0300 Subject: [PATCH] LayoutClickListener test rewrite from TB2 Added log line numbers, as in this case they might provide information pertinent to the test. Change-Id: Iedea8f71cfb5488b510932b3ce4154ee0443c29b --- .../layouts/TestLayoutClickListeners.html | 239 ------------------ .../layouts/TestLayoutClickListeners.java | 44 +--- .../layouts/TestLayoutClickListenersTest.java | 200 +++++++++++++++ 3 files changed, 213 insertions(+), 270 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html create mode 100644 uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java diff --git a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html deleted file mode 100644 index 496994a60c..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - -TestLayoutClickListeners - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TestLayoutClickListeners
open/run/com.vaadin.tests.layouts.TestLayoutClickListeners?restartApplication
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
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:GridLayout: left 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
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:GridLayout: left click on This is tf5
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VGridLayout[0]130,41
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:GridLayout: left click on <none>
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]74,13
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:VerticalLayout: left 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
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:VerticalLayout: left 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]
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:Button A button with its own click listener was clicked
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/VTextField[0]101,14
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]exact:AbsoluteLayout: left click on This is its caption
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]108,13
mouseClickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[3]/VCssLayout[0]/domChild[0]/domChild[0]41,7
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_1exact:CSSLayout: left click on This is its caption
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:CSSLayout: left click on This is its caption
clickvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:Button A button with its own click listener was clicked
dragvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]40,8
dropvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]40,8
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:GridLayout: left click on This is label 1
dragvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]24,7
dropvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VTextField[0]46,13
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:GridLayout: left click on This is label 1
dragvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]25,9
dropvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]25,9
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:VerticalLayout: left click on This is tf5
dragvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[8]/domChild[0]28,11
dropvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VTextField[0]39,7
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:VerticalLayout: left click on This is tf5
dragvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[2]/VAbsoluteLayout[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]21,9
dropvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[2]/VAbsoluteLayout[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]21,9
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:AbsoluteLayout: left click on This is its caption
dragvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/VTextField[0]54,7
dropvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[1]/VTextField[0]52,10
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:AbsoluteLayout: left click on This is its caption
dragvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]51,7
dropvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]51,7
assertTextvaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0exact:CSSLayout: left click on This is its caption
- - diff --git a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java index c29e7710b7..c466d20609 100644 --- a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java +++ b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java @@ -2,8 +2,8 @@ package com.vaadin.tests.layouts; 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; @@ -12,36 +12,22 @@ import com.vaadin.ui.GridLayout; 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() { @@ -62,12 +48,12 @@ public class TestLayoutClickListeners extends AbstractTestCase { @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) { @@ -96,12 +82,12 @@ public class TestLayoutClickListeners extends AbstractTestCase { @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) { @@ -126,7 +112,7 @@ public class TestLayoutClickListeners extends AbstractTestCase { largeTextarea.setHeight("99%"); gl.addComponent(largeTextarea, 0, 3, 3, 3); - gl.addListener(new LayoutClickListener() { + gl.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(LayoutClickEvent event) { @@ -151,10 +137,7 @@ public class TestLayoutClickListeners extends AbstractTestCase { 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() { @@ -162,7 +145,7 @@ public class TestLayoutClickListeners extends AbstractTestCase { VerticalLayout gl = new VerticalLayout(); addContent(gl, 5); - gl.addListener(new LayoutClickListener() { + gl.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(LayoutClickEvent event) { @@ -196,7 +179,7 @@ public class TestLayoutClickListeners extends AbstractTestCase { } @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"; } @@ -204,5 +187,4 @@ public class TestLayoutClickListeners extends AbstractTestCase { protected Integer getTicketNumber() { return 3541; } - } diff --git a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java new file mode 100644 index 0000000000..0c6b5cbff4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java @@ -0,0 +1,200 @@ +/* + * 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 "); + } + + @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); + } +} -- 2.39.5