Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 callbacks.now++; | 560 callbacks.now++; |
| 561 manager.refresh([resourceProvider.getResource(proj2Path)]); | 561 manager.refresh([resourceProvider.getResource(proj2Path)]); |
| 562 return pumpEventQueue().then((_) { | 562 return pumpEventQueue().then((_) { |
| 563 expect(callbacks.currentContextPaths.toList(), unorderedEquals(roots)); | 563 expect(callbacks.currentContextPaths.toList(), unorderedEquals(roots)); |
| 564 expect(callbacks.currentContextTimestamps[projPath], then); | 564 expect(callbacks.currentContextTimestamps[projPath], then); |
| 565 expect(callbacks.currentContextTimestamps[proj2Path], callbacks.now); | 565 expect(callbacks.currentContextTimestamps[proj2Path], callbacks.now); |
| 566 }); | 566 }); |
| 567 }); | 567 }); |
| 568 } | 568 } |
| 569 | 569 |
| 570 test_embedder_packagespec() async { | |
| 571 // Create files. | |
| 572 String libPath = newFolder([projPath, LIB_NAME]); | |
| 573 newFile([libPath, 'main.dart']); | |
| 574 newFile([libPath, 'nope.dart']); | |
| 575 String sdkExtPath = newFolder([projPath, 'sdk_ext']); | |
| 576 newFile([sdkExtPath, 'entry.dart']); | |
| 577 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); | |
| 578 newFile([sdkExtSrcPath, 'part.dart']); | |
| 579 // Setup _embedder.yaml. | |
| 580 newFile( | |
| 581 [libPath, '_embedder.yaml'], | |
| 582 r''' | |
| 583 embedder_libs: | |
| 584 "dart:foobar": "../sdk_ext/entry.dart" | |
| 585 "dart:typed_data": "../sdk_ext/src/part" | |
| 586 '''); | |
| 587 // Setup .packages file | |
| 588 newFile( | |
| 589 [projPath, '.packages'], | |
| 590 r''' | |
| 591 test_pack:lib/'''); | |
| 592 // Setup context. | |
| 593 | |
| 594 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | |
| 595 await pumpEventQueue(); | |
| 596 // Confirm that one context was created. | |
| 597 var contexts = | |
| 598 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); | |
| 599 expect(contexts, isNotNull); | |
| 600 expect(contexts.length, equals(1)); | |
|
pquitslund
2015/11/11 21:19:34
[Nit]: can be simplified to:
expect(contexts.leng
Brian Wilkerson
2015/11/11 22:09:14
or, better yet:
expect(contexts, hasLength(1));
| |
| 601 var context = contexts[0]; | |
| 602 var source = context.sourceFactory.forUri('dart:foobar'); | |
| 603 expect(source, isNotNull); | |
| 604 expect(source.fullName, equals('/my/proj/sdk_ext/entry.dart')); | |
|
pquitslund
2015/11/11 21:19:34
[Nit]: can be simplified to:
expect(source.fullNa
| |
| 605 // We can't find dart:core because we didn't list it in our | |
| 606 // embedder_libs map. | |
| 607 expect(context.sourceFactory.forUri('dart:core'), isNull); | |
| 608 // We can find dart:typed_data because we listed it in our | |
| 609 // embedder_libs map. | |
| 610 expect(context.sourceFactory.forUri('dart:typed_data'), isNotNull); | |
| 611 } | |
| 612 | |
| 570 test_sdk_ext_packagespec() async { | 613 test_sdk_ext_packagespec() async { |
| 571 // Create files. | 614 // Create files. |
| 572 String libPath = newFolder([projPath, LIB_NAME]); | 615 String libPath = newFolder([projPath, LIB_NAME]); |
| 573 newFile([libPath, 'main.dart']); | 616 newFile([libPath, 'main.dart']); |
| 574 newFile([libPath, 'nope.dart']); | 617 newFile([libPath, 'nope.dart']); |
| 575 String sdkExtPath = newFolder([projPath, 'sdk_ext']); | 618 String sdkExtPath = newFolder([projPath, 'sdk_ext']); |
| 576 newFile([sdkExtPath, 'entry.dart']); | 619 newFile([sdkExtPath, 'entry.dart']); |
| 577 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); | 620 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); |
| 578 newFile([sdkExtSrcPath, 'part.dart']); | 621 newFile([sdkExtSrcPath, 'part.dart']); |
| 579 // Setup sdk extension mapping. | 622 // Setup sdk extension mapping. |
| 580 newFile( | 623 newFile( |
| 581 [libPath, '_sdkext'], | 624 [libPath, '_sdkext'], |
| 582 r''' | 625 r''' |
| 583 { | 626 { |
| 584 "dart:foobar": "../sdk_ext/entry.dart" | 627 "dart:foobar": "../sdk_ext/entry.dart" |
| 585 } | 628 } |
| 586 '''); | 629 '''); |
| 587 // Setup .packages file | 630 // Setup .packages file |
| 588 newFile( | 631 newFile( |
| 589 [projPath, '.packages'], | 632 [projPath, '.packages'], |
| 590 r''' | 633 r''' |
| 591 test_pack:lib/ | 634 test_pack:lib/'''); |
| 592 '''); | |
| 593 // Setup context. | 635 // Setup context. |
| 594 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 636 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 595 // Confirm that one context was created. | 637 // Confirm that one context was created. |
| 596 var contexts = | 638 var contexts = |
| 597 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); | 639 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); |
| 598 expect(contexts, isNotNull); | 640 expect(contexts, isNotNull); |
| 599 expect(contexts.length, equals(1)); | 641 expect(contexts.length, equals(1)); |
| 600 var context = contexts[0]; | 642 var context = contexts[0]; |
| 601 var source = context.sourceFactory.forUri('dart:foobar'); | 643 var source = context.sourceFactory.forUri('dart:foobar'); |
| 602 expect(source.fullName, equals('/my/proj/sdk_ext/entry.dart')); | 644 expect(source.fullName, equals('/my/proj/sdk_ext/entry.dart')); |
| (...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1940 class TestUriResolver extends UriResolver { | 1982 class TestUriResolver extends UriResolver { |
| 1941 Map<Uri, Source> uriMap; | 1983 Map<Uri, Source> uriMap; |
| 1942 | 1984 |
| 1943 TestUriResolver(this.uriMap); | 1985 TestUriResolver(this.uriMap); |
| 1944 | 1986 |
| 1945 @override | 1987 @override |
| 1946 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 1988 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 1947 return uriMap[uri]; | 1989 return uriMap[uri]; |
| 1948 } | 1990 } |
| 1949 } | 1991 } |
| OLD | NEW |