Ejemplo n.º 1
0
  @Test
  public void testDeleteMultipleBranches() throws Exception {
    // expand first level
    SWTBotTree tree = getOrOpenView().bot().tree();
    refreshAndWait();
    // open a branch (checkout)
    SWTBotTreeItem localBranchesItem =
        myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).expand();
    SWTBotTreeItem masterNode = localBranchesItem.getNode("master");
    // create first branch (abc)
    masterNode.select();
    ContextMenuHelper.clickContextMenu(tree, "Create Branch...");
    SWTBotShell createBranchShell = bot.shell(UIText.CreateBranchWizard_NewBranchTitle);
    createBranchShell.bot().textWithId("BranchName").setText("abc");
    createBranchShell.bot().checkBox(UIText.CreateBranchPage_CheckoutButton).deselect();
    createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click();
    // create second branch (123)
    ContextMenuHelper.clickContextMenu(tree, "Create Branch...");
    createBranchShell = bot.shell(UIText.CreateBranchWizard_NewBranchTitle);
    createBranchShell.bot().textWithId("BranchName").setText("123");
    createBranchShell.bot().checkBox(UIText.CreateBranchPage_CheckoutButton).deselect();
    createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click();
    refreshAndWait();
    localBranchesItem = myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).expand();
    // delete both
    localBranchesItem.select("abc", "123");
    ContextMenuHelper.clickContextMenuSync(
        tree, myUtil.getPluginLocalizedValue("RepoViewDeleteBranch.label"));
    refreshAndWait();

    SWTBotTreeItem[] items = myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).getItems();
    assertEquals("Wrong number of branches", 2, items.length);
    assertEquals("master", items[0].getText());
    assertEquals("stable", items[1].getText());
  }
Ejemplo n.º 2
0
 @Test
 public void menuWithoutStashes() {
   SWTBotTree tree = selectProject();
   assertTrue(ContextMenuHelper.isContextMenuItemEnabled(tree, "Team", STASHES));
   assertFalse(
       ContextMenuHelper.isContextMenuItemEnabled(
           tree, "Team", STASHES, UIText.StashesMenu_NoStashedChangesText));
 }
Ejemplo n.º 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);
 }
  @Test
  public void testResetToTag() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();

    String initialContent = getTestFileContent();
    createTag("ResetToFirst", "The first tag");
    touchAndSubmit(null);
    String newContent = getTestFileContent();
    assertFalse("Wrong content", initialContent.equals(newContent));
    createTag("ResetToSecond", "The second tag");
    refreshAndWait();
    myRepoViewUtil.getTagsItem(tree, repositoryFile).expand().getNode("ResetToFirst").select();

    ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue("ResetCommand"));

    SWTBotShell resetDialog = bot.shell(UIText.ResetCommand_WizardTitle);
    resetDialog.bot().radio(UIText.ResetTargetSelectionDialog_ResetTypeHardButton).click();
    resetDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
    TestUtil.joinJobs(JobFamilies.RESET);

    bot.shell(UIText.ResetTargetSelectionDialog_ResetQuestion)
        .bot()
        .button(IDialogConstants.YES_LABEL)
        .click();

    Job.getJobManager().join(JobFamilies.RESET, null);

    ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
    assertEquals("Wrong content", initialContent, getTestFileContent());
  }
Ejemplo n.º 5
0
 /**
  * Show properties
  *
  * @throws Exception
  */
 @Test
 public void testShowProperties() throws Exception {
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   item.select();
   ContextMenuHelper.clickContextMenuSync(
       tree, myUtil.getPluginLocalizedValue("ShowIn"), "Properties");
   SWTBotView propertieView = bot.viewById(IPageLayout.ID_PROP_SHEET);
   assertTrue(propertieView.isActive());
 }
 private void createTag(String name, String message) throws Exception {
   SWTBotTree tree = getOrOpenView().bot().tree();
   myRepoViewUtil.getTagsItem(tree, repositoryFile).select();
   ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue("CreateTagCommand"));
   String shellTitle = UIText.CreateTagDialog_NewTag;
   SWTBotShell createDialog = bot.shell(shellTitle).activate();
   TestUtil.joinJobs(JobFamilies.FILL_TAG_LIST);
   createDialog.bot().textWithLabel(UIText.CreateTagDialog_tagName).setText(name);
   createDialog.bot().styledTextWithLabel(UIText.CreateTagDialog_tagMessage).setText(message);
   createDialog.bot().button(IDialogConstants.OK_LABEL).click();
   TestUtil.joinJobs(JobFamilies.TAG);
 }
Ejemplo n.º 7
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);
  }
Ejemplo n.º 8
0
  @Test
  public void stashAndApplyChanges() throws Exception {
    String originalContent = getTestFileContent();

    String modifiedContent = "changes to stash";
    touch(modifiedContent);
    assertEquals(modifiedContent, getTestFileContent());

    ContextMenuHelper.clickContextMenu(
        selectProject(), "Team", STASHES, UIText.StashesMenu_StashChangesActionText);

    SWTBotShell createDialog = bot.shell(UIText.StashCreateCommand_titleEnterCommitMessage);
    SWTBotText enterMessageText = createDialog.bot().text(0);
    String stashMessage = "stash message";
    enterMessageText.setText(stashMessage);
    createDialog.bot().button(IDialogConstants.OK_LABEL).click();

    assertEquals(originalContent, getTestFileContent());

    ContextMenuHelper.clickContextMenu(
        selectProject(),
        "Team",
        STASHES,
        MessageFormat.format(UIText.StashesMenu_StashItemText, Integer.valueOf(0), stashMessage));

    SWTBotEditor stashEditor = bot.activeEditor();
    // Check if text with message is there
    stashEditor.bot().styledText(stashMessage);

    stashEditor
        .bot()
        .toolbarButtonWithTooltip(util.getPluginLocalizedValue("StashApplyCommand.label"))
        .click();

    assertEquals(modifiedContent, getTestFileContent());
  }
Ejemplo n.º 9
0
 @Test
 public void testImportWizardGeneralProjectWithWorkingSet() throws Exception {
   deleteAllProjects();
   assertProjectExistence(PROJ1, false);
   String workingSetName = "myWorkingSet";
   removeWorkingSet(workingSetName);
   SWTBotTree tree = getOrOpenView().bot().tree();
   String wizardTitle =
       NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile.getPath());
   // start wizard from PROJ1
   myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand().getNode(PROJ1).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();
   SWTBotButton button = shell.bot().button(IDialogConstants.NEXT_LABEL);
   // Set focus on the next button. If this is not done, Wizard Framework restores
   // the focus to the "Import as &General Project" radio button. Setting the focus on
   // the radio button selects the button and causes the test to fail.
   // See also SWTBot Bug 337465
   button.setFocus();
   button.click();
   shell.bot().text(UIText.WizardProjectsImportPage_ImportProjectsDescription);
   shell.bot().tree().getAllItems()[0].check();
   // add to working set
   shell.bot().checkBox("Add project to working sets").select();
   // create new working set
   shell.bot().button("Select...").click();
   SWTBotShell workingSetDialog = bot.shell("Select Working Sets");
   workingSetDialog.bot().button("New...").click();
   SWTBotShell newDialog = bot.shell("New Working Set");
   newDialog.bot().table().select("Java");
   newDialog.bot().button(IDialogConstants.NEXT_LABEL).click();
   newDialog.bot().text(0).setText(workingSetName);
   newDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
   workingSetDialog.bot().table().getTableItem(workingSetName).check();
   workingSetDialog.bot().button(IDialogConstants.OK_LABEL).click();
   shell.bot().button(IDialogConstants.FINISH_LABEL).click();
   bot.waitUntil(Conditions.shellCloses(shell));
   assertProjectExistence(PROJ1, true);
   assertProjectInWorkingSet(workingSetName, PROJ1);
   assertProjectIsShared(PROJ1, true);
   removeWorkingSet(workingSetName);
 }
Ejemplo n.º 10
0
  @Test
  public void testDeleteFileNotInProject() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    refreshAndWait();

    SWTBotTreeItem folder = findWorkdirNode(tree, PROJ2, FOLDER);
    folder.getNode(FILE1).select();

    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("RepoViewDeleteFile.label"));

    SWTBotShell confirm = bot.shell(UIText.DeleteResourcesOperationUI_confirmActionTitle);
    confirm.bot().button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(shellCloses(confirm));
    TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH);

    folder = findWorkdirNode(tree, PROJ2, FOLDER);
    assertThat(folder.getNodes(), not(hasItem(FILE1)));
    assertThat(folder.getNodes(), hasItem(FILE2));
  }
  @Test
  public void testDeleteTag() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    int initialCount = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand().rowCount();

    createTag("Delete1", "The first tag");
    refreshAndWait();
    SWTBotTreeItem tagsItem = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand();
    SWTBotTreeItem[] items = tagsItem.getItems();
    assertEquals("Wrong number of tags", initialCount + 1, items.length);
    tagsItem.select("Delete1");
    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("DeleteTagCommand.name"));
    bot.shell(UIText.DeleteTagCommand_titleConfirm).bot().button(IDialogConstants.OK_LABEL).click();
    TestUtil.joinJobs(JobFamilies.TAG);
    refreshAndWait();
    tagsItem = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand();
    items = tagsItem.getItems();
    assertEquals("Wrong number of tags", initialCount, items.length);
  }
Ejemplo n.º 12
0
  @Test
  public void testDeleteFileInProject() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    refreshAndWait();

    IProject project1 = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);
    // Make sure that the refresh doesn't happen on delete and cause a timeout
    project1.refreshLocal(IResource.DEPTH_INFINITE, null);

    SWTBotTreeItem folder = findWorkdirNode(tree, PROJ1, FOLDER);
    folder.getNode(FILE1).select();

    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("RepoViewDeleteFile.label"));

    SWTBotShell confirm = bot.shell("Delete Resources");
    confirm.bot().button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(shellCloses(confirm));
    TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH);

    folder = findWorkdirNode(tree, PROJ1, FOLDER);
    assertThat(folder.getNodes(), not(hasItem(FILE1)));
    assertThat(folder.getNodes(), hasItem(FILE2));
  }
 private void runFetch(SWTBotTree tree) {
   JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.FETCH, 60, TimeUnit.SECONDS);
   ContextMenuHelper.clickContextMenuSync(
       tree, myUtil.getPluginLocalizedValue("SimpleFetchCommand"));
   jobJoiner.join();
 }