-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always calculate Escalator max row count the same way (#8740)
* Rename getMaxEscalatorRowCapacity to describe what it does * Always calculate Escalator max row count the same way This changes Escalator to not take a horizontal scrollbar into account when trying to determine "maximum visible rows". This will add another row, compared to previous versions, when there is a horizontal scrollbar. In reality, it would likely make sense to always add 10 more rows to have some buffer above and below the visible area. Fixes #8661
- Loading branch information
1 parent
4ecf4f9
commit 67001c7
Showing
6 changed files
with
218 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...in/java/com/vaadin/v7/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.vaadin.v7.tests.components.grid; | ||
|
||
import com.vaadin.annotations.Theme; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.tests.components.AbstractTestUI; | ||
import com.vaadin.v7.data.Item; | ||
import com.vaadin.v7.data.util.BeanItemContainer; | ||
import com.vaadin.v7.data.util.GeneratedPropertyContainer; | ||
import com.vaadin.v7.data.util.PropertyValueGenerator; | ||
import com.vaadin.v7.ui.Grid; | ||
import com.vaadin.v7.ui.Grid.Column; | ||
import com.vaadin.v7.ui.renderers.ButtonRenderer; | ||
|
||
@Theme("valo") | ||
public class HideGridColumnWhenHavingUnsuitableHeight extends AbstractTestUI { | ||
|
||
private Grid grid; | ||
|
||
public static class SampleBean { | ||
|
||
private String col1; | ||
private String col2; | ||
|
||
public SampleBean() { | ||
} | ||
|
||
public String getCol1() { | ||
return col1; | ||
} | ||
|
||
public void setCol1(String col1) { | ||
this.col1 = col1; | ||
} | ||
|
||
public String getCol2() { | ||
return col2; | ||
} | ||
|
||
public void setCol2(String col2) { | ||
this.col2 = col2; | ||
} | ||
} | ||
|
||
@SuppressWarnings("serial") | ||
@Override | ||
protected void setup(VaadinRequest vaadinRequest) { | ||
grid = new Grid(); | ||
|
||
BeanItemContainer<SampleBean> container = generateData(50); | ||
GeneratedPropertyContainer gpc = new GeneratedPropertyContainer( | ||
container); | ||
grid.setContainerDataSource(gpc); | ||
|
||
gpc.addGeneratedProperty("Button1", | ||
new PropertyValueGenerator<String>() { | ||
@Override | ||
public String getValue(Item item, Object itemId, | ||
Object propertyId) { | ||
return "Button 1"; | ||
} | ||
|
||
@Override | ||
public Class<String> getType() { | ||
return String.class; | ||
} | ||
}); | ||
grid.getColumn("Button1").setRenderer(new ButtonRenderer()); | ||
grid.getColumn("col1").setWidth(1600); | ||
for (Column gridCol : grid.getColumns()) { | ||
gridCol.setHidable(true); | ||
} | ||
grid.setWidth("100%"); | ||
grid.setHeight("425px"); | ||
|
||
grid.setColumns("col1", "col2", "Button1"); | ||
|
||
addComponent(grid); | ||
} | ||
|
||
private BeanItemContainer<SampleBean> generateData(int rows) { | ||
BeanItemContainer<SampleBean> container = new BeanItemContainer<SampleBean>( | ||
SampleBean.class); | ||
for (int y = 0; y < rows; ++y) { | ||
SampleBean sampleBean = new SampleBean(); | ||
sampleBean.setCol1("Row " + y + " Column 1"); | ||
sampleBean.setCol2("Row " + y + " Column 2"); | ||
container.addBean(sampleBean); | ||
} | ||
return container; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridScrollTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.basics; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
import com.vaadin.testbench.elements.GridElement; | ||
|
||
public class GridScrollTest extends GridBasicsTest { | ||
|
||
@Test | ||
public void workPendingWhileScrolling() { | ||
openTestURL("theme=valo"); | ||
String script = "var c = window.vaadin.clients.runcomvaadintestscomponentsgridbasicsGridBasics;\n" | ||
// Scroll down and cause lazy loading | ||
+ "c.getElementByPath(\"//Grid[0]#cell[21]\"); \n" | ||
+ "return c.isActive();"; | ||
|
||
Boolean active = (Boolean) executeScript(script); | ||
assertTrue("Grid should be marked to have workPending while scrolling", | ||
active); | ||
} | ||
|
||
@Test | ||
public void scrollIntoViewThroughSubPart() { | ||
openTestURL("theme=valo"); | ||
GridElement grid = $(GridElement.class).first(); | ||
assertEquals("(10, 0)", grid.getCell(10, 0).getText()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ava/com/vaadin/v7/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeightTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.vaadin.v7.tests.components.grid; | ||
|
||
import java.util.List; | ||
import java.util.logging.Level; | ||
|
||
import org.junit.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
|
||
import com.vaadin.testbench.elements.GridElement; | ||
import com.vaadin.tests.tb3.SingleBrowserTest; | ||
|
||
public class HideGridColumnWhenHavingUnsuitableHeightTest | ||
extends SingleBrowserTest { | ||
|
||
@Test | ||
public void hideAndScroll() { | ||
openTestURL("debug"); | ||
GridElement grid = $(GridElement.class).first(); | ||
|
||
getSidebarOpenButton(grid).click(); | ||
// Hide first column | ||
getSidebarPopup().findElements(By.tagName("td")).get(0).click(); | ||
|
||
grid.scrollToRow(25); | ||
assertNoDebugMessage(Level.SEVERE); | ||
} | ||
|
||
protected WebElement getSidebarOpenButton(GridElement grid) { | ||
List<WebElement> elements = grid | ||
.findElements(By.className("v-grid-sidebar-button")); | ||
return elements.isEmpty() ? null : elements.get(0); | ||
} | ||
|
||
protected WebElement getSidebarPopup() { | ||
List<WebElement> elements = findElements( | ||
By.className("v-grid-sidebar-popup")); | ||
return elements.isEmpty() ? null : elements.get(0); | ||
} | ||
} |