/**
   * Test adding a file in a symlinked package where the "packages" directory is in a pub folder
   * that is not the project folder
   */
  public void test_traverse_package_file_added2() throws Exception {

    projectContainer.remove(PUBSPEC_FILE_NAME);
    File myAppDir = new File(projDir, "myapp");

    if (!symlinkPackage(myAppDir)) {
      return;
    }

    // Create delta with a added file in pkg1
    MockFolder myApp = projectContainer.getMockFolder("myapp");
    MockFolder packages = myApp.addFolder(PACKAGES_DIRECTORY_NAME);
    MockFolder pkg1 = packages.addFolder("pkg1");
    MockFile file = pkg1.addFile("bar.dart");
    MockDelta delta = new MockDelta(projectContainer);
    delta.add(myApp).add(PACKAGES_DIRECTORY_NAME).add("pkg1").add("bar.dart", ADDED);

    DeltaProcessor processor = new DeltaProcessor(project);
    ProjectUpdater updater = new ProjectUpdater();
    processor.addDeltaListener(updater);
    processor.traverse(delta);
    updater.applyChanges();

    File addedFile = new File(pkg1Dir, file.getName());
    project.assertChanged(myApp, new File[] {addedFile}, null, null, null);
  }
  @Override
  protected void setUp() throws Exception {
    projectContainer = TestProjects.newPubProject3();
    project = new DeltaProcessorMockProject(projectContainer);

    projDir = FileUtilities2.createTempDir(projectContainer.getName());
    pkg1Dir = FileUtilities2.createTempDir("pkg1").getCanonicalFile();
    projectContainer.setLocation(new Path(projDir.getAbsolutePath()));
  }
  /** Test removing a directory contained in a symlinked package */
  public void test_traverse_package_directory_removed() throws Exception {
    if (!symlinkPackage(projDir)) {
      return;
    }

    MockFolder packages = projectContainer.getMockFolder(PACKAGES_DIRECTORY_NAME);
    MockFolder pkg = packages.getMockFolder("pkg1");
    MockFolder folder = (MockFolder) pkg.remove("some_folder");
    MockDelta delta = new MockDelta(projectContainer);
    delta.add(PACKAGES_DIRECTORY_NAME).add("pkg1").add(folder, REMOVED);

    DeltaProcessor processor = new DeltaProcessor(project);
    ProjectUpdater updater = new ProjectUpdater();
    processor.addDeltaListener(updater);
    processor.traverse(delta);
    updater.applyChanges();

    File removedDir = new File(pkg1Dir, folder.getName());
    project.assertChanged(projectContainer, null, null, null, new File[] {removedDir});
    project.assertNoCalls();
  }
  /**
   * Test changing a file in a symlinked package.
   *
   * <p>In addition, test that the delta processor correctly traverses starting with the "packages"
   * directory rather than the project director, similar to what will be sent to the {@link
   * DeltaProcessor} by the {@link WorkspaceDeltaProcessor}.
   */
  public void test_traverse_package_file_changed() throws Exception {
    if (!symlinkPackage(projDir)) {
      return;
    }

    MockFolder packages = projectContainer.getMockFolder(PACKAGES_DIRECTORY_NAME);
    MockFolder pkg1 = packages.getMockFolder("pkg1");
    MockFile file = pkg1.getMockFile("bar.dart");
    MockDelta delta = new MockDelta(packages);
    delta.add("pkg1").add("bar.dart");

    DeltaProcessor processor = new DeltaProcessor(project);
    ProjectUpdater updater = new ProjectUpdater();
    processor.addDeltaListener(updater);
    processor.traverse(delta);
    updater.applyChanges();

    File changedFile = new File(pkg1Dir, file.getName());
    project.assertChanged(projectContainer, null, new File[] {changedFile}, null, null);
    project.assertNoCalls();
  }