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

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

Issue 2717933002: fix source restoreUri test (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
11 import 'package:test/test.dart'; 11 import 'package:test/test.dart';
12 import 'package:test_reflective_loader/test_reflective_loader.dart'; 12 import 'package:test_reflective_loader/test_reflective_loader.dart';
13 13
14 import 'abstract_context.dart'; 14 import 'abstract_context.dart';
15 15
16 main() { 16 main() {
17 defineReflectiveSuite(() { 17 defineReflectiveSuite(() {
18 defineReflectiveTests(SourceFactoryImplTest); 18 defineReflectiveTests(SourceFactoryImplTest);
19 }); 19 });
20 } 20 }
21 21
22 @reflectiveTest 22 @reflectiveTest
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 String libPath = resourceProvider.convertPath('/pkgs/somepkg/lib/');
26 'foo': Uri.parse('file:///pkgs/somepkg/lib/') 26 Uri libUri = resourceProvider.getFolder(libPath).toUri();
27 }; 27 Map<String, Uri> packageUriMap = <String, Uri>{'foo': libUri};
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 Source libSource = newSource('/pkgs/somepkg/lib');
33 // TODO(danrubel) fix on Windows 33 Uri uri = sourceFactory.restoreUri(libSource);
34 if (resourceProvider.absolutePathContext.separator != r'\') { 34 try {
35 expect(uri, Uri.parse('package:foo/')); 35 expect(uri, Uri.parse('package:foo/'));
36 } catch (e) {
37 print('=== debug info ===');
38 print('libPath: $libPath');
39 print('libUri: $libUri');
40 print('libSource: ${libSource?.fullName}');
41 rethrow;
36 } 42 }
37 } 43 }
38 } 44 }
39 45
40 /** 46 /**
41 * An implementation of [Packages] used for testing. 47 * An implementation of [Packages] used for testing.
42 */ 48 */
43 class _MockPackages implements Packages { 49 class _MockPackages implements Packages {
44 final Map<String, Uri> map; 50 final Map<String, Uri> map;
45 51
46 _MockPackages(this.map); 52 _MockPackages(this.map);
47 53
48 @override 54 @override
49 Iterable<String> get packages => map.keys; 55 Iterable<String> get packages => map.keys;
50 56
51 @override 57 @override
52 Map<String, Uri> asMap() => map; 58 Map<String, Uri> asMap() => map;
53 59
54 @override 60 @override
55 Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) { 61 Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) {
56 fail('Unexpected invocation of resolve'); 62 fail('Unexpected invocation of resolve');
57 return null; 63 return null;
58 } 64 }
59 } 65 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698