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

Unified Diff: tests/standalone/io/windows_file_system_async_links_test.dart

Issue 14642012: dart:io | Add asynchronous versions of the methods of FileSystemEntity and Link. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/link_async_test.dart ('k') | tests/standalone/io/windows_file_system_links_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/windows_file_system_async_links_test.dart
diff --git a/tests/standalone/io/windows_file_system_async_links_test.dart b/tests/standalone/io/windows_file_system_async_links_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5560776e0f846ea6e623df12626cca61f4a6c114
--- /dev/null
+++ b/tests/standalone/io/windows_file_system_async_links_test.dart
@@ -0,0 +1,105 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:async";
+import 'package:expect/expect.dart';
+import "dart:io";
+import "dart:isolate";
+
+
+class FutureExpect {
+ static Future isTrue(Future<bool> result) =>
+ result.then((value) => Expect.isTrue(value));
+ static Future isFalse(Future<bool> result) =>
+ result.then((value) => Expect.isFalse(value));
+ static Future equals(expected, Future result) =>
+ result.then((value) => Expect.equals(expected, value));
+ static Future listEquals(expected, Future result) =>
+ result.then((value) => Expect.listEquals(expected, value));
+ static Future throws(Future result) =>
+ result.then((value) {
+ throw new ExpectException(
+ "FutureExpect.throws received $value instead of an exception");
+ }, onError: (_) => null);
+}
+
+
+Future testJunctionTypeDelete() {
+ return new Directory('').createTemp().then((temp) {
+ var x = '${temp.path}${Platform.pathSeparator}x';
+ var y = '${temp.path}${Platform.pathSeparator}y';
+ return new Directory(x).create()
+ .then((_) => new Link(y).create(x))
+ .then((_) => FutureExpect.isTrue(new Directory(y).exists()))
+ .then((_) => FutureExpect.isTrue(new Directory(x).exists()))
+ .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y)))
+ .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x)))
+ .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(y)))
+ .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(x)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.type(y)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.type(x)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.type(y, followLinks: false)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.type(x, followLinks: false)))
+ .then((_) => FutureExpect.equals(x, new Link(y).target()))
+
+ // Test Junction pointing to a missing directory.
+ .then((_) => new Directory(x).delete())
+ .then((_) => FutureExpect.isTrue(new Link(y).exists()))
+ .then((_) => FutureExpect.isFalse(new Directory(x).exists()))
+ .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y)))
+ .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x)))
+ .then((_) => FutureExpect.isFalse(FileSystemEntity.isDirectory(y)))
+ .then((_) => FutureExpect.isFalse(FileSystemEntity.isDirectory(x)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.type(y)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
+ FileSystemEntity.type(x)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.type(y, followLinks: false)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
+ FileSystemEntity.type(x, followLinks: false)))
+ .then((_) => FutureExpect.equals(x, new Link(y).target()))
+
+ // Delete Junction pointing to a missing directory.
+ .then((_) => new Link(y).delete())
+ .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(y)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
+ FileSystemEntity.type(y)))
+ .then((_) => FutureExpect.throws(new Link(y).target()))
+
+ .then((_) => new Directory(x).create())
+ .then((_) => new Link(y).create(x))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.type(y, followLinks: false)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.type(x, followLinks: false)))
+ .then((_) => FutureExpect.equals(x, new Link(y).target()))
+
+ // Delete Junction pointing to an existing directory.
+ .then((_) => new Directory(y).delete())
+ .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
+ FileSystemEntity.type(y)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
+ FileSystemEntity.type(y, followLinks: false)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.type(x)))
+ .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.type(x, followLinks: false)))
+ .then((_) => FutureExpect.throws(new Link(y).target()))
+ .then((_) => temp.delete(recursive: true));
+ });
+}
+
+
+main() {
+ // Links on other platforms are tested by file_system_[async_]links_test.
+ if (Platform.operatingSystem == 'windows') {
+ ReceivePort keepAlive = new ReceivePort();
+ testJunctionTypeDelete().then((_) => keepAlive.close());
+ }
+}
« no previous file with comments | « tests/standalone/io/link_async_test.dart ('k') | tests/standalone/io/windows_file_system_links_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698