Exemplo n.º 1
0
 @Test
 public void getsSingleSelection() throws Exception {
   bot.checkBox("Multiple Columns").select();
   tree = bot.treeInGroup("Tree");
   tree.select(2);
   TableCollection selection = tree.selection();
   assertEquals(1, selection.rowCount());
   assertEquals(4, selection.columnCount());
   assertEquals(
       new TableCollection()
           .add(new TableRow(new String[] {"Node 3", "images", "91571", "yesterday"})),
       selection);
 }
  @Test
  public void testDeleteDiagrams() {

    final DiagramRepositoryStore diagramStore =
        RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);

    final int nbDiagramsInRepository = diagramStore.getChildren().size();

    final SWTBotMenu diagramMenu = bot.menu("Diagram");
    final List<String> newDiagramsName = new ArrayList<String>();
    for (int i = 0; i < nbDiagrams; i++) {
      SWTBotTestUtil.createNewDiagram(bot);
      bot.waitUntil(Conditions.widgetIsEnabled(diagramMenu), 40000);
      newDiagramsName.add(bot.activeEditor().getTitle());
    }
    assertEquals("4 diagrams should have been created", nbDiagrams, newDiagramsName.size());

    final int nbEditors = bot.editors().size();
    final String currentDiagramName = bot.activeEditor().getTitle();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Diagram")), 10000);
    bot.menu("Diagram").menu("Delete...").click();
    bot.waitUntil(Conditions.shellIsActive(Messages.DeleteDiagramWizardPage_title), 10000);

    final SWTBotTree tree = bot.tree();
    assertEquals(
        "the list of diagrams should contain 4 items",
        nbDiagramsInRepository + nbDiagrams,
        tree.getAllItems().length);

    final TableCollection selection = tree.selection();
    assertEquals(
        "only " + currentDiagramName + " should be selected in the tree viewer",
        1,
        selection.rowCount());
    assertEquals(
        "diagram " + currentDiagramName + " should be selected",
        currentDiagramName,
        selection.get(0, 0));

    //   final SWTBotTreeItem firstSwtBotTreeItem = tree.getAllItems()[1];
    //   final SWTBotTreeItem secondSwtBotTreeItem = tree.getAllItems()[2];
    //   final SWTBotTreeItem thirdSwtBotTreeItem = tree.getAllItems()[3];

    tree.select(newDiagramsName.get(1), newDiagramsName.get(2), newDiagramsName.get(3));

    bot.button(Messages.removeProcessLabel).click();

    bot.waitUntil(Conditions.shellIsActive(Messages.confirmProcessDeleteTitle));
    bot.button(IDialogConstants.YES_LABEL).click();
    bot.waitUntil(
        new ICondition() {

          @Override
          public boolean test() throws Exception {
            return nbEditors - 3 == bot.editors().size();
          }

          @Override
          public void init(final SWTBot bot) {}

          @Override
          public String getFailureMessage() {
            return "editors have not been closed after deleted diagrams";
          }
        },
        40000,
        100);

    assertEquals(
        "deleted diagrams are still in repository",
        nbDiagramsInRepository + 1,
        diagramStore.getChildren().size());
  }