1 package com.vaadin.tests.components.embedded;
3 import org.junit.Assert;
4 import org.junit.Before;
6 import org.openqa.selenium.By;
8 import com.vaadin.testbench.elements.EmbeddedElement;
9 import com.vaadin.testbench.elements.LabelElement;
10 import com.vaadin.testbench.parallel.BrowserUtil;
11 import com.vaadin.tests.tb3.MultiBrowserTest;
13 public class EmbeddedClickListenerRelativeCoordinatesTest
14 extends MultiBrowserTest {
18 public void setup() throws Exception {
21 waitForElementPresent(By.className("v-embedded"));
25 public void testRelativeClick() {
27 checkLocation(41, 22);
33 private void clickAt(int x, int y) {
34 EmbeddedElement embedded = $(EmbeddedElement.class).first();
36 // IE8 consistently clicks two pixels left and above of the given
45 private void checkLocation(int expectedX, int expectedY) {
46 LabelElement xLabel = $(LabelElement.class).id("x");
47 LabelElement yLabel = $(LabelElement.class).id("y");
49 int x = Integer.parseInt(xLabel.getText());
50 int y = Integer.parseInt(yLabel.getText());
53 "Reported X-coordinate from Embedded does not match click location",
56 // IE10 and IE11 sometimes click one pixel below the given position
57 int tolerance = isIE() ? 1 : 0;
59 "Reported Y-coordinate from Embedded does not match click location",
60 Math.abs(expectedY - y) <= tolerance);
63 private boolean isIE() {
64 return BrowserUtil.isIE(getDesiredCapabilities());
67 private boolean isIE8() {
68 return BrowserUtil.isIE8(getDesiredCapabilities());