OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library RequestReplyTest; | 5 library RequestReplyTest; |
6 | 6 |
7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
8 import '../../pkg/unittest/lib/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 import "remote_unittest_helper.dart"; |
9 | 10 |
10 void entry(initPort) { | 11 void entry(initPort) { |
11 ReceivePort port = new ReceivePort(); | 12 ReceivePort port = new ReceivePort(); |
12 initPort.send(port.sendPort); | 13 initPort.send(port.sendPort); |
13 port.listen((pair) { | 14 port.listen((pair) { |
14 var message = pair[0]; | 15 var message = pair[0]; |
15 SendPort replyTo = pair[1]; | 16 SendPort replyTo = pair[1]; |
16 replyTo.send(message + 87); | 17 replyTo.send(message + 87); |
17 port.close(); | 18 port.close(); |
18 }); | 19 }); |
19 } | 20 } |
20 | 21 |
21 void main() { | 22 void main([args, port]) { |
| 23 if (testRemote(main, port)) return; |
22 test("send", () { | 24 test("send", () { |
23 ReceivePort init = new ReceivePort(); | 25 ReceivePort init = new ReceivePort(); |
24 Isolate.spawn(entry, init.sendPort); | 26 Isolate.spawn(entry, init.sendPort); |
25 init.first.then(expectAsync1((port) { | 27 init.first.then(expectAsync1((port) { |
26 ReceivePort reply = new ReceivePort(); | 28 ReceivePort reply = new ReceivePort(); |
27 port.send([99, reply.sendPort]); | 29 port.send([99, reply.sendPort]); |
28 reply.listen(expectAsync1((message) { | 30 reply.listen(expectAsync1((message) { |
29 expect(message, 99 + 87); | 31 expect(message, 99 + 87); |
30 reply.close(); | 32 reply.close(); |
31 })); | 33 })); |
32 })); | 34 })); |
33 }); | 35 }); |
34 } | 36 } |
OLD | NEW |