// "Operations and Monitoring Explorer"
  public static SWTBotTree getTree(String ViewTitle) throws Exception {
    SWTBotView view = bot.viewByTitle(ViewTitle);
    view.show();

    Tree tree = (Tree) bot.widget(widgetOfType(Tree.class), view.getWidget());
    return new SWTBotTree(tree);
  }
Ejemplo n.º 2
0
 /** Before Test */
 @Override
 @Before
 public void before() {
   super.before();
   fViewBot = fBot.viewByTitle("Control Flow");
   fViewBot.show();
   fViewBot.setFocus();
 }
Ejemplo n.º 3
0
  @Test
  public void shouldShowViolationsForSelectionAndChildren() throws Exception {
    SwtBotUtils.openPerspective(bot, ISonarConstants.PERSPECTIVE_ID);

    SWTBotView view = bot.viewById(ViolationsView.ID);
    view.show();

    assertThat(view.bot().tree().hasItems(), is(false));

    new ImportProjectBot().setPath(getProjectPath(PROJECT_NAME)).finish();
    // Enable Sonar nature
    ProjectUtils.configureProject(PROJECT_NAME);

    new PackageExplorerBot()
        .expandAndSelect(
            PROJECT_NAME, "src/main/java", "(default package)", "ClassOnDefaultPackage.java");

    bot.sleep(5000);

    assertThat(view.bot().tree().hasItems(), is(true));
  }
Ejemplo n.º 4
0
  /**
   * Link with editor, both ways
   *
   * @throws Exception
   */
  @Test
  @Ignore("'Link with Selection' does not activate editor on selection change (bug 409722).")
  public void testLinkWithSelectionEditor() throws Exception {
    deleteAllProjects();
    shareProjects(repositoryFile);
    SWTBotTree tree = getOrOpenView().bot().tree();
    myRepoViewUtil.getRootItem(tree, repositoryFile).select();
    // the selection should be root
    assertTrue(tree.selection().get(0, 0).startsWith(REPO1));

    SWTBotView view = TestUtil.showExplorerView();
    SWTBotTree projectExplorerTree = view.bot().tree();

    SWTBotTreeItem item =
        getProjectItem(projectExplorerTree, PROJ1).expand().getNode(FOLDER).expand().getNode(FILE1);
    view.show();
    item.doubleClick();

    item =
        getProjectItem(projectExplorerTree, PROJ1).expand().getNode(FOLDER).expand().getNode(FILE2);
    view.show();
    item.doubleClick();
    // now we should have two editors

    // the selection should be still be root
    assertTrue(tree.selection().get(0, 0).startsWith(REPO1));

    // activate the link with selection
    toggleLinkWithSelection();

    bot.editorByTitle(FILE2).show();
    // the selection should have changed to the latest editor
    TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE2, 10000);

    bot.editorByTitle(FILE1).show();
    // selection should have changed
    TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE1, 10000);

    // deactivate the link with editor
    toggleLinkWithSelection();

    bot.editorByTitle(FILE2).show();
    // the selection should be still be test.txt
    TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE1, 10000);

    bot.editorByTitle(FILE1).show();

    myRepoViewUtil
        .getWorkdirItem(tree, repositoryFile)
        .expand()
        .getNode(PROJ1)
        .expand()
        .getNode(FOLDER)
        .expand()
        .getNode(FILE2)
        .select();

    // the editor should still be test.txt
    assertEquals(FILE1, bot.activeEditor().getTitle());

    // activate again
    toggleLinkWithSelection();

    // make sure focus is here
    // tried to remove this waitInUI but failed.
    // tried setting focus, waiting for focus, joining RepositoriesView
    // refresh job
    waitInUI();
    myRepoViewUtil
        .getWorkdirItem(tree, repositoryFile)
        .expand()
        .getNode(PROJ1)
        .expand()
        .getNode(FOLDER)
        .expand()
        .getNode(FILE2)
        .select();
    TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE2), 10000);

    myRepoViewUtil
        .getWorkdirItem(tree, repositoryFile)
        .expand()
        .getNode(PROJ1)
        .expand()
        .getNode(FOLDER)
        .expand()
        .getNode(FILE1)
        .select();
    TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE1), 10000);

    // deactivate the link with editor
    toggleLinkWithSelection();

    myRepoViewUtil
        .getWorkdirItem(tree, repositoryFile)
        .expand()
        .getNode(PROJ1)
        .expand()
        .getNode(FOLDER)
        .expand()
        .getNode(FILE2)
        .select();
    TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE1), 10000);
  }
  /**
   * test opening a trace, importing
   *
   * @throws IOException won't happen
   */
  @Test
  public void test() throws IOException {
    File f = File.createTempFile("temp", ".xml").getCanonicalFile();
    try (FileWriter fw = new FileWriter(f)) {
      fw.write(TRACE_CONTENT);
    }
    File exportPackage = new File(EXPORT_LOCATION);
    if (exportPackage.exists()) {
      exportPackage.delete();
    }
    assertFalse(
        "File: " + EXPORT_LOCATION + " already present, aborting test", exportPackage.exists());
    assertTrue("Trace :" + f.getAbsolutePath() + " does not exist, aborting test", f.exists());
    SWTBotUtils.createProject(PROJECT_NAME);
    SWTBotUtils.openTrace(PROJECT_NAME, f.getAbsolutePath(), XMLSTUB_ID);
    WaitUtils.waitForJobs();
    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(trace);
    assertEquals(
        "Incorrect opened trace!",
        f.getAbsolutePath(),
        (new File(trace.getPath())).getAbsolutePath());
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    assertNotNull("Cannot find " + PROJECT_EXPLORER, projectExplorerBot);
    projectExplorerBot.show();
    SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);

    treeItem.contextMenu(EXPORT_TRACE_PACKAGE).click();
    fBot.waitUntil(Conditions.shellIsActive(EXPORT_TRACE_PACKAGE_TITLE));
    SWTBot shellBot = fBot.activeShell().bot();
    shellBot.button(DESELECT_ALL).click();
    SWTBotTreeItem[] items = fBot.tree().getAllItems();
    for (SWTBotTreeItem item : items) {
      assertEquals(item.isChecked(), false);
    }
    shellBot.button(SELECT_ALL).click();
    for (SWTBotTreeItem item : items) {
      assertEquals(item.isChecked(), true);
    }
    shellBot.radio(SAVE_IN_TAR_FORMAT).click();
    shellBot.radio(SAVE_IN_ZIP_FORMAT).click();

    shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click();
    shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click();
    shellBot.comboBox().setText(EXPORT_LOCATION);
    SWTBotShell shell = fBot.activeShell();
    shellBot.button(FINISH).click();
    // finished exporting
    WaitUtils.waitForJobs();
    fBot.waitUntil(Conditions.shellCloses(shell));
    fBot = new SWTWorkbenchBot();
    exportPackage = new File(EXPORT_LOCATION);
    assertTrue("Exported package", exportPackage.exists());
    // Fixme: determine why exportPackageSize is different on different machines
    // assertEquals("Exported package size check", PACKAGE_SIZE, exportPackage.length());

    // import
    treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    treeItem.contextMenu(IMPORT_TRACE_PACKAGE).click();
    fBot.waitUntil(Conditions.shellIsActive(IMPORT_TRACE_PACKAGE_TITLE));
    shellBot = fBot.activeShell().bot();
    shellBot.comboBox().setText(EXPORT_LOCATION);
    shellBot.comboBox().typeText("\n");

    shellBot.button(SELECT_ALL).click();
    shell = fBot.activeShell();
    shellBot.button(FINISH).click();
    fBot.button("Yes To All").click();
    fBot.waitUntil(Conditions.shellCloses(shell));
    fBot = new SWTWorkbenchBot();
    SWTBotUtils.openEditor(fBot, PROJECT_NAME, new Path(f.getName()));
    trace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(trace);
    assertEquals("Test if import matches", f.getName(), trace.getName());
    assertFalse("Test if import files don't match", f.getAbsolutePath().equals(trace.getPath()));
    SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
    WaitUtils.waitForJobs();
  }