| 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 analyzer.test.file_system.physical_resource_provider_test; | 5 library analyzer.test.file_system.physical_resource_provider_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:core' hide Resource; | 8 import 'dart:core' hide Resource; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 new io.File(oldPath).writeAsStringSync('text'); | 173 new io.File(oldPath).writeAsStringSync('text'); |
| 174 new io.Directory(newPath).createSync(); | 174 new io.Directory(newPath).createSync(); |
| 175 File file = PhysicalResourceProvider.INSTANCE.getResource(oldPath); | 175 File file = PhysicalResourceProvider.INSTANCE.getResource(oldPath); |
| 176 expect(() { | 176 expect(() { |
| 177 file.renameSync(newPath); | 177 file.renameSync(newPath); |
| 178 }, throwsA(_isFileSystemException)); | 178 }, throwsA(_isFileSystemException)); |
| 179 expect(file.path, oldPath); | 179 expect(file.path, oldPath); |
| 180 expect(file.exists, isTrue); | 180 expect(file.exists, isTrue); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void test_toUri() { |
| 184 String path = '/foo/file.txt'; |
| 185 File file = PhysicalResourceProvider.INSTANCE.getFile(path); |
| 186 expect(file.toUri(), new Uri.file(path)); |
| 187 } |
| 188 |
| 183 void test_shortName() { | 189 void test_shortName() { |
| 184 expect(file.shortName, 'file.txt'); | 190 expect(file.shortName, 'file.txt'); |
| 185 } | 191 } |
| 186 | 192 |
| 187 void test_toString() { | 193 void test_toString() { |
| 188 expect(file.toString(), path); | 194 expect(file.toString(), path); |
| 189 } | 195 } |
| 190 | 196 |
| 191 void test_writeAsBytesSync() { | 197 void test_writeAsBytesSync() { |
| 192 new io.File(path).writeAsBytesSync(<int>[1, 2]); | 198 new io.File(path).writeAsBytesSync(<int>[1, 2]); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 while (true) { | 372 while (true) { |
| 367 Resource grandParent = parent.parent; | 373 Resource grandParent = parent.parent; |
| 368 if (grandParent == null) { | 374 if (grandParent == null) { |
| 369 break; | 375 break; |
| 370 } | 376 } |
| 371 expect(grandParent, new isInstanceOf<Folder>()); | 377 expect(grandParent, new isInstanceOf<Folder>()); |
| 372 expect(grandParent.path.length, lessThan(parent.path.length)); | 378 expect(grandParent.path.length, lessThan(parent.path.length)); |
| 373 parent = grandParent; | 379 parent = grandParent; |
| 374 } | 380 } |
| 375 } | 381 } |
| 382 |
| 383 void test_toUri() { |
| 384 String path = '/foo/directory'; |
| 385 Folder folder = PhysicalResourceProvider.INSTANCE.getFolder(path); |
| 386 expect(folder.toUri(), new Uri.directory(path)); |
| 387 } |
| 376 } | 388 } |
| 377 | 389 |
| 378 @reflectiveTest | 390 @reflectiveTest |
| 379 class PhysicalResourceProviderTest extends _BaseTest { | 391 class PhysicalResourceProviderTest extends _BaseTest { |
| 380 test_getModificationTimes() async { | 392 test_getModificationTimes() async { |
| 381 PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE; | 393 PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE; |
| 382 String path = join(tempPath, 'file1.txt'); | 394 String path = join(tempPath, 'file1.txt'); |
| 383 new io.File(path).writeAsStringSync(''); | 395 new io.File(path).writeAsStringSync(''); |
| 384 Source source = provider.getFile(path).createSource(); | 396 Source source = provider.getFile(path).createSource(); |
| 385 List<int> times = await provider.getModificationTimes([source]); | 397 List<int> times = await provider.getModificationTimes([source]); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 565 |
| 554 setUp() { | 566 setUp() { |
| 555 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource'); | 567 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource'); |
| 556 tempPath = tempDirectory.absolute.path; | 568 tempPath = tempDirectory.absolute.path; |
| 557 } | 569 } |
| 558 | 570 |
| 559 tearDown() { | 571 tearDown() { |
| 560 tempDirectory.deleteSync(recursive: true); | 572 tempDirectory.deleteSync(recursive: true); |
| 561 } | 573 } |
| 562 } | 574 } |
| OLD | NEW |