Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8359598

[TestBug] VirtualFlowTestUtils should not create a temporary Stage

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • javafx
    • generic
    • generic

      Currently, the VirtualFlowTestUtils used ONLY for tests has many utility methods to get and do something with the VirtualFlow of Virtualized Controls.

      It has one flaw: It may creates a temporary Stage with the StageLoader, when the Control was never inside a Scene (and Stage) yet. This is done to get the VirtualFlow, which is not possible otherwise.

      Take the following test code:
      ...
      VirtualFlowTestUtils.clickOnRow(tableView, 2);
      VirtualFlowTestUtils.clickOnRow(tableView, 4);
      ...

      What it does it to create a Stage for the first method and dispose it after. And create another Stage for the second method and dispose it after.

      This does not test a realistic scenario and the chance is quite high that developers used that methods without even knowing that it contains such logic.

      So the idea is to remove the StageLoader code from VirtualFlowTestUtils and rather use it in the Test code before calling the Util methods.

      For the example above, this would result in:
      ...
      stageLoader = new StageLoader(tableView);
      VirtualFlowTestUtils.clickOnRow(tableView, 2);
      VirtualFlowTestUtils.clickOnRow(tableView, 4);
      ...

      The stageLoader should be disposed in an @AfterEach.

            mhanl Marius Hanl
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: