Chromium Code Reviews| 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; | 5 library test.resource; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'mocks.dart'; | 9 import 'mocks.dart'; |
| 10 | 10 |
| 11 import 'package:analysis_server/src/resource.dart'; | 11 import 'package:analysis_server/src/resource.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 12 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
| 13 import 'package:analyzer/src/generated/source_io.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:path/path.dart'; | 14 import 'package:path/path.dart'; |
| 15 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
| 16 import 'package:watcher/watcher.dart'; | 16 import 'package:watcher/watcher.dart'; |
| 17 | 17 |
| 18 main() { | 18 main() { |
| 19 groupSep = ' | '; | 19 groupSep = ' | '; |
| 20 | 20 |
| 21 group('MemoryResourceProvider', () { | 21 group('MemoryResourceProvider', () { |
| 22 MemoryResourceProvider provider; | 22 MemoryResourceProvider provider; |
| 23 | 23 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 expect(source.shortName, 'test.dart'); | 416 expect(source.shortName, 'test.dart'); |
| 417 }); | 417 }); |
| 418 | 418 |
| 419 test('resolveRelative', () { | 419 test('resolveRelative', () { |
| 420 var relative = source.resolveRelative(new Uri.file('bar/baz.dart')); | 420 var relative = source.resolveRelative(new Uri.file('bar/baz.dart')); |
| 421 expect(relative.fullName, '/foo/bar/baz.dart'); | 421 expect(relative.fullName, '/foo/bar/baz.dart'); |
| 422 }); | 422 }); |
| 423 }); | 423 }); |
| 424 }); | 424 }); |
| 425 }); | 425 }); |
| 426 | |
| 427 group('ResourceUriResolver', _testResourceResourceUriResolver); | |
| 426 } | 428 } |
| 427 | 429 |
| 428 var _isFile = new isInstanceOf<File>(); | 430 var _isFile = new isInstanceOf<File>(); |
| 429 var _isFolder = new isInstanceOf<Folder>(); | 431 var _isFolder = new isInstanceOf<Folder>(); |
| 430 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); | 432 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); |
| 433 | |
| 434 | |
| 435 void _testResourceResourceUriResolver() { | |
|
Brian Wilkerson
2014/06/24 13:53:41
I don't understand the value of private names in t
scheglov
2014/06/24 15:21:23
Done.
| |
| 436 MemoryResourceProvider provider; | |
| 437 ResourceUriResolver resolver; | |
| 438 | |
| 439 setUp(() { | |
| 440 provider = new MemoryResourceProvider(); | |
| 441 resolver = new ResourceUriResolver(provider); | |
| 442 provider.newFile('/test.dart', ''); | |
| 443 provider.newFolder('/folder'); | |
| 444 }); | |
| 445 | |
| 446 group('fromEncoding', () { | |
| 447 test('file', () { | |
| 448 var uri = new Uri(path: '/test.dart'); | |
| 449 Source source = resolver.fromEncoding(UriKind.FILE_URI, uri); | |
| 450 expect(source, isNotNull); | |
| 451 expect(source.exists(), isTrue); | |
| 452 expect(source.fullName, '/test.dart'); | |
| 453 }); | |
| 454 | |
| 455 test('not a UriKind.FILE_URI', () { | |
| 456 var uri = new Uri(path: '/test.dart'); | |
| 457 Source source = resolver.fromEncoding(UriKind.DART_URI, uri); | |
| 458 expect(source, isNull); | |
| 459 }); | |
| 460 }); | |
| 461 | |
| 462 group('resolveAbsolute', () { | |
| 463 test('file', () { | |
| 464 var uri = new Uri(scheme: 'file', path: '/test.dart'); | |
| 465 Source source = resolver.resolveAbsolute(uri); | |
| 466 expect(source, isNotNull); | |
| 467 expect(source.exists(), isTrue); | |
| 468 expect(source.fullName, '/test.dart'); | |
| 469 }); | |
| 470 | |
| 471 test('folder', () { | |
| 472 var uri = new Uri(scheme: 'file', path: '/folder'); | |
| 473 Source source = resolver.resolveAbsolute(uri); | |
| 474 expect(source, isNull); | |
| 475 }); | |
| 476 | |
| 477 test('not a file URI', () { | |
| 478 var uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart'); | |
| 479 Source source = resolver.resolveAbsolute(uri); | |
| 480 expect(source, isNull); | |
| 481 }); | |
| 482 }); | |
| 483 } | |
| OLD | NEW |