use of org.eclipse.swtbot.swt.finder.waits.ICondition in project eclipse-integration-commons by spring-projects.
the class SWTBotConditions method waitChildNodeToAppear.
public static SWTBotTreeItem waitChildNodeToAppear(SWTBot bot, final SWTBotTreeItem parentNode, final String nodeName) {
final SWTBotTreeItem[] child = new SWTBotTreeItem[1];
bot.waitUntil(new ICondition() {
public boolean test() throws Exception {
child[0] = parentNode.getNode(nodeName);
return child[0] != null;
}
public void init(SWTBot bot) {
//
}
public String getFailureMessage() {
return "Unable to find child node: " + nodeName + " for parent node: " + parentNode.getText();
}
}, CHILD_NODE_POPULATE_TIMEOUT);
return child[0];
}
use of org.eclipse.swtbot.swt.finder.waits.ICondition in project syncope by apache.
the class SyncopeViewTest method canOpenMailTemplateEditor.
public boolean canOpenMailTemplateEditor() {
final int initBotEditors = BOT.editors().size();
SWTBotTreeItem optin = syncopeView.bot().tree().expandNode("Mail Templates").getNode("optin");
optin.setFocus();
optin.select().contextMenu("View Template").click();
// wait for template keys reload
BOT.waitWhile(new ICondition() {
@Override
public boolean test() throws Exception {
return BOT.editors().size() == initBotEditors;
}
@Override
public void init(final SWTBot bot) {
}
@Override
public String getFailureMessage() {
return "Unable to Login";
}
});
return !BOT.editors().isEmpty();
}
use of org.eclipse.swtbot.swt.finder.waits.ICondition in project syncope by apache.
the class SyncopeViewTest method canDeleteReportTemplate.
private boolean canDeleteReportTemplate() {
SWTBotTreeItem rTemplateHead = syncopeView.bot().tree().getTreeItem("Report Templates");
if (!rTemplateHead.isExpanded()) {
rTemplateHead.expand();
}
SWTBotTreeItem rNewTemplate = rTemplateHead.getNode("newReportTemplate");
rNewTemplate.setFocus();
rNewTemplate.select().contextMenu("Remove template").click();
BOT.sleep(1000);
// wait for template keys reload
BOT.waitWhile(new ICondition() {
@Override
public boolean test() throws Exception {
String title = BOT.activeShell().getText();
return title.equals("Loading Templates");
}
@Override
public void init(final SWTBot bot) {
}
@Override
public String getFailureMessage() {
return "Unable to Login";
}
});
// recheck available templates
rTemplateItem = syncopeView.bot().tree().expandNode("Report Templates");
rtemplateList = rTemplateItem.getItems();
return (rtemplateList.length == 2);
}
use of org.eclipse.swtbot.swt.finder.waits.ICondition in project dsl-devkit by dsldevkit.
the class SwtWorkbenchBot method waitUntilWizardPageAppears.
/**
* Waits until a wizard page with the given title is visible and active.
*
* @param wizardPageTitle
* the title of the wizard page
*/
public void waitUntilWizardPageAppears(final String wizardPageTitle) {
waitUntil(new ICondition() {
@Override
@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
public boolean test() {
return syncExec(new BoolResult() {
@Override
public Boolean run() {
SWTBotShell wizardShell = activeShell();
if (wizardShell.widget.getData() instanceof WizardDialog) {
return ((WizardDialog) wizardShell.widget.getData()).getCurrentPage().getTitle().equals(wizardPageTitle);
}
return false;
}
});
}
@Override
public void init(final SWTBot paramSWTBot) {
}
@Override
public String getFailureMessage() {
return NLS.bind("Failed to find the wizard page with title ''{0}''.", wizardPageTitle);
}
});
// additionally, we need to wait until the wizard page has finished loading (button cancel is enabled).
waitUntil(new ICondition() {
@Override
@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
public boolean test() {
return button("Cancel").isEnabled();
}
@Override
public void init(final SWTBot bot) {
}
@Override
public String getFailureMessage() {
return NLS.bind("Failed while waiting for the wizard page with title ''{0}''.", wizardPageTitle);
}
});
sleep(DELAY_WIZARD_PAGE);
}
use of org.eclipse.swtbot.swt.finder.waits.ICondition in project epp.mpc by eclipse.
the class AbstractMarketplaceWizardBotTest method closeWizard.
protected void closeWizard() {
String problem = null;
List<Exception> exceptions = new ArrayList<Exception>();
SWTBotShell mpcShell;
try {
// check if dialog is still open
mpcShell = bot.shell("Eclipse Marketplace");
} catch (TimeoutException e) {
// no MPC wizard found - maybe a bit strange, but so be it...
return;
}
// check if any message dialogs are open
boolean dumpedThreads = false;
try {
WaitForObjectCondition<Shell> subShellResult = Conditions.waitForShell(Matchers.any(Shell.class), mpcShell.widget);
bot.waitUntil(subShellResult, 100, 60);
List<Shell> subShells = subShellResult.getAllMatches();
for (Shell shell : subShells) {
if (shell == mpcShell.widget) {
continue;
}
try {
SWTBotShell botShell = new SWTBotShell(shell);
// children are unexpected, so let's cry foul...
if (problem == null) {
problem = "MPC wizard has open child dialog:";
}
problem += "\n" + describeShell(botShell);
logger.info(problem);
problem += "\n" + captureShellScreenshot(botShell);
// "Wizard can not be closed due to an active operation"
if (!dumpedThreads) {
dumpedThreads = true;
dumpThreads();
}
// kill message dialog
botShell.close();
} catch (Exception ex) {
exceptions.add(ex);
}
}
} catch (Exception ex) {
exceptions.add(ex);
}
// try killing it softly
try {
mpcShell.activate();
waitForWizardProgress(SWTBotPreferences.TIMEOUT);
// same as pressing "Cancel" actually
mpcShell.close();
ICondition shellCloses = Conditions.shellCloses(mpcShell);
bot.waitUntil(shellCloses);
return;
} catch (Exception ex) {
exceptions.add(ex);
}
// now kill it hard - this is a last resort, because it can cause spurious errors in MPC jobs
// also dump threads, since this is often caused by the wizard not being cancellable due to a still running operation:
// "Wizard can not be closed due to an active operation"
problem += "\nFailed to close wizard regularly. Forcing close.";
if (!dumpedThreads) {
dumpedThreads = true;
dumpThreads();
}
try {
final Shell shell = mpcShell.widget;
if (!shell.isDisposed()) {
Display display = shell.getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
if (!shell.isDisposed()) {
shell.dispose();
}
}
});
}
} catch (Exception ex) {
exceptions.add(ex);
}
if (problem != null || !exceptions.isEmpty()) {
// something happened
try {
fail(problem);
} catch (AssertionError e) {
for (Exception exception : exceptions) {
e.addSuppressed(exception);
}
throw e;
}
}
}
Aggregations