예제 #1
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);
  }
예제 #2
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));
  }
예제 #3
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));
 }
예제 #4
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));
  }