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

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

Issue 17848003: dart:io | Add rename to Link (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix again Created 7 years, 6 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 | « sdk/lib/io/link.dart ('k') | tests/standalone/io/link_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/link_async_test.dart
diff --git a/tests/standalone/io/link_async_test.dart b/tests/standalone/io/link_async_test.dart
index 0cc4a7a739dc051fd9765073342b4443b871af61..e691e32f0508b1ca7707ff4bd0d06e01c05849a6 100644
--- a/tests/standalone/io/link_async_test.dart
+++ b/tests/standalone/io/link_async_test.dart
@@ -164,6 +164,44 @@ Future testCreateLoopingLink() {
}
+Future testRename() {
+ Future testRename(Path base, String target) {
+ Link link1;
+ Link link2;
+ return new Link.fromPath(base.append('c')).create(target)
+ .then((link) {
+ link1 = link;
+ Expect.isTrue(link1.existsSync());
+ return link1.rename(base.append('d').toNativePath());
+ })
+ .then((link) {
+ link2 = link;
+ Expect.isFalse(link1.existsSync());
+ Expect.isTrue(link2.existsSync());
+ return link2.delete();
+ })
+ .then((_) => Expect.isFalse(link2.existsSync()));
+ }
+
+ return new Directory('').createTemp().then((baseDir) {
+ Path base = new Path(baseDir.path);
+ var targetsFutures = [];
+ targetsFutures.add(new Directory.fromPath(base.append('a')).create());
+ if (Platform.isWindows) {
+ // Currently only links to directories are supported on Windows.
+ targetsFutures.add(
+ new Directory.fromPath(base.append('b')).create());
+ } else {
+ targetsFutures.add(new File.fromPath(base.append('b')).create());
+ }
+ return Future.wait(targetsFutures).then((targets) {
+ return testRename(base, targets[0].path)
+ .then((_) => testRename(base, targets[1].path))
+ .then((_) => baseDir.delete(recursive: true));
+ });
+ });
+}
+
Future testDirectoryListing(Path base, Directory baseDir) {
Map makeExpected(bool recursive, bool followLinks) {
Map expected = new Map();
@@ -219,5 +257,6 @@ main() {
ReceivePort keepAlive = new ReceivePort();
testCreate()
.then((_) => testCreateLoopingLink())
+ .then((_) => testRename())
.then((_) => keepAlive.close());
}
« no previous file with comments | « sdk/lib/io/link.dart ('k') | tests/standalone/io/link_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698