| 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 // TOTAL should be bigger the our directory listing buffer. |
| 14 const int TOTAL = 128; |
| 13 new Directory("").createTemp().then((d) { | 15 new Directory("").createTemp().then((d) { |
| 14 // Linux reads 2K at a time, so be sure to be >>. | 16 for (int i = 0; i < TOTAL; i++) { |
| 15 int total = 4 * 1024 + 1; | 17 new Directory("${d.path}/$i").createSync(); |
| 16 for (int i = 0; i < total; i++) { | 18 new File("${d.path}/$i/file").createSync(); |
| 17 new File("${d.path}/$i").createSync(); | |
| 18 } | 19 } |
| 19 bool first = true; | 20 bool first = true; |
| 20 var subscription; | 21 var subscription; |
| 21 int count = 0; | 22 int count = 0; |
| 22 subscription = d.list().listen((file) { | 23 subscription = d.list(recursive: true).listen((file) { |
| 23 if (first) { | 24 if (file is File) { |
| 24 first = false; | 25 if (first) { |
| 25 subscription.pause(); | 26 first = false; |
| 26 Timer.run(() { | 27 subscription.pause(); |
| 27 for (int i = 0; i < total; i++) { | 28 Timer.run(() { |
| 28 new File("${d.path}/$i").deleteSync(); | 29 for (int i = 0; i < TOTAL; i++) { |
| 29 } | 30 new File("${d.path}/$i/file").deleteSync(); |
| 30 subscription.resume(); | 31 } |
| 31 }); | 32 subscription.resume(); |
| 33 }); |
| 34 } |
| 35 count++; |
| 32 } | 36 } |
| 33 count++; | |
| 34 }, onDone: () { | 37 }, onDone: () { |
| 35 Expect.notEquals(total, count); | 38 Expect.notEquals(TOTAL, count); |
| 39 Expect.isTrue(count > 0); |
| 36 keepAlive.close(); | 40 keepAlive.close(); |
| 37 d.delete().then((ignore) => keepAlive.close()); | 41 d.delete(recursive: true).then((ignore) => keepAlive.close()); |
| 38 }); | 42 }); |
| 39 }); | 43 }); |
| 40 } | 44 } |
| 41 | 45 |
| 42 void main() { | 46 void main() { |
| 43 testPauseList(); | 47 testPauseList(); |
| 44 } | 48 } |
| OLD | NEW |