Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e91c687f377996bceb09425c9a72c56cc4528219 |
| --- /dev/null |
| +++ b/tests/standalone/io/directory_list_pause_test.dart |
| @@ -0,0 +1,43 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import "package:expect/expect.dart"; |
| +import "dart:async"; |
| +import "dart:io"; |
| +import "dart:isolate"; |
| + |
| + |
| +void testPauseList() { |
| + var keepAlive = new ReceivePort(); |
| + new Directory("").createTemp().then((d) { |
| + 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
|
| + for (int i = 0; i < total; i++) { |
| + new File("${d.path}/$i").createSync(); |
| + } |
| + bool first = true; |
| + var subscription; |
| + int count = 0; |
| + subscription = d.list().listen((file) { |
| + if (first) { |
| + first = false; |
| + subscription.pause(); |
| + Timer.run(() { |
| + for (int i = 0; i < total; i++) { |
| + new File("${d.path}/$i").deleteSync(); |
| + } |
| + subscription.resume(); |
| + }); |
| + } |
| + count++; |
| + }, onDone: () { |
| + Expect.isTrue(count < total); |
| + keepAlive.close(); |
| + d.delete().then((ignore) => keepAlive.close()); |
| + }); |
| + }); |
| +} |
| + |
| +void main() { |
| + testPauseList(); |
| +} |