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

Side by Side Diff: pkg/analyzer/test/src/context/source_test.dart

Issue 2659333003: fix SourceFactoryImpl restoreUri (Closed)
Patch Set: merge Created 3 years, 10 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« 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