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