Java源码示例:org.eclipse.swtbot.swt.finder.waits.Conditions
示例1
@BeforeClass
public static void beforeClass() throws Exception {
RCPTestSetupHelper.beforeClass();
// Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc
// see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb
Display.getDefault().syncExec(new Runnable() {
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
}
});
bot = new SWTWorkbenchBot();
// Wait for the Toolbox shell to be available
final Matcher<Shell> withText = withText("TLA+ Toolbox");
bot.waitUntil(Conditions.waitForShell(withText), 30000);
// Wait for the Toolbox UI to be fully started.
final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File");
final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class),
withMnemonic);
bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000);
}
示例2
@BeforeClass
public static void beforeClass() throws Exception {
RCPTestSetupHelper.beforeClass();
// Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc
// see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb
Display.getDefault().syncExec(new Runnable() {
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
}
});
bot = new SWTWorkbenchBot();
// Wait for the Toolbox shell to be available
final Matcher<Shell> withText = withText("TLA+ Toolbox");
bot.waitUntil(Conditions.waitForShell(withText), 30000);
// Wait for the Toolbox UI to be fully started.
final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File");
final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class),
withMnemonic);
bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000);
}
示例3
/**
* Test 8.11: Run Profile "TestSpecificRecursive"
*/
@Test
public void test_8_11() {
SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
projectExplorerBot.show();
SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.comboBox().setSelection("TestSpecificRecursive");
fBot.button("Next >").click();
fBot.button("Finish").click();
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();
TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
fBot.waitUntil(new TraceCountCondition(project, 2));
final TmfTraceFolder tracesFolder = project.getTracesFolder();
assertNotNull(tracesFolder);
List<TmfTraceElement> traces = tracesFolder.getTraces();
assertEquals(2, traces.size());
testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
}
示例4
/**
* Test 8.14: Cancel Import
*/
@Test
public void test_8_14() {
SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
projectExplorerBot.show();
SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.comboBox().setSelection("TestAllRecursive");
fBot.button("Next >").click();
fBot.button("Finish").click();
fBot.button("Cancel").click();
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();
/* Can't verify cancelled import, it depends on timing */
}
示例5
/**
* Test 8.15: Run Profile "TestMultiNodse"
*/
@Test
public void test_8_15() {
SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
projectExplorerBot.show();
SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.comboBox().setSelection("TestMultiNode");
fBot.button("Next >").click();
fBot.button("Finish").click();
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();
TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
fBot.waitUntil(new TraceCountCondition(project, 2));
final TmfTraceFolder tracesFolder = project.getTracesFolder();
assertNotNull(tracesFolder);
List<TmfTraceElement> traces = tracesFolder.getTraces();
assertEquals(2, traces.size());
testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
testTrace(traces.get(1), CONNECTION_NODE2_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
}
示例6
/**
* Test 9.2: Cannot connect to remote host (wrong password)
*
* This test is ignored to avoid repeated authentication failures in the CI
* infrastructure. The @Ignore tag can be removed to run the test locally.
*/
@Test
@Ignore
public void test_9_02() {
SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
projectExplorerBot.show();
SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.comboBox().setSelection("TestLocal");
fBot.button("Finish").click();
SWTBotShell anyShell = SWTBotUtils.anyShellOf(fBot, AUTHENTICATION_SHELL_NAME, PASSWORD_SHELL_NAME).activate();
if (anyShell.getText().equals(AUTHENTICATION_SHELL_NAME)) {
fBot.button("Yes").click();
}
fBot.shell(PASSWORD_SHELL_NAME).activate();
fBot.textWithLabel("Password:").setText("anonymous");
fBot.button("OK").click();
fBot.shell(PASSWORD_SHELL_NAME).activate();
fBot.button("Cancel").click();
/* ErrorDialog is inhibited by the platform when running tests */
fBot.button("Cancel").click();
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();
}
示例7
/**
* Clear the trace folder (using the UI)
*
* @param bot
* a given workbench bot
* @param projectName
* the name of the project (needs to exist)
*/
public static void clearTracesFolderUI(SWTWorkbenchBot bot, String projectName) {
SWTBotTreeItem tracesFolder = selectTracesFolder(bot, projectName);
tracesFolder.contextMenu().menu("Clear").click();
String CONFIRM_CLEAR_DIALOG_TITLE = "Confirm Clear";
SWTBotShell shell = bot.shell(CONFIRM_CLEAR_DIALOG_TITLE).activate();
shell.bot().button("Yes").click();
bot.waitUntil(Conditions.shellCloses(shell));
bot.waitWhile(ConditionHelpers.treeItemHasChildren(tracesFolder));
try {
/* This ensures that the Clear workspace operation has completed */
ResourcesPlugin.getWorkspace().run(monitor -> {}, null);
} catch (CoreException e) {
// Ignore
}
}
示例8
@Override
protected SWTBotRootMenu contextMenu(final Control control) throws WidgetNotFoundException {
Rectangle bounds = absoluteLocation();
if (bounds == null) {
return null;
}
UIThreadRunnable.syncExec(new VoidResult() {
@Override
public void run() {
final Event event = new Event();
event.time = (int) System.currentTimeMillis();
event.display = control.getDisplay();
event.widget = control;
event.x = bounds.x + widget.getTimeDataProvider().getNameSpace() / 2;
event.y = bounds.y + bounds.height / 2;
control.notifyListeners(SWT.MenuDetect, event);
}
});
select();
WaitForObjectCondition<Menu> waitForMenu = Conditions.waitForPopupMenu(control);
new SWTBot().waitUntilWidgetAppears(waitForMenu);
return new SWTBotRootMenu(waitForMenu.get(0));
}
示例9
/**
* Clean up after a test, reset the views and reset the states of the
* timegraph by pressing reset on all the resets of the legend
*/
@After
public void after() {
// reset all
fViewBot.toolbarButton(SHOW_LEGEND).click();
SWTBotShell legendShell = fBot.shell(LEGEND_NAME);
SWTBot legendBot = legendShell.bot();
for (int i = 0; i < StubPresentationProvider.STATES.length; i++) {
SWTBotButton resetButton = legendBot.button(i);
if (resetButton.isEnabled()) {
resetButton.click();
}
}
legendBot.button(OK_BUTTON).click();
TmfTraceStub trace = fTrace;
assertNotNull(trace);
UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceClosedSignal(this, trace)));
fBot.waitUntil(Conditions.shellCloses(legendShell));
fViewBot.close();
fBot.waitUntil(ConditionHelpers.viewIsClosed(fViewBot));
fTrace.dispose();
}
示例10
/**
* Add a Text Data
*
* @param dataName
*/
private void addDataOnSelectedElementWithName(final String dataName, final String tabId) {
bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_DATA).show();
SWTBotTestUtil.selectTabbedPropertyView(bot, tabId);
bot.buttonWithId(SWTBotConstants.SWTBOT_ID_ADD_PROCESS_DATA).click();
// Shell "New variable"
bot.waitUntil(Conditions.shellIsActive(Messages.newVariable));
bot.textWithLabel(Messages.name + " *").setText(dataName);
bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
bot.button(IDialogConstants.FINISH_LABEL).click();
SWTBotTestUtil.waitUntilRootShellIsActive(bot);
final BotApplicationWorkbenchWindow applicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
applicationWorkbenchWindow.save();
SWTBotTestUtil.waitUntilRootShellIsActive(bot);
}
示例11
private static void importCustomParsers() {
// FIXME: We can't use Manage Custom Parsers > Import because it uses a native dialog. We'll still check that they show up in the dialog
CustomTxtTraceDefinition[] txtDefinitions = CustomTxtTraceDefinition.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
txtDefinitions[0].save();
CustomXmlTraceDefinition[] xmlDefinitions = CustomXmlTraceDefinition.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
xmlDefinitions[0].save();
SWTBotTreeItem traceFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
traceFolder.contextMenu("Manage Custom Parsers...").click();
SWTBotShell shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
SWTBot shellBot = shell.bot();
// Make sure the custom text trace type is imported
shellBot.list().select(CUSTOM_TEXT_LOG.getTraceType());
// Make sure the custom xml trace type is imported
shellBot.radio("XML").click();
shellBot.list().select(CUSTOM_XML_LOG.getTraceType());
shellBot.button("Close").click();
shellBot.waitUntil(Conditions.shellCloses(shell), DISK_ACCESS_TIMEOUT);
}
示例12
@Override
public void confirmShellSessionInvitationAndShellAddProject(
String projectName, TypeOfCreateProject usingWhichProject) throws RemoteException {
SWTBot bot = new SWTBot();
bot.waitUntil(
Conditions.shellIsActive(SHELL_SESSION_INVITATION),
SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
SWTBotShell invitationShell = bot.shell(SHELL_SESSION_INVITATION);
invitationShell.bot().button(ACCEPT).click();
bot.waitUntil(
Conditions.shellCloses(invitationShell), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
confirmShellAddProjectUsingWhichProject(projectName, usingWhichProject);
views().sarosView().waitUntilIsInSession();
}
示例13
private void createWidget(String widgetId, String widgetType, int inputIndex)
throws Exception {
SWTBotShell activeShell = bot.activeShell();
bot.button("Add...").click();
assertFalse("button ok should be disabled",
bot.button(IDialogConstants.OK_LABEL).isEnabled());
bot.textWithLabel("Widget id*").setText(widgetId);
bot.comboBoxWithLabel("Widget type").setSelection(widgetType);
if (!widgetType.equals("Group")) {
bot.comboBoxWithLabel("Input *").setSelection(inputIndex);
} else {
assertFalse("inputs combo box should be disabled for Group widget",
bot.comboBoxWithLabel("Input *").isEnabled());
}
assertTrue("button ok should be enabled",
bot.button(IDialogConstants.OK_LABEL).isEnabled());
bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.OK_LABEL)), 5000);
bot.button(IDialogConstants.OK_LABEL).click();
activeShell.setFocus();
}
示例14
@Override
public void confirmShellAddProjectUsingExistProjectWithCopy(String projectName)
throws RemoteException {
SWTBot bot = new SWTBot();
bot.waitUntil(
Conditions.shellIsActive(SHELL_ADD_PROJECTS), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS);
shell.activate();
shell.bot().radio("Use existing project").click();
shell.bot().checkBox("Create copy for working distributed. New project name:").click();
shell.bot().button(FINISH).click();
shell.bot().waitUntil(Conditions.shellCloses(shell));
}
示例15
@Override
public void confirmShellAddProjectUsingWhichProject(
String projectName, TypeOfCreateProject usingWhichProject) throws RemoteException {
SWTBot bot = new SWTBot();
bot.waitUntil(
Conditions.shellIsActive(SHELL_ADD_PROJECTS), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS);
shell.activate();
switch (usingWhichProject) {
case NEW_PROJECT:
confirmShellAddProjectWithNewProject(projectName);
break;
case EXIST_PROJECT:
confirmShellAddProjectUsingExistProject(projectName);
break;
case EXIST_PROJECT_WITH_COPY:
confirmShellAddProjectUsingExistProjectWithCopy(projectName);
break;
}
}
示例16
public void removeConnectorDefinition(final String name, final String version) {
SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
bot.tree().setFocus();
bot.waitUntil(new SelectNodeUnder(bot, name + " (" + version + ")", "Uncategorized"), 10000, 1000);
assertNotNull("could not find" + name + " (" + version + ")", bot
.tree().select("Uncategorized").expandNode("Uncategorized")
.getNode(name + " (" + version + ")"));
bot.tree().select("Uncategorized").expandNode("Uncategorized").select(name + " (" + version + ")");
bot.button("Delete").click();
if (!FileActionDialog.getDisablePopup()) {
bot.waitUntil(Conditions.shellIsActive("Delete?"));
bot.button(IDialogConstants.YES_LABEL).click();
}
bot.button(IDialogConstants.CANCEL_LABEL).click();
}
示例17
@Override
public void confirmShellAddProjectToSession(String project, String[] files)
throws RemoteException {
SWTBot bot = new SWTBot();
SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS_TO_SESSION);
shell.activate();
// wait for tree update
bot.sleep(500);
SWTBotTree tree = shell.bot().tree();
selectProjectFiles(tree, project, files);
shell.bot().button(FINISH).click();
bot.waitUntil(Conditions.shellCloses(shell));
}
示例18
public void deployOrganization(String organization, String user) {
SWTBotTreeItem organizationTreeItem = getOrganizationFolderTreeItem();
clickOnContextualMenu(getTreeItem(organizationTreeItem, getDisplayName(organization)), "Deploy");
bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.actors.i18n.Messages.deployOrganizationTitle));
bot.text().setText(user);
bot.button("Deploy").click();
bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.actors.i18n.Messages.deployInformationTitle));
SWTBotShell activeShell = bot.activeShell();
bot.button(IDialogConstants.OK_LABEL).click();
bot.waitUntil(Conditions.shellCloses(activeShell));
}
示例19
public BotBdmModelEditor removePackage(String packageName) {
selectPackage(packageName);
bot.toolbarButtonWithId(BusinessObjectList.REMOVE_BUTTON_ID).click();
bot.waitUntil(Conditions.shellIsActive(Messages.deletePackageConfirmTitle));
SWTBotShell activeShell = bot.activeShell();
activeShell.bot().button(IDialogConstants.YES_LABEL).click();
bot.waitUntil(Conditions.shellCloses(activeShell));
return this;
}
示例20
@Override
public void rename(String nickname) throws RemoteException {
getTreeItem().select();
ContextMenuHelper.clickContextMenu(tree, CM_RENAME);
SWTBotShell shell = new SWTBot().shell(SHELL_SET_NEW_NICKNAME);
shell.activate();
shell.bot().text().setText(nickname);
shell.bot().button(OK).click();
shell.bot().waitUntil(Conditions.shellCloses(shell));
// wait for tree update in saros session view
new SWTBot().sleep(500);
}
示例21
/**
* Adds a new spec to the toolbox, opens it and tests if parsing is done on
* a non-UI thread
*
* @see Bug #103 in general/bugzilla/index.html
*/
@Test
@Ignore
public void parseSpecInNonUIThread() {
// Open specA
SWTBotMenu fileMenu = bot.menu("File");
SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
addNewSpecMenu.click();
bot.textWithLabel("Root-module file:").setText(specB);
bot.button("Finish").click();
assertNoBackendCodeInUIThread();
// Open specB
addNewSpecMenu.click();
bot.textWithLabel("Root-module file:").setText(specA);
bot.button("Finish").click();
assertNoBackendCodeInUIThread();
final String specName = getSpecName(new File(specB));
// increase timeout since farsite spec takes a long time to parse
final long timeout = SWTBotPreferences.TIMEOUT * 4;
// specs are created in non-UI thread asynchronously which causes a
// delay before the menu entry becomes available
bot.waitUntil(Conditions.waitForMenu(waitForToolboxShell(), WithText.<MenuItem> withText(specName)), timeout);
// Go back to previous spec
openSpecMenu.menu(specName);
assertNoBackendCodeInUIThread();
}
示例22
@Before
public void setUp() throws Exception {
super.setUp();
// create a dummy spec "ToBeRenamedSpec"
SWTBotMenu fileMenu = bot.menu("File");
SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
addNewSpecMenu.click();
String path = System.getProperty("java.io.tmpdir") + File.separator + "RSHTest"
+ System.currentTimeMillis();
path += File.separator + TEST_SPEC + TLA_SUFFIX;
bot.textWithLabel("Root-module file:").setText(path);
bot.button("Finish").click();
final String specName = getSpecName(new File(path));
bot.waitUntil(Conditions.waitForMenu(bot.activeShell(), WithText.<MenuItem> withText(specName)));
// create a new dummy model
final SWTBotMenu modelMenu = bot.menu("TLC Model Checker");
final SWTBotMenu newModelMenu = modelMenu.menu("New Model...");
newModelMenu.click();
bot.button("OK").click();
bot.waitUntil(new ModelEditorOpenCondition(TEST_MODEL));
// save and close model editor
SWTBotEditor activeEditor = bot.activeEditor();
activeEditor.saveAndClose();
checkSpecAndModelExistenceAPI(TEST_SPEC, TEST_MODEL);
}
示例23
@Before
public void setUp() throws Exception {
super.setUp();
// create a dummy spec "ToBeRenamedSpec"
SWTBotMenu fileMenu = bot.menu("File");
SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
addNewSpecMenu.click();
String path = System.getProperty("java.io.tmpdir") + File.separator + "RSHTest"
+ System.currentTimeMillis();
path += File.separator + TEST_SPEC + TLA_SUFFIX;
bot.textWithLabel("Root-module file:").setText(path);
bot.button("Finish").click();
final String specName = getSpecName(new File(path));
bot.waitUntil(Conditions.waitForMenu(bot.activeShell(), WithText.<MenuItem> withText(specName)));
// create a new dummy model
final SWTBotMenu modelMenu = bot.menu("TLC Model Checker");
final SWTBotMenu newModelMenu = modelMenu.menu("New Model...");
newModelMenu.click();
bot.button("OK").click();
bot.waitUntil(new ModelEditorOpenCondition(TEST_MODEL));
// save and close model editor
SWTBotEditor activeEditor = bot.activeEditor();
activeEditor.saveAndClose();
checkSpecAndModelExistenceAPI(TEST_SPEC, TEST_MODEL);
}
示例24
private void editGroovyEditor(int buttonIndex, String inputName, String inputtype, String scriptName,
String groovyScript) {
SWTBotShell activeShell = bot.activeShell();
bot.toolbarButtonWithId(SWTBOT_ID_EDITBUTTON, buttonIndex).click();
bot.table().select("Script");
bot.waitUntil(Conditions.widgetIsEnabled(bot.textWithLabel("Name")), 10000);
bot.textWithLabel("Name").setText(scriptName);
bot.styledText().setText(groovyScript);
assertFalse("return type combobox should be disabled", bot.comboBoxWithLabel("Return type").isEnabled());
assertEquals("return type should be" + inputtype, bot.comboBoxWithLabel("Return type").getText(), inputtype);
bot.button(IDialogConstants.OK_LABEL).click();
activeShell.setFocus();
assertEquals("wrong value for " + inputName, bot.textWithLabel(inputName).getText(), scriptName);
}
示例25
/**
* Creates a tracing projects
*
* @param traceProjectName
* the name of the test project
*/
protected static void createProject(String traceProjectName) {
SWTBotUtils.focusMainWindow(fBot.shells());
fBot.menu("File").menu("New").menu("Project...").click();
fBot.shell("New Project").activate();
SWTBotTree tree = fBot.tree();
assertNotNull(tree);
final String tracingKey = "Tracing";
fBot.waitUntil(ConditionHelpers.isTreeNodeAvailable(tracingKey, tree));
final SWTBotTreeItem tracingNode = tree.expandNode(tracingKey);
tracingNode.select();
final String projectKey = "Tracing Project";
fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(projectKey, tracingNode));
final SWTBotTreeItem tracingProject = tracingNode.getNode(projectKey);
assertNotNull(tracingProject);
tracingProject.select();
tracingProject.click();
SWTBotButton nextButton = fBot.button("Next >");
fBot.waitUntil(Conditions.widgetIsEnabled(nextButton));
nextButton.click();
fBot.shell("Tracing Project").activate();
final SWTBotText text = fBot.text();
text.setText(traceProjectName);
fBot.button("Finish").click();
WaitUtils.waitForJobs();
}
示例26
/**
* Create a temporary archive from the specified resource.
*/
private static String createArchive(IResource sourceResource) throws URISyntaxException {
IPath exportedPath = sourceResource.getFullPath();
SWTBotTreeItem traceFilesProject = SWTBotUtils.selectProject(fBot, TRACE_PROJECT_NAME);
traceFilesProject.contextMenu("Export...").click();
SWTBotShell activeShell = fBot.shell("Export").activate();
SWTBotTree exportWizardsTree = fBot.tree();
SWTBotTreeItem treeItem = SWTBotUtils.getTreeItem(fBot, exportWizardsTree, "General", "Archive File");
treeItem.select();
fBot.button("Next >").click();
fBot.button("&Deselect All").click();
try {
String resolveLinkedResLabel = "Resolve and export linked resources";
fBot.waitUntil(Conditions.waitForWidget(withMnemonic(resolveLinkedResLabel)), 100);
fBot.checkBox(resolveLinkedResLabel).select();
} catch (TimeoutException e) {
// Ignore, doesn't exist pre-4.6M5
}
if (sourceResource instanceof IFile) {
String[] folderPath = exportedPath.removeLastSegments(1).segments();
String fileName = exportedPath.lastSegment();
SWTBotImportWizardUtils.selectFile(fBot, fileName, folderPath);
} else {
selectFolder(exportedPath.segments());
}
String workspacePath = URIUtil.toFile(URIUtil.fromString(System.getProperty("osgi.instance.area"))).getAbsolutePath();
final String archiveDestinationPath = workspacePath + File.separator + TRACE_PROJECT_NAME + File.separator + GENERATED_ARCHIVE_NAME;
fBot.comboBox().setText(archiveDestinationPath);
fBot.button("&Finish").click();
fBot.waitUntil(Conditions.shellCloses(activeShell), IMPORT_TIME_OUT);
return archiveDestinationPath;
}
示例27
/**
* Test 8.5: Re-Run Profile "TestAllRecursive" (Rename)
*/
@Test
public void test_8_05() {
SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
projectExplorerBot.show();
SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);
tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.comboBox().setSelection("TestAllRecursive");
fBot.button("Next >").click();
fBot.button("Finish").click();
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();
tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.comboBox().setSelection("TestAllRecursive");
fBot.button("Next >").click();
fBot.button("Finish").click();
fBot.shell(CONFIRMATION_SHELL_NAME).activate();
fBot.button("Rename").click();
fBot.shell(CONFIRMATION_SHELL_NAME).activate();
fBot.button("Rename All").click();
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();
TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
fBot.waitUntil(new TraceCountCondition(project, 6));
final TmfTraceFolder tracesFolder = project.getTracesFolder();
assertNotNull(tracesFolder);
List<TmfTraceElement> traces = tracesFolder.getTraces();
assertEquals(6, traces.size());
testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace(2)", TRACE_TYPE_KERNEL);
testTrace(traces.get(2), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
testTrace(traces.get(3), CONNECTION_NODE1_NAME + "/resources/unrecognized", null);
testTrace(traces.get(4), CONNECTION_NODE1_NAME + "/resources/syslog(2)", TRACE_TYPE_SYSLOG);
testTrace(traces.get(5), CONNECTION_NODE1_NAME + "/resources/unrecognized(2)", null);
}
示例28
@Test
public void testConditionExpressions() throws IOException, InterruptedException {
new BotApplicationWorkbenchWindow(bot).importBOSArchive()
.setArchive(
TestDecisionTable.class.getResource("TestDecisionTable-1.0.bos"))
.finish();
final SWTBotEditor botEditor = bot.activeEditor();
final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());
gmfEditor.getEditPart("sf1").click();
bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
SWTBotTestUtil.selectTabbedPropertyView(bot, "General");
bot.radio(useDecisionTable).click();
bot.waitUntil(Conditions.widgetIsEnabled(bot.button(editDecisionTable)));
bot.button(editDecisionTable).click();
bot.waitUntil(Conditions.shellIsActive(Messages.wizardPageTitle));
bot.waitUntil(Conditions.widgetIsEnabled(bot.link("<A>" + Messages.addRow + "</A>")));
bot.link("<A>" + Messages.addRow + "</A>").click(Messages.addRow);
bot.waitUntil(Conditions.widgetIsEnabled(bot.link("<A>" + Messages.addCondition + "</A>")));
addTrueCondition(0, "true");
addTrueCondition(1, "1==2");
addFalseCondition(2, "sdkgjskrg");
changeCondition(2, "myBoolean");
testUpdateLineButtonEnabled();
bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_ERASEBUTTON, 0).click();
testUpdateLineButtonNotEnabled();
changeCondition(0, "myText==\"\"");
testUpdateLineButtonEnabled();
bot.button(Messages.updateLine).click();
bot.button(IDialogConstants.FINISH_LABEL).click();
}
示例29
private void rename(String shellTitle, String buttonName, String newName) {
treeItem.select();
ContextMenuHelper.clickContextMenu(tree, MENU_REFACTOR, MENU_RENAME);
SWTBotShell shell = new SWTBot().shell(shellTitle);
shell.activate();
shell.bot().textWithLabel(LABEL_NEW_NAME).setText(newName);
shell.bot().button(buttonName).click();
shell.bot().waitUntil(Conditions.shellCloses(shell), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
}
示例30
private static void testImport(Runnable selectionFunctor, Runnable verifyTracesFunctor) {
SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
assertNotNull("Cannot find " + PROJECT_EXPLORER, projectExplorerBot);
projectExplorerBot.show();
SWTBotTreeItem treeItem = getTracesFolderTreeItem(projectExplorerBot);
treeItem.contextMenu(FETCH_COMMAND_NAME).click();
SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.button("Manage Profiles").click();
fBot.shell("Preferences (Filtered)").activate();
createProfile();
shell.activate();
assertEquals(PROFILE_NAME, fBot.comboBoxWithLabel("Profile name:").getText());
assertEquals(CONNECTION_NODE_TEXT, fBot.textWithLabel("Nodes:").getText());
// Make sure if we go to the next page and come back that the first page
// still has valid values
fBot.button("Next >").click();
fBot.button("< Back").click();
assertEquals(PROFILE_NAME, fBot.comboBoxWithLabel("Profile name:").getText());
assertEquals(CONNECTION_NODE_TEXT, fBot.textWithLabel("Nodes:").getText());
fBot.button("Next >").click();
selectionFunctor.run();
fBot.button("Finish").click();
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();
verifyTracesFunctor.run();
deleteProfile();
}