Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: tests/standalone/io/directory_test.dart

Issue 10351011: Change Platform members to getters instead of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding new test binaries Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/standalone/io/directory_error_test.dart ('k') | tests/standalone/io/file_error_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } else { 315 } else {
316 emptyTemplateTestRunning = true; 316 emptyTemplateTestRunning = true;
317 stage3(); 317 stage3();
318 } 318 }
319 } 319 }
320 320
321 static void testCreateDeleteTemp() { 321 static void testCreateDeleteTemp() {
322 Directory tempDirectory = new Directory(""); 322 Directory tempDirectory = new Directory("");
323 tempDirectory.createTemp(() { 323 tempDirectory.createTemp(() {
324 String filename = tempDirectory.path + 324 String filename = tempDirectory.path +
325 Platform.pathSeparator() + "dart_testfile"; 325 Platform.pathSeparator + "dart_testfile";
326 File file = new File(filename); 326 File file = new File(filename);
327 Expect.isFalse(file.existsSync()); 327 Expect.isFalse(file.existsSync());
328 file.onError = (e) { 328 file.onError = (e) {
329 Expect.fail("testCreateTemp file.onError called: $e"); 329 Expect.fail("testCreateTemp file.onError called: $e");
330 }; 330 };
331 file.create(() { 331 file.create(() {
332 file.exists((bool exists) { 332 file.exists((bool exists) {
333 Expect.isTrue(exists); 333 Expect.isTrue(exists);
334 // Try to delete the directory containing the file - should throw. 334 // Try to delete the directory containing the file - should throw.
335 Expect.throws(tempDirectory.deleteSync); 335 Expect.throws(tempDirectory.deleteSync);
336 Expect.isTrue(tempDirectory.existsSync()); 336 Expect.isTrue(tempDirectory.existsSync());
337 337
338 // Delete the file, and then delete the directory. 338 // Delete the file, and then delete the directory.
339 file.delete(() { 339 file.delete(() {
340 tempDirectory.deleteSync(); 340 tempDirectory.deleteSync();
341 Expect.isFalse(tempDirectory.existsSync()); 341 Expect.isFalse(tempDirectory.existsSync());
342 }); 342 });
343 }); 343 });
344 }); 344 });
345 }); 345 });
346 } 346 }
347 347
348 static void testCurrent() { 348 static void testCurrent() {
349 Directory current = new Directory.current(); 349 Directory current = new Directory.current();
350 if (Platform.operatingSystem() != "windows") { 350 if (Platform.operatingSystem != "windows") {
351 Expect.equals("/", current.path.substring(0, 1)); 351 Expect.equals("/", current.path.substring(0, 1));
352 } 352 }
353 } 353 }
354 354
355 static void testMain() { 355 static void testMain() {
356 testListing(); 356 testListing();
357 testListNonExistent(); 357 testListNonExistent();
358 testListTooLongName(); 358 testListTooLongName();
359 testDeleteNonExistent(); 359 testDeleteNonExistent();
360 testDeleteTooLongName(); 360 testDeleteTooLongName();
(...skipping 19 matching lines...) Expand all
380 current.createTemp(createPhaseCallback); 380 current.createTemp(createPhaseCallback);
381 } 381 }
382 382
383 void errorCallback(e) { 383 void errorCallback(e) {
384 Expect.fail("Error callback called in NestedTempDirectoryTest: $e"); 384 Expect.fail("Error callback called in NestedTempDirectoryTest: $e");
385 } 385 }
386 386
387 void createPhaseCallback() { 387 void createPhaseCallback() {
388 createdDirectories.add(current); 388 createdDirectories.add(current);
389 int nestingDepth = 6; 389 int nestingDepth = 6;
390 var os = Platform.operatingSystem(); 390 var os = Platform.operatingSystem;
391 if (os == "windows") nestingDepth = 2; 391 if (os == "windows") nestingDepth = 2;
392 if (createdDirectories.length < nestingDepth) { 392 if (createdDirectories.length < nestingDepth) {
393 current = new Directory( 393 current = new Directory(
394 current.path + "/nested_temp_dir_${createdDirectories.length}_"); 394 current.path + "/nested_temp_dir_${createdDirectories.length}_");
395 current.onError = errorCallback; 395 current.onError = errorCallback;
396 current.createTemp(createPhaseCallback); 396 current.createTemp(createPhaseCallback);
397 } else { 397 } else {
398 deletePhaseCallback(); 398 deletePhaseCallback();
399 } 399 }
400 } 400 }
401 401
402 void deletePhaseCallback() { 402 void deletePhaseCallback() {
403 if (!createdDirectories.isEmpty()) { 403 if (!createdDirectories.isEmpty()) {
404 current = createdDirectories.removeLast(); 404 current = createdDirectories.removeLast();
405 current.deleteSync(); 405 current.deleteSync();
406 deletePhaseCallback(); 406 deletePhaseCallback();
407 } 407 }
408 } 408 }
409 409
410 static void testMain() { 410 static void testMain() {
411 new NestedTempDirectoryTest.run(); 411 new NestedTempDirectoryTest.run();
412 new NestedTempDirectoryTest.run(); 412 new NestedTempDirectoryTest.run();
413 } 413 }
414 } 414 }
415 415
416 416
417 String illegalTempDirectoryLocation() { 417 String illegalTempDirectoryLocation() {
418 // Determine a platform specific illegal location for a temporary directory. 418 // Determine a platform specific illegal location for a temporary directory.
419 var os = Platform.operatingSystem(); 419 var os = Platform.operatingSystem;
420 if (os == "linux" || os == "macos") { 420 if (os == "linux" || os == "macos") {
421 return "/dev/zero/"; 421 return "/dev/zero/";
422 } 422 }
423 if (os == "windows") { 423 if (os == "windows") {
424 return "*"; 424 return "*";
425 } 425 }
426 return null; 426 return null;
427 } 427 }
428 428
429 429
(...skipping 21 matching lines...) Expand all
451 dir.createTemp(() => resultPort.toSendPort().send("success")); 451 dir.createTemp(() => resultPort.toSendPort().send("success"));
452 } 452 }
453 453
454 454
455 main() { 455 main() {
456 DirectoryTest.testMain(); 456 DirectoryTest.testMain();
457 NestedTempDirectoryTest.testMain(); 457 NestedTempDirectoryTest.testMain();
458 testCreateTempErrorSync(); 458 testCreateTempErrorSync();
459 testCreateTempError(); 459 testCreateTempError();
460 } 460 }
OLDNEW
« no previous file with comments | « tests/standalone/io/directory_error_test.dart ('k') | tests/standalone/io/file_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698