| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library analyzer.test.src.context.source_test; |
| 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/src/context/source.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:package_config/packages.dart'; |
| 11 import 'package:test/test.dart'; |
| 12 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 13 |
| 14 import 'abstract_context.dart'; |
| 15 |
| 16 main() { |
| 17 defineReflectiveSuite(() { |
| 18 defineReflectiveTests(SourceFactoryImplTest); |
| 19 }); |
| 20 } |
| 21 |
| 22 @reflectiveTest |
| 23 class SourceFactoryImplTest extends AbstractContextTest { |
| 24 void test_restoreUri() { |
| 25 Map<String, Uri> packageUriMap = <String, Uri>{ |
| 26 'foo': Uri.parse('file:///pkgs/somepkg/lib/') |
| 27 }; |
| 28 SourceFactoryImpl sourceFactory = new SourceFactoryImpl( |
| 29 <UriResolver>[new ResourceUriResolver(resourceProvider)], |
| 30 new _MockPackages(packageUriMap), |
| 31 ); |
| 32 Uri uri = sourceFactory.restoreUri(newSource('/pkgs/somepkg/lib')); |
| 33 expect(uri, Uri.parse('package:foo/')); |
| 34 } |
| 35 } |
| 36 |
| 37 /** |
| 38 * An implementation of [Packages] used for testing. |
| 39 */ |
| 40 class _MockPackages implements Packages { |
| 41 final Map<String, Uri> map; |
| 42 |
| 43 _MockPackages(this.map); |
| 44 |
| 45 @override |
| 46 Iterable<String> get packages => map.keys; |
| 47 |
| 48 @override |
| 49 Map<String, Uri> asMap() => map; |
| 50 |
| 51 @override |
| 52 Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) { |
| 53 fail('Unexpected invocation of resolve'); |
| 54 return null; |
| 55 } |
| 56 } |
| OLD | NEW |