/** * 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); }
/** 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(); }
/** 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(); }