@Test
  public void testCreateNewDawnEditorSetName() throws Exception {
    getBot().menu("File").menu("New").menu("Other...").click();

    SWTBotShell shell = getBot().shell("New");
    shell.activate();
    getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
    getBot().button("Next >").click();

    shell = getBot().shell("New");
    shell.activate();

    SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
    fileSemanticNameLabel.setText("test.acore");
    assertEquals("test.acore", fileSemanticNameLabel.getText());

    getBot().button("Next >").click();

    SWTBotCombo comboBox = getBot().comboBox(0); // bot.ccomboBox(0);
    comboBox.setFocus();
    comboBox.setSelection("ACore Root");

    getBot().button("Finish").click();

    SWTBotEditor editor = getBot().editorByTitle("test.acore");
    assertNotNull(editor);
    editor.close();
  }
  @Test
  public void testCreateNewDawnAcoreEditor() throws Exception {
    getBot().menu("File").menu("New").menu("Other...").click();

    SWTBotShell shell = getBot().shell("New");
    shell.activate();
    getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
    getBot().button("Next >").click();
    getBot().button("Next >").click();

    shell = getBot().shell("New");
    shell.activate();

    SWTBotCombo comboBox = getBot().comboBox(0); // bot.ccomboBox(0);
    comboBox.setFocus();
    comboBox.setSelection("ACore Root");

    getBot().button("Finish").click();

    sleep(500);

    SWTBotEditor editor = getBot().editorByTitle("default.acore");
    assertNotNull(editor);
    editor.close();
    {
      assertEquals(true, resourceExists("/default.acore"));
    }
  }
예제 #3
0
  @Test
  public void shareProjectWithExternalRepo() throws Exception {
    String repoName = "ExternalRepositoryForShare";
    createProject(projectName0);
    String location1 = createProject(projectName1);
    String location2 = createProject(projectName2);
    createProject(projectName3);

    ExistingOrNewPage existingOrNewPage = sharingWizard.openWizard(projectName1, projectName2);
    SWTBotShell createRepoDialog = existingOrNewPage.clickCreateRepository();
    String repoDir =
        Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
    File repoFolder = new File(repoDir, repoName);
    createRepoDialog
        .bot()
        .textWithLabel(UIText.CreateRepositoryPage_DirectoryLabel)
        .setText(repoFolder.getAbsolutePath());
    createRepoDialog.bot().button(IDialogConstants.FINISH_LABEL).click();

    SWTBotCombo combo = bot.comboBoxWithLabel(UIText.ExistingOrNewPage_ExistingRepositoryLabel);
    assertTrue(combo.getText().startsWith(repoName));
    Repository targetRepo = lookupRepository(new File(repoFolder, Constants.DOT_GIT));

    assertTrue(combo.getText().endsWith(targetRepo.getDirectory().getPath()));
    assertEquals(
        targetRepo.getWorkTree().getPath(),
        bot.textWithLabel(UIText.ExistingOrNewPage_WorkingDirectoryLabel).getText());
    String[][] contents = new String[2][3];
    contents[0][0] = projectName1;
    contents[0][1] = new Path(location1).toString();
    contents[0][2] = new Path(targetRepo.getWorkTree().getPath()).append(projectName1).toString();

    contents[1][0] = projectName2;
    contents[1][1] = new Path(location2).toString();
    contents[1][2] = new Path(targetRepo.getWorkTree().getPath()).append(projectName2).toString();
    existingOrNewPage.assertTableContents(contents);

    existingOrNewPage.setRelativePath("a/b");

    contents[0][2] =
        new Path(targetRepo.getWorkTree().getPath()).append("a/b").append(projectName1).toString();
    contents[1][2] =
        new Path(targetRepo.getWorkTree().getPath()).append("a/b").append(projectName2).toString();
    existingOrNewPage.assertTableContents(contents);

    bot.button(IDialogConstants.FINISH_LABEL).click();
    Thread.sleep(1000);
    String location1Path =
        ResourcesPlugin.getWorkspace().getRoot().getProject(projectName1).getLocation().toString();
    assertEquals(contents[0][2], location1Path);
    String location2Path =
        ResourcesPlugin.getWorkspace().getRoot().getProject(projectName2).getLocation().toString();
    assertEquals(contents[1][2], location2Path);
  }
  private void selectImportFromArchive(String archivePath) {
    SWTBotRadio button = fBot.radio("Select &archive file:");
    button.click();

    SWTBotCombo sourceCombo = fBot.comboBox(1);

    sourceCombo.setText(new File(archivePath).getAbsolutePath());

    SWTBotText text = fBot.text();
    text.setFocus();
  }
  /** 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);
  }
예제 #6
0
  // Verify we can do a double rename of configurations, renaming one
  // configuration to
  // another and inheriting the settings properly.
  @Test
  public void t5doubleRenameOk() throws Exception {
    openProperties("Autotools", "Configure Settings");
    SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: ");
    bot.button("Manage Configurations...").click();
    SWTBotShell shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    bot.table().select("debug");
    bot.button("Set Active").click();
    // Rename "debug" to "release" and rename "default" to "debug".
    // The settings should follow the rename operation.
    renameConfiguration("debug", "release");
    renameConfiguration("default", "debug");
    bot.button("OK").click();
    shell = bot.shell("Properties for " + projectName);
    shell.activate();
    bot.button("OK").click();

    // Verify changes have taken effect permanently
    openProperties("Autotools", "Configure Settings");
    configs = bot.comboBoxWithLabel("Configuration: ");
    assertTrue(configs.getText().contains("release"));
    assertTrue(configs.getText().contains("Active"));
    bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
    SWTBotText text = bot.textWithLabel("Additional command-line options");
    String setting = text.getText();
    assertEquals("--enable-jeff", setting);
    configs.setFocus();
    configs.setSelection("debug");
    assertTrue(configs.getText().contains("debug"));
    bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
    text = bot.textWithLabel("Additional command-line options");
    setting = text.getText();
    assertEquals("", setting);

    // Undo the changes made by this test
    configs = bot.comboBoxWithLabel("Configuration: ");
    bot.button("Manage Configurations...").click();
    shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    bot.table().select("Build (GNU)");
    bot.button("Set Active").click();
    renameConfiguration("debug", "default");
    renameConfiguration("release", "debug");
    bot.button("OK").click();
    shell = bot.shell("Properties for " + projectName);
    shell.activate();
    bot.button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell));
  }
  @Test
  public void testCreateNewDawnDiagramTypeFolder() throws Exception {
    {
      CDOSession session = openSession();
      ResourceSet resourceSet = new ResourceSetImpl();
      CDOTransaction transaction = session.openTransaction(resourceSet);

      final URI uri = URI.createURI("cdo:/folder/dummy");
      resourceSet.createResource(uri);
      transaction.commit();
    }

    getBot().menu("File").menu("New").menu("Other...").click();

    SWTBotShell shell = getBot().shell("New");
    shell.activate();
    getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
    getBot().button("Next >").click();

    shell = getBot().shell("New");
    shell.activate();

    SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
    fileNameLabel.setText("test.acore");

    SWTBotText folder = getBot().textWithLabel("Enter or select the parent folder: ");
    folder.setText("/folder");
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";

    getBot().button("Next >").click();

    SWTBotCombo comboBox = getBot().comboBox(0); // bot.ccomboBox(0);
    comboBox.setFocus();
    comboBox.setSelection("ACore Root");

    getBot().button("Finish").click();

    SWTBotEditor editor = getBot().editorByTitle("test.acore");
    assertNotNull(editor);
    editor.close();

    {
      assertEquals(true, resourceExists("/folder/test.acore"));
    }
  }
예제 #8
0
 // Verify we can do a double rename of configurations, renaming one
 // configuration to
 // another and then cancel without changing configuration settings.
 @Test
 public void t4doubleRenameCancel() throws Exception {
   openProperties("Autotools", "Configure Settings");
   SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: ");
   bot.button("Manage Configurations...").click();
   // Rename "debug" to "release" and rename "default" to "debug".
   // The settings should follow the rename operation.
   renameConfiguration("debug", "release");
   renameConfiguration("default", "debug");
   bot.button("OK").click();
   // Verify that "release" has --enable-jeff set and that
   // the new "debug" configuration has no user setting.
   SWTBotShell shell = bot.shell("Properties for " + projectName);
   shell.activate();
   configs = bot.comboBoxWithLabel("Configuration: ");
   bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
   SWTBotText text = bot.textWithLabel("Additional command-line options");
   String setting = text.getText();
   assertEquals("--enable-jeff", setting);
   configs.setFocus();
   configs.setSelection("debug");
   bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
   text = bot.textWithLabel("Additional command-line options");
   setting = text.getText();
   assertEquals("", setting);
   bot.button("Cancel").click();
   // Cancel and then verify that "debug" is back to normal with
   // --enable-jeff set and that "default" is back to normal with
   // no user setting.
   openProperties("Autotools", "Configure Settings");
   configs = bot.comboBoxWithLabel("Configuration: ");
   configs.setSelection("debug");
   assertTrue(configs.getText().contains("debug"));
   bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
   text = bot.textWithLabel("Additional command-line options");
   setting = text.getText();
   assertEquals("--enable-jeff", setting);
   configs.setFocus();
   configs.setSelection("default");
   assertTrue(configs.getText().contains("default"));
   bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
   text = bot.textWithLabel("Additional command-line options");
   setting = text.getText();
   assertEquals("", setting);
   bot.button("OK").click();
   bot.waitUntil(Conditions.shellCloses(shell));
 }
예제 #9
0
  // Verify a new configuration will copy the configuration parameters
  // of its base configuration.
  @Test
  public void t3newConfigCopiesParms() throws Exception {
    projectExplorer.bot().tree().select(projectName);
    clickContextMenu(
        projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage...");
    SWTBotShell shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    SWTBotTable table = bot.table();
    assertTrue(table.containsItem("debug"));
    table.getTableItem("debug").select();
    bot.button("Set Active").click();
    bot.button("OK").click();
    // Verify the debug configuration is active and has a user parameter:
    // --enable-jeff
    openProperties("Autotools", "Configure Settings");
    SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: ");
    configs.setFocus();
    String[] items = configs.items();
    for (int i = 0; i < items.length; ++i) {
      if (items[i].contains("debug") && items[i].contains("Active")) {
        configs.setSelection(i);
      }
    }
    assertTrue(configs.getText().contains("debug"));
    bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
    SWTBotText text = bot.textWithLabel("Additional command-line options");
    String val = text.getText();
    assertEquals("--enable-jeff", val);
    // Verify that the build directory for the new configuration has been
    // switched to build-debug
    shell = bot.shell("Properties for " + projectName);
    shell.activate();
    bot.text().setText("");

    bot.tree().select("C/C++ Build");
    String buildDir = bot.textWithLabel("Build directory:").getText();
    assertTrue(buildDir.endsWith("build-debug"));
    // Verify the default configuration has no user setting
    bot.tree().expandNode("Autotools").select("Configure Settings");
    configs = bot.comboBoxWithLabel("Configuration: ");
    configs.setSelection("default");
    bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
    text = bot.textWithLabel("Additional command-line options");
    val = text.getText();
    assertEquals("", val);
    bot.button("OK").click();
    // Build the project again and verify we get a build-debug directory
    projectExplorer.bot().tree().select(projectName);
    clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project");
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    assertNotNull(workspace);
    IWorkspaceRoot root = workspace.getRoot();
    assertNotNull(root);
    IProject project = root.getProject(projectName);
    assertNotNull(project);
    IPath path = project.getLocation();
    // We need to wait until the config.status file is created so
    // sleep a bit and look for it...give up after 20 seconds
    File f = null;
    for (int i = 0; i < 40; ++i) {
      bot.sleep(500);
      f = new File(path.append("build-debug/src/a.out").toOSString());
      if (f.exists()) {
        break;
      }
    }
    assertTrue(f.exists());
    f = new File(path.append("build-debug/config.status").toOSString());
    assertTrue(f.exists());
    try (BufferedReader r = new BufferedReader(new FileReader(f))) {
      int ch;
      boolean optionFound = false;
      // Read config.status and look for the string --enable-jeff
      // which is a simple verification that the option was used in the
      // configure step.
      while ((ch = r.read()) != -1) {
        if (ch == '-') {
          char[] buf = new char[12];
          r.mark(100);
          int count = r.read(buf);
          if (count < 12) {
            break;
          }
          String s = new String(buf);
          if (s.equals("-enable-jeff")) {
            optionFound = true;
            break;
          } else {
            r.reset();
          }
        }
      }
      assertTrue(optionFound);
    }
    // Verify we cleaned out the top-level build directory (i.e. that there
    // is no config.status there anymore).
    path = project.getLocation().append("config.status");
    f = new File(path.toOSString());
    assertTrue(!f.exists());
    path = project.getLocation().append(".autotools");
    f = new File(path.toOSString());
    assertTrue(f.exists());
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document d = db.parse(f);
    Element e = d.getDocumentElement();
    // Get the stored configuration data
    NodeList cfgs = e.getElementsByTagName("configuration"); // $NON-NLS-1$
    assertEquals(3, cfgs.getLength());
    int foundUser = 0;
    for (int x = 0; x < cfgs.getLength(); ++x) {
      Node n = cfgs.item(x);
      NodeList l = n.getChildNodes();
      // Verify two of the user fields in .autotools file are set to
      // --enable-jeff
      for (int y = 0; y < l.getLength(); ++y) {
        Node child = l.item(y);
        if (child.getNodeName().equals("option")) { // $NON-NLS-1$
          NamedNodeMap optionAttrs = child.getAttributes();
          Node idNode = optionAttrs.getNamedItem("id"); // $NON-NLS-1$
          Node valueNode = optionAttrs.getNamedItem("value"); // $NON-NLS-1$
          assertNotNull(idNode);
          assertNotNull(valueNode);
          String id = idNode.getNodeValue();
          String value = valueNode.getNodeValue();
          if (id.equals("user")) {
            if (value.equals("--enable-jeff")) {
              ++foundUser;
            }
          }
        }
      }
    }
    assertEquals(2, foundUser);

    clickContextMenu(
        projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage...");
    shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    table = bot.table();
    assertTrue(table.containsItem("Build (GNU)"));
    table.getTableItem("Build (GNU)").select();
    bot.button("Set Active").click();
    bot.button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell));
  }