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

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

Issue 10414046: Add support for directory renaming to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/directory_win.cc ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/directory_error_test.dart
diff --git a/tests/standalone/io/directory_error_test.dart b/tests/standalone/io/directory_error_test.dart
index 5c978cce88ef274aae37a890b5063390064f8e92..96eaf324f3cd07414160950a47a155cb02ecd8ad 100644
--- a/tests/standalone/io/directory_error_test.dart
+++ b/tests/standalone/io/directory_error_test.dart
@@ -179,6 +179,56 @@ void testListNonExistent(Directory temp, Function done) {
}
+void testRenameNonExistent(Directory temp, Function done) {
+ Directory nonExistent = new Directory("${temp.path}/nonExistent");
+ var newPath = "${temp.path}/nonExistent2";
+ Expect.throws(() => nonExistent.renameSync(newPath),
+ (e) => e is DirectoryIOException);
+ var renameDone = nonExistent.rename(newPath);
+ renameDone.then((ignore) => Expect.fail('rename non existent'));
+ renameDone.handleException((e) {
+ Expect.isTrue(e is DirectoryIOException);
+ done();
+ return true;
+ });
+}
+
+
+void testRenameFileAsDirectory(Directory temp, Function done) {
+ File f = new File("${temp.path}/file");
+ var newPath = "${temp.path}/file2";
+ f.createSync();
+ var d = new Directory(f.name);
+ Expect.throws(() => d.renameSync(newPath),
+ (e) => e is DirectoryIOException);
+ var renameDone = d.rename(newPath);
+ renameDone.then((ignore) => Expect.fail('rename file as directory'));
+ renameDone.handleException((e) {
+ Expect.isTrue(e is DirectoryIOException);
+ done();
+ return true;
+ });
+}
+
+
+testRenameOverwriteFile(Directory temp, Function done) {
+ var d = new Directory('');
+ var temp1 = d.createTempSync();
+ var fileName = '${temp.path}/x';
+ new File(fileName).createSync();
+ Expect.throws(() => temp1.renameSync(fileName),
+ (e) => e is DirectoryIOException);
+ var renameDone = temp1.rename(fileName);
+ renameDone.then((ignore) => Expect.fail('rename dir overwrite file'));
+ renameDone.handleException((e) {
+ Expect.isTrue(e is DirectoryIOException);
+ temp1.deleteRecursivelySync();
+ done();
+ return true;
+ });
+}
+
+
void runTest(Function test) {
// Create a temporary directory for the test.
var temp = new Directory('').createTempSync();
@@ -201,4 +251,7 @@ main() {
runTest(testDeleteNonExistent);
runTest(testDeleteRecursivelyNonExistent);
runTest(testListNonExistent);
+ runTest(testRenameNonExistent);
+ runTest(testRenameFileAsDirectory);
+ runTest(testRenameOverwriteFile);
}
« no previous file with comments | « runtime/bin/directory_win.cc ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698