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

Testbug: broken usage of MouseEventFirer/VirtualFlowTestUtils

XMLWordPrintable

      TableViewMouseInputTest.test_rt_38464_cellSelection has a code comment hinting to a problem with using the test utils:

           // setup: get cell and create a mouse firer on it
           TableCell cell_4_2 = VirtualFlowTestUtils.getCell(table, 4, 2);
           MouseEventFirer firer = new MouseEventFirer(cell_4_2);
           ....
           // while testing cell states
          if (row == 4 && column == 2) {
              // bizarrely cell (4,2), i.e. the bottom-right cell consisting
              // of Michael Brown's email address, doesn't exist.
              continue;
           }

      The reason here is that the test relies on the auto-creation of a StageLoader for the table, done both by the test utils and then again by the firer - the latter does so for the isolated cell, implicitly moving it from the table's scenegraph into the new scene.

      Fix is to manually add the table to a scene (via a stageloader, f.i.) before (at least) creating a firer.

      Probably should take a closer look at similar test patterns and see whether they might effect the test outcome (in either direction). The scenegraph seems stable enough when moved around (as a whole) across multiple scenes, f.i. when repeatedly getting cells from the test utils (didn't find any weirdness, but didn't try too hard ;)

      A test demonstrating the mis-/behavior with/out commented code line:

          @Test
          public void testMouseFirerInScene() {
               // get row and cell in that row (doesn't matter which exactly
              TableRow<?> tableRow = (TableRow) VirtualFlowTestUtils.getCell(tableView, 1);
              TableCell<?, ?> tableCell = (TableCell) VirtualFlowTestUtils.getCell(tableView, 1, 0);
              assertSame("sanity: parent of cell is expected row", tableRow, tableCell.getParent());

              // manually install scene to keep table's scenegraph stable
              // stageLoader = new StageLoader(tableView);
              new MouseEventFirer(tableCell).fireMousePressAndRelease(KeyModifier.SHIFT);
              assertSame("parent of cell must be unchanged", tableRow, tableCell.getParent());
          }

            Unassigned Unassigned
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: