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

Fix scroll direction as UP was going down (and DOWN up). #95

Merged
merged 2 commits into from
Jun 19, 2014

Conversation

lgringo
Copy link
Contributor

@lgringo lgringo commented Jun 18, 2014

When FxRobot has been refactored, Up and Down scroll have been inverted.

Old code :

/**
 * Scrolls the mouse-wheel a given number of notches in a direction.
 *
 * @param amount    the number of notches to scroll
 * @param direction
 * @return
*/
public GuiTest scroll(int amount, VerticalDirection direction) {
    for (int x = 0; x < Math.abs(amount); x++) {
       screenRobot.scrollMouse(directionToInteger(direction));
    }
    return this;
 }

private int directionToInteger(VerticalDirection direction) {
    if (direction == VerticalDirection.UP)
        return -1;
     return 1;
 }

Actual code is :

@Override
public void scroll(int amount) {
    if (amount >= 0) {
        scrollUp(amount);
    }
    else {
        scrollDown(Math.abs(amount));
    }
}
[...]
@Override
public void scrollUp(int positiveAmount) {
    for (int scrollTick = 0; scrollTick < positiveAmount; scrollTick++) {
        screenRobot.scrollMouse(1);
    }
}

@Override
public void scrollDown(int positiveAmount) {
    for (int scrollTick = 0; scrollTick < positiveAmount; scrollTick++) {
        screenRobot.scrollMouse(-1);
    }
}

Regression test added (I hope the Duke with a guitar image do not have a copyright).

hastebrot added a commit that referenced this pull request Jun 19, 2014
fix(ScrollRobotImpl): Scroll direction as UP was going down (and DOWN up).
@hastebrot hastebrot merged commit e704b83 into TestFX:master Jun 19, 2014
@hastebrot
Copy link
Member

Thanks!

@hastebrot hastebrot added the bug label Jun 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants