Package org.eclipse.swtbot.swt.finder.widgets

Examples of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem


        bot.button("Next >").click();
        bot.textWithLabel("Project name:").setText(projectName);
        bot.button("Finish").click();
        SWTUtils.sleep(2000);
        SWTBotTree projectsTree = bot.viewByTitle("Project Explorer").bot().tree();
        SWTBotTreeItem projectTree = projectsTree.getTreeItem(projectName);
        return new ProjectBot(projectTree);
    }
View Full Code Here


        SWTBotShell shell = bot.shell("New File");
        shell.activate();
        bot.textWithLabel("File name:").setText(fileName);
        bot.button("Finish").click();
        SWTUtils.sleep(2000);
        SWTBotTreeItem treeItem = projectTree.getNode(fileName);
        return new ProjectFileBot(treeItem);
    }
View Full Code Here

  public void testDeleteSingleBranch() throws Exception {
    // expand first level
    SWTBotTree tree = getOrOpenView().bot().tree();
    refreshAndWait();
    // create a branch (no checkout)
    SWTBotTreeItem localBranchesItem = myRepoViewUtil.getLocalBranchesItem(
        tree, repositoryFile).expand();
    SWTBotTreeItem masterNode = localBranchesItem.getNode("master");
    masterNode.select();
    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("RepoViewCreateBranch.label"));
    SWTBotShell createBranchShell = bot
        .shell(UIText.CreateBranchWizard_NewBranchTitle);
    createBranchShell.bot().textWithId("BranchName").setText("abc");
View Full Code Here

  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()
View Full Code Here

    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));
  }
View Full Code Here

  @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));
  }
View Full Code Here

        myUtil.getPluginLocalizedValue("LinkWithSelectionCommand"))
        .click();
  }

  private SWTBotTreeItem findWorkdirNode(SWTBotTree tree, String... nodes) throws Exception {
    SWTBotTreeItem item = myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand();
    for (String node : nodes)
      item = item.getNode(node).expand();
    return item;
  }
View Full Code Here

  @Test
  public void testExpandRemotes() throws Exception {
    removeRemotesConfig(repositoryFile);
    refreshAndWait();
    SWTBotTree tree = getOrOpenView().bot().tree();
    SWTBotTreeItem remotesItem = myRepoViewUtil.getRemotesItem(tree,
        repositoryFile).expand();
    assertEquals("Wrong number of remotes", 0, remotesItem.getNodes()
        .size());
    StoredConfig cfg = lookupRepository(repositoryFile).getConfig();
    String remoteUri = "file:///" + remoteRepositoryFile.getPath();

    cfg.setString("remote", "test", "url", remoteUri);
    cfg.setString("remote", "test", "fetch", "somejunk");
    cfg.setString("remote", "test2", "url", remoteUri);
    cfg.setString("remote", "test2", "fetch", "somejunk");
    cfg.setString("remote", "test2", "pushurl", remoteUri);
    cfg.setString("remote", "test2", "push", "somejunk");
    cfg.setString("remote", "test3", "pushurl", "somejunk");
    cfg.setString("remote", "test3", "push", "somejunk");
    cfg.save();
    cfg.load();
    refreshAndWait();
    remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile)
        .expand();
    assertEquals("Wrong number of remotes", 3, remotesItem.getNodes()
        .size());

    remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile)
        .expand();
    List<String> testnodes = remotesItem.getNode("test").expand()
        .getNodes();
    assertEquals(2, testnodes.size());
    List<String> test2nodes = remotesItem.getNode("test2").expand()
        .getNodes();
    assertEquals(2, test2nodes.size());
    // error node should be shown
    remotesItem.getNode("test3").expand().getNodes();
    assertEquals(1, remotesItem.getNode("test3").expand().getNodes().size());

    // test the properties view on remote
    remotesItem.getNode("test").select();
    ContextMenuHelper.clickContextMenuSync(tree,
        myUtil.getPluginLocalizedValue("ShowIn"),
        "Properties");
    waitInUI();
    assertEquals("org.eclipse.ui.views.PropertySheet", bot.activeView()
        .getReference().getId());

    removeRemotesConfig(repositoryFile);
    refreshAndWait();
    remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile)
        .expand();
    assertEquals("Wrong number of remotes", 0, remotesItem.getNodes()
        .size());
  }
View Full Code Here

  @Test
  public void testConfigureRemote() throws Exception {
    removeRemotesConfig(repositoryFile);
    refreshAndWait();
    SWTBotTree tree = getOrOpenView().bot().tree();
    SWTBotTreeItem remotesItem = myRepoViewUtil.getRemotesItem(tree,
        repositoryFile).expand();

    remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile)
        .expand();
    remotesItem.select();
    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("NewRemoteCommand"));
    SWTBotShell shell = bot.shell(UIText.NewRemoteDialog_WindowTitle);
    shell.bot().textWithLabel(UIText.NewRemoteDialog_NameLabel).setText(
        "testRemote");
    // configure fetch first
    shell.bot().radio(UIText.NewRemoteDialog_FetchRadio).click();
    shell.bot().button(IDialogConstants.OK_LABEL).click();

    // configure fetch dialog
    shell = bot.shell(UIText.SimpleConfigureFetchDialog_WindowTitle);
    // change uri
    shell.bot().button(UIText.SimpleConfigureFetchDialog_ChangeUriButton)
        .click();
    shell = bot.shell(UIText.SelectUriWiazrd_Title);
    shell.bot().text().setText("file:///" + remoteRepositoryFile.getPath());
    shell.bot().button(IDialogConstants.FINISH_LABEL).click();
    // now we have the fetch URI
    // back to dialog
    shell = bot.shell(UIText.SimpleConfigureFetchDialog_WindowTitle);
    shell.bot().button(UIText.SimpleConfigureFetchDialog_AddRefSpecButton)
        .click();
    shell = bot.shell(UIText.SimpleFetchRefSpecWizard_WizardTitle);
    shell.bot().textWithLabel(UIText.FetchSourcePage_SourceLabel).setText(
        "refs/heads/*");
    shell.bot().button(IDialogConstants.NEXT_LABEL).click();
    shell.bot().textWithLabel(UIText.FetchDestinationPage_DestinationLabel)
        .setText("refs/remotes/testRemote/*");
    shell.bot().button(IDialogConstants.FINISH_LABEL).click();
    // back to dialog
    shell = bot.shell(UIText.SimpleConfigureFetchDialog_WindowTitle);
    // save
    shell.bot().button(UIText.SimpleConfigureFetchDialog_SaveButton)
        .click();

    refreshAndWait();
    // assert 1 children
    SWTBotTreeItem item = myRepoViewUtil.getRemotesItem(tree,
        repositoryFile).expand().getNode("testRemote").expand();
    List<String> children = item.getNodes();
    assertEquals(2, children.size());
    item.select();
    // now we add push
    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("ConfigurePushCommand"));

    shell = bot.shell(UIText.SimpleConfigurePushDialog_WindowTitle);
    shell.bot()
        .button(UIText.SimpleConfigurePushDialog_AddRefSpecButton, 1)
        .click();

    // add push spec
    shell = bot.shell(UIText.RefSpecDialog_WindowTitle);

    shell.bot().textWithLabel(UIText.RefSpecDialog_SourceBranchPushLabel)
        .setText("HEAD");
    shell.bot().textWithLabel(UIText.RefSpecDialog_DestinationPushLabel)
        .setText("refs/for/master");
    final Text text = shell.bot().textWithLabel(
        UIText.RefSpecDialog_DestinationPushLabel).widget;
    shell.display.syncExec(new Runnable() {

      public void run() {
        text.setFocus();
        text.notifyListeners(SWT.Modify, new Event());
      }
    });
    shell.bot().button(IDialogConstants.OK_LABEL).click();
    shell = bot.shell(UIText.SimpleConfigurePushDialog_WindowTitle);
    shell.bot().button(UIText.SimpleConfigurePushDialog_SaveButton).click();

    refreshAndWait();
    // assert 2 children
    item = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand()
        .getNode("testRemote").expand();
    children = item.getNodes();
    assertEquals(2, children.size());
    item.getNode(0).select();
    // we remove the fetch, the URI is copied into push
    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("RemoveFetchCommand"));
    refreshAndWait();
    // assert 1 children
    item = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand()
        .getNode("testRemote").expand();
    children = item.getNodes();
    assertEquals(1, children.size());
    item.getNode(0).select();
    // now we also remove the push
    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("RemovePushCommand"));
    refreshAndWait();
    // assert 0 children
    item = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand()
        .getNode("testRemote").expand();
    children = item.getNodes();
    assertEquals(0, children.size());

    myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand().getNode(
        "testRemote").select();

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

    String shellText = UIText.SimpleConfigureFetchDialog_WindowTitle;
    shell = bot.shell(shellText);
    // change uri
    shell.bot().button(UIText.SimpleConfigureFetchDialog_ChangeUriButton)
        .click();
    shell = bot.shell(UIText.SelectUriWiazrd_Title);
    shell.bot().text().setText("file:///" + remoteRepositoryFile.getPath());
    shell.bot().button(IDialogConstants.FINISH_LABEL).click();
    // back to dialog
    shell = bot.shell(shellText);
    // add refSpec
    shell.bot().button(UIText.SimpleConfigureFetchDialog_AddRefSpecButton)
        .click();
    shell = bot.shell(UIText.SimpleFetchRefSpecWizard_WizardTitle);
    shell.bot().textWithLabel(UIText.FetchSourcePage_SourceLabel).setText(
        "refs/heads/*");
    shell.bot().button(IDialogConstants.NEXT_LABEL).click();
    shell.bot().textWithLabel(UIText.FetchDestinationPage_DestinationLabel)
        .setText("refs/remotes/testRemote/*");
    shell.bot().button(IDialogConstants.FINISH_LABEL).click();
    // back to dialog
    shell = bot.shell(shellText);
    // save
    shell.bot().button(UIText.SimpleConfigureFetchDialog_SaveButton)
        .click();
    refreshAndWait();
    // assert 1 children
    item = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand()
        .getNode("testRemote").expand();
    children = item.getNodes();
    assertEquals(2, children.size());

    // we remove the fetch again
    item = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand()
        .getNode("testRemote").expand();
    children = item.getNodes();
    assertEquals(2, children.size());
    item.getNode(0).select();
    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("RemoveFetchCommand"));
    refreshAndWait();

    myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand().getNode(
        "testRemote").select();

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

    shellText = UIText.SimpleConfigurePushDialog_WindowTitle;
    shell = bot.shell(shellText);
    shell.bot().button(UIText.SimpleConfigurePushDialog_AddPushUriButton)
        .click();

    // back to dialog
    shell = bot.shell(shellText);
    shell = bot.shell(UIText.SelectUriWiazrd_Title);
    shell.bot().text().setText("file:///" + remoteRepositoryFile.getPath());
    shell.bot().button(IDialogConstants.FINISH_LABEL).click();
    shell = bot.shell(shellText);
    // Add is on two buttons
    shell.bot()
        .button(UIText.SimpleConfigurePushDialog_AddRefSpecButton, 1)
        .click();
    // add push spec
    shell = bot.shell(UIText.RefSpecDialog_WindowTitle);

    shell.bot().textWithLabel(UIText.RefSpecDialog_SourceBranchPushLabel)
        .setText("HEAD");
    shell.bot().textWithLabel(UIText.RefSpecDialog_DestinationPushLabel)
        .setText("refs/for/master");
    final Text text2 = shell.bot().textWithLabel(
        UIText.RefSpecDialog_DestinationPushLabel).widget;
    shell.display.syncExec(new Runnable() {

      public void run() {
        // focus for update of other fields
        text2.setFocus();
        text2.notifyListeners(SWT.Modify, new Event());
      }
    });

    shell.bot().button(IDialogConstants.OK_LABEL).click();

    // back to dialog
    shell = bot.shell(shellText);
    shell.bot().button(UIText.SimpleConfigurePushDialog_SaveButton).click();
    refreshAndWait();
    // assert 2 children
    item = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand()
        .getNode("testRemote").expand();
    children = item.getNodes();
    assertEquals(1, children.size());
    item.select();
    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("RepoViewRemoveRemote.label"));
    shell = bot.shell(UIText.RepositoriesView_ConfirmDeleteRemoteHeader);
    // Cancel
    shell.bot().button(IDialogConstants.CANCEL_LABEL).click();

    refreshAndWait();
    // assert 2 children
    item = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand()
        .getNode("testRemote").expand();
    children = item.getNodes();
    assertEquals(1, children.size());

    ContextMenuHelper.clickContextMenu(tree, myUtil
        .getPluginLocalizedValue("RepoViewRemoveRemote.label"));
    // OK
View Full Code Here

  }

  @Test
  public void testCreateCheckoutDeleteLocalBranch() throws Exception {
    final SWTBotView view = getOrOpenView();
    SWTBotTreeItem localItem = myRepoViewUtil.getLocalBranchesItem(view
        .bot().tree(), repositoryFile);
    localItem.expand();
    assertEquals("Wrong number of children", 1, localItem.getNodes().size());

    assertEquals("master", localItem.getNodes().get(0));
    localItem.getNode(0).select();

    ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil
        .getPluginLocalizedValue("CreateBranchCommand"));

    SWTBotShell createPage = bot
        .shell(UIText.CreateBranchWizard_NewBranchTitle);
    createPage.activate();
    // getting text with label doesn't work
    createPage.bot().textWithId("BranchName").setText("newLocal");
    createPage.bot().checkBox(UIText.CreateBranchPage_CheckoutButton)
        .deselect();
    createPage.bot().button(IDialogConstants.FINISH_LABEL).click();
    refreshAndWait();

    localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(),
        repositoryFile);
    localItem.expand();
    assertEquals("Wrong number of children", 2, localItem.getNodes().size());

    localItem.getNode(0).select();
    assertCheckoutNotAvailable(view);
    localItem.getNode(1).select();
    ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil
        .getPluginLocalizedValue("CheckoutCommand"));
    TestUtil.joinJobs(JobFamilies.CHECKOUT);

    assertCheckoutNotAvailable(view);

    localItem.getNode(0).select();
    ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil
        .getPluginLocalizedValue("CheckoutCommand"));
    TestUtil.joinJobs(JobFamilies.CHECKOUT);
    localItem.getNode(1).select();
    refreshAndWait();
    ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil
        .getPluginLocalizedValue("RepoViewDeleteBranch.label"));
    refreshAndWait();
    localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(),
        repositoryFile);
    localItem.expand();
    assertEquals("Wrong number of children", 1, localItem.getNodes().size());
  }
View Full Code Here

TOP

Related Classes of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.