| Index: pkg/analyzer/test/src/context/source_test.dart
|
| diff --git a/pkg/analyzer/test/src/context/source_test.dart b/pkg/analyzer/test/src/context/source_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1fc0784769b00d9661442db96c8472f34f9cde03
|
| --- /dev/null
|
| +++ b/pkg/analyzer/test/src/context/source_test.dart
|
| @@ -0,0 +1,56 @@
|
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +library analyzer.test.src.context.source_test;
|
| +
|
| +import 'package:analyzer/file_system/file_system.dart';
|
| +import 'package:analyzer/src/context/source.dart';
|
| +import 'package:analyzer/src/generated/source.dart';
|
| +import 'package:package_config/packages.dart';
|
| +import 'package:test/test.dart';
|
| +import 'package:test_reflective_loader/test_reflective_loader.dart';
|
| +
|
| +import 'abstract_context.dart';
|
| +
|
| +main() {
|
| + defineReflectiveSuite(() {
|
| + defineReflectiveTests(SourceFactoryImplTest);
|
| + });
|
| +}
|
| +
|
| +@reflectiveTest
|
| +class SourceFactoryImplTest extends AbstractContextTest {
|
| + void test_restoreUri() {
|
| + Map<String, Uri> packageUriMap = <String, Uri>{
|
| + 'foo': Uri.parse('file:///pkgs/somepkg/lib/')
|
| + };
|
| + SourceFactoryImpl sourceFactory = new SourceFactoryImpl(
|
| + <UriResolver>[new ResourceUriResolver(resourceProvider)],
|
| + new _MockPackages(packageUriMap),
|
| + );
|
| + Uri uri = sourceFactory.restoreUri(newSource('/pkgs/somepkg/lib'));
|
| + expect(uri, Uri.parse('package:foo/'));
|
| + }
|
| +}
|
| +
|
| +/**
|
| + * An implementation of [Packages] used for testing.
|
| + */
|
| +class _MockPackages implements Packages {
|
| + final Map<String, Uri> map;
|
| +
|
| + _MockPackages(this.map);
|
| +
|
| + @override
|
| + Iterable<String> get packages => map.keys;
|
| +
|
| + @override
|
| + Map<String, Uri> asMap() => map;
|
| +
|
| + @override
|
| + Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) {
|
| + fail('Unexpected invocation of resolve');
|
| + return null;
|
| + }
|
| +}
|
|
|