use of org.fest.swing.exception.ComponentLookupException in project intellij-community by JetBrains.
the class GuiTestUtil method findComboBox.
public static JComboBoxFixture findComboBox(@NotNull Robot robot, @NotNull Container container, @NotNull String labelText) {
JLabel label = (JLabel) robot.finder().find(container, new ComponentMatcher() {
@Override
public boolean matches(Component p0) {
return (p0 instanceof JLabel && ((JLabel) p0).getText() != null && ((JLabel) p0).getText().equals(labelText));
}
});
if (label == null)
throw new ComponentLookupException("Unable to find label with text \" + labelText+\"");
Container boundedCmp = (Container) label.getLabelFor();
if (boundedCmp == null)
throw new ComponentLookupException("Unable to find bounded component for label \" + labelText+\"");
JComboBox cb = robot.finder().findByType(boundedCmp, JComboBox.class);
if (cb == null)
throw new ComponentLookupException("Unable to find JComboBox near label \" + labelText+\"");
return new JComboBoxFixture(robot, cb);
}
use of org.fest.swing.exception.ComponentLookupException in project intellij-community by JetBrains.
the class ActionLinkFixture method findByActionId.
@NotNull
public static ActionLinkFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
final Ref<ActionLink> actionLinkRef = new Ref<ActionLink>();
pause(new Condition("Find ActionLink with ID '" + actionId + "'") {
@Override
public boolean test() {
Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {
@Override
protected boolean isMatching(@NotNull ActionLink actionLink) {
if (actionLink.isVisible()) {
AnAction action = actionLink.getAction();
String id = ActionManager.getInstance().getId(action);
return actionId.equals(id);
}
return false;
}
});
if (found.size() == 1) {
actionLinkRef.set(getFirstItem(found));
return true;
}
return false;
}
}, SHORT_TIMEOUT);
ActionLink actionLink = actionLinkRef.get();
if (actionLink == null) {
throw new ComponentLookupException("Failed to find ActionLink with ID '" + actionId + "'");
}
return new ActionLinkFixture(robot, actionLink);
}
use of org.fest.swing.exception.ComponentLookupException in project intellij-community by JetBrains.
the class ActionLinkFixture method findActionLinkByName.
@NotNull
public static ActionLinkFixture findActionLinkByName(@NotNull final String actionName, @NotNull final Robot robot, @NotNull final Container container, @NotNull final Timeout timeout) {
final Ref<ActionLink> actionLinkRef = new Ref<ActionLink>();
pause(new Condition("Find ActionLink with name '" + actionName + "'") {
@Override
public boolean test() {
Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {
@Override
protected boolean isMatching(@NotNull ActionLink actionLink) {
if (actionLink.isVisible()) {
return actionLink.getText().equals(actionName);
}
return false;
}
});
if (found.size() == 1) {
actionLinkRef.set(getFirstItem(found));
return true;
}
return false;
}
}, timeout);
ActionLink actionLink = actionLinkRef.get();
if (actionLink == null) {
throw new ComponentLookupException("Failed to find ActionLink with name '" + actionName + "'");
}
return new ActionLinkFixture(robot, actionLink);
}
use of org.fest.swing.exception.ComponentLookupException in project android by JetBrains.
the class ActionButtonFixture method findByActionId.
@NotNull
public static ActionButtonFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
final Ref<ActionButton> actionButtonRef = new Ref<>();
Wait.seconds(1).expecting("ActionButton with ID '" + actionId + "' to be visible").until(() -> {
Collection<ActionButton> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionButton>(ActionButton.class) {
@Override
protected boolean isMatching(@NotNull ActionButton button) {
if (button.isVisible()) {
AnAction action = button.getAction();
if (action != null) {
String id = ActionManager.getInstance().getId(action);
return actionId.equals(id);
}
}
return false;
}
});
if (found.size() == 1) {
actionButtonRef.set(getFirstItem(found));
return true;
}
return false;
});
ActionButton button = actionButtonRef.get();
if (button == null) {
throw new ComponentLookupException("Failed to find ActionButton with ID '" + actionId + "'");
}
return new ActionButtonFixture(robot, button);
}
use of org.fest.swing.exception.ComponentLookupException in project android by JetBrains.
the class ActionLinkFixture method findByActionId.
@NotNull
public static ActionLinkFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
final Ref<ActionLink> actionLinkRef = new Ref<>();
Wait.seconds(1).expecting("ActionLink with ID '" + actionId + "' to be visible").until(() -> {
Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {
@Override
protected boolean isMatching(@NotNull ActionLink actionLink) {
if (actionLink.isVisible()) {
AnAction action = actionLink.getAction();
String id = ActionManager.getInstance().getId(action);
return actionId.equals(id);
}
return false;
}
});
if (found.size() == 1) {
actionLinkRef.set(getFirstItem(found));
return true;
}
return false;
});
ActionLink actionLink = actionLinkRef.get();
if (actionLink == null) {
throw new ComponentLookupException("Failed to find ActionLink with ID '" + actionId + "'");
}
return new ActionLinkFixture(robot, actionLink);
}
Aggregations