/** Ensures that ExternalJavaActionCalls with unchecked precondition are not displayed. */
 public void testPopupMenuWithExternalJavaActionCallAndFalsePrecondition() {
   // When getting the contextual menu of
   // "Employee" Class -- "wage" attribute
   // The precondition value is false and the Java Action Call action
   // should
   // not be displayed
   boolean foundContextMenu = true;
   final SWTBotTreeItem node =
       editor
           .bot()
           .tree()
           .getTreeItem(TREE_ITEM_WITH_JAVA_ACTION_CONTAINER_NAME)
           .expand()
           .getNode(TREE_ITEM_WITH_JAVA_ACTION_NAME)
           .select();
   // The test must be passed in the exception, so we deactivated the catch
   // of
   // "error log" view
   setErrorCatchActive(false);
   try {
     node.contextMenu(JAVA_ACTION_CALL_NAME);
   } catch (TimeoutException e) {
     foundContextMenu = false;
   }
   assertFalse(
       "Java Action Call  "
           + JAVA_ACTION_CALL_NAME
           + " should not be displayed on TreeITem "
           + TREE_ITEM_WITH_JAVA_ACTION_NAME,
       foundContextMenu);
   setErrorCatchActive(true);
 }
  /**
   * Selects an entry in the given tree and optionally expands the selected entry. Takes care that
   * all attributes and child entries are initialized so that there are no pending background
   * actions and event notifications. This is necessary to avoid race conditions.
   *
   * @param bot the SWT bot
   * @param tree the given tree
   * @param expandChild true to expand the child entry
   * @param path the path to the entry
   * @return the selected entry as SWTBotTreeItem
   * @throws Exception the exception
   */
  public static SWTBotTreeItem selectEntry(
      final SWTWorkbenchBot bot,
      final SWTBotTree tree,
      final boolean expandChild,
      final String... path) {
    List<String> pathList = new ArrayList<String>(Arrays.asList(path));
    SWTBotTreeItem entry = null;

    while (!pathList.isEmpty()) {
      String currentPath = pathList.remove(0);

      if (entry == null) {
        currentPath = adjustNodeName(tree, currentPath);
        entry = tree.getTreeItem(currentPath);
      } else {
        // adjust current path, because the label is decorated with the
        // number of children
        currentPath = adjustNodeName(entry, currentPath);
        entry = entry.getNode(currentPath);
      }
      entry.click();

      if (!pathList.isEmpty() || expandChild) {
        // expand entry and wait till
        // - children are displayed
        // - next child is visible
        final String nextName = !pathList.isEmpty() ? pathList.get(0) : null;
        expandEntry(bot, entry, nextName);
      }

      entry.select();
    }
    return entry;
  }
  @Test
  @Ignore // workspace model dosn't show non-workspace files ... yet ;)
  public void shouldShowCompareEditorForNonWorkspaceFileFromSynchronization() throws Exception {
    // given
    String content = "file content";
    String name = "non-workspace.txt";
    File root = new File(getTestDirectory(), REPO1);
    File nonWorkspace = new File(root, name);
    BufferedWriter writer = new BufferedWriter(new FileWriter(nonWorkspace));
    writer.append(content);
    writer.close();

    // when
    launchSynchronization(INITIAL_TAG, HEAD, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem workingTree = syncViewTree.expandNode(PROJ1);
    assertEquals(1, syncViewTree.getAllItems().length);
    workingTree.expand().getNode(name).doubleClick();

    SWTBotEditor editor = bot.editorByTitle(name);
    editor.setFocus();

    // the WidgetNotFoundException will be thrown when widget with given content cannot be not found
    SWTBotStyledText left = editor.bot().styledText(content);
    SWTBotStyledText right = editor.bot().styledText("");
    // to be complete sure assert that both sides are not the same
    assertNotSame(left, right);
  }
  @Test
  public void shouldNotShowIgnoredFiles() throws Exception {
    // given
    resetRepositoryToCreateInitialTag();
    String ignoredName = "to-be-ignored.txt";

    IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);

    IFile ignoredFile = proj.getFile(ignoredName);
    ignoredFile.create(
        new ByteArrayInputStream("content of ignored file".getBytes(proj.getDefaultCharset())),
        false,
        null);

    IFile gitignore = proj.getFile(".gitignore");
    gitignore.create(
        new ByteArrayInputStream(ignoredName.getBytes(proj.getDefaultCharset())), false, null);
    proj.refreshLocal(IResource.DEPTH_INFINITE, null);

    // when
    launchSynchronization(INITIAL_TAG, HEAD, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem projectTree = waitForNodeWithText(syncViewTree, PROJ1);
    projectTree.expand();
    assertEquals(1, projectTree.getItems().length);
  }
Ejemplo n.º 5
0
 /**
  * First level should have 5 children
  *
  * @throws Exception
  */
 @Test
 public void testExpandFirstLevel() throws Exception {
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile).expand();
   SWTBotTreeItem[] children = item.getItems();
   assertEquals("Wrong number of children", 5, children.length);
 }
  @After
  public void canDeleteEWSApp() {
    SWTBotView openshiftExplorer = open.viewOpen(OpenShiftUI.Explorer.iView);

    SWTBotTreeItem account =
        openshiftExplorer.bot().tree().getAllItems()[0].doubleClick(); // expand account

    bot.waitWhile(new NonSystemJobRunsCondition(), TIME_60S * 2, TIME_1S);

    account
        .getNode(EWS_APP_NAME + " " + OpenShiftUI.AppType.JBOSS_EWS)
        .contextMenu(OpenShiftUI.Labels.EXPLORER_DELETE_APP)
        .click();

    bot.waitForShell(OpenShiftUI.Shell.DELETE_APP);

    bot.button(IDELabel.Button.OK).click();
    bot.waitWhile(new NonSystemJobRunsCondition(), TIME_60S * 2, TIME_1S);

    assertTrue(
        "Application still present in the OpenShift Explorer!", account.getItems().length == 0);

    projectExplorer.show();
    projectExplorer.deleteAllProjects();

    assertFalse("The project still exists!", bot.tree().getAllItems().length > 0);

    servers.show();
    servers.deleteServer(EWS_APP_NAME + " at OpenShift");
  }
 /** Ensures that PopupMenu is not created if its precondition is not checked. */
 public void testPopupMenuWithFalsePrecondition() {
   // When getting the contextual menu of
   // "NamedEntity" Class -- "wrongFeature" attribute
   // The precondition value is false and the Pop-up Menu should
   // not be displayed
   boolean foundContextMenu = true;
   SWTBotTreeItem unaplicableNode =
       editor
           .bot()
           .tree()
           .getTreeItem(TREE_ITEM_WITH_UNAPLICABLE_POPUP_CONTAINER_NAME)
           .expand()
           .getNode(TREE_ITEM_WITH_UNAPLICABLE_POPUP_NAME);
   try {
     unaplicableNode.contextMenu(POP_UP_MENU_NAME);
   } catch (TimeoutException e) {
     foundContextMenu = false;
   }
   assertFalse(
       "Pop-up Menu "
           + POP_UP_MENU_NAME
           + " should not be displayed on TreeITem "
           + TREE_ITEM_WITH_UNAPLICABLE_POPUP_NAME,
       foundContextMenu);
 }
  private SWTBotTreeItem getEntry(String ViewTitle, String... path) throws Exception {

    SWTBotTree browserTree = getTree(ViewTitle);
    List<String> pathList = new ArrayList<String>(Arrays.asList(path));
    SWTBotTreeItem entry = null;

    while (!pathList.isEmpty()) {
      String node = pathList.remove(0);

      if (entry == null) {
        node = adjustNodeName(browserTree, node);
        entry = browserTree.getTreeItem(node);
      } else {
        // adjust current path, because the label is decorated with the
        // number of children
        node = adjustNodeName(entry, node);
        entry = entry.getNode(node);
      }

      if (!pathList.isEmpty()) {
        // expand entry and wait till
        // - children are displayed
        // - next child is visible
        final String nextNode = !pathList.isEmpty() ? pathList.get(0) : null;
        expand(entry, true, nextNode);
      }
    }

    return entry;
  }
  public void testCancelTagLibDefenition() {
    openPage();
    openPalette();
    // Test open import dialog
    bot.viewByTitle(ActionItem.View.GeneralPalette.LABEL.getName()).setFocus(); // $NON-NLS-1$
    new PaletteView().getToolbarButtonWitTooltip("Import").click();
    bot.shell("Import Tags from TLD File").activate(); // $NON-NLS-1$

    // Test open edit TLD dialog

    bot.button("Browse...").click(); // $NON-NLS-1$
    bot.shell("Edit TLD").activate(); // $NON-NLS-1$
    delay();
    // Test cancel TLD
    SWTBotTree tree = bot.tree();
    delay();
    SWTBotTreeItem item = tree.expandNode(JBT_TEST_PROJECT_NAME);
    delay();
    item.getNode("html_basic.tld [h]").select(); // $NON-NLS-1$ //$NON-NLS-2$
    delay();
    bot.button("Cancel").click(); // $NON-NLS-1$

    // Test check fields

    bot.shell("Import Tags from TLD File").activate(); // $NON-NLS-1$
    assertEquals("", bot.textWithLabel("TLD File:*").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("", bot.textWithLabel("Name:*").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("", bot.textWithLabel("Default Prefix:").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("", bot.textWithLabel("Library URI:").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    bot.button("Cancel").click(); // $NON-NLS-1$
  }
Ejemplo n.º 10
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.º 11
0
  public void confirmShellShareProjectFiles(String project, String[] files, JID[] jids) {
    SWTBot bot = new SWTBot();
    SWTBotShell shell = bot.shell(SHELL_SHARE_PROJECT);
    shell.activate();

    // wait for tree update
    bot.sleep(500);

    SWTBotTree tree = shell.bot().tree();

    selectProjectFiles(tree, project, files);

    shell.bot().button(NEXT).click();

    // wait for tree update
    bot.sleep(500);

    tree = shell.bot().tree();

    for (SWTBotTreeItem item : tree.getAllItems()) while (item.isChecked()) item.uncheck();

    for (JID jid : jids)
      WidgetUtil.getTreeItemWithRegex(tree, Pattern.quote(jid.getBase()) + ".*").check();

    shell.bot().button(FINISH).click();
    bot.waitUntil(Conditions.shellCloses(shell));
  }
 private SWTBotTreeItem getProjectTreeItem(SWTBotTree projectsTree, String projectName) {
   for (SWTBotTreeItem item : projectsTree.getAllItems()) {
     if (projectName.equals(getProjectLabel(item.getText()))) {
       return item;
     }
   }
   throw new IllegalStateException("Project " + projectName + " not available");
 }
  private void testFetchFromOrigin(boolean useRemote) throws Exception {

    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile);
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile2);

    Repository repository = lookupRepository(clonedRepositoryFile2);
    // add the configuration for push from cloned2
    repository.getConfig().setString("remote", "origin", "push", "refs/heads/*:refs/heads/*");
    repository.getConfig().save();

    SWTBotTree tree = getOrOpenView().bot().tree();

    String destinationString = clonedRepositoryFile.getParentFile().getName() + " - " + "origin";
    String dialogTitle = NLS.bind(UIText.FetchResultDialog_title, destinationString);

    selectNode(tree, useRemote, true);
    runFetch(tree);

    SWTBotShell confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
    confirm.close();

    deleteAllProjects();
    shareProjects(clonedRepositoryFile2);
    String objid = repository.getRef("refs/heads/master").getTarget().getObjectId().name();
    objid = objid.substring(0, 7);
    touchAndSubmit(null);
    // push from other repository
    PushOperationUI op = new PushOperationUI(repository, "origin", false);
    op.start();

    String pushdialogTitle = NLS.bind(UIText.PushResultDialog_title, op.getDestinationString());

    bot.shell(pushdialogTitle).close();

    deleteAllProjects();

    refreshAndWait();

    selectNode(tree, useRemote, true);
    runFetch(tree);

    confirm = bot.shell(dialogTitle);
    SWTBotTreeItem[] treeItems = confirm.bot().tree().getAllItems();
    boolean found = false;
    for (SWTBotTreeItem item : treeItems) {
      found = item.getText().contains(objid);
      if (found) break;
    }
    assertTrue(found);
    confirm.close();

    selectNode(tree, useRemote, true);
    runFetch(tree);

    confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
  }
Ejemplo n.º 14
0
 /**
  * Checks for the Symbolic Reference node
  *
  * @throws Exception
  */
 @Test
 public void testExpandSymbolicRef() throws Exception {
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getSymbolicRefsItem(tree, repositoryFile).expand();
   List<String> children = item.getNodes();
   boolean found = false;
   for (String child : children) if (child.contains(Constants.HEAD)) found = true;
   assertTrue(found);
 }
Ejemplo n.º 15
0
 private SWTBotTreeItem selectInProjectExplorer(String path) {
   final SWTBotTree wizardTree = viewByTitle(UIConstants.PACKAGE_EXPLORER_VIEW_NAME).bot().tree();
   final String[] split = path.split("/");
   SWTBotTreeItem treeItem = wizardTree.expandNode(split[0]).select();
   for (int i = 1; i < split.length; i++) {
     treeItem = treeItem.expandNode(split[i]).select();
   }
   return treeItem;
 }
Ejemplo n.º 16
0
 /**
  * Select the object <code>next</code> as a subnode of the <code>currentNode</code>.
  *
  * @param currentNode the currentNode
  * @param next the subnode to select
  * @return the selected node
  */
 private SWTBotTreeItem selectSubNode(SWTBotTreeItem currentNode, Object next) {
   final AdapterFactory adapterFactory = EEFRuntimePlugin.getDefault().getAdapterFactory();
   final IItemLabelProvider labelProvider =
       (IItemLabelProvider) adapterFactory.adapt(next, IItemLabelProvider.class);
   final String text = labelProvider.getText(next);
   final SWTBotTreeItem node2 = currentNode.getNode(text);
   node2.select();
   return node2;
 }
  private void selectProjects() {
    selectCopyProjectsIntoWorkspace();
    getBot().button("Deselect All").click();
    SWTBotTree projectsTree = getProjectsTree();

    for (String projectName : projectNames) {
      SWTBotTreeItem projectItem = getProjectTreeItem(projectsTree, projectName);
      projectItem.check();
    }
  }
Ejemplo n.º 18
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 static String adjustNodeName(SWTBotTree tree, String nodeName) {
   SWTBotTreeItem[] allItems = tree.getAllItems();
   for (SWTBotTreeItem item : allItems) {
     String node = item.getText();
     if (node.toUpperCase().startsWith(nodeName.toUpperCase())) {
       return node;
     }
   }
   return null;
 }
Ejemplo n.º 20
0
 @Override
 public boolean test() throws Exception {
   fParentItem.expand();
   for (SWTBotTreeItem item : fParentItem.getItems()) {
     if (item.getText().matches(fRegex)) {
       fItem = item;
       return true;
     }
   }
   return false;
 }
  /** Import a gzip trace */
  @Test
  public void testGzipImport() {
    final String traceType = "Test trace : TMF Tests";
    final String tracesNode = "Traces [1]";

    /*
     * Actual importing
     */
    openImportWizard();
    selectImportFromArchive(fGzipTrace.getAbsolutePath());
    selectFolder(ROOT_FOLDER);
    SWTBotCheckBox checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace);
    assertFalse(checkBox.isEnabled());
    SWTBotCombo comboBox = fBot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType);
    comboBox.setSelection(traceType);
    importFinish();
    /*
     * Remove .gz extension
     */
    assertNotNull(fGzipTrace);
    String name = fGzipTrace.getName();
    assertNotNull(name);
    assertTrue(name.length() > 3);
    String traceName = name.substring(0, name.length() - 3);
    assertNotNull(traceName);
    assertFalse(traceName.isEmpty());

    /*
     * Open trace
     */
    SWTBotView projectExplorer = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectExplorer.setFocus();
    final SWTBotTree tree = projectExplorer.bot().tree();
    /*
     * This appears to be problematic due to the length of the file name and
     * the resolution in our CI.
     */
    tree.expandNode(PROJECT_NAME, true);
    SWTBotTreeItem treeItem = tree.getTreeItem(PROJECT_NAME);
    fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(tracesNode, treeItem));
    treeItem = treeItem.getNode(tracesNode);
    fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(traceName, treeItem));
    treeItem = treeItem.getNode(traceName);
    treeItem.doubleClick();
    SWTBotUtils.waitForJobs();
    /*
     * Check results
     */
    SWTBotTable editor = fBot.activeEditor().bot().table();
    String c22 = editor.cell(2, 2);
    String c10 = editor.cell(1, 0);
    assertEquals("Type-1", c22);
    assertEquals("", c10);
  }
 private void findSelectEnterpriseRuntimeLibrary(SWTBotExt bot) throws Exception {
   SWTBotTree libraryTree = bot.tree(1);
   boolean libraryFound = false;
   for (SWTBotTreeItem libraryItem : libraryTree.getAllItems()) {
     if (libraryItem.getText().contains("JBoss Enterprise Application Platform")) {
       libraryTree.select(libraryItem);
       libraryFound = true;
       break;
     }
   }
   if (!libraryFound) throw new RuntimeException("No runtime library has been found");
 }
Ejemplo n.º 23
0
  private void selectProjectFiles(SWTBotTree tree, String project, String[] files) {
    for (SWTBotTreeItem item : tree.getAllItems()) while (item.isChecked()) item.uncheck();

    for (String file : files) {
      String[] nodes = file.split("/|\\\\");
      List<String> regex = new ArrayList<String>(nodes.length + 1);
      regex.add(Pattern.quote(project));

      for (String node : nodes) regex.add(Pattern.quote(node));

      WidgetUtil.getTreeItemWithRegex(tree, regex.toArray(new String[0])).check();
    }
  }
Ejemplo n.º 24
0
 /**
  * Select the given element in the given editor.
  *
  * @param editor the editor where the bot must process
  * @param element the element to select
  * @return the selected node
  */
 public SWTBotTreeItem selectNode(SWTBotTree tree, EObject element) {
   assertNotNull("The model has not been initialized.", testModelResource);
   final List<Object> expansionPath = EEFModelHelper.getExpansionPath(element);
   final Iterator<Object> iterator = expansionPath.iterator();
   Object next = null;
   SWTBotTreeItem node2 = tree.getTreeItem(testModelResource.getURI().toString());
   while (iterator.hasNext()) {
     node2.expand();
     next = iterator.next();
     node2 = selectSubNode(node2, next);
   }
   return node2;
 }
Ejemplo n.º 25
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);
 }
Ejemplo n.º 26
0
 /**
  * Open (expand, file->editor, branch->checkout)
  *
  * @throws Exception
  */
 @Test
 public void testOpen() throws Exception {
   // expand first level
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   item.collapse();
   refreshAndWait();
   item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   assertTrue("Item should not be expanded", !item.isExpanded());
   item.doubleClick();
   assertTrue("Item should be expanded", item.isExpanded());
   // open a file in editor
   item = myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand();
   SWTBotTreeItem fileiItem =
       item.getNode(PROJ1).expand().getNode(FOLDER).expand().getNode(FILE1).select();
   fileiItem.doubleClick();
   assertTrue(bot.activeEditor().getTitle().equals(FILE1));
   bot.activeEditor().close();
   // open a branch (checkout)
   checkoutWithDoubleClick(tree, "master");
   String contentMaster = getTestFileContent();
   checkoutWithDoubleClick(tree, "stable");
   TestUtil.joinJobs(JobFamilies.CHECKOUT);
   String contentStable = getTestFileContent();
   assertNotEquals("Content of master and stable should differ", contentMaster, contentStable);
 }
  @Test
  public void connectDBTest() {

    openPerspective("Hibernate");

    bot.viewByTitle("Hibernate Configurations").setFocus();
    bot.viewByTitle("Hibernate Configurations").show();

    SWTBot viewBot = bot.viewByTitle("Hibernate Configurations").bot();
    SWTBotTreeItem item =
        TreeHelper.expandNode(
            viewBot, Properties.SEAM_PROJECT_NAME, "Database", "ModeShape.ModeShape");
    item.select();
    assertTrue("Could not find node with text:" + item.getText(), item.isVisible());
  }
Ejemplo n.º 28
0
 /**
  * Checks is some context menus are available, should be replaced with real tests
  *
  * @throws Exception
  */
 @Test
 public void testContextMenuRepository() throws Exception {
   // We just check if the dialogs open, the actual commit and import projects
   // is tested elsewhere
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   item.select();
   assertClickOpens(
       tree,
       myUtil.getPluginLocalizedValue("RepoViewCommit.label"),
       UIText.CommitDialog_CommitChanges);
   assertClickOpens(
       tree,
       myUtil.getPluginLocalizedValue("RepoViewImportProjects.label"),
       NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile));
 }
  /**
   * Remove Project from all Servers
   *
   * @param projectName
   * @param stringToContain
   */
  public void removeProjectFromServers(String projectName, String stringToContain) {

    eclipse.showView(ViewType.SERVERS);

    delay();

    try {
      SWTBotTree serverTree = bot.viewByTitle(IDELabel.View.SERVERS).bot().tree();

      delay();

      // Expand All
      for (SWTBotTreeItem serverTreeItem : serverTree.getAllItems()) {
        serverTreeItem.expand();
        // if JSF Test Project is deployed to server remove it
        SWTBotTreeItem[] serverTreeItemChildren = serverTreeItem.getItems();
        if (serverTreeItemChildren != null && serverTreeItemChildren.length > 0) {
          int itemIndex = 0;
          boolean found = false;
          String treeItemlabel = null;
          do {
            treeItemlabel = serverTreeItemChildren[itemIndex].getText();
            found =
                treeItemlabel.startsWith(projectName)
                    && (stringToContain == null || treeItemlabel.indexOf(stringToContain) >= 0);
          } while (!found && ++itemIndex < serverTreeItemChildren.length);
          // Server Tree Item has Child with Text equal to JSF TEst Project
          if (found) {
            log.info("Found project to be removed from server: " + treeItemlabel);
            ContextMenuHelper.prepareTreeItemForContextMenu(
                serverTree, serverTreeItemChildren[itemIndex]);
            new SWTBotMenu(
                    ContextMenuHelper.getContextMenu(serverTree, IDELabel.Menu.REMOVE, false))
                .click();
            bot.shell("Server").activate();
            bot.button(IDELabel.Button.OK).click();
            log.info("Removed project from server: " + treeItemlabel);
            bot.sleep(10 * 1000L);
          }
        }
      }
      delay();

    } catch (WidgetNotFoundException wnfe) {
      // do nothing it means there is no server defined
    }
  }
 private static String adjustNodeName(SWTBotTreeItem child, String nodeName) {
   List<String> nodes = child.getNodes();
   for (String node : nodes) {
     if (node.toUpperCase().startsWith(nodeName.toUpperCase())) {
       return node;
     }
   }
   return null;
 }