aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTomi Virtanen <tltv@vaadin.com>2014-05-16 11:25:01 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-06-05 15:48:13 +0300
commit9e494f526cad2e6302cddd31200800450d3c857e (patch)
tree69f4c8b13097f6a5ce9d354dca60134f47174154 /uitest
parent94a051b54283230758280f9b7a609e27763bac93 (diff)
downloadvaadin-framework-9e494f526cad2e6302cddd31200800450d3c857e.tar.gz
vaadin-framework-9e494f526cad2e6302cddd31200800450d3c857e.zip
Fix for 'Aborting layout after 100 passess' (#13359)
'Aborting layout after 100 passes.' is caused by LayoutManager falling into a loop on rounding fractional layout slot sizes up and down while trying to fit layout's content in the space available. LayoutManager round always up, that causes this issue with IE9+ and Chrome. This change helps LayoutManager to round fractional sizes down for browsers that causes problems if rounded up. Browsers may fall into the loop especially with a zoom level other than 100%. Not with any zoom level though. Problematic zoom level varies by browser. OrderedLayoutExpandTest uses zoom levels other than 100%. Test for Chrome is the only one that really is able to reproduce error without the fix. IE9/10 would too, but the zoom level could not be set exactly to the required 95% for IE. Test works best as a regression test for other browsers. Change-Id: Ie840b074df5fed5ea3b15fba9a6fd372a5c0b76a
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpand.java109
-rw-r--r--uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpandTest.java132
2 files changed, 241 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpand.java b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpand.java
new file mode 100644
index 0000000000..e51e9a49a5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpand.java
@@ -0,0 +1,109 @@
+/*
+ * 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.components.orderedlayout;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.UI;
+
+@SuppressWarnings("serial")
+public class OrderedLayoutExpand extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ ThreeColumnLayout layout = new ThreeColumnLayout(
+ createLabelWithUndefinedSize("first component"),
+ createLabelWithUndefinedSize("second component"),
+ createLabelWithUndefinedSize("third component"));
+
+ addComponent(layout);
+ setWidth("600px");
+
+ if (UI.getCurrent().getPage().getWebBrowser().isChrome()) {
+ getPage().getStyles().add("body { zoom: 1.10; }");
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ StringBuilder sb = new StringBuilder(
+ "You should not see 'Aborting layout after 100 passes.' error with debug mode and ");
+ if (UI.getCurrent().getPage().getWebBrowser().isChrome()) {
+ sb.append(" Zoom is ");
+ sb.append("1.10");
+ } else {
+ sb.append(" zoom level 95%.");
+ }
+ return sb.toString();
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 13359;
+ }
+
+ private Label createLabelWithUndefinedSize(String caption) {
+ Label label = new Label(caption);
+ label.setSizeUndefined();
+ return label;
+ }
+
+ private static class ThreeColumnLayout extends HorizontalLayout {
+ public ThreeColumnLayout(Component leftComponent,
+ Component centerComponent, Component rightComponent) {
+ setWidth("100%");
+ setMargin(true);
+ Component left = createLeftHolder(leftComponent);
+ this.addComponent(left);
+ setComponentAlignment(left, Alignment.MIDDLE_LEFT);
+ setExpandRatio(left, 1f);
+ Component center = createCenterHolder(centerComponent);
+ this.addComponent(center);
+ setComponentAlignment(center, Alignment.MIDDLE_CENTER);
+ setExpandRatio(center, 0f);
+ Component right = createRightHolder(rightComponent);
+ this.addComponent(right);
+ setComponentAlignment(right, Alignment.MIDDLE_RIGHT);
+ setExpandRatio(right, 1f);
+ }
+
+ private Component createLeftHolder(Component c) {
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.addComponent(c);
+ hl.setWidth(100, Unit.PERCENTAGE);
+ return hl;
+ }
+
+ private Component createCenterHolder(Component c) {
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.addComponent(c);
+ hl.setComponentAlignment(c, Alignment.MIDDLE_CENTER);
+ return hl;
+ }
+
+ private Component createRightHolder(Component c) {
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.addComponent(c);
+ hl.setWidth(100, Unit.PERCENTAGE);
+ return hl;
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpandTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpandTest.java
new file mode 100644
index 0000000000..46b5f6b8b0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutExpandTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.components.orderedlayout;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class OrderedLayoutExpandTest extends MultiBrowserTest {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest()
+ */
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsersToTest = super.getBrowsersToTest();
+
+ // Not sure why, but IE11 might give the following error message:
+ // "org.openqa.selenium.WebDriverException: Unexpected error launching
+ // Internet Explorer. Browser zoom level was set to 75%. It should be
+ // set to 100%".
+
+ // setting "ignoreZoomSetting" capability to true seems to help, but if
+ // it keeps bugging, just skip the IE11 completely bu uncommenting the
+ // line below.
+ // browsersToTest.remove(Browser.IE11.getDesiredCapabilities());
+ Browser.IE11.getDesiredCapabilities().setCapability(
+ "ignoreZoomSetting", true);
+
+ // Can't test with IE8 with a zoom level other than 100%. IE8 could be
+ // removed to speed up the test run.
+ // browsersToTest.remove(Browser.IE8.getDesiredCapabilities());
+
+ return browsersToTest;
+ }
+
+ @Test
+ public void testNoAbortingLayoutAfter100PassesError() throws Exception {
+ setDebug(true);
+ openTestURL();
+
+ if (!getDesiredCapabilities().equals(
+ Browser.CHROME.getDesiredCapabilities())) {
+ // Chrome uses css to to set zoom level to 110% that is known to
+ // cause issues with the test app.
+ // Other browsers tries to set browser's zoom level directly.
+ WebElement html = driver.findElement(By.tagName("html"));
+ // reset to 100% just in case
+ html.sendKeys(Keys.chord(Keys.CONTROL, "0"));
+ // zoom browser to 75% (ie) or 90% (FF). It depends on browser
+ // how much "Ctrl + '-'" zooms out.
+ html.sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT));
+ }
+
+ // open debug window's Examine component hierarchy tab
+ openDebugExamineComponentHierarchyTab();
+
+ // click "Check layouts for potential problems" button
+ clickDebugCheckLayoutsForPotentialProblems();
+
+ // find div containing a successful layout analyze result
+ WebElement pass = findLayoutAnalyzePassElement();
+ // find div containing a error message with
+ // "Aborting layout after 100 passess" message.
+ WebElement error = findLayoutAnalyzeAbortedElement();
+
+ Assert.assertNull(error);
+ Assert.assertNotNull(pass);
+
+ if (!getDesiredCapabilities().equals(
+ Browser.CHROME.getDesiredCapabilities())) {
+ WebElement html = driver.findElement(By.tagName("html"));
+ // reset zoom level back to 100%
+ html.sendKeys(Keys.chord(Keys.CONTROL, "0"));
+ }
+ }
+
+ private void openDebugExamineComponentHierarchyTab() {
+ WebElement button = findElement(By
+ .xpath("//button[@title='Examine component hierarchy']"));
+ // can't use 'click()' with zoom levels other than 100%
+ button.sendKeys(Keys.chord(Keys.SPACE));
+ }
+
+ private void clickDebugCheckLayoutsForPotentialProblems() {
+ WebElement button = findElement(By
+ .xpath("//button[@title='Check layouts for potential problems']"));
+
+ button.sendKeys(Keys.chord(Keys.SPACE));
+ }
+
+ private WebElement findLayoutAnalyzePassElement() {
+ try {
+ return findElement(By
+ .xpath("//div[text()='Layouts analyzed, no top level problems']"));
+ } catch (NoSuchElementException e) {
+ return null;
+ }
+ }
+
+ private WebElement findLayoutAnalyzeAbortedElement() {
+ try {
+ return findElement(By
+ .xpath("//div[text()='Aborting layout after 100 passess']"));
+ } catch (NoSuchElementException e) {
+ return null;
+ }
+ }
+}