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

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

Issue 11748017: Add synchronous directory listing to dart:io Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments, move tests that fail on Windows due to VM bug 7157 to a separate test file. Created 7 years, 12 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/directory_invalid_arguments_test.dart ('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_list_nonexistent_test.dart
diff --git a/tests/standalone/io/directory_list_nonexistent_test.dart b/tests/standalone/io/directory_list_nonexistent_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4a7829c0298aa637b2a0d615e6b1237f7e8d79a5
--- /dev/null
+++ b/tests/standalone/io/directory_list_nonexistent_test.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2012, 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.
+//
+// Directory listing test that tests listSync on a missing directory.
+//
+// TODO(7157): Merge this test into directory_test.dart testListNonExistent()
+// when it no longer crashes on Windows, when issue 7157 is resolved.
+
+import "dart:io";
+import "dart:isolate";
+
+void testListNonExistent() {
+ new Directory("").createTemp().then((d) {
+ d.delete().then((ignore) {
+ Expect.throws(() => d.listSync(), (e) => e is DirectoryIOException);
+ Expect.throws(() => d.listSync(recursive: true),
+ (e) => e is DirectoryIOException);
+ });
+ });
+}
+
+void testListTooLongName() {
+ new Directory("").createTemp().then((d) {
+ var subDirName = 'subdir';
+ var subDir = new Directory("${d.path}/$subDirName");
+ subDir.create().then((ignore) {
+ // Construct a long string of the form
+ // 'tempdir/subdir/../subdir/../subdir'.
+ var buffer = new StringBuffer();
+ buffer.add(subDir.path);
+ for (var i = 0; i < 1000; i++) {
+ buffer.add("/../${subDirName}");
+ }
+ var long = new Directory("${buffer.toString()}");
+ Expect.throws(() => long.listSync(),
+ (e) => e is DirectoryIOException);
+ Expect.throws(() => long.listSync(recursive: true),
+ (e) => e is DirectoryIOException);
+ });
+ });
+}
+
+void main() {
+ testListNonExistent();
+ testListTooLongName();
+}
« no previous file with comments | « tests/standalone/io/directory_invalid_arguments_test.dart ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698