From a5977d2b16b75ee0bd96e117d5a7ed8e22e5bf49 Mon Sep 17 00:00:00 2001 From: "Maxim.Kolmakov" Date: Tue, 13 Jun 2017 18:13:24 +0200 Subject: [PATCH] [gui-test] Avoid private fields and reuse parent robot() and target() --- .../fixtures/ComponentWithBrowseButtonFixture.java | 8 ++------ .../testGuiFramework/fixtures/JDialogFixture.java | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ComponentWithBrowseButtonFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ComponentWithBrowseButtonFixture.java index 80d1a91d635c..625d62bc09e8 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ComponentWithBrowseButtonFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ComponentWithBrowseButtonFixture.java @@ -24,21 +24,17 @@ import org.jetbrains.annotations.NotNull; import java.awt.*; public class ComponentWithBrowseButtonFixture extends JComponentFixture { - 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); } } diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/JDialogFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/JDialogFixture.java index b7a955f44797..70b93db03f35 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/JDialogFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/JDialogFixture.java @@ -29,21 +29,17 @@ import java.util.Collection; public class JDialogFixture extends ComponentFixture implements ContainerFixture { - 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 matcher = getMatcher(myDialog.getTitle()); + GenericTypeMatcher 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(); } }); }