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

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

Issue 45833003: Fix directory-listing to return a future on cancel. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix reporting of immediate errors from directory listing. Created 7 years, 2 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
index 9bb7d47e3ae7e4b191d02f2d6f48c70d4ce6ec13..c2beb008b1d6b17dcd690895f916e1ffcdcf5eff 100644
--- a/tests/standalone/io/directory_list_pause_test.dart
+++ b/tests/standalone/io/directory_list_pause_test.dart
@@ -43,6 +43,55 @@ void testPauseList() {
});
}
+
+void testPauseResumeCancelList() {
+ asyncStart();
+ // TOTAL should be bigger the our directory listing buffer.
+ const int TOTAL = 128;
+ Directory.systemTemp.createTemp('dart_directory_list_pause').then((d) {
+ for (int i = 0; i < TOTAL; i++) {
+ new Directory("${d.path}/$i").createSync();
+ new File("${d.path}/$i/file").createSync();
+ }
+ var subscription;
+ subscription = d.list(recursive: true).listen((entity) {
+ subscription.pause();
+ subscription.resume();
+ void close() {
+ d.deleteSync(recursive: true);
+ asyncEnd();
+ }
+ var future = subscription.cancel();
+ if (future != null) {
+ future.whenComplete(close);
+ } else {
+ close();
+ }
+ }, onDone: () {
+ Expect.fail('the stream was canceled, onDone should not happend');
+ });
+ });
+}
+
+void testListIsEmpty() {
+ asyncStart();
+ // TOTAL should be bigger the our directory listing buffer.
+ const int TOTAL = 128;
+ Directory.systemTemp.createTemp('dart_directory_list_pause').then((d) {
+ for (int i = 0; i < TOTAL; i++) {
+ new Directory("${d.path}/$i").createSync();
+ new File("${d.path}/$i/file").createSync();
+ }
+ d.list(recursive: true).isEmpty.then((empty) {
+ Expect.isFalse(empty);
+ d.deleteSync(recursive: true);
+ asyncEnd();
+ });
+ });
+}
+
void main() {
testPauseList();
+ testPauseResumeCancelList();
+ testListIsEmpty();
}
« 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