use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-integration-commons by spring-projects.
the class SWTBotUtils method selectChildTreeElement.
/**
* Given a view name containing a tree, this method will attempt to select a
* node contained within a parent.
*
* @param bot
* containing shell with a tree
* @param shellName
* of the shell containing tree
* @param parentName
* parent containing the node to be selected
* @param childName
* node to be selected
* @return the selected node
*/
public static SWTBotTreeItem selectChildTreeElement(SWTBot bot, String shellName, String parentName, String childName) {
SWTBotShell shell = bot.shell(shellName);
shell.activate();
SWTBotTreeItem parentNode = SWTBotConditions.waitForNodeExpanded(bot, parentName);
SWTBotTreeItem childNode = SWTBotConditions.waitChildNodeToAppear(bot, parentNode, childName);
return childNode.select();
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-integration-commons by spring-projects.
the class SWTBotUtils method openPerspective.
/**
* Open a particular perspective, or try to activate it if it can't be
* opened (maybe it already open)
*/
public static void openPerspective(SWTWorkbenchBot bot, String perspectiveLabel) {
SWTBotShell shell = null;
try {
menu(bot, "Window").menu("Open Perspective").menu("Other...").click();
shell = bot.shell("Open Perspective");
// SWTBotUtils.screenshot("openPerspective_"+perspectiveLabel);
assertTrue(shell.isOpen());
bot.waitUntil(SWTBotUtils.widgetMakeActive(shell));
shell.bot().table().select(perspectiveLabel);
shell.bot().button("OK").click();
bot.waitUntil(Conditions.shellCloses(shell));
} catch (Exception e) {
if (shell != null && shell.isOpen())
shell.close();
System.err.println("Couldn't open perspective '" + perspectiveLabel + "'\n" + "trying to activate already open perspective instead");
// maybe somehow the perspective is already opened (by another test
// before us)
SWTBotPerspective perspective = bot.perspectiveByLabel(perspectiveLabel);
perspective.activate();
assertTrue(perspective.isActive());
}
Assert.assertEquals(perspectiveLabel, bot.activePerspective().getLabel());
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-integration-commons by spring-projects.
the class UITestCase method activateFileNewWizardShell.
/**
* Activate a wizard from the "File >> New" menu.
*
* @param projectWizardName
* @param wizardShellName
* @return A reference to the Wizard's shell.
*/
protected SWTBotShell activateFileNewWizardShell(String projectWizardName, String wizardShellName) {
SWTBotUtils.menu(bot, "File").menu("New").menu(projectWizardName).click();
SWTBotShell shell = bot.shell(wizardShellName);
shell.activate();
return shell;
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell 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;
}
}
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project epp.mpc by eclipse.
the class MarketplaceWizardTest method testMoreInfoLearnMore.
// TODO conditional on embedded browser availability
// FIXME
@Ignore("Tooltip doesn't stay open")
@Test
public void testMoreInfoLearnMore() {
SWTBotClickableStyledText descriptionLabel = SWTBotClickableStyledText.from(bot.styledTextWithId(AbstractMarketplaceDiscoveryItem.WIDGET_ID_KEY, AbstractMarketplaceDiscoveryItem.WIDGET_ID_DESCRIPTION));
StyleRange linkRange = findLink(descriptionLabel, "more\u00a0info");
bot.sleep(5000);
descriptionLabel.click(linkRange);
bot.sleep(5000);
SWTBotShell tooltip = bot.shellWithId(AbstractMarketplaceDiscoveryItem.WIDGET_ID_KEY, DiscoveryItem.WIDGET_ID_OVERVIEW);
SWTBotLink moreLink = tooltip.bot().linkWithId(AbstractMarketplaceDiscoveryItem.WIDGET_ID_KEY, DiscoveryItem.WIDGET_ID_LEARNMORE);
moreLink.click();
checkMarketplaceBrowser();
}
Aggregations