OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.generated.test.generated.source_factory; | 5 library analyzer.test.generated.test.generated.source_factory; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 resolvers.add(customResolver); | 88 resolvers.add(customResolver); |
89 } | 89 } |
90 SourceFactory factory = new SourceFactory(resolvers, packages); | 90 SourceFactory factory = new SourceFactory(resolvers, packages); |
91 return factory.restoreUri(source); | 91 return factory.restoreUri(source); |
92 } | 92 } |
93 | 93 |
94 group('SourceFactoryTest', () { | 94 group('SourceFactoryTest', () { |
95 group('package mapping', () { | 95 group('package mapping', () { |
96 group('resolveUri', () { | 96 group('resolveUri', () { |
97 test('URI in mapping', () { | 97 test('URI in mapping', () { |
98 String uri = resolvePackageUri( | 98 String uri = resolvePackageUri(config: ''' |
99 config: ''' | |
100 unittest:file:///home/somebody/.pub/cache/unittest-0.9.9/lib/ | 99 unittest:file:///home/somebody/.pub/cache/unittest-0.9.9/lib/ |
101 async:file:///home/somebody/.pub/cache/async-1.1.0/lib/ | 100 async:file:///home/somebody/.pub/cache/async-1.1.0/lib/ |
102 quiver:file:///home/somebody/.pub/cache/quiver-1.2.1/lib | 101 quiver:file:///home/somebody/.pub/cache/quiver-1.2.1/lib |
103 ''', | 102 ''', uri: 'package:unittest/unittest.dart'); |
104 uri: 'package:unittest/unittest.dart'); | |
105 expect( | 103 expect( |
106 uri, | 104 uri, |
107 equals( | 105 equals( |
108 '/home/somebody/.pub/cache/unittest-0.9.9/lib/unittest.dart'))
; | 106 '/home/somebody/.pub/cache/unittest-0.9.9/lib/unittest.dart'))
; |
109 }); | 107 }); |
110 test('URI in mapping (no scheme)', () { | 108 test('URI in mapping (no scheme)', () { |
111 String uri = resolvePackageUri( | 109 String uri = resolvePackageUri(config: ''' |
112 config: ''' | |
113 unittest:/home/somebody/.pub/cache/unittest-0.9.9/lib/ | 110 unittest:/home/somebody/.pub/cache/unittest-0.9.9/lib/ |
114 async:/home/somebody/.pub/cache/async-1.1.0/lib/ | 111 async:/home/somebody/.pub/cache/async-1.1.0/lib/ |
115 quiver:/home/somebody/.pub/cache/quiver-1.2.1/lib | 112 quiver:/home/somebody/.pub/cache/quiver-1.2.1/lib |
116 ''', | 113 ''', uri: 'package:unittest/unittest.dart'); |
117 uri: 'package:unittest/unittest.dart'); | |
118 expect( | 114 expect( |
119 uri, | 115 uri, |
120 equals( | 116 equals( |
121 '/home/somebody/.pub/cache/unittest-0.9.9/lib/unittest.dart'))
; | 117 '/home/somebody/.pub/cache/unittest-0.9.9/lib/unittest.dart'))
; |
122 }); | 118 }); |
123 test('URI not in mapping', () { | 119 test('URI not in mapping', () { |
124 String uri = resolvePackageUri( | 120 String uri = resolvePackageUri( |
125 config: 'unittest:/home/somebody/.pub/cache/unittest-0.9.9/lib/', | 121 config: 'unittest:/home/somebody/.pub/cache/unittest-0.9.9/lib/', |
126 uri: 'package:foo/foo.dart'); | 122 uri: 'package:foo/foo.dart'); |
127 expect(uri, isNull); | 123 expect(uri, isNull); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); | 355 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); |
360 | 356 |
361 @override | 357 @override |
362 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 358 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
363 if (uri.toString() == encoding) { | 359 if (uri.toString() == encoding) { |
364 return new TestSource(); | 360 return new TestSource(); |
365 } | 361 } |
366 return null; | 362 return null; |
367 } | 363 } |
368 } | 364 } |
OLD | NEW |