コード例 #1
0
ファイル: SWTBotTreeTest.java プロジェクト: kingtang/swtbot
 @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));
 }
コード例 #2
0
ファイル: SWTBotTreeTest.java プロジェクト: kingtang/swtbot
 @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);
 }
コード例 #3
0
 /**
  * Import wizard golden path test
  *
  * @throws Exception
  */
 @Test
 public void testImportWizard() throws Exception {
   deleteAllProjects();
   assertProjectExistence(PROJ1, false);
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   String wizardTitle =
       NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile.getPath());
   // start wizard from root item
   item.select();
   ContextMenuHelper.clickContextMenu(
       tree, myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
   SWTBotShell shell = bot.shell(wizardTitle);
   bot.radio(UIText.GitSelectWizardPage_ImportExistingButton).click();
   TableCollection selected = shell.bot().tree().selection();
   String wizardNode = selected.get(0, 0);
   // wizard directory should be working dir
   assertEquals(myRepoViewUtil.getWorkdirItem(tree, repositoryFile).getText(), wizardNode);
   shell.close();
   // start wizard from .git
   myRepoViewUtil
       .getWorkdirItem(tree, repositoryFile)
       .expand()
       .getNode(Constants.DOT_GIT)
       .select();
   ContextMenuHelper.clickContextMenu(
       tree, myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
   shell = bot.shell(wizardTitle);
   selected = shell.bot().tree().selection();
   wizardNode = selected.get(0, 0);
   // wizard directory should be .git
   assertEquals(Constants.DOT_GIT, wizardNode);
   shell.bot().button(IDialogConstants.NEXT_LABEL).click();
   shell.bot().label("Import Projects"); // wait for import projects page
   assertEquals(0, shell.bot().tree().getAllItems().length);
   shell.bot().button(IDialogConstants.BACK_LABEL).click();
   // go to project with .project
   shell.bot().tree().getAllItems()[0].getNode(PROJ1).select();
   // next is 1
   shell.bot().button(IDialogConstants.NEXT_LABEL).click();
   bot.button(UIText.WizardProjectsImportPage_deselectAll).click();
   assertEquals(1, shell.bot().tree().getAllItems().length);
   assertTrue(!shell.bot().button(IDialogConstants.FINISH_LABEL).isEnabled());
   shell.bot().button(UIText.WizardProjectsImportPage_selectAll).click();
   assertTrue(shell.bot().button(IDialogConstants.FINISH_LABEL).isEnabled());
   shell.bot().button(IDialogConstants.FINISH_LABEL).click();
   bot.waitUntil(Conditions.shellCloses(shell));
   assertProjectExistence(PROJ1, true);
   assertProjectIsShared(PROJ1, true);
 }
コード例 #4
0
  @Test
  public void testImportWizardGeneralProject() throws Exception {
    deleteAllProjects();
    assertProjectExistence(PROJ2, false);
    SWTBotTree tree = getOrOpenView().bot().tree();
    String wizardTitle =
        NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile.getPath());
    // start wizard from PROJ2
    myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand().getNode(PROJ2).select();
    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
    SWTBotShell shell = bot.shell(wizardTitle);
    shell = bot.shell(wizardTitle);
    // try import existing project first
    bot.radio(UIText.GitSelectWizardPage_ImportExistingButton).click();
    TableCollection selected = shell.bot().tree().selection();
    String wizardNode = selected.get(0, 0);
    // wizard directory should be PROJ2
    assertEquals(PROJ2, wizardNode);
    shell.bot().button(IDialogConstants.NEXT_LABEL).click();
    shell.bot().text(" " + UIText.GitProjectsImportPage_NoProjectsMessage);
    assertEquals(0, shell.bot().tree().getAllItems().length);
    shell.bot().button(IDialogConstants.BACK_LABEL).click();
    // import as general
    shell.bot().radio(UIText.GitSelectWizardPage_ImportAsGeneralButton).click();
    shell.bot().button(IDialogConstants.NEXT_LABEL).click();
    assertEquals(
        PROJ2,
        shell.bot().textWithLabel(UIText.GitCreateGeneralProjectPage_ProjectNameLabel).getText());
    // switch to a sub directory and see if this is used
    shell.bot().button(IDialogConstants.BACK_LABEL).click();
    shell.bot().tree().getAllItems()[0].expand().getNode(PROJ2).expand().getNode(FOLDER).select();
    shell.bot().button(IDialogConstants.NEXT_LABEL).click();
    String name =
        shell.bot().textWithLabel(UIText.GitCreateGeneralProjectPage_ProjectNameLabel).getText();
    assertEquals(FOLDER, name);
    shell.bot().button(IDialogConstants.BACK_LABEL).click();
    // switch back to the root directory
    shell.bot().tree().getAllItems()[0].expand().getNode(PROJ2).select();
    shell.bot().button(IDialogConstants.NEXT_LABEL).click();
    assertEquals(
        PROJ2,
        shell.bot().textWithLabel(UIText.GitCreateGeneralProjectPage_ProjectNameLabel).getText());

    shell.bot().button(IDialogConstants.FINISH_LABEL).click();
    bot.waitUntil(Conditions.shellCloses(shell));
    assertProjectExistence(PROJ2, true);
    assertProjectIsShared(PROJ2, true);
  }
コード例 #5
0
ファイル: SWTBotTreeTest.java プロジェクト: kingtang/swtbot
  @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));
  }
コード例 #6
0
  @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());
  }