Esempio n. 1
0
 @Test
 public void setsMultipleSelection() throws Exception {
   bot.radio("SWT.MULTI").click();
   tree = bot.treeInGroup("Tree");
   tree.select(new String[] {"Node 2", "Node 4"});
   assertEquals(2, tree.selectionCount());
   TableCollection selection = tree.selection();
   assertEquals("Node 2", selection.get(0, 0));
   assertEquals("Node 4", selection.get(1, 0));
 }
Esempio n. 2
0
  @Test
  public void getsMultipleSingleSelection() throws Exception {
    bot.radio("SWT.MULTI").click();
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");
    tree.select(new int[] {1, 2});

    TableCollection selection = tree.selection();
    assertEquals("Node 2", selection.get(0, 0));
    assertEquals("databases", selection.get(0, 1));
    assertEquals("2556", selection.get(0, 2));
    assertEquals("tomorrow", selection.get(0, 3));

    assertEquals(
        new TableRow(new String[] {"Node 3", "images", "91571", "yesterday"}), selection.get(1));
  }
  /**
   * 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();
  }