From 4d6cb7b107040ec9aedf9b73725675309a1c5729 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 26 Sep 2017 10:28:14 +0300 Subject: Relayout GridLayout when font loading completes (#10077) If a GridLayout is used and font loading is not complete, force another layout after all fonts are loaded. Fixes #9921 Fixes #8207 --- .../gridlayout/GridLayoutWithLabelTest.java | 28 +++++++++++++++++ .../tests/fonticon/GridLayoutOnFontLoadTest.java | 36 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java create mode 100644 uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java (limited to 'uitest/src/test') diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java new file mode 100644 index 0000000000..b8caac693d --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java @@ -0,0 +1,28 @@ +package com.vaadin.tests.components.gridlayout; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.GridLayoutElement; +import com.vaadin.testbench.elementsbase.AbstractElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutWithLabelTest extends MultiBrowserTest { + + @Test + public void selectingOptionShouldNotCauseLabelToChangeSize() { + openTestURL(); + AbstractElement gridLayout = $(GridLayoutElement.class).first(); + CheckBoxElement cb = $(CheckBoxElement.class).first(); + + int before = gridLayout.getSize().getWidth(); + cb.click(); // Turn on + cb.click(); // Turn off + int after = gridLayout.getSize().getWidth(); + + Assert.assertEquals( + "layout width should not have changed after checkbox was toggled", + before, after); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java b/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java new file mode 100644 index 0000000000..db5c08c653 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java @@ -0,0 +1,36 @@ +package com.vaadin.tests.fonticon; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.TextAreaElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutOnFontLoadTest extends MultiBrowserTest { + + @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(); + + Assert.assertTrue( + "Button overlaps with checkbox (layout done before fonts loaded)", + button.getLocation().getX() + button.getSize().width <= checkbox + .getLocation().getX()); + Assert.assertTrue( + "TextArea overlaps with grid caption (layout done before fonts loaded)", + textarea.getLocation().getY() + textarea.getSize().height + + 10 < grid.getLocation().getY()); + } + +} -- cgit v1.2.3