Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 1295463003: Add _sdkext support back to analysis server (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/context_manager.dart'; 9 import 'package:analysis_server/src/context_manager.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 337 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
338 // Verify that the context in other_lib wasn't created and that the 338 // Verify that the context in other_lib wasn't created and that the
339 // context in lib was created. 339 // context in lib was created.
340 var contexts = 340 var contexts =
341 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); 341 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
342 expect(contexts.length, 2); 342 expect(contexts.length, 2);
343 expect(contexts[0].name, equals('/my/proj')); 343 expect(contexts[0].name, equals('/my/proj'));
344 expect(contexts[1].name, equals('/my/proj/lib')); 344 expect(contexts[1].name, equals('/my/proj/lib'));
345 } 345 }
346 346
347 test_sdk_ext_packagespec() async {
Paul Berry 2015/08/13 17:12:07 This test verifies correct behavior of your change
Cutch 2015/08/13 19:24:17 Done.
348 // Create files.
349 String libPath = newFolder([projPath, LIB_NAME]);
350 newFile([libPath, 'main.dart']);
351 newFile([libPath, 'nope.dart']);
352 String sdkExtPath = newFolder([projPath, 'sdk_ext']);
353 newFile([sdkExtPath, 'entry.dart']);
354 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']);
355 newFile([sdkExtSrcPath, 'part.dart']);
356 // Setup sdk extension mapping.
357 newFile(
358 [libPath, '_sdkext'],
359 r'''
360 {
361 "dart:foobar": "../sdk_ext/entry.dart"
362 }
363 ''');
364 // Setup .packages file
365 newFile(
366 [projPath, '.packages'],
367 r'''
368 test_pack:lib/
369 ''');
370 // Setup context.
371 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
372 // Confirm that one context was created.
373 var contexts =
374 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
375 expect(contexts, isNotNull);
376 expect(contexts.length, equals(1));
377 var context = contexts[0];
378 var source = context.sourceFactory.forUri('dart:foobar');
379 expect(source.fullName, equals('/my/proj/sdk_ext/entry.dart'));
380 }
381
382
347 test_refresh_folder_with_packagespec() { 383 test_refresh_folder_with_packagespec() {
348 // create a context with a .packages file 384 // create a context with a .packages file
349 String packagespecFile = posix.join(projPath, '.packages'); 385 String packagespecFile = posix.join(projPath, '.packages');
350 resourceProvider.newFile(packagespecFile, ''); 386 resourceProvider.newFile(packagespecFile, '');
351 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 387 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
352 return pumpEventQueue().then((_) { 388 return pumpEventQueue().then((_) {
353 expect(callbacks.currentContextPaths.toList(), [projPath]); 389 expect(callbacks.currentContextPaths.toList(), [projPath]);
354 callbacks.now++; 390 callbacks.now++;
355 manager.refresh(null); 391 manager.refresh(null);
356 return pumpEventQueue().then((_) { 392 return pumpEventQueue().then((_) {
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 class TestUriResolver extends UriResolver { 1715 class TestUriResolver extends UriResolver {
1680 Map<Uri, Source> uriMap; 1716 Map<Uri, Source> uriMap;
1681 1717
1682 TestUriResolver(this.uriMap); 1718 TestUriResolver(this.uriMap);
1683 1719
1684 @override 1720 @override
1685 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 1721 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
1686 return uriMap[uri]; 1722 return uriMap[uri];
1687 } 1723 }
1688 } 1724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698