RFR: 8256397: MultipleSelectionModel throws IndexOutOfBoundException [v5]
Andy Goryachev
angorya at openjdk.org
Fri Nov 18 18:21:34 UTC 2022
On Thu, 14 Jul 2022 08:05:25 GMT, Florian Kirmaier <fkirmaier at openjdk.org> wrote:
>> Fixing IndexOutOfBoundsException in the MultipleSelectionModelBase and added a unit-test for it.
>> ticket: https://bugs.openjdk.java.net/browse/JDK-8256397
>> run test: `./gradlew --continue -PFULL_TEST=true controls:test --tests "*MultipleSelectionModelImplTest*"`
>
> Florian Kirmaier has updated the pull request incrementally with one additional commit since the last revision:
>
> JDK_8256397
> Fixed more issues with the multiple selection model change events, and verified them with more unit-tests.
modules/javafx.controls/src/test/java/test/javafx/scene/control/MultipleSelectionModelImplTest.java line 1456:
> 1454: testSelectedIndicesChangeEventsFactory(0, new int[]{2,3}, 1, new int[]{5,7},
> 1455: new int[][]{new int[]{1}, new int[]{5,7}});
> 1456:
Do we have a test that tries to select indexes outside of the model?
modules/javafx.controls/src/test/java/test/javafx/scene/control/MultipleSelectionModelImplTest.java line 1467:
> 1465:
> 1466: testSelectedIndicesChangeEventsFactory(2, new int[]{3, 6,7}, 0, new int[]{1,4,5,8,9},
> 1467: new int[][]{new int[]{0,1},new int[]{4,5},new int[]{8,9}});
I wonder if this test covers all the possible code paths in the implementation. To illustrate just a subset of scenarios that should be tested, let's consider these scenarios (initial selection on the top line, change on the bottom line):
index 0 flipped, index 1 unchanged:
-I-
||-
index 1 unchanged
-|-
-|-
index 1 unchanged, index 2 flipped
-|-
-||
index 0 and 2 flipped
|--
--|
etc.
Perhaps it is possible to design a test that user random number generator to generate initial state and the changes, apply these to both MultipleSelectionModelBase and let's say a BitSet, and then compare the results - doing this 10,000 times (a sort of fuzzing test). A model with 10 items might be sufficient.
modules/javafx.controls/src/test/java/test/javafx/scene/control/MultipleSelectionModelImplTest.java line 1478:
> 1476: listView.getItems().add("item-4");
> 1477: listView.getItems().add("item-5");
> 1478: listView.getItems().add("item-6");
minor:
.getItems().addAll(
"1",
"2",
..
);
-------------
PR: https://git.openjdk.org/jfx/pull/353
More information about the openjfx-dev
mailing list