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

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

Issue 23886004: Update dart:io tests to use asyncStart/asyncEnd (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 3 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
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";
6 import "dart:async"; 5 import "dart:async";
7 import "dart:io"; 6 import "dart:io";
8 import "dart:isolate"; 7
8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart";
9 10
10 11
11 void testPauseList() { 12 void testPauseList() {
12 var keepAlive = new ReceivePort(); 13 asyncStart();
13 // TOTAL should be bigger the our directory listing buffer. 14 // TOTAL should be bigger the our directory listing buffer.
14 const int TOTAL = 128; 15 const int TOTAL = 128;
15 new Directory("").createTemp().then((d) { 16 new Directory("").createTemp().then((d) {
16 for (int i = 0; i < TOTAL; i++) { 17 for (int i = 0; i < TOTAL; i++) {
17 new Directory("${d.path}/$i").createSync(); 18 new Directory("${d.path}/$i").createSync();
18 new File("${d.path}/$i/file").createSync(); 19 new File("${d.path}/$i/file").createSync();
19 } 20 }
20 bool first = true; 21 bool first = true;
21 var subscription; 22 var subscription;
22 int count = 0; 23 int count = 0;
23 subscription = d.list(recursive: true).listen((file) { 24 subscription = d.list(recursive: true).listen((file) {
24 if (file is File) { 25 if (file is File) {
25 if (first) { 26 if (first) {
26 first = false; 27 first = false;
27 subscription.pause(); 28 subscription.pause();
28 Timer.run(() { 29 Timer.run(() {
29 for (int i = 0; i < TOTAL; i++) { 30 for (int i = 0; i < TOTAL; i++) {
30 new File("${d.path}/$i/file").deleteSync(); 31 new File("${d.path}/$i/file").deleteSync();
31 } 32 }
32 subscription.resume(); 33 subscription.resume();
33 }); 34 });
34 } 35 }
35 count++; 36 count++;
36 } 37 }
37 }, onDone: () { 38 }, onDone: () {
38 Expect.notEquals(TOTAL, count); 39 Expect.notEquals(TOTAL, count);
39 Expect.isTrue(count > 0); 40 Expect.isTrue(count > 0);
40 d.delete(recursive: true).then((ignore) => keepAlive.close()); 41 d.delete(recursive: true).then((ignore) => asyncEnd());
41 }); 42 });
42 }); 43 });
43 } 44 }
44 45
45 void main() { 46 void main() {
46 testPauseList(); 47 testPauseList();
47 } 48 }
OLDNEW
« no previous file with comments | « tests/standalone/io/directory_list_nonexistent_test.dart ('k') | tests/standalone/io/directory_non_ascii_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698