From 3dba07d162eda32e397605c778d3662a8f1520fb Mon Sep 17 00:00:00 2001 From: elmot Date: Tue, 9 Jun 2015 10:54:46 +0300 Subject: [PATCH] Fix for "Grid detail row outline overflows" (#17826) Clipping of an existing spacer decoration was not updated after adding/removing another spacer. Change-Id: I0e0da484fe135cf109dd081a0d30a818813f8283 --- .../com/vaadin/client/widgets/Escalator.java | 5 +- .../grid/GridSpacerDecoClipTest.java | 90 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/grid/GridSpacerDecoClipTest.java diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java index 55462d18fe..45c8267d53 100644 --- a/client/src/com/vaadin/client/widgets/Escalator.java +++ b/client/src/com/vaadin/client/widgets/Escalator.java @@ -1278,7 +1278,7 @@ public class Escalator extends Widget implements RequiresResize, *

* The implementation must call {@link #paintRemoveRow(Element, int)} * for each row that is removed from the DOM. - * + * * @param index * the logical index of the first removed row * @param numberOfRows @@ -4994,6 +4994,7 @@ public class Escalator extends Widget implements RequiresResize, spacerScrollerRegistration.removeHandler(); spacerScrollerRegistration = null; } + recalculateElementSizes(); } public Map getSpacers() { @@ -5304,6 +5305,7 @@ public class Escalator extends Widget implements RequiresResize, initSpacerContent(spacer); body.sortDomElements(); + recalculateElementSizes(); } private void updateExistingSpacer(int rowIndex, double newHeight) { @@ -6284,6 +6286,7 @@ public class Escalator extends Widget implements RequiresResize, body.recalculateSectionHeight(); footer.recalculateSectionHeight(); + body.spacerContainer.updateSpacerDecosVisibility(); scroller.recalculateScrollbarsForVirtualViewport(); body.verifyEscalatorCount(); body.reapplySpacerWidths(); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridSpacerDecoClipTest.java b/uitest/src/com/vaadin/tests/components/grid/GridSpacerDecoClipTest.java new file mode 100644 index 0000000000..c4db770ae1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridSpacerDecoClipTest.java @@ -0,0 +1,90 @@ +/* + * 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.grid; + +import com.vaadin.testbench.TestBenchElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.tests.minitutorials.v7_5.ShowingExtraDataForRows; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.SearchContext; + +/** + * Test for "Grid detail row outline overflows" (#17826) + * + * @author Vaadin Ltd + */ +public class GridSpacerDecoClipTest extends MultiBrowserTest { + + private static final String SPACER_CSS_CLASS_DECO = "v-grid-spacer-deco"; + @Override + protected Class getUIClass() { + return ShowingExtraDataForRows.class; + } + + @Test + public void testNewSpacerClip() { + openTestURL(); + + GridElement gridElement = $(GridElement.class).first(); + gridElement.scrollToRow(999); + GridElement.GridRowElement nextToLastRow = gridElement.getRow(998); + nextToLastRow.doubleClick(); + + TestBenchElement deco = getSpacerDeco(0); + System.out.println("Lower deco.clip = " + deco.getCssValue("clip")); + GridElement.GridRowElement nearToBottomRow = gridElement.getRow(993); + nearToBottomRow.doubleClick(); + deco = getSpacerDeco(0); + System.out.println("Lower deco.clip = " + deco.getCssValue("clip")); + Assert.assertNotEquals("Spacer deco clipping is not updated after opening another spacer", + "auto", deco.getCssValue("clip")); + } + + @Test + public void testRemovedSpacerClip() throws InterruptedException { + openTestURL(); + + GridElement gridElement = $(GridElement.class).first(); + gridElement.scrollToRow(999); + GridElement.GridRowElement lastRow = gridElement.getRow(999); + lastRow.doubleClick(); //Open lowest Row Details + + TestBenchElement deco = getSpacerDeco(0); + System.out.println("deco.rect = " + deco.getCssValue("clip")); + + GridElement.GridRowElement nearToBottomRow = gridElement.getRow(993); + + nearToBottomRow.doubleClick(); //Open upper Row Details, lower Row Details goes out of visible range + Thread.sleep(500); + nearToBottomRow.doubleClick(); //Close upper Row Details, lower Row Details goes back to visible range + + deco = getSpacerDeco(0); + String clip = deco.getCssValue("clip"); + System.out.println("deco.rect = " + clip); + + Assert.assertTrue("Part of lower Row Details is visible, its deco clip height should be positive, but it is negative", + clip.indexOf('-') < 0); + } + + private TestBenchElement getSpacerDeco(int index) { + SearchContext context = this.getContext(); + return (TestBenchElement) context.findElements(By.className(SPACER_CSS_CLASS_DECO)).get(index); + } +} + -- 2.39.5