| Index: pkg/analyzer/test/generated/source_factory_test.dart
|
| diff --git a/pkg/analyzer/test/generated/source_factory_test.dart b/pkg/analyzer/test/generated/source_factory_test.dart
|
| index 42e2d7a148096dadd2d868f958dc2fd31338b448..0133de5ae35e99a65360eefe664742cb2b3c7483 100644
|
| --- a/pkg/analyzer/test/generated/source_factory_test.dart
|
| +++ b/pkg/analyzer/test/generated/source_factory_test.dart
|
| @@ -7,16 +7,15 @@ library analyzer.test.generated.test.generated.source_factory;
|
| import 'dart:convert';
|
|
|
| import 'package:analyzer/file_system/file_system.dart';
|
| -import 'package:analyzer/file_system/physical_file_system.dart';
|
| import 'package:analyzer/file_system/memory_file_system.dart';
|
| import 'package:analyzer/source/package_map_resolver.dart';
|
| import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine, Logger;
|
| import 'package:analyzer/src/generated/java_core.dart';
|
| import 'package:analyzer/src/generated/java_engine_io.dart';
|
| -import 'package:analyzer/src/generated/java_io.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| import 'package:analyzer/src/generated/source_io.dart';
|
| import 'package:analyzer/src/generated/utilities_dart.dart' as utils;
|
| +import 'package:analyzer/src/source/source_resource.dart';
|
| import 'package:package_config/packages.dart';
|
| import 'package:package_config/packages_file.dart' as pkgfile show parse;
|
| import 'package:package_config/src/packages_impl.dart';
|
| @@ -40,9 +39,10 @@ Source createSource({String path, String uri}) =>
|
| .createSource(uri != null ? Uri.parse(uri) : null);
|
|
|
| void runPackageMapTests() {
|
| + MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
|
| final Uri baseUri = new Uri.file('test/base');
|
| final List<UriResolver> testResolvers = [
|
| - new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)
|
| + new ResourceUriResolver(resourceProvider)
|
| ];
|
|
|
| Packages createPackageMap(Uri base, String configFileContents) {
|
| @@ -172,7 +172,7 @@ unittest:/home/somebody/.pub/cache/unittest-0.9.9/lib/
|
| async:/home/somebody/.pub/cache/async-1.1.0/lib/
|
| quiver:/home/somebody/.pub/cache/quiver-1.2.1/lib
|
| ''',
|
| - source: new FileBasedSource(FileUtilities2.createFile(
|
| + source: new FileSource(resourceProvider.getFile(
|
| '/home/somebody/.pub/cache/unittest-0.9.9/lib/unittest.dart')));
|
| expect(uri, isNotNull);
|
| expect(uri.toString(), equals('package:unittest/unittest.dart'));
|
| @@ -207,6 +207,19 @@ foo:http://www.google.com
|
| });
|
| }
|
|
|
| +class AbsoluteUriResolver extends UriResolver {
|
| + final MemoryResourceProvider resourceProvider;
|
| +
|
| + AbsoluteUriResolver(this.resourceProvider);
|
| +
|
| + @override
|
| + Source resolveAbsolute(Uri uri, [Uri actualUri]) {
|
| + return new FileSource(
|
| + resourceProvider.getFile(resourceProvider.pathContext.fromUri(uri)),
|
| + actualUri);
|
| + }
|
| +}
|
| +
|
| class CustomUriResolver extends UriResolver {
|
| String uriPath;
|
| CustomUriResolver({this.uriPath});
|
| @@ -218,6 +231,8 @@ class CustomUriResolver extends UriResolver {
|
|
|
| @reflectiveTest
|
| class SourceFactoryTest {
|
| + MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
|
| +
|
| void test_creation() {
|
| expect(new SourceFactory([]), isNotNull);
|
| }
|
| @@ -250,10 +265,10 @@ class SourceFactoryTest {
|
|
|
| void test_resolveUri_nonAbsolute_absolute() {
|
| SourceFactory factory =
|
| - new SourceFactory([new UriResolver_nonAbsolute_absolute()]);
|
| + new SourceFactory([new AbsoluteUriResolver(resourceProvider)]);
|
| String absolutePath = "/does/not/matter.dart";
|
| Source containingSource =
|
| - new FileBasedSource(FileUtilities2.createFile("/does/not/exist.dart"));
|
| + new FileSource(resourceProvider.getFile("/does/not/exist.dart"));
|
| Source result = factory.resolveUri(containingSource, absolutePath);
|
| expect(result.fullName,
|
| FileUtilities2.createFile(absolutePath).getAbsolutePath());
|
| @@ -261,9 +276,9 @@ class SourceFactoryTest {
|
|
|
| void test_resolveUri_nonAbsolute_relative() {
|
| SourceFactory factory =
|
| - new SourceFactory([new UriResolver_nonAbsolute_relative()]);
|
| + new SourceFactory([new AbsoluteUriResolver(resourceProvider)]);
|
| Source containingSource =
|
| - new FileBasedSource(FileUtilities2.createFile("/does/not/have.dart"));
|
| + new FileSource(resourceProvider.getFile("/does/not/have.dart"));
|
| Source result = factory.resolveUri(containingSource, "exist.dart");
|
| expect(result.fullName,
|
| FileUtilities2.createFile("/does/not/exist.dart").getAbsolutePath());
|
| @@ -299,10 +314,10 @@ class SourceFactoryTest {
|
| }
|
|
|
| void test_restoreUri() {
|
| - JavaFile file1 = FileUtilities2.createFile("/some/file1.dart");
|
| - JavaFile file2 = FileUtilities2.createFile("/some/file2.dart");
|
| - Source source1 = new FileBasedSource(file1);
|
| - Source source2 = new FileBasedSource(file2);
|
| + File file1 = resourceProvider.getFile("/some/file1.dart");
|
| + File file2 = resourceProvider.getFile("/some/file2.dart");
|
| + Source source1 = new FileSource(file1);
|
| + Source source2 = new FileSource(file2);
|
| Uri expected1 = parseUriWithException("file:///my_file.dart");
|
| SourceFactory factory =
|
| new SourceFactory([new UriResolver_restoreUri(source1, expected1)]);
|
| @@ -323,20 +338,6 @@ class UriResolver_absolute extends UriResolver {
|
| }
|
| }
|
|
|
| -class UriResolver_nonAbsolute_absolute extends UriResolver {
|
| - @override
|
| - Source resolveAbsolute(Uri uri, [Uri actualUri]) {
|
| - return new FileBasedSource(new JavaFile.fromUri(uri), actualUri);
|
| - }
|
| -}
|
| -
|
| -class UriResolver_nonAbsolute_relative extends UriResolver {
|
| - @override
|
| - Source resolveAbsolute(Uri uri, [Uri actualUri]) {
|
| - return new FileBasedSource(new JavaFile.fromUri(uri), actualUri);
|
| - }
|
| -}
|
| -
|
| class UriResolver_restoreUri extends UriResolver {
|
| Source source1;
|
| Uri expected1;
|
|
|