OLD | NEW |
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 test.resource_uri_resolver; | 5 library test.resource_uri_resolver; |
6 | 6 |
7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
11 | 11 |
12 | 12 |
13 main() { | 13 main() { |
14 groupSep = ' | '; | 14 groupSep = ' | '; |
15 group('ResourceUriResolver', () { | 15 group('ResourceUriResolver', () { |
16 MemoryResourceProvider provider; | 16 MemoryResourceProvider provider; |
17 ResourceUriResolver resolver; | 17 ResourceUriResolver resolver; |
18 | 18 |
19 setUp(() { | 19 setUp(() { |
20 provider = new MemoryResourceProvider(); | 20 provider = new MemoryResourceProvider(); |
21 resolver = new ResourceUriResolver(provider); | 21 resolver = new ResourceUriResolver(provider); |
22 provider.newFile('/test.dart', ''); | 22 provider.newFile('/test.dart', ''); |
23 provider.newFolder('/folder'); | 23 provider.newFolder('/folder'); |
24 }); | 24 }); |
25 | 25 |
26 group('fromEncoding', () { | |
27 test('file', () { | |
28 var uri = new Uri(path: '/test.dart'); | |
29 Source source = resolver.fromEncoding(UriKind.FILE_URI, uri); | |
30 expect(source, isNotNull); | |
31 expect(source.exists(), isTrue); | |
32 expect(source.fullName, '/test.dart'); | |
33 }); | |
34 | |
35 test('not a UriKind.FILE_URI', () { | |
36 var uri = new Uri(path: '/test.dart'); | |
37 Source source = resolver.fromEncoding(UriKind.DART_URI, uri); | |
38 expect(source, isNull); | |
39 }); | |
40 }); | |
41 | |
42 group('resolveAbsolute', () { | 26 group('resolveAbsolute', () { |
43 test('file', () { | 27 test('file', () { |
44 var uri = new Uri(scheme: 'file', path: '/test.dart'); | 28 var uri = new Uri(scheme: 'file', path: '/test.dart'); |
45 Source source = resolver.resolveAbsolute(uri); | 29 Source source = resolver.resolveAbsolute(uri); |
46 expect(source, isNotNull); | 30 expect(source, isNotNull); |
47 expect(source.exists(), isTrue); | 31 expect(source.exists(), isTrue); |
48 expect(source.fullName, '/test.dart'); | 32 expect(source.fullName, '/test.dart'); |
49 }); | 33 }); |
50 | 34 |
51 test('folder', () { | 35 test('folder', () { |
52 var uri = new Uri(scheme: 'file', path: '/folder'); | 36 var uri = new Uri(scheme: 'file', path: '/folder'); |
53 Source source = resolver.resolveAbsolute(uri); | 37 Source source = resolver.resolveAbsolute(uri); |
54 expect(source, isNull); | 38 expect(source, isNull); |
55 }); | 39 }); |
56 | 40 |
57 test('not a file URI', () { | 41 test('not a file URI', () { |
58 var uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart'); | 42 var uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart'); |
59 Source source = resolver.resolveAbsolute(uri); | 43 Source source = resolver.resolveAbsolute(uri); |
60 expect(source, isNull); | 44 expect(source, isNull); |
61 }); | 45 }); |
62 }); | 46 }); |
63 }); | 47 }); |
64 } | 48 } |
OLD | NEW |