OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "dart:async"; | 5 import "dart:async"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 | 7 |
8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 void testListIsEmpty() { | 76 void testListIsEmpty() { |
77 asyncStart(); | 77 asyncStart(); |
78 // TOTAL should be bigger the our directory listing buffer. | 78 // TOTAL should be bigger the our directory listing buffer. |
79 const int TOTAL = 128; | 79 const int TOTAL = 128; |
80 Directory.systemTemp.createTemp('dart_directory_list_pause').then((d) { | 80 Directory.systemTemp.createTemp('dart_directory_list_pause').then((d) { |
81 for (int i = 0; i < TOTAL; i++) { | 81 for (int i = 0; i < TOTAL; i++) { |
82 new Directory("${d.path}/$i").createSync(); | 82 new Directory("${d.path}/$i").createSync(); |
83 new File("${d.path}/$i/file").createSync(); | 83 new File("${d.path}/$i/file").createSync(); |
84 } | 84 } |
| 85 // isEmpty will cancel the stream after first data event. |
85 d.list(recursive: true).isEmpty.then((empty) { | 86 d.list(recursive: true).isEmpty.then((empty) { |
86 Expect.isFalse(empty); | 87 Expect.isFalse(empty); |
87 d.deleteSync(recursive: true); | 88 d.deleteSync(recursive: true); |
88 asyncEnd(); | 89 asyncEnd(); |
89 }); | 90 }); |
90 }); | 91 }); |
91 } | 92 } |
92 | 93 |
93 void main() { | 94 void main() { |
94 testPauseList(); | 95 testPauseList(); |
95 testPauseResumeCancelList(); | 96 testPauseResumeCancelList(); |
96 testListIsEmpty(); | 97 testListIsEmpty(); |
97 } | 98 } |
OLD | NEW |