Search in sources :

Example 1 with TableCollection

use of org.eclipse.swtbot.swt.finder.utils.TableCollection in project egit by eclipse.

the class GitRepositoriesViewTest method testImportWizardGeneralProject.

@Test
public void testImportWizardGeneralProject() throws Exception {
    removeSmartImportWizardToForceGitImportWizardUsage();
    deleteAllProjects();
    assertProjectExistence(PROJ2, false);
    TestUtil.processUIEvents();
    SWTBotTree tree = getOrOpenView().bot().tree();
    String wizardTitle = NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile.getPath());
    // start wizard from PROJ2
    TestUtil.expandAndWait(myRepoViewUtil.getWorkdirItem(tree, repositoryFile)).getNode(PROJ2).select();
    ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
    TestUtil.processUIEvents();
    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();
    SWTBotTreeItem item = TestUtil.expandAndWait(shell.bot().tree().getAllItems()[0]);
    TestUtil.expandAndWait(item.getNode(PROJ2)).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
    TestUtil.expandAndWait(shell.bot().tree().getAllItems()[0]).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);
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) TableCollection(org.eclipse.swtbot.swt.finder.utils.TableCollection) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 2 with TableCollection

use of org.eclipse.swtbot.swt.finder.utils.TableCollection in project egit by eclipse.

the class BranchAndResetActionTest method checkout.

private void checkout(String[] nodeTexts) throws Exception {
    SWTBotShell dialog = openCheckoutBranchDialog();
    TestUtil.navigateTo(dialog.bot().tree(), nodeTexts).select();
    TableCollection tc = dialog.bot().tree().selection();
    assertEquals("Wrong selection count", 1, tc.rowCount());
    assertTrue("Wrong item selected", tc.get(0, 0).startsWith(nodeTexts[1]));
    dialog.bot().button(UIText.CheckoutDialog_OkCheckout).click();
    TestUtil.joinJobs(JobFamilies.CHECKOUT);
}
Also used : TableCollection(org.eclipse.swtbot.swt.finder.utils.TableCollection) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 3 with TableCollection

use of org.eclipse.swtbot.swt.finder.utils.TableCollection in project egit by eclipse.

the class BranchAndResetActionTest method checkoutAndVerify.

private void checkoutAndVerify(String[] nodeTexts) throws IOException, Exception {
    SWTBotShell dialog = openCheckoutBranchDialog();
    TableCollection tc = dialog.bot().tree().selection();
    assertEquals("Wrong selection count", 0, tc.rowCount());
    TestUtil.navigateTo(dialog.bot().tree(), nodeTexts).select();
    tc = dialog.bot().tree().selection();
    assertEquals("Wrong selection count", 1, tc.rowCount());
    assertTrue("Wrong item selected", tc.get(0, 0).startsWith(nodeTexts[1]));
    Repository repo = lookupRepository(repositoryFile);
    dialog.bot().button(UIText.CheckoutDialog_OkCheckout).click();
    TestUtil.joinJobs(JobFamilies.CHECKOUT);
    if (ObjectId.isId(repo.getBranch())) {
        String mapped = Activator.getDefault().getRepositoryUtil().mapCommitToRef(repo, repo.getBranch(), false);
        assertEquals("Wrong branch", nodeTexts[1], mapped.substring(mapped.lastIndexOf('/') + 1));
    } else
        assertEquals("Wrong branch", nodeTexts[1], repo.getBranch());
}
Also used : Repository(org.eclipse.jgit.lib.Repository) TableCollection(org.eclipse.swtbot.swt.finder.utils.TableCollection) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 4 with TableCollection

use of org.eclipse.swtbot.swt.finder.utils.TableCollection in project eclipse-integration-commons by spring-projects.

the class SWTBotUtils method getSelection.

public static String getSelection(SWTBotTree tree) {
    TableCollection selections = tree.selection();
    String selection = "";
    for (int r = 0; r < selections.rowCount(); r++) {
        if (r > 0)
            selection += "\n";
        TableRow row = selections.get(r);
        for (int c = 0; c < row.columnCount(); c++) {
            if (c > 0)
                selection += " >> ";
            selection += row.get(c);
        }
    }
    return selection;
}
Also used : TableRow(org.eclipse.swtbot.swt.finder.utils.TableRow) TableCollection(org.eclipse.swtbot.swt.finder.utils.TableCollection)

Example 5 with TableCollection

use of org.eclipse.swtbot.swt.finder.utils.TableCollection in project egit by eclipse.

the class GitRepositoriesViewRepoHandlingTest method testShowIn.

@Test
public void testShowIn() throws Exception {
    clearView();
    deleteAllProjects();
    shareProjects(repositoryFile);
    refreshAndWait();
    assertProjectExistence(PROJ1, true);
    assertEmpty();
    getOrOpenView().show();
    SWTBotView view = TestUtil.showExplorerView();
    SWTBotTree explorerTree = view.bot().tree();
    SWTBotTreeItem projectItem = getProjectItem(explorerTree, PROJ1).select();
    ContextMenuHelper.clickContextMenuSync(explorerTree, "Show In", viewName);
    refreshAndWait();
    assertHasRepo(repositoryFile);
    SWTBotTree viewerTree = getOrOpenView().bot().tree();
    TableCollection selection = viewerTree.selection();
    assertEquals("Selection should contain one element: " + selection, 1, selection.rowCount());
    String nodeText = selection.get(0).get(0);
    assertTrue("Node text should contain project name", projectItem.getText().startsWith(nodeText));
    view.show();
    SWTBotTreeItem item = TestUtil.expandAndWait(projectItem);
    item = TestUtil.expandAndWait(item.getNode(FOLDER));
    item.getNode(FILE1).select();
    ContextMenuHelper.clickContextMenuSync(explorerTree, "Show In", viewName);
    selection = viewerTree.selection();
    assertTrue("Selection should contain one eelement", selection.rowCount() == 1);
    nodeText = selection.get(0).get(0);
    assertEquals("Node text should contain file name", FILE1, nodeText);
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TableCollection(org.eclipse.swtbot.swt.finder.utils.TableCollection) Test(org.junit.Test)

Aggregations

TableCollection (org.eclipse.swtbot.swt.finder.utils.TableCollection)6 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)4 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)3 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)3 Test (org.junit.Test)3 Repository (org.eclipse.jgit.lib.Repository)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 TableRow (org.eclipse.swtbot.swt.finder.utils.TableRow)1