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

Side by Side Diff: tests/html/isolates_test.dart

Issue 10412015: aChange all asyncTest/callbackDone style tests to use the new expectAsync/ (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 #library('IsolatesTest'); 1 #library('IsolatesTest');
2 #import('../../lib/unittest/unittest.dart'); 2 #import('../../lib/unittest/unittest.dart');
3 #import('../../lib/unittest/html_config.dart'); 3 #import('../../lib/unittest/html_config.dart');
4 #import('dart:html'); 4 #import('dart:html');
5 #import('dart:json'); 5 #import('dart:json');
6 #import('dart:isolate', prefix:'isolate'); 6 #import('dart:isolate', prefix:'isolate');
7 7
8 class PingPongIsolate extends isolate.Isolate { 8 class PingPongIsolate extends isolate.Isolate {
9 PingPongIsolate() : super.heavy(); 9 PingPongIsolate() : super.heavy();
10 10
(...skipping 15 matching lines...) Expand all
26 port.receive((message, replyTo) { 26 port.receive((message, replyTo) {
27 replyTo.send(responseFor(message), null); 27 replyTo.send(responseFor(message), null);
28 }); 28 });
29 } 29 }
30 30
31 static String responseFor(message) => 'response for $message'; 31 static String responseFor(message) => 'response for $message';
32 } 32 }
33 33
34 main() { 34 main() {
35 useHtmlConfiguration(); 35 useHtmlConfiguration();
36 asyncTest('IsolateSpawn', 1, () { 36 test('IsolateSpawn', () {
37 new PingPongIsolate().spawn().then(expectAsync1((isolate.SendPort port) {
38 }));
39 });
40 test('NonDOMIsolates', () {
41 var callback = expectAsync0((){});
37 new PingPongIsolate().spawn().then((isolate.SendPort port) { 42 new PingPongIsolate().spawn().then((isolate.SendPort port) {
38 callbackDone(); 43 guardAsync(() {
39 }); 44 final msg1 = 'foo';
40 }); 45 final msg2 = 'bar';
41 asyncTest('NonDOMIsolates', 1, () { 46 port.call(msg1).then((response) {
42 new PingPongIsolate().spawn().then((isolate.SendPort port) { 47 guardAsync(() {
43 final msg1 = 'foo'; 48 Expect.equals(PingPongIsolate.responseFor(msg1), response);
44 final msg2 = 'bar'; 49 port.call(msg2).then((response) {
45 port.call(msg1).then((response) { 50 guardAsync(() {
46 Expect.equals(PingPongIsolate.responseFor(msg1), response); 51 Expect.equals(PingPongIsolate.responseFor(msg2), response);
47 port.call(msg2).then((response) { 52 callback();
48 Expect.equals(PingPongIsolate.responseFor(msg2), response); 53 });
49 callbackDone(); 54 });
55 });
50 }); 56 });
51 }); 57 });
52 }); 58 });
53 }); 59 });
54 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698