コード例 #1
0
  /**
   * 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;
  }
コード例 #2
0
  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;
  }
 @Test
 public void testPropertiesContextMenu() throws Exception {
   openDialog();
   // use index 1 since first tree is property page navigation tree
   SWTBotTree tree = mBot.tree(1);
   ContextMenuHelper.clickContextMenu(tree, "Add");
   new NewPropertyInputDialogTestFixture("keyx", "valuex").inputData();
   ContextMenuHelper.clickContextMenu(tree, "Add");
   new NewPropertyInputDialogTestFixture("keyz", "valuez").inputData();
   tree.getTreeItem("keyz").select();
   ContextMenuHelper.clickContextMenu(tree, "Delete");
   tree.unselect();
   // delete should not show up when the selection is empty
   assertThat(SWTTestUtil.getMenuItems(tree).get("Delete"), nullValue());
   mBot.button("OK").click();
   Thread.sleep(WAIT_TIME);
   AbstractUIRunner.syncRun(
       new ThrowableRunnable() {
         @Override
         public void run() throws Throwable {
           assertDeployedStrategy(
               mStrategy,
               mEngine,
               StrategyState.STOPPED,
               "Strategy1",
               "Claz",
               "Lang",
               "c:\\path",
               true,
               ImmutableMap.of("keyx", "valuex"));
         }
       });
 }
コード例 #4
0
ファイル: SuperBot.java プロジェクト: raimis55/saros
  @Override
  public void confirmShellShareProjects(String[] projectNames, JID... jids) throws RemoteException {

    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();

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

    for (String projectName : projectNames) tree.getTreeItem(projectName).check();

    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));
  }
コード例 #5
0
ファイル: ErlangSWTBotTest.java プロジェクト: jakobc/erlide
 protected static boolean isProjectCreated(final String name) {
   try {
     final SWTBotView packageExplorer = getNavigator();
     final SWTBotTree tree = packageExplorer.bot().tree();
     tree.getTreeItem(name);
     return true;
   } catch (final WidgetNotFoundException e) {
     return false;
   }
 }
コード例 #6
0
  /** 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);
  }
コード例 #7
0
 @Test
 // (Test Cases for 1.8) test case 5
 public void testInvalidCacheSizeOKToLeave() throws Exception {
   Utility.createProject(Messages.projCache);
   SWTBotShell propShell = Utility.selCacheUsingCnxtMenu(Messages.projCache, Messages.role1);
   wabot.checkBox().select();
   /*
    * To avoid missing storage account error,
    * type some value. Requires typeText only.
    */
   wabot.textWithLabel(Messages.keyLbl).typeText("a");
   wabot.textWithLabel(Messages.nameLbl).typeText("a");
   // Cache size = 0
   wabot.textWithLabel(Messages.cachScaleLbl).setText("");
   wabot.textWithLabel(Messages.cachScaleLbl).typeText("0");
   SWTBotTree properties = propShell.bot().tree();
   properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select();
   SWTBotShell errorShell =
       wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate();
   Boolean zeroErr =
       errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " "));
   wabot.button("OK").click();
   // Cache size < 0 i.e. Negative
   wabot.textWithLabel(Messages.cachScaleLbl).setText("");
   wabot.textWithLabel(Messages.cachScaleLbl).typeText("-2");
   properties = propShell.bot().tree();
   properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select();
   errorShell = wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate();
   Boolean negErr = errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " "));
   wabot.button("OK").click();
   // Cache size > 100
   wabot.textWithLabel(Messages.cachScaleLbl).setText("");
   wabot.textWithLabel(Messages.cachScaleLbl).typeText("105%");
   properties = propShell.bot().tree();
   properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select();
   errorShell = wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate();
   Boolean grtErr = errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " "));
   wabot.button("OK").click();
   assertTrue("testInvalidCacheSizeOKToLeave", zeroErr && negErr && grtErr);
   propShell.close();
 }
コード例 #8
0
ファイル: SWTEEFBot.java プロジェクト: sthibaudeau/eef
 /**
  * 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;
 }
コード例 #9
0
  /**
   * Delete Project from workspace
   *
   * @param projectName
   */
  public void deleteProject(String projectName) {

    removeProjectFromServers(projectName);

    SWTBot packageExplorer = eclipse.showView(ViewType.PACKAGE_EXPLORER);
    delay();
    SWTBotTree tree = packageExplorer.tree();
    delay();

    ContextMenuHelper.prepareTreeItemForContextMenu(tree, tree.getTreeItem(projectName));
    new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.DELETE, false)).click();
    bot.shell(IDELabel.Shell.DELETE_RESOURCES).activate();
    bot.button(IDELabel.Button.OK).click();

    new SWTUtilExt(bot).waitForNonIgnoredJobs();
  }
コード例 #10
0
ファイル: SuperBot.java プロジェクト: raimis55/saros
  @Override
  public void confirmShellAddProjectsToSession(String... projectNames) throws RemoteException {

    SWTBot bot = new SWTBot();
    SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS_TO_SESSION);
    shell.activate();

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

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

    for (String projectName : projectNames) tree.getTreeItem(projectName).check();

    shell.bot().button(FINISH).click();
    bot.waitUntil(Conditions.shellCloses(shell));
  }
コード例 #11
0
  private void testClient() {
    Assert.assertTrue("service must exist", servicePassed);
    clientHelper.createClient(
        deploymentHelper.getWSDLUrl(getWsProjectName(), getWsName()),
        WebServiceRuntime.JBOSS_WS,
        getWsClientProjectName(),
        getEarProjectName(),
        SliderLevel.DEVELOP,
        getWsClientPackage());
    IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(getWsClientProjectName());
    String pkg = "org/jboss/wsclient";
    String cls = "src/" + pkg + "/AreaService.java";
    Assert.assertTrue(p.getFile(cls).exists());
    cls = "src/" + pkg + "/clientsample/ClientSample.java";
    IFile f = p.getFile(cls);
    Assert.assertTrue(f.exists());
    replaceContent(f, "/resources/jbossws/clientsample.java.ws");

    /*
     * workaround for https://issues.jboss.org/browse/JBIDE-9817
     */
    projectExplorer.selectProject(getWsClientProjectName());
    SWTBotTree tree = projectExplorer.bot().tree();
    SWTBotTreeItem item = tree.getTreeItem(getWsClientProjectName());
    item.expand();
    removeRuntimeLibrary(tree, item, bot, util);

    /* workaround problems with generated code that require JAX-WS API 2.2 */
    jaxWsApi22RequirementWorkaround(getWsClientProjectName(), getWsClientPackage());

    eclipse.runJavaApplication(
        getWsClientProjectName(), "org.jboss.wsclient.clientsample.ClientSample", null);
    util.waitForNonIgnoredJobs();

    // wait until the client ends (prints the last line)
    new WaitUntil(new ConsoleHasText("Call Over!"), TimePeriod.NORMAL);

    ConsoleView cw = new ConsoleView();
    String consoleOutput = cw.getConsoleText();
    LOGGER.info(consoleOutput);
    Assert.assertTrue(consoleOutput, consoleOutput.contains("Server said: 37.5"));
    Assert.assertTrue(consoleOutput.contains("Server said: 3512.3699"));
  }
コード例 #12
0
  /**
   * Choose Run On Server menu for specified project
   *
   * @param bot
   * @param projectName
   */
  public static void runProjectOnServer(SWTWorkbenchBot bot, String projectName) {

    SWTBotTree packageExplorerTree = eclipse.showView(ViewType.PACKAGE_EXPLORER).tree();

    packageExplorerTree.setFocus();
    SWTBotTreeItem packageExplorerTreeItem = packageExplorerTree.getTreeItem(projectName);

    packageExplorerTreeItem.select();
    packageExplorerTreeItem.click();
    // Search for Menu Item with Run on Server substring within label
    final SWTBotMenu menuRunAs = bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RUN_AS);
    final MenuItem menuItem =
        UIThreadRunnable.syncExec(
            new WidgetResult<MenuItem>() {
              public MenuItem run() {
                int menuItemIndex = 0;
                MenuItem menuItem = null;
                final MenuItem[] menuItems = menuRunAs.widget.getMenu().getItems();
                while (menuItem == null && menuItemIndex < menuItems.length) {
                  if (menuItems[menuItemIndex].getText().indexOf("Run on Server") > -1) {
                    menuItem = menuItems[menuItemIndex];
                  } else {
                    menuItemIndex++;
                  }
                }
                return menuItem;
              }
            });
    if (menuItem != null) {
      new SWTBotMenu(menuItem).click();
      bot.shell(IDELabel.Shell.RUN_ON_SERVER).activate();
      bot.button(IDELabel.Button.FINISH).click();
      SWTUtilExt swtUtil = new SWTUtilExt(bot);
      swtUtil.waitForAll(10 * 1000L);
    } else {
      throw new WidgetNotFoundException("Unable to find Menu Item with Label 'Run on Server'");
    }
  }
コード例 #13
0
  @Test
  public void testServerBuild() {

    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor activeEditor = bot.activeEditor();
    final String editorTitle = activeEditor.getTitle();
    // System.out.println("editorTitle1 = "+editorTitle1);
    assertFalse("Error: first diagram name is empty.", editorTitle.isEmpty());

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();
    new BotGefProcessDiagramEditor(bot).selectElement("Step1");
    new BotExecutionDiagramPropertiesView(bot).selectFormTab().selectLegacy();

    // get the GEF editor to activate tools
    final SWTBotGefEditor gmfEditor = bot.gefEditor(editorTitle);

    // Create 2 Pools
    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 500);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 800);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    // Save Diagram
    bot.menu("Diagram").menu("Save").click();

    // System.out.println(editorTitle);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Server")));

    // Menu Server > Build...
    bot.menu("Server").menu("Build...").click();

    // shell 'Build'
    final SWTBotShell shell = bot.shell(Messages.buildTitle);
    bot.waitUntil(Conditions.shellIsActive(Messages.buildTitle));

    // select and check created Diagram in the Tree
    final SWTBotTree tree = bot.treeWithLabel("Select processes to export");
    final SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle);

    // check the diagram to export
    diagramTreeItem.select().check();
    diagramTreeItem.expand();

    // Number of pool in the diagram
    final int poolListSize = diagramTreeItem.getItems().length;
    // System.out.println("Diagram contains "+ poolListSize + " items");
    assertEquals("Error: Diagram must contain 3 Pools.", 3, poolListSize);

    // unselect the first pool of the list

    diagramTreeItem.getNode(0).select();
    diagramTreeItem.getNode(0).uncheck();

    final Vector<String> poolTitleList = new Vector<String>(3);
    final int poolTitleListSize = poolTitleList.size();

    // check the selected pools
    for (int i = 1; i < poolTitleListSize; i++) {
      final SWTBotTreeItem poolTreeItem = diagramTreeItem.getNode(i);
      poolTitleList.set(i, poolTreeItem.getText());
      final String poolName = getItemName(poolTitleList.get(i));

      // test the good pool is checked
      assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked());
      assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i));
    }
    // create tmp directory to write diagrams
    final File tmpBarFolder = new File(ProjectUtil.getBonitaStudioWorkFolder(), "testExportBar");
    tmpBarFolder.mkdirs();
    // set the path where files are saved
    final String tmpBarFolderPath = tmpBarFolder.getAbsolutePath();
    bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(tmpBarFolderPath);
    //		String tmpBarFolderPath = bot.comboBoxWithLabel(Messages.destinationPath+" *").getText();
    //		System.out.println("tmpBarFolder = "+tmpBarFolderPath);

    // click 'Finish' button to close 'Build' shell
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    //  click 'OK' button to close 'Export' shell
    bot.waitUntil(new ShellIsActiveWithThreadSTacksOnFailure(Messages.exportSuccessTitle));
    bot.button(IDialogConstants.OK_LABEL).click();

    // wait the shell to close before checking creation of files
    bot.waitUntil(Conditions.shellCloses(shell));

    // check pools files exist
    for (int i = 1; i < poolTitleListSize; i++) {
      final String tmpPoolTitle = poolTitleList.get(i);
      final String poolFileName =
          getItemName(tmpPoolTitle) + "--" + getItemVersion(tmpPoolTitle) + ".bar";
      final File poolFile = new File(tmpBarFolderPath, poolFileName);

      assertTrue("Error: The Pool export must exist", poolFile.exists());
      assertTrue("Error: The Pool export must be a file", poolFile.isFile());
    }
  }