TileSelector { public boolean isSelected(Tile<?> tile) { return selectedTiles.contains(tile); } private  TileSelector(WidgetPane pane); static TileSelector forPane(WidgetPane pane); ObservableSet<Tile<?>> getSelectedTiles(); boolean isSelected(Tile<?> tile); boolean areTilesSelected(); void deselectAll(); void select(Tile<?> tile); void deselect(Tile<?> tile); void toggleSelect(Tile<?> tile); void selectOnly(Tile<?> tile);  }
@Test @Tag("NonHeadlessTests") public void testDragToSelectSingle() { clickOn(pane.localToScreen(128, 256)) .drag() .dropTo(pane.localToScreen(0, 0)); waitForFxEvents(); assertTrue(firstTile.isSelected(), "First tile should have been selected by drag"); assertFalse(secondTile.isSelected(), "Middle tile should not have been selected"); assertFalse(thirdTile.isSelected(), "Rightmost tile should not have been selected"); }
@Test public void testDragToSelectMultiple() { clickOn(pane.localToScreen(256, 256)) .drag() .dropTo(pane.localToScreen(0, 0)); waitForFxEvents(); assertTrue(firstTile.isSelected(), "First tile should have been selected by drag"); assertTrue(secondTile.isSelected(), "Middle tile should have been selected by drag"); assertFalse(thirdTile.isSelected(), "Rightmost tile should not have been selected"); }
@Test public void testDoubleClickToSelectUnselectedTile() { testDragToSelectMultiple(); doubleClickOn(thirdTile); waitForFxEvents(); assertAll("All but the first tile should be selected", () -> assertFalse(firstTile.isSelected(), "First tile was still selected"), () -> assertFalse(secondTile.isSelected(), "Second tile was still selected"), () -> assertTrue(thirdTile.isSelected(), "Third tile was not selected") ); }
@Test public void testDoubleClickToSelectTileInSelection() { testDragToSelectMultiple(); doubleClickOn(firstTile); assertTrue(firstTile.isSelected(), "First tile should be selected"); assertFalse(secondTile.isSelected(), "Second tile should have been deselected by double-click"); }
@Test @Tag("NonHeadlessTests") public void testCtrlClickToSelect() { press(KeyCode.CONTROL); clickOn(firstTile); release(KeyCode.CONTROL); waitForFxEvents(); assertTrue(firstTile.isSelected(), "Tile should have been selected by CTRL+click"); }
@Test @Tag("NonHeadlessTests") public void testCtrlClickToAddToSelection() { testDragToSelectMultiple(); press(KeyCode.CONTROL); clickOn(thirdTile); release(KeyCode.CONTROL); waitForFxEvents(); assertAll("All tiles should be selected", () -> assertTrue(firstTile.isSelected(), "First tile was not selected"), () -> assertTrue(secondTile.isSelected(), "Second tile was not selected"), () -> assertTrue(thirdTile.isSelected(), "Third tile was not selected") ); press(KeyCode.CONTROL); clickOn(firstTile); release(KeyCode.CONTROL); waitForFxEvents(); assertAll("All but the first tile should be selected", () -> assertFalse(firstTile.isSelected(), "First tile was still selected"), () -> assertTrue(secondTile.isSelected(), "Second tile was not selected"), () -> assertTrue(thirdTile.isSelected(), "Third tile was not selected") ); }