[gui-test] Avoid private fields and reuse parent robot() and target()

This commit is contained in:
Maxim.Kolmakov
2017-06-13 18:15:11 +02:00
parent 6c87335476
commit a5977d2b16
2 changed files with 4 additions and 12 deletions
@@ -24,21 +24,17 @@ import org.jetbrains.annotations.NotNull;
import java.awt.*;
public class ComponentWithBrowseButtonFixture extends JComponentFixture<ComponentWithBrowseButtonFixture, ComponentWithBrowseButton> {
private final ComponentWithBrowseButton myComponentWithBrowseButton;
@NotNull private final Robot myRobot;
public ComponentWithBrowseButtonFixture(ComponentWithBrowseButton componentWithBrowseButton, @NotNull Robot robot) {
super(ComponentWithBrowseButtonFixture.class, robot, componentWithBrowseButton);
myComponentWithBrowseButton = componentWithBrowseButton;
myRobot = robot;
}
public void clickButton() {
FixedSizeButton button = myComponentWithBrowseButton.getButton();
FixedSizeButton button = target().getButton();
Point locationOnScreen = button.getLocationOnScreen();
Rectangle bounds = button.getBounds();
final Point point =
new Point(locationOnScreen.x + bounds.x + bounds.width / 2, locationOnScreen.y + bounds.y + bounds.height / 2);
myRobot.click(point, MouseButton.LEFT_BUTTON, 1);
robot().click(point, MouseButton.LEFT_BUTTON, 1);
}
}
@@ -29,21 +29,17 @@ import java.util.Collection;
public class JDialogFixture extends ComponentFixture<JDialogFixture, JDialog> implements ContainerFixture<JDialog> {
private final Robot myRobot;
private final JDialog myDialog;
public JDialogFixture(@NotNull Robot robot, JDialog jDialog) {
super(JDialogFixture.class, robot, jDialog);
myRobot = robot;
myDialog = jDialog;
}
public void waitTillGone() {
GenericTypeMatcher<JDialog> matcher = getMatcher(myDialog.getTitle());
GenericTypeMatcher<JDialog> matcher = getMatcher(target().getTitle());
Pause.pause(new Condition("Wait till dialog gone") {
@Override
public boolean test() {
return myRobot.finder().findAll(matcher).isEmpty();
return robot().finder().findAll(matcher).isEmpty();
}
});
}