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(); |
} |