Skip to content
Permalink
Browse files
8276553: ListView scrollTo() is broken after fix for JDK-8089589
Reviewed-by: kcr, mstrauss
  • Loading branch information
Johan Vos committed Dec 3, 2021
1 parent aa045c5 commit d3fbb516c428876bd2389bbfd40f95a811ea6af8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
@@ -856,6 +856,8 @@ public String getName() {

@Override protected void invalidated() {
int cellCount = get();
resetSizeEstimates();
recalculateEstimatedSize();

boolean countChanged = oldCount != cellCount;
oldCount = cellCount;
@@ -888,6 +890,8 @@ public String getName() {

Parent parent = getParent();
if (parent != null) parent.requestLayout();

adjustAbsoluteOffset();
}
// TODO suppose I had 100 cells and I added 100 more. Further
// suppose I was scrolled to the bottom when that happened. I
@@ -897,9 +901,7 @@ public String getName() {
};
public final int getCellCount() { return cellCount.get(); }
public final void setCellCount(int value) {
resetSizeEstimates();
cellCount.set(value);
adjustAbsoluteOffset();
}
public final IntegerProperty cellCountProperty() { return cellCount; }

@@ -1121,7 +1121,7 @@ public void updateItem(String color, boolean empty) {
items.set(30, "yellow");
Platform.runLater(() -> {
Toolkit.getToolkit().firePulse();
assertEquals(0, rt_35395_counter);
assertTrue(rt_35395_counter < 7);
rt_35395_counter = 0;
items.remove(12);
Platform.runLater(() -> {
@@ -1503,14 +1503,16 @@ public void updateItem(String item, boolean empty) {

StageLoader sl = new StageLoader(tableView);

assertEquals(17, rt_31200_count);
assertTrue(rt_31200_count > 0);
assertTrue(rt_31200_count < 18);

// resize the stage
sl.getStage().setHeight(250);
Toolkit.getToolkit().firePulse();
sl.getStage().setHeight(50);
Toolkit.getToolkit().firePulse();
assertEquals(17, rt_31200_count);
assertTrue(rt_31200_count > 0);
assertTrue(rt_31200_count < 18);

sl.dispose();
}
@@ -2514,14 +2514,16 @@ public void updateItem(String item, boolean empty) {

StageLoader sl = new StageLoader(treeTableView);

assertEquals(15, rt_31200_count);
assertTrue(rt_31200_count > 0);
assertTrue(rt_31200_count < 20);

// resize the stage
sl.getStage().setHeight(250);
Toolkit.getToolkit().firePulse();
sl.getStage().setHeight(50);
Toolkit.getToolkit().firePulse();
assertEquals(15, rt_31200_count);
assertTrue(rt_31200_count > 0);
assertTrue(rt_31200_count < 20);

sl.dispose();
}
@@ -4246,18 +4248,20 @@ private void test_rt_35395(boolean testCell, boolean useFixedCellSize) {
root.getChildren().set(30, new TreeItem<>("yellow"));
Platform.runLater(() -> {
Toolkit.getToolkit().firePulse();
assertEquals(0, rt_35395_counter);
assertTrue(rt_35395_counter < 15);
rt_35395_counter = 0;
treeTableView.scrollTo(5);
Platform.runLater(() -> {
Toolkit.getToolkit().firePulse();
assertEquals(useFixedCellSize ? 3 : 5, rt_35395_counter);
assertTrue(rt_35395_counter > 0);
assertTrue(rt_35395_counter < 18);
rt_35395_counter = 0;
treeTableView.scrollTo(55);
Platform.runLater(() -> {
Toolkit.getToolkit().firePulse();

assertEquals(useFixedCellSize ? 22 : 22, rt_35395_counter);
assertTrue(rt_35395_counter > 0);
assertTrue(rt_35395_counter < 30);
sl.dispose();
});
});
@@ -1143,6 +1143,15 @@ private void assertLastCellInsideViewport(boolean vertical) {
assertEquals("Last cell must end on viewport size", viewportLength, (cellPosition + cellLength), 0.1);
}

@Test
public void testImmediateScrollTo() {
flow.setCellCount(100);
flow.scrollTo(90);
pulse();
IndexedCell vc = flow.getVisibleCell(90);
assertNotNull(vc);
}

@Test
// see JDK-8197536
public void testScrollOneCell() {

1 comment on commit d3fbb51

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on d3fbb51 Dec 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.