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

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

Issue 16813006: Make Directory.list pull-based, making it possible to pause, resume and cancel directory listing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review update. 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/directory_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/directory_list_pause_test.dart
diff --git a/tests/standalone/io/directory_list_pause_test.dart b/tests/standalone/io/directory_list_pause_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..86ff1566d87a6979dbc1b0fb6c46840853505674
--- /dev/null
+++ b/tests/standalone/io/directory_list_pause_test.dart
@@ -0,0 +1,44 @@
+// 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 "package:expect/expect.dart";
+import "dart:async";
+import "dart:io";
+import "dart:isolate";
+
+
+void testPauseList() {
+ var keepAlive = new ReceivePort();
+ new Directory("").createTemp().then((d) {
+ // Linux reads 2K at a time.
+ int total = 2 * 1024 + 1;
+ for (int i = 0; i < total; i++) {
+ new File("${d.path}/$i").createSync();
+ }
+ bool first = true;
+ var subscription;
+ int count = 0;
+ subscription = d.list().listen((file) {
+ if (first) {
+ first = false;
+ subscription.pause();
+ Timer.run(() {
+ for (int i = 0; i < total; i++) {
+ new File("${d.path}/$i").deleteSync();
+ }
+ subscription.resume();
+ });
+ }
+ count++;
+ }, onDone: () {
+ Expect.isTrue(count < total);
+ keepAlive.close();
+ d.delete().then((ignore) => keepAlive.close());
+ });
+ });
+}
+
+void main() {
+ testPauseList();
+}
« no previous file with comments | « sdk/lib/io/directory_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698