Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(870)

Unified Diff: pkg/analyzer/test/src/context/source_test.dart

Issue 2659333003: fix SourceFactoryImpl restoreUri (Closed)
Patch Set: merge Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/context/source.dart ('k') | pkg/analyzer/test/src/context/test_all.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
+}
« no previous file with comments | « pkg/analyzer/lib/src/context/source.dart ('k') | pkg/analyzer/test/src/context/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698