| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Directory listing test. | 5 // Directory listing test. |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("dart:isolate"); | 8 #import("dart:isolate"); |
| 9 | 9 |
| 10 class DirectoryTest { | 10 class DirectoryTest { |
| 11 static void testListing() { | 11 static void testListing() { |
| 12 bool listedDir = false; | 12 bool listedDir = false; |
| 13 bool listedFile = false; | 13 bool listedFile = false; |
| 14 | 14 |
| 15 Directory directory = new Directory(""); | 15 Directory directory = new Directory(""); |
| 16 directory.createTempSync(); | 16 directory.createTempSync(); |
| 17 Directory subDirectory = new Directory("${directory.path}/subdir"); | 17 Directory subDirectory = new Directory("${directory.path}/subdir"); |
| 18 Expect.isFalse(subDirectory.existsSync()); | 18 Expect.isFalse(subDirectory.existsSync()); |
| 19 subDirectory.createSync(); | 19 subDirectory.createSync(); |
| 20 File f = new File('${subDirectory.path}/file.txt'); | 20 File f = new File('${subDirectory.path}/file.txt'); |
| 21 Expect.isFalse(f.existsSync()); | 21 Expect.isFalse(f.existsSync()); |
| 22 f.createSync(); | 22 f.createSync(); |
| 23 | 23 |
| 24 directory.dirHandler = (dir) { | 24 directory.onDir = (dir) { |
| 25 listedDir = true; | 25 listedDir = true; |
| 26 Expect.isTrue(dir.contains(directory.path)); | 26 Expect.isTrue(dir.contains(directory.path)); |
| 27 Expect.isTrue(dir.contains('subdir')); | 27 Expect.isTrue(dir.contains('subdir')); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 directory.fileHandler = (f) { | 30 directory.onFile = (f) { |
| 31 listedFile = true; | 31 listedFile = true; |
| 32 Expect.isTrue(f.contains(directory.path)); | 32 Expect.isTrue(f.contains(directory.path)); |
| 33 Expect.isTrue(f.contains('subdir')); | 33 Expect.isTrue(f.contains('subdir')); |
| 34 Expect.isTrue(f.contains('file.txt')); | 34 Expect.isTrue(f.contains('file.txt')); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 directory.doneHandler = (completed) { | 37 directory.onDone = (completed) { |
| 38 Expect.isTrue(completed, "directory listing did not complete"); | 38 Expect.isTrue(completed, "directory listing did not complete"); |
| 39 Expect.isTrue(listedDir, "directory not found"); | 39 Expect.isTrue(listedDir, "directory not found"); |
| 40 Expect.isTrue(listedFile, "file not found"); | 40 Expect.isTrue(listedFile, "file not found"); |
| 41 directory.delete(recursive: true); | 41 directory.delete(recursive: true); |
| 42 directory.deleteHandler = () { | 42 directory.onDelete = () { |
| 43 f.exists(); | 43 f.exists(); |
| 44 f.existsHandler = (exists) => Expect.isFalse(exists); | 44 f.onExists = (exists) => Expect.isFalse(exists); |
| 45 directory.exists(); | 45 directory.exists(); |
| 46 directory.existsHandler = (exists) => Expect.isFalse(exists); | 46 directory.onExists = (exists) => Expect.isFalse(exists); |
| 47 subDirectory.exists(); | 47 subDirectory.exists(); |
| 48 subDirectory.existsHandler = (exists) => Expect.isFalse(exists); | 48 subDirectory.onExists = (exists) => Expect.isFalse(exists); |
| 49 }; | 49 }; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 directory.errorHandler = (error) { | 52 directory.onError = (error) { |
| 53 Expect.fail("error listing directory: $error"); | 53 Expect.fail("error listing directory: $error"); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 directory.list(recursive: true); | 56 directory.list(recursive: true); |
| 57 | 57 |
| 58 // Listing is asynchronous, so nothing should be listed at this | 58 // Listing is asynchronous, so nothing should be listed at this |
| 59 // point. | 59 // point. |
| 60 Expect.isFalse(listedDir); | 60 Expect.isFalse(listedDir); |
| 61 Expect.isFalse(listedFile); | 61 Expect.isFalse(listedFile); |
| 62 } | 62 } |
| 63 | 63 |
| 64 static void testListNonExistent() { | 64 static void testListNonExistent() { |
| 65 Directory d = new Directory(""); | 65 Directory d = new Directory(""); |
| 66 d.errorHandler = (error) { | 66 d.onError = (error) { |
| 67 Expect.fail("Directory error: $error"); | 67 Expect.fail("Directory error: $error"); |
| 68 }; | 68 }; |
| 69 d.createTemp(); | 69 d.createTemp(); |
| 70 d.createTempHandler = () { | 70 d.onCreateTemp = () { |
| 71 d.delete(); | 71 d.delete(); |
| 72 d.deleteHandler = () { | 72 d.onDelete = () { |
| 73 // Test that listing a non-existing directory fails. | 73 // Test that listing a non-existing directory fails. |
| 74 d.errorHandler = (error) { | 74 d.onError = (error) { |
| 75 // TODO(ager): When directory errors have been changed to | 75 // TODO(ager): When directory errors have been changed to |
| 76 // post back exceptions, check that we get the right exception | 76 // post back exceptions, check that we get the right exception |
| 77 // type here. | 77 // type here. |
| 78 }; | 78 }; |
| 79 d.fileHandler = (file) { | 79 d.onFile = (file) { |
| 80 Expect.fail("Listing of non-existing directory should fail"); | 80 Expect.fail("Listing of non-existing directory should fail"); |
| 81 }; | 81 }; |
| 82 d.fileHandler = (dir) { | 82 d.onFile = (dir) { |
| 83 Expect.fail("Listing of non-existing directory should fail"); | 83 Expect.fail("Listing of non-existing directory should fail"); |
| 84 }; | 84 }; |
| 85 d.doneHandler = (done) { | 85 d.onDone = (done) { |
| 86 Expect.isFalse(done); | 86 Expect.isFalse(done); |
| 87 }; | 87 }; |
| 88 d.list(); | 88 d.list(); |
| 89 d.list(recursive: true); | 89 d.list(recursive: true); |
| 90 }; | 90 }; |
| 91 }; | 91 }; |
| 92 } | 92 } |
| 93 | 93 |
| 94 static void testListTooLongName() { | 94 static void testListTooLongName() { |
| 95 Directory d = new Directory(""); | 95 Directory d = new Directory(""); |
| 96 d.errorHandler = (error) { | 96 d.onError = (error) { |
| 97 Expect.fail("Directory error: $error"); | 97 Expect.fail("Directory error: $error"); |
| 98 }; | 98 }; |
| 99 d.createTemp(); | 99 d.createTemp(); |
| 100 d.createTempHandler = () { | 100 d.onCreateTemp = () { |
| 101 var subDirName = 'subdir'; | 101 var subDirName = 'subdir'; |
| 102 var subDir = new Directory("${d.path}/$subDirName"); | 102 var subDir = new Directory("${d.path}/$subDirName"); |
| 103 subDir.errorHandler = (error) { | 103 subDir.onError = (error) { |
| 104 Expect.fail("Directory error: $error"); | 104 Expect.fail("Directory error: $error"); |
| 105 }; | 105 }; |
| 106 subDir.create(); | 106 subDir.create(); |
| 107 subDir.createHandler = () { | 107 subDir.onCreate = () { |
| 108 // Construct a long string of the form | 108 // Construct a long string of the form |
| 109 // 'tempdir/subdir/../subdir/../subdir'. | 109 // 'tempdir/subdir/../subdir/../subdir'. |
| 110 var buffer = new StringBuffer(); | 110 var buffer = new StringBuffer(); |
| 111 buffer.add(subDir.path); | 111 buffer.add(subDir.path); |
| 112 for (var i = 0; i < 1000; i++) { | 112 for (var i = 0; i < 1000; i++) { |
| 113 buffer.add("/../${subDirName}"); | 113 buffer.add("/../${subDirName}"); |
| 114 } | 114 } |
| 115 var long = new Directory("${buffer.toString()}"); | 115 var long = new Directory("${buffer.toString()}"); |
| 116 var errors = 0; | 116 var errors = 0; |
| 117 long.errorHandler = (error) { | 117 long.onError = (error) { |
| 118 // TODO(ager): When directory errors have been changed to | 118 // TODO(ager): When directory errors have been changed to |
| 119 // post back exceptions, check that we get the right exception | 119 // post back exceptions, check that we get the right exception |
| 120 // type here. | 120 // type here. |
| 121 if (++errors == 2) { | 121 if (++errors == 2) { |
| 122 d.delete(recursive: true); | 122 d.delete(recursive: true); |
| 123 } | 123 } |
| 124 }; | 124 }; |
| 125 long.fileHandler = (file) { | 125 long.onFile = (file) { |
| 126 Expect.fail("Listing of non-existing directory should fail"); | 126 Expect.fail("Listing of non-existing directory should fail"); |
| 127 }; | 127 }; |
| 128 long.fileHandler = (dir) { | 128 long.onFile = (dir) { |
| 129 Expect.fail("Listing of non-existing directory should fail"); | 129 Expect.fail("Listing of non-existing directory should fail"); |
| 130 }; | 130 }; |
| 131 long.doneHandler = (done) { | 131 long.onDone = (done) { |
| 132 Expect.isFalse(done); | 132 Expect.isFalse(done); |
| 133 }; | 133 }; |
| 134 long.list(); | 134 long.list(); |
| 135 long.list(recursive: true); | 135 long.list(recursive: true); |
| 136 }; | 136 }; |
| 137 }; | 137 }; |
| 138 } | 138 } |
| 139 | 139 |
| 140 static void testDeleteNonExistent() { | 140 static void testDeleteNonExistent() { |
| 141 Directory d = new Directory(""); | 141 Directory d = new Directory(""); |
| 142 d.errorHandler = (error) { | 142 d.onError = (error) { |
| 143 Expect.fail("Directory error: $error"); | 143 Expect.fail("Directory error: $error"); |
| 144 }; | 144 }; |
| 145 d.createTemp(); | 145 d.createTemp(); |
| 146 d.createTempHandler = () { | 146 d.onCreateTemp = () { |
| 147 d.delete(); | 147 d.delete(); |
| 148 d.deleteHandler = () { | 148 d.onDelete = () { |
| 149 // Test that deleting a non-existing directory fails. | 149 // Test that deleting a non-existing directory fails. |
| 150 d.errorHandler = (error) { | 150 d.onError = (error) { |
| 151 // TODO(ager): When directory errors have been changed to | 151 // TODO(ager): When directory errors have been changed to |
| 152 // post back exceptions, check that we get the right exception | 152 // post back exceptions, check that we get the right exception |
| 153 // type here. | 153 // type here. |
| 154 }; | 154 }; |
| 155 d.deleteHandler = () { | 155 d.onDelete = () { |
| 156 Expect.fail("Deletion of non-existing directory should fail"); | 156 Expect.fail("Deletion of non-existing directory should fail"); |
| 157 }; | 157 }; |
| 158 d.delete(); | 158 d.delete(); |
| 159 d.delete(recursive: true); | 159 d.delete(recursive: true); |
| 160 }; | 160 }; |
| 161 }; | 161 }; |
| 162 } | 162 } |
| 163 | 163 |
| 164 static void testDeleteTooLongName() { | 164 static void testDeleteTooLongName() { |
| 165 Directory d = new Directory(""); | 165 Directory d = new Directory(""); |
| 166 d.errorHandler = (error) { | 166 d.onError = (error) { |
| 167 Expect.fail("Directory error: $error"); | 167 Expect.fail("Directory error: $error"); |
| 168 }; | 168 }; |
| 169 d.createTemp(); | 169 d.createTemp(); |
| 170 d.createTempHandler = () { | 170 d.onCreateTemp = () { |
| 171 var subDirName = 'subdir'; | 171 var subDirName = 'subdir'; |
| 172 var subDir = new Directory("${d.path}/$subDirName"); | 172 var subDir = new Directory("${d.path}/$subDirName"); |
| 173 subDir.errorHandler = (error) { | 173 subDir.onError = (error) { |
| 174 Expect.fail("Directory error: $error"); | 174 Expect.fail("Directory error: $error"); |
| 175 }; | 175 }; |
| 176 subDir.create(); | 176 subDir.create(); |
| 177 subDir.createHandler = () { | 177 subDir.onCreate = () { |
| 178 // Construct a long string of the form | 178 // Construct a long string of the form |
| 179 // 'tempdir/subdir/../subdir/../subdir'. | 179 // 'tempdir/subdir/../subdir/../subdir'. |
| 180 var buffer = new StringBuffer(); | 180 var buffer = new StringBuffer(); |
| 181 buffer.add(subDir.path); | 181 buffer.add(subDir.path); |
| 182 for (var i = 0; i < 1000; i++) { | 182 for (var i = 0; i < 1000; i++) { |
| 183 buffer.add("/../${subDirName}"); | 183 buffer.add("/../${subDirName}"); |
| 184 } | 184 } |
| 185 var long = new Directory("${buffer.toString()}"); | 185 var long = new Directory("${buffer.toString()}"); |
| 186 var errors = 0; | 186 var errors = 0; |
| 187 long.errorHandler = (error) { | 187 long.onError = (error) { |
| 188 // TODO(ager): When directory errors have been changed to | 188 // TODO(ager): When directory errors have been changed to |
| 189 // post back exceptions, check that we get the right exception | 189 // post back exceptions, check that we get the right exception |
| 190 // type here. | 190 // type here. |
| 191 if (++errors == 2) { | 191 if (++errors == 2) { |
| 192 d.delete(recursive: true); | 192 d.delete(recursive: true); |
| 193 } | 193 } |
| 194 }; | 194 }; |
| 195 long.deleteHandler = () { | 195 long.onDelete = () { |
| 196 Expect.fail("Deletion of a directory with a long name should fail"); | 196 Expect.fail("Deletion of a directory with a long name should fail"); |
| 197 }; | 197 }; |
| 198 long.delete(); | 198 long.delete(); |
| 199 long.delete(recursive:true); | 199 long.delete(recursive:true); |
| 200 }; | 200 }; |
| 201 }; | 201 }; |
| 202 } | 202 } |
| 203 | 203 |
| 204 static void testDeleteNonExistentSync() { | 204 static void testDeleteNonExistentSync() { |
| 205 Directory d = new Directory(""); | 205 Directory d = new Directory(""); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 222 for (var i = 0; i < 1000; i++) { | 222 for (var i = 0; i < 1000; i++) { |
| 223 buffer.add("/../${subDirName}"); | 223 buffer.add("/../${subDirName}"); |
| 224 } | 224 } |
| 225 var long = new Directory("${buffer.toString()}"); | 225 var long = new Directory("${buffer.toString()}"); |
| 226 Expect.throws(long.deleteSync); | 226 Expect.throws(long.deleteSync); |
| 227 Expect.throws(() => long.deleteSync(recursive:true)); | 227 Expect.throws(() => long.deleteSync(recursive:true)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 static void testExistsCreateDelete() { | 230 static void testExistsCreateDelete() { |
| 231 Directory d = new Directory(""); | 231 Directory d = new Directory(""); |
| 232 d.createTempHandler = () { | 232 d.onCreateTemp = () { |
| 233 d.existsHandler = (bool exists) { | 233 d.onExists = (bool exists) { |
| 234 Expect.isTrue(exists); | 234 Expect.isTrue(exists); |
| 235 Directory created = new Directory("${d.path}/subdir"); | 235 Directory created = new Directory("${d.path}/subdir"); |
| 236 created.createHandler = () { | 236 created.onCreate = () { |
| 237 created.existsHandler = (bool exists) { | 237 created.onExists = (bool exists) { |
| 238 Expect.isTrue(exists); | 238 Expect.isTrue(exists); |
| 239 created.deleteHandler = () { | 239 created.onDelete = () { |
| 240 created.existsHandler = (bool exists) { | 240 created.onExists = (bool exists) { |
| 241 Expect.isFalse(exists); | 241 Expect.isFalse(exists); |
| 242 d.deleteHandler = () { | 242 d.onDelete = () { |
| 243 d.existsHandler = (bool exists) { | 243 d.onExists = (bool exists) { |
| 244 Expect.isFalse(exists); | 244 Expect.isFalse(exists); |
| 245 }; | 245 }; |
| 246 d.exists(); | 246 d.exists(); |
| 247 }; | 247 }; |
| 248 d.delete(); | 248 d.delete(); |
| 249 }; | 249 }; |
| 250 created.exists(); | 250 created.exists(); |
| 251 }; | 251 }; |
| 252 created.delete(); | 252 created.delete(); |
| 253 }; | 253 }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 281 bool emptyTemplateTestRunning = false; | 281 bool emptyTemplateTestRunning = false; |
| 282 | 282 |
| 283 // Stages 0 through 2 run twice, the second time with an empty path. | 283 // Stages 0 through 2 run twice, the second time with an empty path. |
| 284 Function stage0; | 284 Function stage0; |
| 285 Function stage1a; | 285 Function stage1a; |
| 286 Function stage1b; | 286 Function stage1b; |
| 287 Function stage2; | 287 Function stage2; |
| 288 Function stage3; // Loops to stage 0. | 288 Function stage3; // Loops to stage 0. |
| 289 | 289 |
| 290 Function error(String message) { | 290 Function error(String message) { |
| 291 Expect.fail("Directory errorHandler: $message"); | 291 Expect.fail("Directory onError: $message"); |
| 292 } | 292 } |
| 293 | 293 |
| 294 stage0 = () { | 294 stage0 = () { |
| 295 tempDir1.createTempHandler = stage1a; | 295 tempDir1.onCreateTemp = stage1a; |
| 296 tempDir1.errorHandler = error; | 296 tempDir1.onError = error; |
| 297 tempDir1.createTemp(); | 297 tempDir1.createTemp(); |
| 298 tempDir2.createTempHandler = stage1b; | 298 tempDir2.onCreateTemp = stage1b; |
| 299 tempDir2.errorHandler = error; | 299 tempDir2.onError = error; |
| 300 tempDir2.createTemp(); | 300 tempDir2.createTemp(); |
| 301 }; | 301 }; |
| 302 | 302 |
| 303 stage1a = () { | 303 stage1a = () { |
| 304 stage1aDone = true; | 304 stage1aDone = true; |
| 305 Expect.isTrue(tempDir1.existsSync()); | 305 Expect.isTrue(tempDir1.existsSync()); |
| 306 if (stage1bDone) { | 306 if (stage1bDone) { |
| 307 stage2(); | 307 stage2(); |
| 308 } | 308 } |
| 309 }; | 309 }; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 if (new Directory("/tmp").existsSync()) { | 341 if (new Directory("/tmp").existsSync()) { |
| 342 stage0(); | 342 stage0(); |
| 343 } else { | 343 } else { |
| 344 emptyTemplateTestRunning = true; | 344 emptyTemplateTestRunning = true; |
| 345 stage3(); | 345 stage3(); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 static void testCreateDeleteTemp() { | 349 static void testCreateDeleteTemp() { |
| 350 Directory tempDirectory = new Directory(""); | 350 Directory tempDirectory = new Directory(""); |
| 351 tempDirectory.createTempHandler = () { | 351 tempDirectory.onCreateTemp = () { |
| 352 String filename = tempDirectory.path + | 352 String filename = tempDirectory.path + |
| 353 new Platform().pathSeparator() + "dart_testfile"; | 353 new Platform().pathSeparator() + "dart_testfile"; |
| 354 File file = new File(filename); | 354 File file = new File(filename); |
| 355 Expect.isFalse(file.existsSync()); | 355 Expect.isFalse(file.existsSync()); |
| 356 file.errorHandler = (error) { | 356 file.onError = (error) { |
| 357 Expect.fail("testCreateTemp file.errorHandler called: $error"); | 357 Expect.fail("testCreateTemp file.onError called: $error"); |
| 358 }; | 358 }; |
| 359 file.createHandler = () { | 359 file.onCreate = () { |
| 360 file.existsHandler = (bool exists) { | 360 file.onExists = (bool exists) { |
| 361 Expect.isTrue(exists); | 361 Expect.isTrue(exists); |
| 362 // Try to delete the directory containing the file - should throw. | 362 // Try to delete the directory containing the file - should throw. |
| 363 Expect.throws(tempDirectory.deleteSync); | 363 Expect.throws(tempDirectory.deleteSync); |
| 364 Expect.isTrue(tempDirectory.existsSync()); | 364 Expect.isTrue(tempDirectory.existsSync()); |
| 365 | 365 |
| 366 // Delete the file, and then delete the directory. | 366 // Delete the file, and then delete the directory. |
| 367 file.deleteHandler = () { | 367 file.onDelete = () { |
| 368 tempDirectory.deleteSync(); | 368 tempDirectory.deleteSync(); |
| 369 Expect.isFalse(tempDirectory.existsSync()); | 369 Expect.isFalse(tempDirectory.existsSync()); |
| 370 }; | 370 }; |
| 371 file.delete(); | 371 file.delete(); |
| 372 }; | 372 }; |
| 373 file.exists(); | 373 file.exists(); |
| 374 }; | 374 }; |
| 375 file.create(); | 375 file.create(); |
| 376 }; | 376 }; |
| 377 tempDirectory.createTemp(); | 377 tempDirectory.createTemp(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 393 } | 393 } |
| 394 | 394 |
| 395 | 395 |
| 396 class NestedTempDirectoryTest { | 396 class NestedTempDirectoryTest { |
| 397 List<Directory> createdDirectories; | 397 List<Directory> createdDirectories; |
| 398 Directory current; | 398 Directory current; |
| 399 | 399 |
| 400 NestedTempDirectoryTest.run() | 400 NestedTempDirectoryTest.run() |
| 401 : createdDirectories = new List<Directory>(), | 401 : createdDirectories = new List<Directory>(), |
| 402 current = new Directory("") { | 402 current = new Directory("") { |
| 403 current.createTempHandler = createPhaseCallback; | 403 current.onCreateTemp = createPhaseCallback; |
| 404 current.errorHandler = errorCallback; | 404 current.onError = errorCallback; |
| 405 current.createTemp(); | 405 current.createTemp(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void errorCallback(error) { | 408 void errorCallback(error) { |
| 409 Expect.fail("Error callback called in NestedTempDirectoryTest: $error"); | 409 Expect.fail("Error callback called in NestedTempDirectoryTest: $error"); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void createPhaseCallback() { | 412 void createPhaseCallback() { |
| 413 createdDirectories.add(current); | 413 createdDirectories.add(current); |
| 414 int nestingDepth = 6; | 414 int nestingDepth = 6; |
| 415 var os = new Platform().operatingSystem(); | 415 var os = new Platform().operatingSystem(); |
| 416 if (os == "windows") nestingDepth = 2; | 416 if (os == "windows") nestingDepth = 2; |
| 417 if (createdDirectories.length < nestingDepth) { | 417 if (createdDirectories.length < nestingDepth) { |
| 418 current = new Directory( | 418 current = new Directory( |
| 419 current.path + "/nested_temp_dir_${createdDirectories.length}_"); | 419 current.path + "/nested_temp_dir_${createdDirectories.length}_"); |
| 420 current.errorHandler = errorCallback; | 420 current.onError = errorCallback; |
| 421 current.createTempHandler = createPhaseCallback; | 421 current.onCreateTemp = createPhaseCallback; |
| 422 current.createTemp(); | 422 current.createTemp(); |
| 423 } else { | 423 } else { |
| 424 deletePhaseCallback(); | 424 deletePhaseCallback(); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 void deletePhaseCallback() { | 428 void deletePhaseCallback() { |
| 429 if (!createdDirectories.isEmpty()) { | 429 if (!createdDirectories.isEmpty()) { |
| 430 current = createdDirectories.removeLast(); | 430 current = createdDirectories.removeLast(); |
| 431 current.deleteSync(); | 431 current.deleteSync(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 testCreateTempError() { | 465 testCreateTempError() { |
| 466 var location = illegalTempDirectoryLocation(); | 466 var location = illegalTempDirectoryLocation(); |
| 467 if (location == null) return; | 467 if (location == null) return; |
| 468 | 468 |
| 469 var resultPort = new ReceivePort.singleShot(); | 469 var resultPort = new ReceivePort.singleShot(); |
| 470 resultPort.receive((String message, ignored) { | 470 resultPort.receive((String message, ignored) { |
| 471 Expect.equals("error", message); | 471 Expect.equals("error", message); |
| 472 }); | 472 }); |
| 473 | 473 |
| 474 Directory dir = new Directory(location); | 474 Directory dir = new Directory(location); |
| 475 dir.errorHandler = (error) { resultPort.toSendPort().send("error"); }; | 475 dir.onError = (error) { resultPort.toSendPort().send("error"); }; |
| 476 dir.createTempHandler = () { resultPort.toSendPort().send("success"); }; | 476 dir.onCreateTemp = () { resultPort.toSendPort().send("success"); }; |
| 477 dir.createTemp(); | 477 dir.createTemp(); |
| 478 } | 478 } |
| 479 | 479 |
| 480 | 480 |
| 481 main() { | 481 main() { |
| 482 DirectoryTest.testMain(); | 482 DirectoryTest.testMain(); |
| 483 NestedTempDirectoryTest.testMain(); | 483 NestedTempDirectoryTest.testMain(); |
| 484 testCreateTempErrorSync(); | 484 testCreateTempErrorSync(); |
| 485 testCreateTempError(); | 485 testCreateTempError(); |
| 486 } | 486 } |
| OLD | NEW |