コード例 #1
0
  /** Test adding and removing a symlinked package in the "packages" directory */
  public void test_traverse_package_added_removed() throws Exception {

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

    // add package
    MockDelta delta = new MockDelta(projectContainer);
    delta.add(PACKAGES_DIRECTORY_NAME).add("pkg1", ADDED);

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

    // Canonical locations
    File pkg1SomeDir = new File(pkg1Dir, "some_folder");
    File[] added =
        new File[] {
          new File(pkg1Dir, "build.dart"), new File(pkg1Dir, "bar.dart"),
          new File(pkg1SomeDir, "build.dart"), new File(pkg1SomeDir, "bar.dart")
        };

    project.assertChanged(projectContainer, added, null, null, null);
    project.assertNoCalls();

    // remove package
    FileUtilities2.deleteSymLink(new File(packagesDir, "pkg1"));
    delta = new MockDelta(projectContainer);
    delta.add(PACKAGES_DIRECTORY_NAME).add("pkg1", REMOVED);

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

    project.assertPackagesRemoved(projectContainer);
    project.assertNoCalls();
  }
コード例 #2
0
  public void test_getInvertedSourceContainer() throws Exception {
    if (!setupSymlinks()) {
      return;
    }
    File file1 = new File(pkg1CanonicalDir, "file1.dart");
    File file2 = new File(pkg2CanonicalDir, "file2.dart");
    FileBasedSource source1 = new FileBasedSource(file1);
    FileBasedSource source2 = new FileBasedSource(file2);

    PubFolderImpl pubFolder = newTarget();
    InvertedSourceContainer container1 = pubFolder.getInvertedSourceContainer();

    assertFalse(container1.contains(source1));
    assertFalse(container1.contains(source2));

    FileUtilities2.deleteSymLink(new File(packagesDir, "pkg2"));
    InvertedSourceContainer container2 = pubFolder.getInvertedSourceContainer();

    assertFalse(container2.contains(source1));
    assertTrue(container2.contains(source2));
  }