use of org.fest.swing.edt.GuiTask in project intellij-community by JetBrains.
the class SelectSdkDialogFixture method selectPathToSdk.
public SelectSdkDialogFixture selectPathToSdk(@NotNull File pathToSdk) {
final JTextField textField = myRobot.finder().findByType(JTextField.class);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
textField.setText(pathToSdk.getPath());
}
});
final Tree tree = myRobot.finder().findByType(myDialog, Tree.class);
final AbstractTreeBuilder builder = AbstractTreeBuilder.getBuilderFor(tree);
pause(new Condition("Wait until path is updated") {
@Override
public boolean test() {
//noinspection ConstantConditions
return execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
return (textField.getText().equals(pathToSdk.getPath()) && !builder.getUi().getUpdater().hasNodesToUpdate());
}
});
}
}, SHORT_TIMEOUT);
return this;
}
use of org.fest.swing.edt.GuiTask in project intellij-community by JetBrains.
the class ToolWindowFixture method activate.
public void activate() {
if (isActive()) {
return;
}
final Callback callback = new Callback();
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
myToolWindow.activate(callback);
}
});
pause(new Condition("Wait for ToolWindow '" + myToolWindowId + "' to be activated") {
@Override
public boolean test() {
return callback.finished;
}
}, GuiTestUtil.SHORT_TIMEOUT);
}
use of org.fest.swing.edt.GuiTask in project intellij-community by JetBrains.
the class GuiTestUtil method acceptAgreementIfNeeded.
private static void acceptAgreementIfNeeded(Robot robot) {
final String policyAgreement = "Privacy Policy Agreement";
Pair<PrivacyPolicy.Version, String> policy = PrivacyPolicy.getContent();
boolean showPrivacyPolicyAgreement = !PrivacyPolicy.isVersionAccepted(policy.getFirst());
if (!showPrivacyPolicyAgreement) {
LOG.info(policyAgreement + " dialog should be skipped on this system.");
return;
}
try {
final DialogFixture privacyDialogFixture = findDialog(new GenericTypeMatcher<JDialog>(JDialog.class) {
@Override
protected boolean isMatching(@NotNull JDialog dialog) {
if (dialog.getTitle() == null)
return false;
return dialog.getTitle().contains(policyAgreement) && dialog.isShowing();
}
}).withTimeout(LONG_TIMEOUT.duration()).using(robot);
String buttonText = "Accept";
JButton acceptButton = privacyDialogFixture.button(new GenericTypeMatcher<JButton>(JButton.class) {
@Override
protected boolean isMatching(@NotNull JButton button) {
if (button.getText() == null)
return false;
return button.getText().equals(buttonText);
}
}).target();
//we clicking this button to avoid NPE org.fest.util.Preconditions.checkNotNull(Preconditions.java:71)
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
EdtInvocationManager.getInstance().invokeLater(new Runnable() {
@Override
public void run() {
acceptButton.doClick();
}
});
}
});
} catch (WaitTimedOutError we) {
LOG.warn("Timed out waiting for \"" + policyAgreement + "\" JDialog. Continue...");
}
}
Aggregations