| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 void test_createSource() { | 45 void test_createSource() { |
| 46 new io.File(path).writeAsStringSync('contents'); | 46 new io.File(path).writeAsStringSync('contents'); |
| 47 Source source = file.createSource(); | 47 Source source = file.createSource(); |
| 48 expect(source.uriKind, UriKind.FILE_URI); | 48 expect(source.uriKind, UriKind.FILE_URI); |
| 49 expect(source.exists(), isTrue); | 49 expect(source.exists(), isTrue); |
| 50 expect(source.contents.data, 'contents'); | 50 expect(source.contents.data, 'contents'); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void test_delete() { |
| 54 new io.File(path).writeAsStringSync('contents'); |
| 55 expect(file.exists, isTrue); |
| 56 // delete |
| 57 file.delete(); |
| 58 expect(file.exists, isFalse); |
| 59 } |
| 60 |
| 53 void test_equals_differentPaths() { | 61 void test_equals_differentPaths() { |
| 54 String path2 = join(tempPath, 'file2.txt'); | 62 String path2 = join(tempPath, 'file2.txt'); |
| 55 File file2 = PhysicalResourceProvider.INSTANCE.getResource(path2); | 63 File file2 = PhysicalResourceProvider.INSTANCE.getResource(path2); |
| 56 expect(file == file2, isFalse); | 64 expect(file == file2, isFalse); |
| 57 } | 65 } |
| 58 | 66 |
| 59 void test_equals_samePath() { | 67 void test_equals_samePath() { |
| 60 new io.File(path).writeAsStringSync('contents'); | 68 new io.File(path).writeAsStringSync('contents'); |
| 61 File file2 = PhysicalResourceProvider.INSTANCE.getResource(path); | 69 File file2 = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 62 expect(file == file2, isTrue); | 70 expect(file == file2, isTrue); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 equals(join(path2, 'baz'))); | 223 equals(join(path2, 'baz'))); |
| 216 } | 224 } |
| 217 | 225 |
| 218 void test_contains() { | 226 void test_contains() { |
| 219 expect(folder.contains(join(path, 'aaa.txt')), isTrue); | 227 expect(folder.contains(join(path, 'aaa.txt')), isTrue); |
| 220 expect(folder.contains(join(path, 'aaa', 'bbb.txt')), isTrue); | 228 expect(folder.contains(join(path, 'aaa', 'bbb.txt')), isTrue); |
| 221 expect(folder.contains(join(tempPath, 'baz.txt')), isFalse); | 229 expect(folder.contains(join(tempPath, 'baz.txt')), isFalse); |
| 222 expect(folder.contains(path), isFalse); | 230 expect(folder.contains(path), isFalse); |
| 223 } | 231 } |
| 224 | 232 |
| 233 void test_delete() { |
| 234 new io.File(join(path, 'myFile')).createSync(); |
| 235 var child = folder.getChild('myFile'); |
| 236 expect(child, _isFile); |
| 237 expect(child.exists, isTrue); |
| 238 // delete "folder" |
| 239 folder.delete(); |
| 240 expect(child.exists, isFalse); |
| 241 } |
| 242 |
| 225 void test_equals_differentPaths() { | 243 void test_equals_differentPaths() { |
| 226 String path2 = join(tempPath, 'folder2'); | 244 String path2 = join(tempPath, 'folder2'); |
| 227 new io.Directory(path2).createSync(); | 245 new io.Directory(path2).createSync(); |
| 228 Folder folder2 = PhysicalResourceProvider.INSTANCE.getResource(path2); | 246 Folder folder2 = PhysicalResourceProvider.INSTANCE.getResource(path2); |
| 229 expect(folder == folder2, isFalse); | 247 expect(folder == folder2, isFalse); |
| 230 } | 248 } |
| 231 | 249 |
| 232 void test_equals_samePath() { | 250 void test_equals_samePath() { |
| 233 Folder folder2 = PhysicalResourceProvider.INSTANCE.getResource(path); | 251 Folder folder2 = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 234 expect(folder == folder2, isTrue); | 252 expect(folder == folder2, isTrue); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 544 |
| 527 setUp() { | 545 setUp() { |
| 528 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource'); | 546 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource'); |
| 529 tempPath = tempDirectory.absolute.path; | 547 tempPath = tempDirectory.absolute.path; |
| 530 } | 548 } |
| 531 | 549 |
| 532 tearDown() { | 550 tearDown() { |
| 533 tempDirectory.deleteSync(recursive: true); | 551 tempDirectory.deleteSync(recursive: true); |
| 534 } | 552 } |
| 535 } | 553 } |
| OLD | NEW |