org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwtBotTreeUtilities.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/** Wait until the tree item contains the given text with the timeout specified. */
public static void waitUntilTreeTextMatches(
    SWTWorkbenchBot bot,
    final SWTBotTreeItem treeItem,
    final Matcher<String> textMatcher,
    long timeout) {
  bot.waitUntil(
      new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
          return textMatcher.matches(treeItem.getText());
        }

        @Override
        public String getFailureMessage() {
          Description description = new StringDescription();
          description.appendText("Text never matched: ");
          textMatcher.describeMismatch(treeItem.getText(), description);
          return description.toString();
        }
      },
      timeout);
}
 
Example #2
Source File: SystemCallLatencyScatterChartViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private Long recurseFindItem(SWTBotTreeItem item) {
    if (fSeriesName.equals(item.getText())) {
        Object data = item.widget.getData();
        if (data instanceof TmfGenericTreeEntry) {
            ITmfTreeDataModel model = ((TmfGenericTreeEntry<?>) data).getModel();
            if (model != null) {
                return model.getId();
            }
        }
    }
    for (SWTBotTreeItem child : item.getItems()) {
        Long id = recurseFindItem(child);
        if (id >= 0) {
            return id;
        }
    }
    return -1L;
}
 
Example #3
Source File: ProjectFile.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param from
 *            打开文件的入口:右键菜单、双击,请使用 TS 类提供的常量;
 */
public void openFile(Entry from) {
	assertTrue("参数错误,Excel 数据行 row 为 null。", row != null);
	getDataFile();
	SWTBotTreeItem item = select();
	assertTrue("如下选择类型不是文件:" + selectType, selectType == TsUIConstants.ResourceType.FILE);

	switch (from) {
	case DOUBLE_CLICK: {
		item.doubleClick();
		break;
	}
	case CONTEXT_MENU: {
		view.ctxMenuOpenFile().click();
		break;
	}
	default: {
		assertTrue("参数错误,无此入口:" + from, false);
	}
	}
	HSBot.bot().waitUntil(new IsFileOpenedInEditor(fileName));
}
 
Example #4
Source File: ProjectFile.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param from
 *            打开文件的入口:右键菜单、双击,请使用 TS 类提供的常量;
 */
public void openFile(Entry from) {
	assertTrue("参数错误,Excel 数据行 row 为 null。", row != null);
	getDataFile();
	SWTBotTreeItem item = select();
	assertTrue("如下选择类型不是文件:" + selectType, selectType == TsUIConstants.ResourceType.FILE);

	switch (from) {
	case DOUBLE_CLICK: {
		item.doubleClick();
		break;
	}
	case CONTEXT_MENU: {
		view.ctxMenuOpenFile().click();
		break;
	}
	default: {
		assertTrue("参数错误,无此入口:" + from, false);
	}
	}
	HSBot.bot().waitUntil(new IsFileOpenedInEditor(fileName));
}
 
Example #5
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test 8.12: Run Profile "TestSpecificNonRecursive"
 */
@Test
public void test_8_12() {
    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("TestSpecificNonRecursive");
    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, 1));
    final TmfTraceFolder tracesFolder = project.getTracesFolder();
    assertNotNull(tracesFolder);
    List<TmfTraceElement> traces = tracesFolder.getTraces();
    assertEquals(1, traces.size());
    testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
}
 
Example #6
Source File: ProjectExplorerTraceActionsTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test that the trace can be copied with the context menu
 * <p>
 * Action : Copy trace
 * <p>
 * Procedure :Select the Copy menu and provide a new name. Open.
 * <p>
 * Expected Results: Trace is replicated under the new name
 *
 */
@Test
public void test4_03Copy() {
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), TRACE_NAME);

    // Copy the trace as link (default)
    createCopy(traceItem, true);
    // Copy the trace as a new trace
    createCopy(traceItem, false);

    fBot.closeAllEditors();
    SWTBotTreeItem copiedItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), RENAMED_TRACE_NAME);
    copiedItem.contextMenu().menu("Open").click();
    SWTBotImportWizardUtils.testEventsTable(fBot, RENAMED_TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());
    SWTBotTreeItem copiedAsNewItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), RENAMED_AS_NEW_TRACE_NAME);
    copiedAsNewItem.contextMenu().menu("Open").click();
    SWTBotImportWizardUtils.testEventsTable(fBot, RENAMED_AS_NEW_TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());

    // Make sure that the traces have the correct link status (linked or not)
    testLinkStatus(copiedItem, true);
    testLinkStatus(copiedAsNewItem, false);
}
 
Example #7
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #8
Source File: SwtBotProjectHelper.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static SWTBotTreeItem expandNode(final AbstractSWTBot<?> bot, final String node) {
  SWTBotTreeItem item = null;
  if ((bot instanceof SWTBotTree)) {
    item = ((SWTBotTree)bot).getTreeItem(node);
  } else {
    if ((bot instanceof SWTBotTreeItem)) {
      item = ((SWTBotTreeItem)bot).getNode(node);
    }
  }
  boolean _isExpanded = item.isExpanded();
  boolean _not = (!_isExpanded);
  if (_not) {
    item.expand();
  }
  return item;
}
 
Example #9
Source File: ProjectExplorerTracesFolderTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <p>
 * Action : Import unrecognized (ignore)
 * <p>
 *
 * <pre>
 * Procedure : 1) redo 3.10, however unselect "Import unrecognized traces"
 * </pre>
 * <p>
 * Expected Results: unrecognized.log is not imported
 */
@Test
public void test3_11ImportUnrecognizedIgnore() {
    String traceName = UNRECOGNIZED_LOG.getTraceName();
    SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    int numTraces = tracesFolderItem.getItems().length;

    SWTBotTreeItem traceItem = SWTBotUtils.getTreeItem(fBot, tracesFolderItem, traceName);
    String lastModified = getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY);

    int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
    importTrace(optionFlags, traceName);
    verifyTrace(UNRECOGNIZED_LOG, optionFlags);

    assertEquals(lastModified, getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY));
    assertEquals(numTraces, tracesFolderItem.getItems().length);
}
 
Example #10
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test creating a profile, fetching only one trace
 */
@Test
public void testImportOnlyOne() {
    testImport(() -> {
        SWTBotTree tree = fBot.tree();
        fBot.button("Deselect All").click();
        int length = tree.getAllItems().length;
        assertTrue(length > 0);
        // Selecting the second trace under node > traceGroup
        SWTBotTreeItem node = getTreeItem(fBot, tree, new String[] { CONNECTION_NODE_TEXT, TRACE_GROUP_NODE_TEXT }).getNode(1);
        assertEquals("syslog", node.getText());
        node.check();
    }, () -> {
        TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
        fBot.waitUntil(new TraceCountCondition(project, 1));
        final TmfTraceFolder tracesFolder = project.getTracesFolder();
        assertNotNull(tracesFolder);
        List<TmfTraceElement> traces = tracesFolder.getTraces();
        assertEquals(1, traces.size());
        testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
    });
}
 
Example #11
Source File: ProjectContextMenuTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testDynamicWebProjectJava7() {
  IProject project =
      projectCreator.withFacets(JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25).getProject();
  SWTBotTreeItem selected = SwtBotProjectActions.selectProject(bot, project.getName());
  assertThat(
      selected.contextMenu("Debug As"), not(MenuMatcher.hasMenuItem(endsWith("App Engine"))));
  assertThat(
      selected.contextMenu("Run As"), not(MenuMatcher.hasMenuItem(endsWith("App Engine"))));
  assertThat(
      selected.contextMenu(), not(MenuMatcher.hasMenuItem("Deploy to App Engine Standard...")));
  assertThat(
      selected.contextMenu("Configure"),
      MenuMatcher.hasMenuItem("Convert to App Engine Standard Project"));
  assertThat(
      selected.contextMenu("Configure"),
      not(MenuMatcher.hasMenuItem("Reconfigure for App Engine Java 8 runtime")));
}
 
Example #12
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is the treeItem's node removed
 *
 * @param length
 *            length of the node after removal
 * @param treeItem
 *            the treeItem
 * @return ICondition for verification
 */
public static ICondition isTreeChildNodeRemoved(final int length, final SWTBotTreeItem treeItem) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            try {
                return treeItem.getNodes().size() == length;
            } catch (Exception e) {
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("Child of tree item {0} found with text ''{1}'' not removed. Child items: {2}",
                    new String[] { treeItem.toString(), String.valueOf(length), Arrays.toString(treeItem.getItems()) });
        }
    };
}
 
Example #13
Source File: BotContractInputRow.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotContractInputRow getChildRow(final int childIndex) {
    bot.waitUntil(new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            return swtBotTreeItem.expand().getItems().length > childIndex;
        }

        @Override
        public String getFailureMessage() {
            return "Child at index " + childIndex + " doesn't exist";
        }
    });
    final SWTBotTreeItem[] items = swtBotTreeItem.expand().getItems();
    final SWTBotTreeItem childItem = items[childIndex];
    return new BotContractInputRow(bot, childItem);
}
 
Example #14
Source File: ControlViewProfileTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test save session
 */
private void testSaveSession() {
    fProxy.setProfileName(getSessionName());

    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            SESSION_NAME);

    assertEquals(SESSION_NAME, sessionItem.getText());

    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.SAVE_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.SAVE_DIALOG_TITLE).activate();
    shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();
}
 
Example #15
Source File: ContextMenusInSessionArea.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void addProjects(String... projectNames) throws RemoteException {

  SWTBotTreeItem treeItem = getTreeItem();

  log.trace("clicking on context menu item: " + ADD_PROJECTS);

  try {
    treeItem.select();
    ContextMenuHelper.clickContextMenu(tree, ADD_PROJECTS);
  } catch (RuntimeException e) {
    logError(log, e, tree, treeItem);
    throw e;
  }

  SuperBot.getInstance().confirmShellAddProjectsToSession(projectNames);
}
 
Example #16
Source File: TestValidSelectionExport.java    From aCute with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testValidSelectionExport() {
openExportWizard();
SWTBotButton finishButton = bot.button("Finish");
assertTrue("Should be able to Finish an export with a valid Project selected.", finishButton.isEnabled());
finishButton.click();

bot.waitUntil(Conditions.waitForWidget(withText("<terminated> .NET Core Export")),30000);

SWTBotView view = bot.viewByTitle("Project Explorer");
SWTBotTree tree = new SWTBot(view.getWidget()).tree(0);
SWTBotTreeItem projectItem = tree.getTreeItem(project.getName());

try {
	projectItem.expand().getNode("bin");
}catch (WidgetNotFoundException e) {
	SWTBotView consoleView = bot.viewByPartName("Console");
	fail("Export failed: "+ consoleView.bot().styledText().getText());
}
}
 
Example #17
Source File: ProjectContextMenuTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testAppEngineStandardJava7() {
  IProject project =
      projectCreator
          .withFacets(AppEngineStandardFacet.JRE7, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25)
          .getProject();
  SWTBotTreeItem selected = SwtBotProjectActions.selectProject(bot, project.getName());
  assertThat(selected.contextMenu("Debug As"), MenuMatcher.hasMenuItem(endsWith("App Engine")));
  assertThat(selected.contextMenu("Run As"), MenuMatcher.hasMenuItem(endsWith("App Engine")));
  assertThat(selected.contextMenu(), MenuMatcher.hasMenuItem("Deploy to App Engine Standard..."));
  assertThat(
      selected.contextMenu("Configure"),
      not(MenuMatcher.hasMenuItem("Convert to App Engine Standard Project")));
  assertThat(
      selected.contextMenu("Configure"),
      MenuMatcher.hasMenuItem("Reconfigure for App Engine Java 8 runtime"));
}
 
Example #18
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void clearProfiles() {
    openRemoteProfilePreferences();
    SWTBotTree tree = fBot.tree(1);
    for (SWTBotTreeItem profile : tree.getAllItems()) {
        profile.select();
        fBot.button("Remove").click();
    }
    SWTBotUtils.pressOKishButtonInPreferences(fBot);
}
 
Example #19
Source File: SmartImportBdmIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_import_according_to_user_choices_when_conflicts_are_solvable() throws Exception {
    BotApplicationWorkbenchWindow workbenchBot = new BotApplicationWorkbenchWindow(bot);
    ImportBdmWizardBot importBot = workbenchBot.importBDM();
    importBot.setArchive(getFileURL("/smartImport/model_conflicting_ok.zip"));

    SWTBotTree importTree = bot.tree();
    bot.waitUntil(importBot.treeItemAvailable(importTree, HUMAN_PACKAGE));
    bot.waitUntil(importBot.treeItemAvailable(importTree, String.format("%s (%s)", BUSINESS_PACKAGE, Messages.skipped)));
    assertThat(bot.button(org.bonitasoft.studio.ui.i18n.Messages.importLabel).isEnabled()).isTrue();

    SWTBotTreeItem treeItem = importTree.getTreeItem(HUMAN_PACKAGE);
    treeItem.expand();
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format(org.bonitasoft.studio.businessobject.i18n.Messages.conflictingWithSameObject, PERSON_BO)));
    bot.waitUntil(importBot.treeNodeNotAvailable(treeItem, String.format("%s (%s)", ADDRESS_BO, Messages.skipped)));

    assertThat(treeItem.cell(1)).isEqualTo(ImportAction.OVERWRITE.toString());

    importBot.setImportAction(HUMAN_PACKAGE, ImportAction.KEEP.toString());
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format(org.bonitasoft.studio.businessobject.i18n.Messages.conflictingWithSameObject, PERSON_BO)));
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format("%s (%s)", ADDRESS_BO, Messages.skipped)));

    importBot.setImportAction(HUMAN_PACKAGE, ImportAction.OVERWRITE.toString());
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format(org.bonitasoft.studio.businessobject.i18n.Messages.conflictingWithSameObject, PERSON_BO)));
    bot.waitUntil(importBot.treeNodeNotAvailable(treeItem, String.format("%s (%s)", ADDRESS_BO, Messages.skipped)));

    importBot.doImport();

    BusinessObjectModelFileStore fileStore = (BusinessObjectModelFileStore) repositoryStore.getChild("bom.xml", true);
    assertThat(fileStore.getContent().getBusinessObjects()).extracting(BusinessObject::getQualifiedName)
            .containsExactlyInAnyOrder(toQualifiedName(BUSINESS_PACKAGE, LOAN_BO),
                    toQualifiedName(HUMAN_PACKAGE, PERSON_BO));
}
 
Example #20
Source File: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Select a file/folder by providing a parent tree, and a list folders that lead to the
 * file/folder.
 *
 * @param item Root tree item.
 * @param folderPath List of folder names that lead to file.
 * @return Returns a SWTBotTreeItem of the last name in texts.
 */
public static SWTBotTreeItem selectProjectItem(SWTBotTreeItem item, String... folderPath) {
  for (String folder : folderPath) {
    if (item == null) {
      return null;
    }
    item.doubleClick();
    item = item.getNode(folder);
  }
  return item;
}
 
Example #21
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void openRemoteProfilePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);

    // The first tree is the preference "categories" on the left side
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Remote Profiles", treeNode));
    treeNode = treeNode.getNode("Remote Profiles");
    treeNode.select();
}
 
Example #22
Source File: ContextMenusInSessionArea.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void followParticipant() throws RemoteException {
  log.trace("start following participant: " + participantJID.getBase());

  if (isFollowing()) {
    log.warn("you are already following participant: " + participantJID.getBase());
    return;
  }

  if (SuperBot.getInstance().getJID().equals(participantJID)) {
    throw new RuntimeException("you can't follow yourself");
  }

  log.trace("clicking on context menu item: " + CM_FOLLOW_PARTICIPANT);

  SWTBotTreeItem treeItem = getTreeItem();

  try {
    treeItem.select();
    ContextMenuHelper.clickContextMenu(tree, CM_FOLLOW_PARTICIPANT);
  } catch (RuntimeException e) {
    logError(log, e, tree, treeItem);
    throw e;
  }

  waitUntilIsFollowing();
}
 
Example #23
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static List<String> getSelectTraceTypeMenuItems() {
    SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    tracesFolder.expand();
    SWTBotTreeItem trace = tracesFolder.getNode("syslog_collapse");
    trace.select();
    List<String> menuItems = trace.contextMenu().menu("Select Trace Type...").menuItems();
    return menuItems;
}
 
Example #24
Source File: ContextMenusInSarosView.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
protected final void logError(Logger log, Throwable t, SWTBotTree tree, SWTBotTreeItem treeItem) {
  String treeItemText = null;
  String treeText = null;
  try {
    treeText = tree == null ? "not found" : tree.getText();
    treeItemText = treeItem == null ? "not found" : treeItem.getText();
  } catch (RuntimeException e) {
    log.error(e.getMessage(), e);
  }
  log.error(t.getMessage() + "@ tree: " + treeText + ", tree item: " + treeItemText, t);
}
 
Example #25
Source File: CtfTmfExperimentTrimmingTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test setup
 */
@Before
public void setup() {
    WaitUtils.waitForJobs();
    SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    tracesFolder.contextMenu().menu("Open As Experiment...", "Generic Experiment").click();
    SWTBotUtils.activateEditor(fBot, "Experiment");
    SWTBotTreeItem project = SWTBotUtils.selectProject(fBot, PROJECT_NAME);
    SWTBotTreeItem experimentItem = SWTBotUtils.getTraceProjectItem(fBot, project, "Experiments", "Experiment");
    experimentItem.select();
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace trace = traceManager.getActiveTrace();
    assertTrue(String.valueOf(trace), trace instanceof TmfExperiment);
    TmfExperiment experiment = (TmfExperiment) trace;
    assertNotNull(experiment);
    ITmfProjectModelElement elem = TmfProjectRegistry.findElement(experiment.getResource(), true);
    assertTrue(elem instanceof TmfExperimentElement);
    fOriginalExperiment = experiment;
    TmfTimeRange traceCutRange = getTraceCutRange(experiment);
    assertNotNull(traceCutRange);
    fRequestedTraceCutRange = traceCutRange;

    ITmfTimestamp requestedTraceCutEnd = traceCutRange.getEndTime();
    ITmfTimestamp requestedTraceCutStart = traceCutRange.getStartTime();
    assertTrue(experiment.getTimeRange().contains(traceCutRange));
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, requestedTraceCutStart, requestedTraceCutEnd, experiment));
    experimentItem.contextMenu("Export Time Selection as New Trace...").click();
    SWTBotShell shell = fBot.shell("Export trace section to...").activate();
    SWTBot dialogBot = shell.bot();
    assertEquals("Experiment", dialogBot.text().getText());
    dialogBot.text().setText("Experiment-trimmed");
    dialogBot.button("OK").click();
    SWTBotEditor newExperiment = fBot.editorByTitle("Experiment-trimmed");
    newExperiment.setFocus();
    fNewExperiment = traceManager.getActiveTrace();
    assertNotNull("No active trace", fNewExperiment);
    assertEquals("Incorrect active trace", "Experiment-trimmed", fNewExperiment.getName());
    WaitUtils.waitForJobs();
}
 
Example #26
Source File: ActorFilterEditionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void removeActorFilterDefinition(final String name, final String version) {
    SWTBotActorFilterUtil.activateActorFilterDefEditionShell(bot);
    final SWTBotTreeItem expandedUncategorizedNode = bot.tree().expandNode("Uncategorized");
    bot.waitUntil(new SelectNodeUnder(bot, name + " (" + version + ")", UNCATEGORIZED_LABEL), 10000);
    assertNotNull("could not find" + name + " (" + version + ")",
            expandedUncategorizedNode.getNode(name + " (" + version + ")"));
    expandedUncategorizedNode.select(name + " (" + version + ")");
    bot.button("Delete").click();
    if (!FileActionDialog.getDisablePopup()) {
        bot.button(IDialogConstants.YES_LABEL).click();
    }
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}
 
Example #27
Source File: MemoryUsageViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensure that the tree is loaded and then check all entries
 */
private void checkAllEntries() {
    SWTBot bot = getSWTBotView().bot();

    SWTBotUtils.waitUntil(b -> b.tree().visibleRowCount() == 5, bot,
            "Incorrect number of tree entries, expected 5, was " + bot.tree().visibleRowCount());

    for (SWTBotTreeItem entry : bot.tree().getAllItems()) {
        entry.check();
    }
}
 
Example #28
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Waits until the node expands.
 *
 * @param bot
 *          bot to work with, must not be {@code null}
 * @param node
 *          node to wait for, must not be {@code null}
 */
public static void safeBlockingExpand(final SWTWorkbenchBot bot, final SWTBotTreeItem node) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(node, ARGUMENT_NODE);
  if (!node.isExpanded()) {
    node.expand();
    try {
      bot.waitUntil(new DefaultCondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
          return node.isExpanded();
        }

        @Override
        public String getFailureMessage() {
          return "Timeout for node to expand";
        }
      }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND);

    } catch (TimeoutException e) {
      // Try one last time and do not wait anymore
      node.expand();
    }
  }
}
 
Example #29
Source File: ProjectExplorerBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ConnectorImplementationWizardBot newConnectorImplementation() {
    SWTBotTreeItem projectTreeItem = getProjectTreeItem();
    bot.waitUntil(contextMenuAvailable(projectTreeItem, "New"));
    projectTreeItem.contextMenu().menu("New").menu("Connector implementation...").click();
    return new ConnectorImplementationWizardBot(bot,
            org.bonitasoft.studio.connectors.i18n.Messages.newConnectorImplementation);
}
 
Example #30
Source File: MemoryDBManagement.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return 是否能在该数据库类型下找到名为 指定服务器:端口号 的已保存连接;
 */
public boolean isConnectionSaved() {
	SWTBotTreeItem[] items = selectDBType().getItems();
	for (SWTBotTreeItem item : items) {
		if (item.getText().equals(connectionName)) {
			return true;
		}
	}
	return false;
}