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

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu. 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: XsemanticsSwtbotTestBase.java    From xsemantics with Eclipse Public License 1.0 6 votes vote down vote up
protected void createProjectAndAssertNoErrorMarker(String projectType) throws CoreException {
	SWTBotMenu fileMenu = bot.menu("File");
	SWTBotMenu newMenu = fileMenu.menu("New");
	SWTBotMenu projectMenu = newMenu.menu("Project...");
	projectMenu.click();

	SWTBotShell shell = bot.shell("New Project");
	shell.activate();
	SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics");
	waitForTreeItems(xsemanticsNode);
	xsemanticsNode.expandNode(projectType).select();
	bot.button("Next >").click();

	bot.textWithLabel("Project name:").setText(TEST_PROJECT);

	bot.button("Finish").click();

	// creation of a project might require some time
	bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT);
	assertTrue("Project doesn't exist", isProjectCreated(TEST_PROJECT));

	waitForBuild();
	assertNoErrorsInProject();
}
 
Example #2
Source File: XsemanticsImportExamplesProjectWizardTests.java    From xsemantics with Eclipse Public License 1.0 6 votes vote down vote up
protected void createExampleProjects(String projectType,
		String mainProjectId) {
	SWTBotMenu fileMenu = bot.menu("File");
	SWTBotMenu newMenu = fileMenu.menu("New");
	SWTBotMenu otherMenu = newMenu.menu("Other...");
	otherMenu.click();

	SWTBotShell shell = bot.shell("New");
	shell.activate();
	SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics");
	waitForTreeItems(xsemanticsNode);
	SWTBotTreeItem examplesNode = xsemanticsNode.expandNode("Examples");
	waitForTreeItems(examplesNode);
	examplesNode.expandNode(projectType).select();
	bot.button("Next >").click();

	bot.button("Finish").click();

	// creation of a project might require some time
	bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT);
	assertTrue("Project doesn't exist", isProjectCreated(mainProjectId));
	assertTrue("Project doesn't exist", isProjectCreated(mainProjectId
			+ ".tests"));
	assertTrue("Project doesn't exist", isProjectCreated(mainProjectId
			+ ".ui"));
}
 
Example #3
Source File: PDFHandlerThreadingTest.java    From tlaplus with MIT License 6 votes vote down vote up
@Test @Ignore("not ready yet")
public void producePDFInNonUIThread() throws InterruptedException {
	
	// 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(specA);
	bot.button("Finish").click();
	
	// generate PDF
	SWTBotMenu pdfMenu = fileMenu.menu("Produce PDF Version");
	pdfMenu.click();
	
	// wait for the browser to show up with the generated PDF
	SWTBotEditor swtBotEditor = bot.editorById(OpenSpecHandler.TLA_EDITOR);
	Assert.assertNotNull(swtBotEditor);
	
	assertNoBackendCodeInUIThread();
}
 
Example #4
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test enable UST channel on session level (default values)
 */
protected void testEnableUstChannel() {
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());
    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_CHANNEL_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_CHANNEL_DIALOG_TITLE).activate();
    SWTBotText channelText = shell.bot().textWithLabel(ControlViewSwtBotUtil.CHANNEL_NAME_LABEL);
    channelText.setText(UST_CHANNEL_NAME);

    shell.bot().radioInGroup(ControlViewSwtBotUtil.UST_GROUP_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();
    shell.bot().radioInGroup(ControlViewSwtBotUtil.BUFFERTYPE_PER_UID, ControlViewSwtBotUtil.BUFFERTYPE_GROUP_NAME).click();
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();
    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.UST_DOMAIN_NAME, sessionItem));
}
 
Example #5
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test destroy session
 */
protected void testDestroySession() {
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());

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

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.DESTROY_CONFIRM_DIALOG_TITLE).activate();
    shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

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

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeRemoved(0, sessionGroupItem));
    assertEquals(0, sessionGroupItem.getNodes().size());
}
 
Example #6
Source File: PluginTest.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Test that after adding nature to a C project, the add nature menu item
 * disappears.
 */
@Test
public void testAddNatureDisappears() {

    SWTBotTreeItem project = bot.tree().getTreeItem(CPP_PROJ).doubleClick();
    SWTBotMenu menu = project.contextMenu(ADD_NATURE_MENU);

    assertThat("Add CodeChecker Nature menu item wasn't enabled", menu.isEnabled(), is(true));

    menu.click();

    // Widget should be missing now.
    thrown.expect(WidgetNotFoundException.class);
    thrown.expectMessage(containsString("Could not find"));
    project.contextMenu(ADD_NATURE_MENU);
}
 
Example #7
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 #8
Source File: SwtBotWorkbenchActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Opens the preferences dialog from the main Eclipse window.
 * <p>
 * Note: There are some platform-specific intricacies that this abstracts
 * away.
 */
public static void openPreferencesDialog(final SWTWorkbenchBot bot) {
  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      if (SwtBotUtils.isMac()) {
        // TODO: Mac has "Preferences..." under the "Eclipse" menu item.
        // However,
        // the "Eclipse" menu item is a system menu item (like the Apple menu
        // item), and can't be reached via SWTBot.
        openPreferencesDialogViaEvents(bot);
      } else {
        SWTBotMenu windowMenu = bot.menu("Window");
        windowMenu.menu("Preferences").click();
      }
    }
  });
}
 
Example #9
Source File: SwtBotWorkbenchActions.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Opens the preferences dialog from the main Eclipse window.
 * <p>
 * Note: There are some platform-specific intricacies that this abstracts
 * away.
 */
public static void openPreferencesDialog(SWTWorkbenchBot bot) {
  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, () -> {
    if (SwtBotTestingUtilities.isMac()) {
      // TODO: Mac has "Preferences..." under the "Eclipse" menu item.
      // However,
      // the "Eclipse" menu item is a system menu item (like the Apple menu
      // item), and can't be reached via SWTBot.
      openPreferencesDialogViaEvents(bot);
    } else {
      SWTBotMenu windowMenu = bot.menu("Window");
      windowMenu.menu("Preferences").click();
    }
  });
}
 
Example #10
Source File: AbstractRefactoringSwtBotTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void renameInJavaEditor(final SWTBotEclipseEditor javaEditor, final String newName, final String dialogName) {
  final SWTBotMenu renameMenuItem = SwtBotProjectHelper.clickableContextMenu(javaEditor, "Refactor", "Rename...");
  renameMenuItem.click();
  boolean _isUseInlineRefactoring = this.testParams.isUseInlineRefactoring();
  if (_isUseInlineRefactoring) {
    javaEditor.typeText(newName);
    boolean _isUsePreview = this.testParams.isUsePreview();
    if (_isUsePreview) {
      javaEditor.pressShortcut(SWT.CTRL, SWT.CR);
      AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate();
      AbstractRefactoringSwtBotTest.bot.button("OK").click();
    } else {
      javaEditor.pressShortcut(KeyStroke.getInstance(SWT.LF));
    }
  } else {
    SWTBot _bot = AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate().bot();
    final Procedure1<SWTBot> _function = (SWTBot it) -> {
      SWTBotText _textWithLabel = it.textWithLabel("New name:");
      _textWithLabel.setText(newName);
      boolean _isUsePreview_1 = this.testParams.isUsePreview();
      if (_isUsePreview_1) {
        it.button("Next").click();
      }
      it.button("Finish").click();
    };
    ObjectExtensions.<SWTBot>operator_doubleArrow(_bot, _function);
  }
  this.waitForRefactoring(javaEditor);
}
 
Example #11
Source File: DynamicViewMenu.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the menu items. This is expected to be called from within the UI thread. If not it will throw exceptions
 * based on invalid thread access.
 *
 * @param items
 *          the menu items to search through
 * @param menuPath
 *          the menu path without the menu item to find.
 * @param recursive
 *          if set to <code>true</code>, will find sub-menus as well.
 * @return The list of SWTBotMenu items which match the menu path.
 */
@SuppressWarnings("PMD.CyclomaticComplexity")
private static List<SWTBotMenu> getMenuItemsInternal(final IContributionItem[] items, final List<String> menuPath, final boolean recursive) {
  final List<SWTBotMenu> l = new ArrayList<SWTBotMenu>();
  final boolean findAnything = (menuPath == null) || menuPath.isEmpty();
  for (final IContributionItem item : items) {
    try {
      if ((item instanceof MenuManager) && recursive) {
        // Sub menus
        final MenuManager menuManager = (MenuManager) item;
        if (findAnything || menuManager.getMenuText().equals(menuPath.get(0))) {
          List<String> subList = null;
          if (menuPath.size() > 1) {
            subList = menuPath.subList(1, menuPath.size());
          }
          l.addAll(getMenuItemsInternal(menuManager.getItems(), subList, recursive));
        }
      } else if (item instanceof ContributionItem) {
        final ContributionItem dynItem = (ContributionItem) item;
        dynItem.fill(originalMenu, 0);
        final MenuItem[] items2 = originalMenu.getItems();
        for (final MenuItem item2 : items2) {
          l.add(new SWTBotMenu(item2));
        }
      }
    } catch (final WidgetNotFoundException widgetNotFoundException) {
      continue; // Do nothing
    }
  }

  return l;
}
 
Example #12
Source File: ProjectTreeItem.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 转换当前项目中的一个源文件为 XLIFF
 * @param srcFileName
 *            要转换的源文件名称
 */
public void ctxMenuConvertFile(String srcFileName) {
	selectFile("Source", srcFileName);
	SWTBotMenu convertFiles = ptv.ctxMenuConvertSrcFile2Xliff();
	convertFiles.isEnabled();
	convertFiles.click();
	// TODO:确认转换对话框正确打开
}
 
Example #13
Source File: ContextActionUiTestUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the {@link SWTBotMenu}s available on the given widget bot.
 *
 * @param widgetBot
 *          the bot representing the widget, whose {@link SWTBotMenu}s should be returned
 * @return the {@link SWTBotMenu}s on the given widget bot
 */
public static List<SWTBotMenu> getContextMenuItems(final AbstractSWTBot<? extends Control> widgetBot) {
  return UIThreadRunnable.syncExec(new Result<List<SWTBotMenu>>() {
    @Override
    public List<SWTBotMenu> run() {
      List<SWTBotMenu> menuItems = Lists.newArrayList();
      for (MenuItem menuItem : new ContextMenuFinder(widgetBot.widget).findMenus(widgetBot.widget.getShell(), WidgetMatcherFactory.widgetOfType(MenuItem.class), true)) {
        menuItems.add(new SWTBotMenu(menuItem));
      }
      return menuItems;
    }
  });
}
 
Example #14
Source File: ContextActionUiTestUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the disabled {@link SWTBotMenu}s on the given widget bot.
 *
 * @param widgetBot
 *          the bot representing the widget, whose disabled {@link SWTBotMenu}s should be returned
 * @return the disabled {@link SWTBotMenu}s on the given widget bot
 */
public static List<SWTBotMenu> getDisabledContextMenuItems(final AbstractSWTBot<? extends Control> widgetBot) {
  return UIThreadRunnable.syncExec(new Result<List<SWTBotMenu>>() {
    @Override
    public List<SWTBotMenu> run() {
      List<SWTBotMenu> disabledMenuItems = Lists.newArrayList();
      for (MenuItem menuItem : new ContextMenuFinder(widgetBot.widget).findMenus(widgetBot.widget.getShell(), WidgetMatcherFactory.widgetOfType(MenuItem.class), true)) {
        if (!menuItem.isEnabled()) {
          disabledMenuItems.add(new SWTBotMenu(menuItem));
        }
      }
      return disabledMenuItems;
    }
  });
}
 
Example #15
Source File: AbstractRefactoringSwtBotTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void renameInXtendEditor(final SWTBotEclipseEditor xtendEditor, final String newName, final String dialogName) {
  final SWTBotMenu renameMenuItem = SwtBotProjectHelper.clickableContextMenu(xtendEditor, "Refactor", "Rename Element");
  renameMenuItem.click();
  boolean _isUseInlineRefactoring = this.testParams.isUseInlineRefactoring();
  if (_isUseInlineRefactoring) {
    this.waitForLinkedMode();
    xtendEditor.typeText(newName);
    boolean _isUsePreview = this.testParams.isUsePreview();
    if (_isUsePreview) {
      xtendEditor.pressShortcut(SWT.CTRL, SWT.CR);
      AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate();
      AbstractRefactoringSwtBotTest.bot.button("OK").click();
    } else {
      xtendEditor.pressShortcut(KeyStroke.getInstance(SWT.LF));
    }
  } else {
    SWTBot _bot = AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate().bot();
    final Procedure1<SWTBot> _function = (SWTBot it) -> {
      SWTBotText _textWithLabel = it.textWithLabel("New name:");
      _textWithLabel.setText(newName);
      boolean _isUsePreview_1 = this.testParams.isUsePreview();
      if (_isUsePreview_1) {
        it.button("Preview >").click();
      }
      it.button("OK").click();
    };
    ObjectExtensions.<SWTBot>operator_doubleArrow(_bot, _function);
  }
  this.waitForRefactoring(xtendEditor);
}
 
Example #16
Source File: ProjectTreeItem.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 转换当前项目中的一个 XLIFF 为源格式
 * @param xlfFileName
 *            要转换为源格式的 XLIFF 文件名称
 */
public void ctxMenuReverseConvertFile(String xlfFileName) {
	selectFile("XLIFF", xlfFileName);
	SWTBotMenu reverseConvertFile = ptv.ctxMenuConvertXliffFile2Tgt();
	reverseConvertFile.isEnabled();
	reverseConvertFile.click();
	// TODO:确认转换对话框正确打开
}
 
Example #17
Source File: SwtBotProjectActions.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Opens the Properties dialog for a given project.
 *
 * This method assumes that either the Package Explorer or Project Explorer view is visible.
 */
public static void openProjectProperties(SWTWorkbenchBot bot, String projectName) {
  selectProject(bot, projectName);

  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, () -> {
    // Open the Project Properties menu via the File menu
    SWTBotMenu fileMenu = bot.menu("File");
    fileMenu.menu("Properties").click();
  });
}
 
Example #18
Source File: ChartMakerDialogTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void openDialog() {
    // Open the new custom chart dialog
    SWTBotView viewBot = fBot.viewById(CustomChartStubView.ID);
    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    SWTBotMenu menu = viewMenu.menu(CustomChartStubView.MENU_TITLE);
    menu.click();
}
 
Example #19
Source File: TmfAlignTimeAxisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test for the "Align Views" menu item
 */
@Test
public void testMenuItem() {
    fBot = new SWTWorkbenchBot();
    switchToPerspective(AlignPerspectiveFactory1.ID);
    SWTBotView viewBot = fBot.viewById(TimeGraphViewStub.ID);
    SWTBotRootMenu viewMenu = viewBot.viewMenu();

    SWTBotMenu menuItems = viewMenu.menu(ALIGN_VIEWS_ACTION_NAME);
    assertTrue("Align views", menuItems.isChecked());
}
 
Example #20
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Deletes a project
 *
 * @param projectName
 *            the name of the tracing project
 * @param deleteResources
 *            whether or not to deleted resources under the project
 * @param bot
 *            the workbench bot
 */
public static void deleteProject(final String projectName, boolean deleteResources, SWTWorkbenchBot bot) {
    // Wait for any analysis to complete because it might create
    // supplementary files
    WaitUtils.waitForJobs();
    try {
        ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
    }

    WaitUtils.waitForJobs();

    closeSecondaryShells(bot);
    WaitUtils.waitForJobs();

    if (!ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).exists()) {
        return;
    }

    focusMainWindow(bot.shells());

    final SWTBotView projectViewBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectViewBot.setFocus();

    SWTBotTree treeBot = projectViewBot.bot().tree();
    SWTBotTreeItem treeItem = treeBot.getTreeItem(projectName);
    SWTBotMenu contextMenu = treeItem.contextMenu("Delete");
    contextMenu.click();

    handleDeleteDialog(deleteResources, bot);
    WaitUtils.waitForJobs();
}
 
Example #21
Source File: SystemCallLatencyStatisticsTableAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test with an actual trace, this is more of an integration test than a
 * unit test. This test is a slow one too. If some analysis are not well
 * configured, this test will also generates null pointer exceptions. These
 * are will be logged.
 *
 * @throws IOException
 *             trace not found?
 * @throws SecurityException
 *             Reflection error
 * @throws NoSuchMethodException
 *             Reflection error
 * @throws IllegalArgumentException
 *             Reflection error
 */
@Test
public void testWithTrace() throws IOException, NoSuchMethodException, SecurityException, IllegalArgumentException {
    String tracePath = FileUtils.toFile(FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL())).getAbsolutePath();
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotView view = bot.viewById(PRIMARY_VIEW_ID);
    SWTBotUtils.closeViewById(PRIMARY_VIEW_ID, fBot);

    SWTBotUtils.createProject(PROJECT_NAME);
    SWTBotUtils.openTrace(PROJECT_NAME, tracePath, TRACE_TYPE);
    WaitUtils.waitForJobs();
    createTree();
    WaitUtils.waitForJobs();
    SWTBotTreeItem totalEntry = fTreeBot.getTreeItem("bug446190").getNode("Total");
    validate(totalEntry, "Total", "1 µs", "5.904 s", "15.628 ms", "175.875 ms", "1801");
    assertEquals(55, totalEntry.getNodes().size());
    validate(totalEntry.getNode(2), "select", "13.6 µs", "1.509 s", "192.251 ms", "386.369 ms", "58");
    validate(totalEntry.getNode(3), "poll", "6.3 µs", "6.8 µs", "6.55 µs", "---", "2");
    validate(totalEntry.getNode(5), "set_tid_address", "2.3 µs", "2.3 µs", "2.3 µs", "---", "1");
    validate(totalEntry.getNode(7), "pipe", "27.9 µs", "29.7 µs", "28.8 µs", "---", "2");
    testToTsv(view);
    SWTBotMenu menuBot = view.viewMenu().menu("Export to TSV...");
    assertTrue(menuBot.isEnabled());
    assertTrue(menuBot.isVisible());

    fBot.closeAllEditors();
    SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
}
 
Example #22
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test creating a tsv
 *
 * @throws NoSuchMethodException
 *             Error creating the tsv
 * @throws IOException
 *             no such file or the file is locked.
 */
@Test
public void testWriteToTsv() throws NoSuchMethodException, IOException {

    ISegmentStore<@NonNull ISegment> fixture = SegmentStoreFactory.createSegmentStore();
    for (int i = 1; i <= 20; i++) {
        int start = i;
        final int delta = i;
        int end = start + delta * delta;
        fixture.add(createSegment(start, end));
    }
    assertNotNull(getTable());
    getTable().updateModel(fixture);
    SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1", 0, 2));
    SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot();
    SWTBotView viewBot = swtWorkbenchBot.viewById(getTableView().getSite().getId());
    String[] lines = extractTsv(viewBot);
    testTsv(lines);
    List<String> actionResult = Arrays.asList(lines);
    String absolutePath = TmfTraceManager.getTemporaryDirPath() + File.separator + "syscallLatencyTest.testWriteToTsv.tsv";
    TmfFileDialogFactory.setOverrideFiles(absolutePath);
    SWTBotMenu menuBot = viewBot.viewMenu().menu("Export to TSV...");
    try {
        assertTrue(menuBot.isEnabled());
        assertTrue(menuBot.isVisible());
        menuBot.click();

        try (BufferedReader br = new BufferedReader(new FileReader(absolutePath))) {
            List<String> actual = br.lines().collect(Collectors.toList());
            assertEquals("Both reads", actionResult, actual);
        }
    } finally {
        new File(absolutePath).delete();
    }

}
 
Example #23
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test connect to node
 */
protected void testConnectToNode() {
    SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName());
    nodeItem.select();
    SWTBotMenu menuBot = nodeItem.contextMenu(ControlViewSwtBotUtil.CONNECT_MENU_ITEM);
    menuBot.click();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.SESSION_GROUP_NAME, nodeItem));

    // Verify that node is connected
    fBot.waitUntil(ControlViewSwtBotUtil.isStateChanged(fNode, TargetNodeState.CONNECTED));
    // Wait for node configuration jobs
    WaitUtils.waitForJobs();
    assertEquals(TargetNodeState.CONNECTED, fNode.getTargetNodeState());
}
 
Example #24
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test create session
 */
protected void testCreateSession() {
    SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName());

    SWTBotTreeItem sessionGroupItem = nodeItem.getNode(ControlViewSwtBotUtil.SESSION_GROUP_NAME);

    sessionGroupItem.select();
    SWTBotMenu menuBot = sessionGroupItem.contextMenu(ControlViewSwtBotUtil.CREATE_SESSION_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.CREATE_SESSION_DIALOG_TITLE).activate();

    SWTBotText sessionText = shell.bot().textWithLabel(ControlViewSwtBotUtil.SESSION_NAME_LABEL);
    sessionText.setText(SESSION_NAME);

    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    sessionGroupItem.expand();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(getSessionName(), sessionGroupItem));
    assertEquals(1, sessionGroupItem.getNodes().size());

    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());
    assertEquals(getSessionName(), sessionItem.getText());
}
 
Example #25
Source File: ProjectTreeItem.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 转换当前项目中的一个 XLIFF 为源格式
 * @param xlfFileName
 *            要转换为源格式的 XLIFF 文件名称
 */
public void ctxMenuReverseConvertFile(String xlfFileName) {
	selectFile("XLIFF", xlfFileName);
	SWTBotMenu reverseConvertFile = ptv.ctxMenuConvertXliffFile2Tgt();
	reverseConvertFile.isEnabled();
	reverseConvertFile.click();
	// TODO:确认转换对话框正确打开
}
 
Example #26
Source File: ProjectTreeItem.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 转换当前项目中的一个源文件为 XLIFF
 * @param srcFileName
 *            要转换的源文件名称
 */
public void ctxMenuConvertFile(String srcFileName) {
	selectFile("Source", srcFileName);
	SWTBotMenu convertFiles = ptv.ctxMenuConvertSrcFile2Xliff();
	convertFiles.isEnabled();
	convertFiles.click();
	// TODO:确认转换对话框正确打开
}
 
Example #27
Source File: ProjectExplorerDiagramIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void validateMenuAvailable(String diagramName, String poolName, String action) {
    SWTBotTreeItem diagramTreeItem = diagramBot.getDiagramTreeItem(diagramName, DEFAULT_VERSION);
    bot.waitUntil(projectExplorerBot.contextMenuAvailable(diagramTreeItem, action));
    SWTBotMenu contextMenu = diagramTreeItem.contextMenu(action);
    assertThat(contextMenu.menuItems()).hasSize(1);
    assertThat(contextMenu.menuItems().get(0)).isEqualTo(String.format("%s (%s)", poolName, DEFAULT_VERSION));
}
 
Example #28
Source File: ProjectTreeItem.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 打开当前项目中的一个 XLIFF 文件
 * @param xlfFileName
 *            要打开的 XLIFF 文件名称
 */
public void ctxMenuOpenFile(final String xlfFileName) {
	selectFile("XLIFF", xlfFileName);
	SWTBotMenu openFiles = ptv.ctxMenuOpenFile();
	openFiles.isEnabled();
	openFiles.click();

	SWTBotEditor editor = HSBot.bot().editorByTitle(xlfFileName);
	HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
 
Example #29
Source File: TS.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return 菜单:数据库 > 导入 TMX;
 */
public SWTBotMenu menuDBImportTMXFile() {
	return menuDB().menu(TsUIConstants.getString("menuDBImportTMXFile"));
}
 
Example #30
Source File: MemoryDatabaseManagementDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return 右键菜单:删除;
 */
public SWTBotMenu ctxMenuDelete() {
	return dialogBot.tree().contextMenu(TsUIConstants.getString("ctxMenuDelete"));
}