| 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 analyzer.test.src.context.source_test; | 5 library analyzer.test.src.context.source_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/src/context/source.dart'; | 8 import 'package:analyzer/src/context/source.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:package_config/packages.dart'; | 10 import 'package:package_config/packages.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class SourceFactoryImplTest extends AbstractContextTest { | 23 class SourceFactoryImplTest extends AbstractContextTest { |
| 24 void test_restoreUri() { | 24 void test_restoreUri() { |
| 25 Map<String, Uri> packageUriMap = <String, Uri>{ | 25 Map<String, Uri> packageUriMap = <String, Uri>{ |
| 26 'foo': Uri.parse('file:///pkgs/somepkg/lib/') | 26 'foo': Uri.parse('file:///pkgs/somepkg/lib/') |
| 27 }; | 27 }; |
| 28 SourceFactoryImpl sourceFactory = new SourceFactoryImpl( | 28 SourceFactoryImpl sourceFactory = new SourceFactoryImpl( |
| 29 <UriResolver>[new ResourceUriResolver(resourceProvider)], | 29 <UriResolver>[new ResourceUriResolver(resourceProvider)], |
| 30 new _MockPackages(packageUriMap), | 30 new _MockPackages(packageUriMap), |
| 31 ); | 31 ); |
| 32 Uri uri = sourceFactory.restoreUri(newSource('/pkgs/somepkg/lib')); | 32 Uri uri = sourceFactory.restoreUri(newSource('/pkgs/somepkg/lib')); |
| 33 // TODO(danrubel) fix on Windows | 33 expect(uri, Uri.parse('package:foo/')); |
| 34 if (resourceProvider.absolutePathContext.separator != r'\') { | |
| 35 expect(uri, Uri.parse('package:foo/')); | |
| 36 } | |
| 37 } | 34 } |
| 38 } | 35 } |
| 39 | 36 |
| 40 /** | 37 /** |
| 41 * An implementation of [Packages] used for testing. | 38 * An implementation of [Packages] used for testing. |
| 42 */ | 39 */ |
| 43 class _MockPackages implements Packages { | 40 class _MockPackages implements Packages { |
| 44 final Map<String, Uri> map; | 41 final Map<String, Uri> map; |
| 45 | 42 |
| 46 _MockPackages(this.map); | 43 _MockPackages(this.map); |
| 47 | 44 |
| 48 @override | 45 @override |
| 49 Iterable<String> get packages => map.keys; | 46 Iterable<String> get packages => map.keys; |
| 50 | 47 |
| 51 @override | 48 @override |
| 52 Map<String, Uri> asMap() => map; | 49 Map<String, Uri> asMap() => map; |
| 53 | 50 |
| 54 @override | 51 @override |
| 55 Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) { | 52 Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) { |
| 56 fail('Unexpected invocation of resolve'); | 53 fail('Unexpected invocation of resolve'); |
| 57 return null; | 54 return null; |
| 58 } | 55 } |
| 59 } | 56 } |
| OLD | NEW |