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 // Dart test program for testing serialization of messages. | 5 // Dart test program for testing serialization of messages. |
6 // VMOptions=--enable_type_checks --enable_asserts | 6 // VMOptions=--enable_type_checks --enable_asserts |
7 | 7 |
8 library Message2Test; | 8 library Message2Test; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import '../../pkg/unittest/lib/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 import "remote_unittest_helper.dart"; |
11 | 12 |
12 // --------------------------------------------------------------------------- | 13 // --------------------------------------------------------------------------- |
13 // Message passing test 2. | 14 // Message passing test 2. |
14 // --------------------------------------------------------------------------- | 15 // --------------------------------------------------------------------------- |
15 | 16 |
16 class MessageTest { | 17 class MessageTest { |
17 static void mapEqualsDeep(Map expected, Map actual) { | 18 static void mapEqualsDeep(Map expected, Map actual) { |
18 expect(expected, isMap); | 19 expect(expected, isMap); |
19 expect(actual, isMap); | 20 expect(actual, isMap); |
20 expect(actual.length, expected.length); | 21 expect(actual.length, expected.length); |
(...skipping 27 matching lines...) Expand all Loading... |
48 port.close(); | 49 port.close(); |
49 } else { | 50 } else { |
50 // Bounce the received object back so that the sender | 51 // Bounce the received object back so that the sender |
51 // can make sure that the object matches. | 52 // can make sure that the object matches. |
52 message[1].send(message[0]); | 53 message[1].send(message[0]); |
53 } | 54 } |
54 }); | 55 }); |
55 replyPort.send(port.sendPort); | 56 replyPort.send(port.sendPort); |
56 } | 57 } |
57 | 58 |
58 main() { | 59 void main([args, port]) { |
| 60 if (testRemote(main, port)) return; |
59 test("map is equal after it is sent back and forth", () { | 61 test("map is equal after it is sent back and forth", () { |
60 ReceivePort port = new ReceivePort(); | 62 ReceivePort port = new ReceivePort(); |
61 Isolate.spawn(pingPong, port.sendPort); | 63 Isolate.spawn(pingPong, port.sendPort); |
62 port.first.then(expectAsync1((remote) { | 64 port.first.then(expectAsync1((remote) { |
63 Map m = new Map(); | 65 Map m = new Map(); |
64 m[1] = "eins"; | 66 m[1] = "eins"; |
65 m[2] = "deux"; | 67 m[2] = "deux"; |
66 m[3] = "tre"; | 68 m[3] = "tre"; |
67 m[4] = "four"; | 69 m[4] = "four"; |
68 ReceivePort replyPort = new ReceivePort(); | 70 ReceivePort replyPort = new ReceivePort(); |
69 remote.send([m, replyPort.sendPort]); | 71 remote.send([m, replyPort.sendPort]); |
70 replyPort.first.then(expectAsync1((var received) { | 72 replyPort.first.then(expectAsync1((var received) { |
71 MessageTest.mapEqualsDeep(m, received); | 73 MessageTest.mapEqualsDeep(m, received); |
72 remote.send(null); | 74 remote.send(null); |
73 })); | 75 })); |
74 })); | 76 })); |
75 }); | 77 }); |
76 } | 78 } |
OLD | NEW |