OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import "package:expect/expect.dart"; | |
6 import "dart:async"; | |
7 import "dart:io"; | |
8 import "dart:isolate"; | |
9 | |
10 | |
11 void testPauseList() { | |
12 var keepAlive = new ReceivePort(); | |
13 new Directory("").createTemp().then((d) { | |
14 int total = 8 * 1024 + 1; | |
Søren Gjesse
2013/06/17 06:37:47
Why so many files for this test? In principle 128
Anders Johnsen
2013/06/17 07:27:11
My computer reads 2K by default. Changed to 2K + 1
| |
15 for (int i = 0; i < total; i++) { | |
16 new File("${d.path}/$i").createSync(); | |
17 } | |
18 bool first = true; | |
19 var subscription; | |
20 int count = 0; | |
21 subscription = d.list().listen((file) { | |
22 if (first) { | |
23 first = false; | |
24 subscription.pause(); | |
25 Timer.run(() { | |
26 for (int i = 0; i < total; i++) { | |
27 new File("${d.path}/$i").deleteSync(); | |
28 } | |
29 subscription.resume(); | |
30 }); | |
31 } | |
32 count++; | |
33 }, onDone: () { | |
34 Expect.isTrue(count < total); | |
35 keepAlive.close(); | |
36 d.delete().then((ignore) => keepAlive.close()); | |
37 }); | |
38 }); | |
39 } | |
40 | |
41 void main() { | |
42 testPauseList(); | |
43 } | |
OLD | NEW |