Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#doubleClick()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#doubleClick() . 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: 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 2
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Opens a trace in an editor and get the TmfEventsEditor
 *
 * @param bot
 *            the workbench bot
 * @param projectName
 *            the name of the project that contains the trace
 * @param elementPath
 *            the trace element path (relative to Traces folder)
 * @return TmfEventsEditor the opened editor
 */
public static TmfEventsEditor openEditor(SWTWorkbenchBot bot, String projectName, IPath elementPath) {
    final SWTBotView projectExplorerView = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectExplorerView.setFocus();
    SWTBot projectExplorerBot = projectExplorerView.bot();

    final SWTBotTree tree = projectExplorerBot.tree();
    projectExplorerBot.waitUntil(ConditionHelpers.isTreeNodeAvailable(projectName, tree));
    final SWTBotTreeItem treeItem = tree.getTreeItem(projectName);
    treeItem.expand();

    SWTBotTreeItem tracesNode = getTraceProjectItem(projectExplorerBot, treeItem, "Traces");
    tracesNode.expand();

    SWTBotTreeItem currentItem = tracesNode;
    for (String segment : elementPath.segments()) {
        currentItem = getTraceProjectItem(projectExplorerBot, currentItem, segment);
        currentItem.doubleClick();
    }

    SWTBotEditor editor = bot.editorByTitle(elementPath.toString());
    IEditorPart editorPart = editor.getReference().getEditor(false);
    assertTrue(editorPart instanceof TmfEventsEditor);
    return (TmfEventsEditor) editorPart;
}
 
Example 3
Source File: BookmarksViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test bookmarking an experiment
 *
 * @throws IOException
 *             if an error occurs during the file URL -> path conversion
 */
@Test
@Ignore
public void testExperiment() throws IOException {
    /**
     * Create Experiment with 2 LTTng CTF Kernel traces in it and open
     * experiment. Verify that an Events editor is opened showing LTTng
     * Kernel specific columns.
     */
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/A-Test-10K")).getPath(), TRACE_TYPE);
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/A-Test-10K-2")).getPath(), TRACE_TYPE);
    WaitUtils.waitForJobs();
    SWTBotUtils.createExperiment(fBot, PROJECT_NAME, EXPERIMENT_NAME);
    SWTBotTreeItem project = SWTBotUtils.selectProject(fBot, PROJECT_NAME);
    SWTBotTreeItem experiment = SWTBotUtils.getTraceProjectItem(fBot, project, "Experiments", EXPERIMENT_NAME);
    experiment.contextMenu("Select Traces...").click();
    SWTBotShell selectTracesShell = fBot.shell("Select Traces");
    selectTracesShell.bot().button("Select All").click();
    selectTracesShell.bot().button("Finish").click();
    experiment.select();
    experiment.doubleClick();
    SWTBotEditor editor = SWTBotUtils.activeEventsEditor(fBot, EXPERIMENT_NAME);
    assertEquals("Event editor is displaying the wrong trace/experiment", EXPERIMENT_NAME, editor.getTitle());

    bookmarkTest(EXPERIMENT_NAME);
}
 
Example 4
Source File: SwtBotTreeActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Blocks the caller until all of the direct children of the tree have text. The assumption is
 * that the tree does not have any "empty" children.
 *
 * TODO: Refactor some of this logic; it follows the same general pattern as
 * {@link #waitUntilTreeItemHasItem(SWTBot, SWTBotTreeItem, String)}.
 *
 * @param tree the tree to search
 * @throws TimeoutException if all of the direct children of the tree do not have text within the
 *         timeout period
 */
public static void waitUntilTreeHasText(SWTBot bot, final SWTBotTreeItem tree)
    throws TimeoutException {
  // Attempt #1
  if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
    // Attempt #2: Something went wrong, try to cautiously reopen it.
    bot.sleep(1000);

    // There isn't a method to collapse, so double-click instead
    tree.doubleClick();
    bot.waitUntil(new TreeCollapsedCondition(tree.widget));

    bot.sleep(1000);

    tree.expand();
    bot.waitUntil(new TreeExpandedCondition(tree.widget));

    if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
      printTree(tree.widget);
      throw new TimeoutException(
          "Timed out waiting for text of the tree's children, giving up...");
    }
  }
}
 
Example 5
Source File: SwtBotTreeActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Blocks the caller until the tree item has the given item text.
 *
 * @param tree the tree item to search
 * @param nodeText the item text to look for
 * @throws org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException if the item could not
 *         be found within the timeout period
 */
private static void waitUntilTreeItemHasItem(SWTBot bot, final SWTBotTreeItem tree,
    final String nodeText) {

  // Attempt #1
  if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
    // Attempt #2: Something went wrong, try to cautiously reopen it.
    bot.sleep(1000);

    // There isn't a method to collapse, so double-click instead
    tree.doubleClick();
    bot.waitUntil(new TreeCollapsedCondition(tree.widget));

    bot.sleep(1000);

    tree.expand();
    bot.waitUntil(new TreeExpandedCondition(tree.widget));

    if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
      printTree(tree.widget);
      throw new TimeoutException(
          String.format("Timed out waiting for %s, giving up...", nodeText));
    }
  }
}
 
Example 6
Source File: ProjectExplorerTraceActionsTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test that the trace is brought to top if already opened
 * <p>
 * Action : Open Trace (already open)
 * <p>
 * Procedure :Open two traces. Open the first trace again.
 * <p>
 * Expected Results: The first trace editor is simply brought to front.
 */
@Test
public void test4_09BringToTop() {
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), TRACE_NAME);
    traceItem.doubleClick();
    fBot.waitUntil(new ConditionHelpers.ActiveEventsEditor(fBot, TRACE_NAME));
    IEditorReference originalEditor = fBot.activeEditor().getReference();

    createCopy(traceItem, true);

    SWTBotTreeItem copiedItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), RENAMED_TRACE_NAME);
    fBot.viewByTitle(PROJECT_EXPLORER_VIEW_NAME).setFocus();
    copiedItem.doubleClick();
    fBot.waitUntil(new ConditionHelpers.ActiveEventsEditor(fBot, RENAMED_TRACE_NAME));
    SWTBotUtils.delay(1000);
    fBot.viewByTitle(PROJECT_EXPLORER_VIEW_NAME).setFocus();
    traceItem.doubleClick();
    fBot.waitUntil(new ConditionHelpers.ActiveEventsEditor(fBot, TRACE_NAME));
    assertTrue(originalEditor == fBot.activeEditor().getReference());
}
 
Example 7
Source File: ProjectExplorerAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test execution using double-click or context sensitive menu
 */
@Test
public void testAnalysisRun() {
    SWTBotTreeItem traceNode = getExpandedTraceNode(fBot, fKernelTraceFile, false);
    SWTBotTreeItem viewNode = traceNode.getNode("Views");
    viewNode.expand();

    boolean supplExists = supplementaryFileExists(traceNode, IRQ_XML_ANALYSIS_HT_FILE_NAME);
    assertFalse(supplExists);
    SWTBotTreeItem irqAnalysisNode = viewNode.getNode(IRQ_XML_ANALYSIS_NAME);
    irqAnalysisNode.contextMenu().menu("Open").click();
    supplExists = supplementaryFileExists(traceNode, IRQ_XML_ANALYSIS_HT_FILE_NAME);
    assertTrue(supplExists);

    supplExists = supplementaryFileExists(traceNode, FUTEX_XML_ANALYSIS_HT_FILE_NAME);
    assertFalse(supplExists);
    SWTBotTreeItem futexAnalysisNode = viewNode.getNode(FUTEX_XML_ANALYSIS_NAME);
    futexAnalysisNode.doubleClick();
    supplExists = supplementaryFileExists(traceNode, FUTEX_XML_ANALYSIS_HT_FILE_NAME);
    assertTrue(supplExists);
}
 
Example 8
Source File: XmlTimegraphViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Open a the timegraph view
 *
 * @param viewTitle
 *            The view title
 */
private static void openView(final String viewTitle) {
    SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    treeItem = SWTBotUtils.getTreeItem(fBot, treeItem, TRACE_NAME, "Views", ANALYSIS_NAME, viewTitle);
    treeItem.doubleClick();
    WaitUtils.waitForJobs();
}
 
Example 9
Source File: ICEResourcePageTester.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Simulates a double-click of the specified resource in the Resources View.
 *
 * @param resource
 *            The resource to click.
 */
private void doubleClickResource(ICEResource resource) {
	String resourceName = resource.getName();

	// Activate the Resources View.
	SWTBotView resourcesView = getBot().viewByTitle("Resources");
	resourcesView.show();
	// Find the corresponding resource in the view, then double-click it.
	SWTBotTreeItem node = resourcesView.bot().tree()
			.expandNode(resourceName);
	node.doubleClick();

	return;
}
 
Example 10
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 11
Source File: SwtBotProjectDebug.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Goto Debug As > "# MENU_GWT_SUPERDEVMODE"
 */
public static void launchDevModeWithJettyAndWaitForReady(SWTWorkbenchBot bot,
    String projectName) {
  SwtBotUtils.print("Launch DevMode with Jetty");

  // show it has focus
  SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName);
  project.setFocus();
  project.select();
  project.doubleClick();

  // Since the menus have dynamic numbers in them
  // and with out a built in iteration, this is what I came up with
  for (int i = 1; i < 15; i++) {
    bot.sleep(500);
    if (i < 10) {
      number = i + " ";
    } else {
      number = "";
    }

    final String menuLabel = number + MENU_GWT_SUPERDEVMODE;

    SwtBotUtils.print("Trying to select: Run > Debug As > menuLabel=" + menuLabel);

    try {
      bot.menu("Run").menu("Debug As").menu(menuLabel).click();
      break;
    } catch (Exception e) {
      SwtBotUtils.print("Skipping menu item " + menuLabel);
    }
  }

  // Wait for a successful launch - 60s build server wait time, just in case
  ConsoleViewContains.waitForConsoleOutput(bot, "The code server is ready", 60000);

  SwtBotUtils.print("Launched DevMode with Jetty");
}
 
Example 12
Source File: LamiChartViewerTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Execute the LAMI analyses and return the viewBot corresponding to the
 * newly opened view. To avoid tests interracting with each other, it is
 * preferable to use the returned view bot in a try finally statement and
 * make sure the view is closed at the end of the test.
 *
 * @param analysis
 *            The analysis to execute
 * @return The view bot
 */
private SWTBotView executeAnalysis(LamiAnalyses analysis) {
    // Open the LAMI analysis
    SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    SWTBotTreeItem externalAnalyses = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, TRACE.getPath(), "External Analyses", analysis.getAnalysis().getName());
    assertNotNull(externalAnalyses);
    fBot.waitUntil(isLamiAnalysisEnabled(externalAnalyses));
    externalAnalyses.doubleClick();

    fBot.shell("External Analysis Parameters").activate();
    fBot.button("OK").click();
    WaitUtils.waitForJobs();

    SWTBotView viewBot = fBot.viewById(VIEW_ID);
    viewBot.setFocus();
    final @Nullable LamiReportView lamiView = UIThreadRunnable.syncExec((Result<@Nullable LamiReportView>) () -> {
        IViewPart viewRef = viewBot.getViewReference().getView(true);
        return (viewRef instanceof LamiReportView) ? (LamiReportView) viewRef : null;
    });
    assertNotNull(lamiView);
    SWTBotUtils.maximize(lamiView);
    fViewBot = viewBot;

    fCurrentTab = lamiView.getCurrentSelectedPage();

    return viewBot;
}
 
Example 13
Source File: ProjectExplorerTraceActionsTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test renaming of traces that are created with file system symbolic links.
 *
 * @throws CoreException
 *          If error happens
 * @throws TmfTraceImportException
 *          If error happens
 */
@Test
public void testRenameSymbolicLinks() throws CoreException, TmfTraceImportException {
    // Close editor from @Before since not needed
    fBot.closeAllEditors();

    // Create File system symbolic link to traces
    importTraceAsSymlink();
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), SYMBOLIC_FOLDER_NAME, TRACE_NAME);
    fBot.viewByTitle(PROJECT_EXPLORER_VIEW_NAME).setFocus();
    traceItem.doubleClick();
    fBot.waitUntil(new ConditionHelpers.ActiveEventsEditor(fBot, SYMBOLIC_FOLDER_NAME + '/' + TRACE_NAME));

    traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), SYMBOLIC_FOLDER_NAME, TRACE_NAME);
    traceItem.contextMenu().menu("Rename...").click();
    final String RENAME_TRACE_DIALOG_TITLE = "Rename Trace";
    SWTBotShell shell = fBot.shell(RENAME_TRACE_DIALOG_TITLE).activate();
    SWTBotText text = shell.bot().textWithLabel("New Trace name:");
    text.setText(RENAMED_TRACE_NAME);
    shell.bot().button("OK").click();
    fBot.waitUntil(Conditions.shellCloses(shell), DISK_ACCESS_TIMEOUT);
    fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null));

    SWTBotTreeItem copiedItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), SYMBOLIC_FOLDER_NAME, RENAMED_TRACE_NAME);
    copiedItem.contextMenu().menu("Open").click();
    SWTBotImportWizardUtils.testEventsTable(fBot, SYMBOLIC_FOLDER_NAME + '/' + RENAMED_TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());

    // Make sure that the traces have the correct link status
    testLinkStatus(copiedItem, true);
}
 
Example 14
Source File: PatternLatencyViewTestBase.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Open a pattern latency view
 *
 * @param viewTitle
 *            The view title
 */
private static void openView(final String viewTitle) {
    SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    treeItem = SWTBotUtils.getTreeItem(fBot, treeItem, TRACE_NAME, "Views", "XML system call analysis", viewTitle);
    treeItem.doubleClick();
    WaitUtils.waitForJobs();
}
 
Example 15
Source File: SwtBotProjectActions.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Select a file/folder by providing a parent tree, and a list of folders that leads to the
 * file/folder.
 *
 * @param item root tree item
 * @param folderPath list of folder names that lead to file
 * @return the SWTBotTreeItem of the final selected item, or {@code null} if not found
 */
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 16
Source File: ProjectExplorerTracesFolderTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static void openTrace(SWTBotTreeItem traceItem) {
    traceItem.select();
    traceItem.doubleClick();
}
 
Example 17
Source File: ProjectExplorerAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test Class setup
 */
@BeforeClass
public static void init() {
    SWTBotUtils.initialize();

    /* Set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
    fBot = new SWTWorkbenchBot();

    /* Close welcome view */
    SWTBotUtils.closeView("Welcome", fBot);

    /* Switch perspectives */
    SWTBotUtils.switchToTracingPerspective();

    /* Finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
    SWTBotUtils.createProject(TRACE_PROJECT_NAME);

    File kernelTraceFile = new File(CtfTmfTestTraceUtils.getTrace(CtfTestTrace.ARM_64_BIT_HEADER).getPath());
    CtfTmfTestTraceUtils.dispose(CtfTestTrace.ARM_64_BIT_HEADER);

    File ustTraceFile = new File(CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DEBUG_INFO_SYNTH_EXEC).getPath());
    CtfTmfTestTraceUtils.dispose(CtfTestTrace.DEBUG_INFO_SYNTH_EXEC);

    fKernelTraceFile = kernelTraceFile.getName();
    fUstTraceFile = ustTraceFile.getName();

    /* Open Traces*/
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTraceFile.getAbsolutePath(), "org.eclipse.linuxtools.lttng2.kernel.tracetype");
    fBot.waitUntil(ConditionHelpers.isEditorOpened(fBot, fKernelTraceFile));

    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, ustTraceFile.getAbsolutePath(), "org.eclipse.linuxtools.lttng2.ust.tracetype");
    fBot.waitUntil(ConditionHelpers.isEditorOpened(fBot, fUstTraceFile));

    /* Create experiment and open experiment */
    SWTBotUtils.createExperiment(fBot, TRACE_PROJECT_NAME, EXPERIMENT_NAME);

    SWTBotTreeItem project = SWTBotUtils.selectProject(fBot, TRACE_PROJECT_NAME);

    SWTBotTreeItem tracesFolder = SWTBotUtils.getTraceProjectItem(fBot, project, "Traces");
    tracesFolder.expand();

    SWTBotTreeItem ustTrace = tracesFolder.getNode(fUstTraceFile);
    SWTBotTreeItem kernelTrace = tracesFolder.getNode(fKernelTraceFile);
    SWTBotTreeItem experiment = SWTBotUtils.getTraceProjectItem(fBot, project, "Experiments", EXPERIMENT_NAME);

    ustTrace.dragAndDrop(experiment);
    kernelTrace.dragAndDrop(experiment);
    experiment.doubleClick();
}
 
Example 18
Source File: StandardImportGzipTraceTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Import a gzip trace
 */
@Test
public void testGzipImport() {
    final String traceType = "Test trace : TMF Tests";
    final String tracesNode = "Traces [1]";
    final SWTWorkbenchBot bot = getSWTBot();

    /*
     * Actual importing
     */
    openImportWizard();
    SWTBotImportWizardUtils.selectImportFromArchive(bot, fGzipTrace.getAbsolutePath());
    SWTBotImportWizardUtils.selectFolder(bot, true, ROOT_FOLDER);
    SWTBotCheckBox checkBox = bot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace);
    assertFalse(checkBox.isEnabled());
    SWTBotCombo comboBox = bot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType);
    comboBox.setSelection(traceType);
    importFinish();
    /*
     * Remove .gz extension
     */
    assertNotNull(fGzipTrace);
    String name = fGzipTrace.getName();
    assertNotNull(name);
    assertTrue(name.length() > 3);
    String traceName = name.substring(0, name.length() - 3);
    assertNotNull(traceName);
    assertFalse(traceName.isEmpty());

    /*
     * Open trace
     */
    SWTBotView projectExplorer = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectExplorer.setFocus();
    final SWTBotTree tree = projectExplorer.bot().tree();
    /*
     * This appears to be problematic due to the length of the file name and
     * the resolution in our CI.
     */
    SWTBotTreeItem treeItem = SWTBotUtils.getTreeItem(projectExplorer.bot(), tree, PROJECT_NAME, tracesNode, traceName);
    treeItem.doubleClick();
    WaitUtils.waitForJobs();
    /*
     * Check results
     */
    SWTBot editorBot = SWTBotUtils.activeEventsEditor(bot).bot();
    SWTBotTable editorTable = editorBot.table();
    final String expectedContent1 = "Type-1";
    final String expectedContent2 = "";
    editorBot.waitUntil(ConditionHelpers.isTableCellFilled(editorTable, expectedContent1, 2, 2));
    editorBot.waitUntil(ConditionHelpers.isTableCellFilled(editorTable, expectedContent2, 1, 0));
    String c22 = editorTable.cell(2, 2);
    String c10 = editorTable.cell(1, 0);
    assertEquals(expectedContent1, c22);
    assertEquals(expectedContent2, c10);
}
 
Example 19
Source File: BookmarksViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static void bookmarkTest(String editorName) throws IOException {
    SWTBotView fViewBot = fBot.viewByPartName("Bookmarks");
    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    assertEquals("Failed to show the Bookmarks View", "Bookmarks", fViewBot.getTitle());
    /**
     * Add a bookmark: a) Double click to select an event in the event
     * editor b) Go to the Edit > Add Bookmark... menu c) Enter the bookmark
     * description in dialog box
     */
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, editorName);
    SWTBotTable tableBot = editorBot.bot().table();
    SWTBotTableItem tableItem = tableBot.getTableItem(7);
    String expectedTimeStamp = tableItem.getText(1);
    assertNull("The image should not be bookmarked yet", getBookmarkImage(tableItem));

    tableItem.select();
    tableItem.doubleClick();
    fBot.menu("Edit").menu("Add Bookmark...").click();
    WaitUtils.waitForJobs();
    SWTBotShell addBookmarkShell = fBot.shell("Add Bookmark");
    addBookmarkShell.bot().text().setText(BOOKMARK_NAME);
    addBookmarkShell.bot().button("OK").click();
    assertNotNull("Failed to add bookmark in event editor", getBookmarkImage(tableItem));

    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    SWTBotTree bookmarkTree = fViewBot.bot().tree();
    WaitUtils.waitForJobs();
    /**
     * throws WidgetNotFoundException - if the node was not found, nothing
     * to assert
     */
    SWTBotTreeItem bookmark = bookmarkTree.getTreeItem(BOOKMARK_NAME);
    assertEquals(BOOKMARK_NAME, bookmark.cell(0));

    /**
     * Scroll within event table so that bookmark is not visible anymore and
     * then double-click on bookmark in Bookmarks View
     */
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(null, TmfTimestamp.fromMicros(22))));
    bookmark.doubleClick();
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    TableCollection selection = tableBot.selection();
    TableRow row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Open another trace #2 and then double-click on bookmark in Bookmarks
     * view
     */
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/E-Test-10K")).getPath(), TRACE_TYPE);
    WaitUtils.waitForJobs();
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Close the trace #1 and then double-click on bookmark in Bookmarks
     * view
     */
    editorBot.close();
    WaitUtils.waitUntil(eb -> !eb.isActive(), editorBot, "Waiting for the editor to close");
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(eb -> eb.bot().table().selection().rowCount() > 0, editorBot, "Selection is still empty");
    tableBot = editorBot.bot().table();
    WaitUtils.waitUntil(tb -> !Objects.equal(tb.selection().get(0).get(1), "<srch>"), tableBot, "Header is still selected");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Select bookmarks icon in bookmark view right-click on icon and select
     * "Remove Bookmark"
     */
    bookmark.select();
    bookmark.contextMenu("Delete").click();
    SWTBotShell deleteBookmarkShell = fBot.shell("Delete Selected Entries");
    SWTBotUtils.anyButtonOf(deleteBookmarkShell.bot(), "Delete", "Yes").click();
    fBot.waitUntil(Conditions.treeHasRows(bookmarkTree, 0));
    tableItem = editorBot.bot().table().getTableItem(7);
    assertNull("Bookmark not deleted from event table", getBookmarkImage(tableItem));
}
 
Example 20
Source File: ProjectExplorerTraceActionsTest.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Test that the trace opens with double-click
 * <p>
 * Action : Open Trace (double click)
 * <p>
 * Procedure :Double-click a trace
 * <p>
 * Expected Results: Trace is opened
 *
 * @throws WidgetNotFoundException
 *             when a widget is not found
 */
@Test
public void test4_08OpenDoubleClick() throws WidgetNotFoundException {
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), TRACE_NAME);
    traceItem.doubleClick();

    SWTBotImportWizardUtils.testEventsTable(fBot, TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());
    testStatisticsView();
}