OLD | NEW |
1 library IsolatesTest; | 1 library IsolatesTest; |
2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
4 import 'dart:async'; | 4 import 'dart:async'; |
5 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:isolate' as isolate; | 7 import 'dart:isolate' as isolate; |
8 | 8 |
9 String responseFor(message) => 'response for $message'; | 9 String responseFor(message) => 'response for $message'; |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 main() { | 42 main() { |
43 useHtmlConfiguration(); | 43 useHtmlConfiguration(); |
44 test('IsolateSpawn', () { | 44 test('IsolateSpawn', () { |
45 var port = new isolate.ReceivePort(); | 45 var port = new isolate.ReceivePort(); |
46 isolate.Isolate.spawn(isolateEntry, port.sendPort); | 46 isolate.Isolate.spawn(isolateEntry, port.sendPort); |
47 port.close(); | 47 port.close(); |
48 }); | 48 }); |
49 test('NonDOMIsolates', () { | 49 test('NonDOMIsolates', () { |
50 var callback = expectAsync0((){}); | 50 var callback = expectAsync((){}); |
51 var response = new isolate.ReceivePort(); | 51 var response = new isolate.ReceivePort(); |
52 var remote = isolate.Isolate.spawn(isolateEntry, response.sendPort); | 52 var remote = isolate.Isolate.spawn(isolateEntry, response.sendPort); |
53 response.first.then((port) { | 53 response.first.then((port) { |
54 final msg1 = 'foo'; | 54 final msg1 = 'foo'; |
55 final msg2 = 'bar'; | 55 final msg2 = 'bar'; |
56 sendReceive(port, msg1).then((response) { | 56 sendReceive(port, msg1).then((response) { |
57 guardAsync(() { | 57 guardAsync(() { |
58 expect(response, equals(responseFor(msg1))); | 58 expect(response, equals(responseFor(msg1))); |
59 sendReceive(port, msg2).then((response) { | 59 sendReceive(port, msg2).then((response) { |
60 guardAsync(() { | 60 guardAsync(() { |
61 expect(response, equals(responseFor(msg2))); | 61 expect(response, equals(responseFor(msg2))); |
62 callback(); | 62 callback(); |
63 }); | 63 }); |
64 }); | 64 }); |
65 }); | 65 }); |
66 }); | 66 }); |
67 }); | 67 }); |
68 }); | 68 }); |
69 } | 69 } |
OLD | NEW |