예제 #1
0
 public void test_DartModelManager_openLibrary_nonLibrary() throws Exception {
   final File nonLibraryFile =
       TestUtilities.getPluginRelativePath(
               "com.google.dart.tools.core_test", new Path("test_data/Geometry/license.txt"))
           .toFile();
   final DartLibrary[] libraryHolder = new DartLibrary[1];
   ResourcesPlugin.getWorkspace()
       .run(
           new IWorkspaceRunnable() {
             @Override
             public void run(IProgressMonitor monitor) throws CoreException {
               libraryHolder[0] = DartModelManager.getInstance().openLibrary(nonLibraryFile, null);
             }
           },
           null);
   DartLibrary library = libraryHolder[0];
   assertNotNull(library);
   final DartElement parent = library.getParent();
   try {
     assertValidLibrary(library);
   } finally {
     ResourcesPlugin.getWorkspace()
         .run(
             new IWorkspaceRunnable() {
               @Override
               public void run(IProgressMonitor monitor) throws CoreException {
                 ((DartProject) parent).getProject().delete(true, true, monitor);
               }
             },
             null);
   }
 }
예제 #2
0
 /**
  * Assert that the given library is valid.
  *
  * @param library the library to be tested
  * @throws DartModelException if the state of the library could not be determined
  */
 private void assertValidLibrary(DartLibrary library) throws DartModelException {
   assertNotNull(library);
   final DartElement parent = library.getParent();
   assertNotNull(parent);
   assertTrue(parent instanceof DartProject);
   assertEquals("Geometry", library.getDisplayName());
   assertTrue(library.getElementName().endsWith("test_data/Geometry/geometry.dart"));
   CompilationUnit[] units = library.getCompilationUnits();
   assertNotNull(units);
   assertEquals(2, units.length);
 }