use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.
the class ContextMenuHelper method clickContextMenu.
/**
* Clicks the context menu matching the text.
*
* @param bot
*
* @param texts
* the text on the context menu.
* @throws WidgetNotFoundException
* if the widget is not found.
* @throws SWTException
* if the menu item is disabled (the root cause being an
* {@link IllegalStateException})
*/
public static void clickContextMenu(final AbstractSWTBot<?> bot, final String... texts) {
// show
final MenuItem menuItem = UIThreadRunnable.syncExec((WidgetResult<MenuItem>) () -> {
MenuItem theItem = getMenuItem(bot, texts);
if (theItem != null && !theItem.isEnabled())
throw new IllegalStateException("Menu item is diabled");
return theItem;
});
if (menuItem == null) {
throw new WidgetNotFoundException("Could not find menu: " + Arrays.asList(texts));
}
// click
click(menuItem);
// hide
UIThreadRunnable.syncExec(() -> {
if (menuItem.isDisposed())
// menu already gone
return;
hide(menuItem.getParent());
});
}
use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.
the class AbstractSWTBotTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
// delay click speed
// System.setProperty("org.eclipse.swtbot.playback.delay", "200");
bot = new SWTWorkbenchBot();
try {
bot.viewByTitle("Welcome").close();
// hide Subclipse Usage stats popup if present/installed
bot.shell("Subclipse Usage").activate();
bot.button("Cancel").click();
} catch (WidgetNotFoundException e) {
// ignore
}
// Make sure project explorer is open and tree available
ProjectExplorer.openView();
projectExplorerViewTree = ProjectExplorer.getTree();
}
use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.
the class PreferencesTest method setUpWorkbench.
@BeforeClass
public static void setUpWorkbench() throws Exception {
// Set up is based from from GcovTest{c,CPP}.
SWTWorkbenchBot bot = new SWTWorkbenchBot();
try {
// $NON-NLS-1$
bot.viewByTitle("Welcome").close();
// hide Subclipse Usage stats popup if present/installed
// $NON-NLS-1$
bot.shell("Subclipse Usage").activate();
// $NON-NLS-1$
bot.button("Cancel").click();
} catch (WidgetNotFoundException e) {
// ignore
}
// Set C/C++ perspective.
// $NON-NLS-1$
bot.perspectiveByLabel("C/C++").activate();
bot.sleep(500);
for (SWTBotShell sh : bot.shells()) {
if (sh.getText().startsWith("C/C++")) {
// $NON-NLS-1$
sh.activate();
bot.sleep(500);
break;
}
}
// Turn off automatic building by default to avoid timing issues
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription desc = workspace.getDescription();
boolean isAutoBuilding = desc.isAutoBuilding();
if (isAutoBuilding) {
desc.setAutoBuilding(false);
workspace.setDescription(desc);
}
}
use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.
the class ImportRPMsPageTest method setUpBeforeClass.
/**
* Initialize the test project.
*
* @throws CoreException
*/
@BeforeClass
public static void setUpBeforeClass() throws CoreException {
testProject = new TestCreaterepoProject();
assertTrue(testProject.getProject().exists());
bot = new SWTWorkbenchBot();
try {
bot.shell(ICreaterepoTestConstants.MAIN_SHELL).activate();
} catch (WidgetNotFoundException e) {
// cannot activate main shell, continue anyways
}
monitor = new NullProgressMonitor();
TestUtils.openResourcePerspective(bot);
navigator = TestUtils.enterProjectFolder(bot);
}
use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.
the class RepoFormEditorTest method setUpBeforeClass.
/**
* Initialize the test project.
*
* @throws CoreException
*/
@BeforeClass
public static void setUpBeforeClass() throws CoreException {
testProject = new TestCreaterepoProject();
assertTrue(testProject.getProject().exists());
bot = new SWTWorkbenchBot();
try {
bot.shell(ICreaterepoTestConstants.MAIN_SHELL).activate();
} catch (WidgetNotFoundException e) {
// cannot activate main shell, continue anyways
}
TestUtils.openResourcePerspective(bot);
navigator = TestUtils.enterProjectFolder(bot);
}
Aggregations