]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix: Empty space on page after expanded component (#12672)
authorAnna Miroshnik <anna.miroshnik@arcadia.spb.ru>
Tue, 7 Oct 2014 15:37:30 +0000 (19:37 +0400)
committerSauli Tähkäpää <sauli@vaadin.com>
Wed, 29 Oct 2014 08:44:03 +0000 (10:44 +0200)
Full defect name: Empty space on page after expanded component - incorrect height calculation in Chrome

Layout:
[
Panel (auto x auto) [
Grid (auto x auto)
]
AnyComponent (100% x 100%)
<EMPTY SPACE>

Also sleep() was removed from tests BaseLayoutExpandTest and
BaseAddReplaceMoveTest

Change-Id: Ie8a14a58dd53a26a133ea99a7b809d92c1b33a1f

client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponent.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java

index 0c09ae49c6f36e7e385fb63b19e2a88b31515a1b..aace34939275f13b8c3a4b12ed44d4ae946cc2ab 100644 (file)
@@ -152,7 +152,20 @@ public abstract class AbstractOrderedLayoutConnector extends
         public void onElementResize(ElementResizeEvent e) {
             updateLayoutHeight();
             if (needsExpand()) {
-                getWidget().updateExpandCompensation();
+                /*
+                 * updateLayoutHeight causes calling of
+                 * getLayoutManager().setNeedsMeasure(this) which informs this
+                 * LayoutManager that the size of a component might have
+                 * changed. Then a new layout phase is scheduled. So
+                 * updateExpandCompensation must be delayed until layout phase
+                 * will be completed. #12672
+                 */
+                Scheduler.get().scheduleFinally(new ScheduledCommand() {
+                    @Override
+                    public void execute() {
+                        getWidget().updateExpandCompensation();
+                    }
+                });
             }
         }
     };
diff --git a/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponent.java b/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponent.java
new file mode 100644 (file)
index 0000000..c873a7e
--- /dev/null
@@ -0,0 +1,82 @@
+/* 
+ * 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.layout;
+
+import com.vaadin.server.Page;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class EmptySpaceOnPageAfterExpandedComponent extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        getLayout().setHeight("200px");
+
+        VerticalLayout container = new VerticalLayout();
+        container.setStyleName("mystyle");
+        container.setId("container");
+        container.setSpacing(true);
+        container.setSizeFull();
+        addComponent(container);
+
+        Page.getCurrent().getStyles()
+                .add(".mystyle {border: 1px solid black;}");
+
+        GridLayout grid = new GridLayout();
+        grid.setSpacing(true);
+
+        TextField text1 = new TextField();
+        text1.setCaption("Text1");
+        text1.setRequired(true);
+
+        grid.setColumns(1);
+        grid.setRows(1);
+
+        grid.addComponent(text1);
+
+        grid.setSizeUndefined();
+
+        Panel panel = new Panel();
+        panel.setContent(grid);
+
+        panel.setSizeUndefined();
+
+        container.addComponent(panel);
+
+        TextArea expand = new TextArea();
+        expand.setId("expandedElement");
+        expand.setSizeFull();
+        container.addComponent(expand);
+
+        container.setExpandRatio(expand, 1);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Height calculation should be correct in Chrome. There should not be any empty space after expanded component.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 12672;
+    }
+}
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java b/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java
new file mode 100644 (file)
index 0000000..09d1903
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2013 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.layout;
+
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test to make sure that there is no any empty space (in Google Chrome) on page
+ * after expanded component (#12672)
+ * 
+ * Layout:
+ * 
+ * [ Panel (auto x auto) [ Grid (auto x auto) ]
+ * 
+ * AnyComponent (100% x 100%)
+ * 
+ * <HERE SHOULD NOT BE ANY EMPTY SPACE> ]
+ * 
+ * @author Vaadin Ltd
+ */
+public class EmptySpaceOnPageAfterExpandedComponentTest extends
+        MultiBrowserTest {
+
+    @Test
+    public void testNoEmptySpaceOnPageAfterExpandedComponent() {
+        openTestURL();
+
+        final WebElement expandedElement = vaadinElementById("expandedElement");
+        final WebElement containerElement = vaadinElementById("container");
+
+        waitUntil(new ExpectedCondition<Boolean>() {
+            @Override
+            public Boolean apply(WebDriver input) {
+                int expandedElementBottom = expandedElement.getLocation()
+                        .getY() + expandedElement.getSize().getHeight();
+                int containerElementBottom = containerElement.getLocation()
+                        .getY() + containerElement.getSize().getHeight();
+
+                return expandedElementBottom + 1 == containerElementBottom;
+            }
+        });
+    }
+}
index 73dc39009dbc2748553beead6451e428947ce0d1..786e47cef12551aad977fa6a87927de559f4a129 100644 (file)
@@ -19,6 +19,7 @@ import java.io.IOException;
 import java.util.List;
 
 import org.junit.Test;
+import org.openqa.selenium.By;
 
 import com.vaadin.testbench.elements.ButtonElement;
 import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -27,7 +28,7 @@ public abstract class BaseAddReplaceMoveTest extends MultiBrowserTest {
     @Test
     public void LayoutAlignment() throws IOException, InterruptedException {
         openTestURL();
-        sleep(500);
+        waitForElementPresent(By.className("v-table"));
         compareScreen("initial");
         String[] states = { "add", "replace", "move", "remove" };
         List<ButtonElement> buttons = $(ButtonElement.class).all();
@@ -35,7 +36,7 @@ public abstract class BaseAddReplaceMoveTest extends MultiBrowserTest {
         // go through all buttons click them and see result
         for (ButtonElement btn : buttons) {
             btn.click();
-            sleep(500);
+            waitForElementPresent(By.className("v-table"));
             compareScreen(states[index]);
             index++;
         }
index 08f5aed80809693697b27fbed249f235561f7b2a..036b053fb5d86b0e0fb28d84c393fbced9158a26 100644 (file)
@@ -19,21 +19,17 @@ import java.io.IOException;
 import java.util.List;
 
 import org.junit.Test;
+import org.openqa.selenium.By;
 
 import com.vaadin.testbench.elements.ButtonElement;
 import com.vaadin.tests.tb3.MultiBrowserTest;
 
-/**
- *
- * @since
- * @author Vaadin Ltd
- */
 public abstract class BaseLayoutExpandTest extends MultiBrowserTest {
 
     @Test
     public void LayoutExpand() throws IOException, InterruptedException {
         openTestURL();
-        sleep(500);
+        waitForElementPresent(By.className("v-table"));
         compareScreen("initial");
         String[] states = { "expand_100_0", "expand_50_50", "expand_25_75" };
         List<ButtonElement> buttons = $(ButtonElement.class).all();
@@ -41,7 +37,7 @@ public abstract class BaseLayoutExpandTest extends MultiBrowserTest {
         // go through all buttons click them and see result
         for (ButtonElement btn : buttons) {
             btn.click();
-            sleep(500);
+            waitForElementPresent(By.className("v-table"));
             compareScreen(states[index]);
             index++;
         }