| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 import "dart:isolate"; | 8 import "dart:isolate"; |
| 9 | 9 |
| 10 | 10 |
| 11 void testPauseList() { | 11 void testPauseList() { |
| 12 var keepAlive = new ReceivePort(); | 12 var keepAlive = new ReceivePort(); |
| 13 new Directory("").createTemp().then((d) { | 13 new Directory("").createTemp().then((d) { |
| 14 // Linux reads 2K at a time. | 14 // Linux reads 2K at a time, so be sure to be >>. |
| 15 int total = 2 * 1024 + 1; | 15 int total = 4 * 1024 + 1; |
| 16 for (int i = 0; i < total; i++) { | 16 for (int i = 0; i < total; i++) { |
| 17 new File("${d.path}/$i").createSync(); | 17 new File("${d.path}/$i").createSync(); |
| 18 } | 18 } |
| 19 bool first = true; | 19 bool first = true; |
| 20 var subscription; | 20 var subscription; |
| 21 int count = 0; | 21 int count = 0; |
| 22 subscription = d.list().listen((file) { | 22 subscription = d.list().listen((file) { |
| 23 if (first) { | 23 if (first) { |
| 24 first = false; | 24 first = false; |
| 25 subscription.pause(); | 25 subscription.pause(); |
| 26 Timer.run(() { | 26 Timer.run(() { |
| 27 for (int i = 0; i < total; i++) { | 27 for (int i = 0; i < total; i++) { |
| 28 new File("${d.path}/$i").deleteSync(); | 28 new File("${d.path}/$i").deleteSync(); |
| 29 } | 29 } |
| 30 subscription.resume(); | 30 subscription.resume(); |
| 31 }); | 31 }); |
| 32 } | 32 } |
| 33 count++; | 33 count++; |
| 34 }, onDone: () { | 34 }, onDone: () { |
| 35 Expect.isTrue(count < total); | 35 Expect.notEquals(total, count); |
| 36 keepAlive.close(); | 36 keepAlive.close(); |
| 37 d.delete().then((ignore) => keepAlive.close()); | 37 d.delete().then((ignore) => keepAlive.close()); |
| 38 }); | 38 }); |
| 39 }); | 39 }); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void main() { | 42 void main() { |
| 43 testPauseList(); | 43 testPauseList(); |
| 44 } | 44 } |
| OLD | NEW |