Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: tests/standalone/io/directory_list_pause_test.dart

Issue 16813006: Make Directory.list pull-based, making it possible to pause, resume and cancel directory listing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test and review fixes. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW
« sdk/lib/io/directory_impl.dart ('K') | « sdk/lib/io/directory_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698