aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java54
1 files changed, 38 insertions, 16 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java b/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java
index fdf82ff02e..edf3584ff4 100644
--- a/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java
@@ -1,8 +1,8 @@
package com.vaadin.tests.fonticon;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.CheckBoxElement;
@@ -12,26 +12,48 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridLayoutOnFontLoadTest extends MultiBrowserTest {
+ ButtonElement button;
+ CheckBoxElement checkbox;
+ TextAreaElement textarea;
+ GridElement grid;
+
+ private ExpectedCondition<Boolean> checkNoOverlapping(String element1,
+ int position1, String element2, int position2) {
+ return new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver arg0) {
+ return position1 <= position2;
+ }
+
+ @Override
+ public String toString() {
+ // waiting for ...
+ return String
+ .format("the coordinates of the inspected elements ("
+ + element1 + ", " + element2
+ + ") to not overlap, the actual position for each "
+ + "element is " + position1 + ", "+ position2 + "respectively");
+ }
+ };
+ }
+
@Test
public void testComponentsDontOverlap() throws Exception {
openTestURL();
-
// Make sure fonts are loaded.
sleep(1000);
- ButtonElement button = $(ButtonElement.class).first();
- CheckBoxElement checkbox = $(CheckBoxElement.class).first();
- TextAreaElement textarea = $(TextAreaElement.class).first();
- GridElement grid = $(GridElement.class).first();
-
- assertTrue(
- "Button overlaps with checkbox (layout done before fonts loaded)",
- button.getLocation().getX() + button.getSize().width <= checkbox
- .getLocation().getX());
- assertTrue(
- "TextArea overlaps with grid caption (layout done before fonts loaded)",
- textarea.getLocation().getY() + textarea.getSize().height
- + 10 < grid.getLocation().getY());
+ button = $(ButtonElement.class).first();
+ checkbox = $(CheckBoxElement.class).first();
+ textarea = $(TextAreaElement.class).first();
+ grid = $(GridElement.class).first();
+
+ waitUntil(checkNoOverlapping("button",
+ button.getLocation().getX() + button.getSize().width,
+ "checkbox", checkbox.getLocation().getX()));
+ waitUntil(checkNoOverlapping("textarea",
+ textarea.getLocation().getY() + textarea.getSize().height + 10,
+ "grid", grid.getLocation().getY()));
}
}