Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing of change location functionality #42

Open
Oliver-Loeffler opened this issue Oct 25, 2020 · 3 comments
Open

Testing of change location functionality #42

Oliver-Loeffler opened this issue Oct 25, 2020 · 3 comments
Milestone

Comments

@Oliver-Loeffler
Copy link
Owner

It turned out, that the change location (or change directory) functionality implemented is hard to test.
Therefore a rework is needed.

Points which turned out problematic:

  • PathSupplier is actually a path consumer - need to rethink the idea here
  • The SplitMenuButton seems to hard to reach with TestFX - found no way yet to interact with the button or the menu.
@Oliver-Loeffler Oliver-Loeffler added this to the 0.0.11 milestone Nov 14, 2022
@ArchibaldBienetre
Copy link

ArchibaldBienetre commented Nov 26, 2022

(Working with v0.0.9)

I think there is only working with selectors where you can, then choosing click coordinates based on it.

Here's what I got right now: Opening the directory dropdown for choosing the directory, then selecting the first location item there

image

    SplitMenuButton chooseDirectory = robot.lookup("#chooser").queryAs(SplitMenuButton.class);
    Bounds chooseAbsoluteBounds = chooseDirectory.localToScreen(chooseDirectory.getBoundsInLocal());

    // open dropdown with pre-programmed locations
    robot.clickOn(chooseAbsoluteBounds.getMaxX() - 10, chooseAbsoluteBounds.getMaxY() - 10);

    // choose first item in dropdown (user home)
    robot.clickOn(chooseAbsoluteBounds.getMinX() + 20, chooseAbsoluteBounds.getMaxY() + 20);

To then select the first in the list of listed files, I have this code:

private void chooseFirstInListOfFiles(FxRobot robot) {
    ListView<?> listOfFiles = robot.lookup("#listOfFiles").queryListView();
    // I cannot do this programmatically, it seems
    //        listOfFiles.getSelectionModel().selectFirst();
    //        listOfFiles.refresh();
    //        robot.clickOn(listOfFiles);

    clickOnUpperLeftPlusOffset(robot, listOfFiles, 30);
}

private void clickOnUpperLeftPlusOffset(FxRobot robot, Node node, int offset) {
    Bounds absoluteBounds = node.localToScreen(node.getBoundsInLocal());
    robot.clickOn(absoluteBounds.getMinX() + offset, absoluteBounds.getMinY() + offset);
}

@ArchibaldBienetre
Copy link

Something like this would be great: If the location menu items had IDs, we could use these selection (rather than absolute coordinates):
TestFX/TestFX#662 (comment)

@Oliver-Loeffler
Copy link
Owner Author

Thanks for this very nice idea, I will look into this and see, if I get it working.

@Oliver-Loeffler Oliver-Loeffler modified the milestones: 0.0.11, 0.0.12 Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants