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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library analyzer.test.generated.source_factory; | 8 library analyzer.test.generated.source_factory; |
9 | 9 |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 import '../reflective_tests.dart'; | 27 import '../reflective_tests.dart'; |
28 import 'test_support.dart'; | 28 import 'test_support.dart'; |
29 | 29 |
30 main() { | 30 main() { |
31 groupSep = ' | '; | 31 groupSep = ' | '; |
32 runReflectiveTests(SourceFactoryTest); | 32 runReflectiveTests(SourceFactoryTest); |
33 runPackageMapTests(); | 33 runPackageMapTests(); |
34 } | 34 } |
35 | 35 |
| 36 Source createSource({String path, String uri}) => |
| 37 //TODO(pquitslund): find some way to pass an actual URI into source creation |
| 38 new MemoryResourceProvider() |
| 39 .getFile(path) |
| 40 .createSource(uri != null ? Uri.parse(uri) : null); |
| 41 |
36 void runPackageMapTests() { | 42 void runPackageMapTests() { |
37 final Uri baseUri = new Uri.file('test/base'); | 43 final Uri baseUri = new Uri.file('test/base'); |
38 final List<UriResolver> testResolvers = [new FileUriResolver()]; | 44 final List<UriResolver> testResolvers = [new FileUriResolver()]; |
39 | 45 |
40 Packages createPackageMap(Uri base, String configFileContents) { | 46 Packages createPackageMap(Uri base, String configFileContents) { |
41 List<int> bytes = UTF8.encode(configFileContents); | 47 List<int> bytes = UTF8.encode(configFileContents); |
42 Map<String, Uri> map = pkgfile.parse(bytes, base); | 48 Map<String, Uri> map = pkgfile.parse(bytes, base); |
43 return new MapPackages(map); | 49 return new MapPackages(map); |
44 } | 50 } |
45 | 51 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 isTrue); | 169 isTrue); |
164 expect(utils.startsWith(Uri.parse('/foo/bar/'), Uri.parse('/foo/bar/')), | 170 expect(utils.startsWith(Uri.parse('/foo/bar/'), Uri.parse('/foo/bar/')), |
165 isTrue); | 171 isTrue); |
166 expect(utils.startsWith(Uri.parse('/foo/bar'), Uri.parse('/foo/b')), | 172 expect(utils.startsWith(Uri.parse('/foo/bar'), Uri.parse('/foo/b')), |
167 isFalse); | 173 isFalse); |
168 }); | 174 }); |
169 }); | 175 }); |
170 }); | 176 }); |
171 } | 177 } |
172 | 178 |
173 Source createSource({String path, String uri}) => new MemoryResourceProvider() | |
174 .getFile(path) | |
175 .createSource(uri != null ? Uri.parse(uri) : null); | |
176 | |
177 class CustomUriResolver extends UriResolver { | 179 class CustomUriResolver extends UriResolver { |
178 String uriPath; | 180 String uriPath; |
179 CustomUriResolver({this.uriPath}); | 181 CustomUriResolver({this.uriPath}); |
180 | 182 |
181 @override | 183 @override |
182 Source resolveAbsolute(Uri uri) => createSource(path: uriPath); | 184 Source resolveAbsolute(Uri uri, [Uri actualUri]) => |
| 185 createSource(path: uriPath); |
183 } | 186 } |
184 | 187 |
185 @reflectiveTest | 188 @reflectiveTest |
186 class SourceFactoryTest { | 189 class SourceFactoryTest { |
187 void test_creation() { | 190 void test_creation() { |
188 expect(new SourceFactory([]), isNotNull); | 191 expect(new SourceFactory([]), isNotNull); |
189 } | 192 } |
190 | 193 |
191 void test_fromEncoding_invalidUri() { | 194 void test_fromEncoding_invalidUri() { |
192 SourceFactory factory = new SourceFactory([]); | 195 SourceFactory factory = new SourceFactory([]); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 expect(factory.restoreUri(source2), same(null)); | 278 expect(factory.restoreUri(source2), same(null)); |
276 } | 279 } |
277 } | 280 } |
278 | 281 |
279 class UriResolver_absolute extends UriResolver { | 282 class UriResolver_absolute extends UriResolver { |
280 bool invoked = false; | 283 bool invoked = false; |
281 | 284 |
282 UriResolver_absolute(); | 285 UriResolver_absolute(); |
283 | 286 |
284 @override | 287 @override |
285 Source resolveAbsolute(Uri uri) { | 288 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
286 invoked = true; | 289 invoked = true; |
287 return null; | 290 return null; |
288 } | 291 } |
289 } | 292 } |
290 | 293 |
291 class UriResolver_nonAbsolute_absolute extends UriResolver { | 294 class UriResolver_nonAbsolute_absolute extends UriResolver { |
292 @override | 295 @override |
293 Source resolveAbsolute(Uri uri) { | 296 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
294 return new FileBasedSource(new JavaFile.fromUri(uri), uri); | 297 return new FileBasedSource(new JavaFile.fromUri(uri), actualUri); |
295 } | 298 } |
296 } | 299 } |
297 | 300 |
298 class UriResolver_nonAbsolute_relative extends UriResolver { | 301 class UriResolver_nonAbsolute_relative extends UriResolver { |
299 @override | 302 @override |
300 Source resolveAbsolute(Uri uri) { | 303 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
301 return new FileBasedSource(new JavaFile.fromUri(uri), uri); | 304 return new FileBasedSource(new JavaFile.fromUri(uri), actualUri); |
302 } | 305 } |
303 } | 306 } |
304 | 307 |
305 class UriResolver_restoreUri extends UriResolver { | 308 class UriResolver_restoreUri extends UriResolver { |
306 Source source1; | 309 Source source1; |
307 Uri expected1; | 310 Uri expected1; |
308 UriResolver_restoreUri(this.source1, this.expected1); | 311 UriResolver_restoreUri(this.source1, this.expected1); |
309 | 312 |
310 @override | 313 @override |
311 Source resolveAbsolute(Uri uri) => null; | 314 Source resolveAbsolute(Uri uri, [Uri actualUri]) => null; |
312 | 315 |
313 @override | 316 @override |
314 Uri restoreAbsolute(Source source) { | 317 Uri restoreAbsolute(Source source) { |
315 if (identical(source, source1)) { | 318 if (identical(source, source1)) { |
316 return expected1; | 319 return expected1; |
317 } | 320 } |
318 return null; | 321 return null; |
319 } | 322 } |
320 } | 323 } |
321 | 324 |
322 class UriResolver_SourceFactoryTest_test_fromEncoding_valid | 325 class UriResolver_SourceFactoryTest_test_fromEncoding_valid |
323 extends UriResolver { | 326 extends UriResolver { |
324 String encoding; | 327 String encoding; |
325 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); | 328 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); |
326 | 329 |
327 @override | 330 @override |
328 Source resolveAbsolute(Uri uri) { | 331 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
329 if (uri.toString() == encoding) { | 332 if (uri.toString() == encoding) { |
330 return new TestSource(); | 333 return new TestSource(); |
331 } | 334 } |
332 return null; | 335 return null; |
333 } | 336 } |
334 } | 337 } |
OLD | NEW |