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 isolate communication with | 5 // Dart test program for testing isolate communication with |
6 // complex messages. | 6 // complex messages. |
7 | 7 |
8 library IsolateComplexMessagesTest; | 8 library IsolateComplexMessagesTest; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import '../../pkg/unittest/lib/unittest.dart'; | 10 import '../../pkg/unittest/lib/unittest.dart'; |
11 | 11 |
12 main() { | 12 main() { |
13 test("complex messages are serialized correctly", () { | 13 test("complex messages are serialized correctly", () { |
14 ReceivePort local = new ReceivePort(); | 14 ReceivePort local = new ReceivePort(); |
15 Isolate.spawn(logMessages, local.sendPort); | 15 Isolate.spawn(logMessages, local.sendPort); |
16 var done = expectAsync0((){}); | 16 var done = expectAsync0((){}); |
17 local.listen(expectAsync1((msg) { | 17 local.listen(expectAsync1((msg) { |
18 switch (msg[0]) { | 18 switch (msg[0]) { |
19 case "init": | 19 case "init": |
20 var remote = msg[1]; | 20 var remote = msg[1]; |
21 remote.send(1, null); | 21 remote.send(1); |
22 remote.send("Hello", null); | 22 remote.send("Hello"); |
23 remote.send("World", null); | 23 remote.send("World"); |
24 remote.send(const [null, 1, 2, 3, 4], null); | 24 remote.send(const [null, 1, 2, 3, 4]); |
25 remote.send(const [1, 2.0, true, false, 0xffffffffff], null); | 25 remote.send(const [1, 2.0, true, false, 0xffffffffff]); |
26 remote.send(const ["Hello", "World", 0xffffffffff], null); | 26 remote.send(const ["Hello", "World", 0xffffffffff]); |
27 // Shutdown the LogRunner. | 27 // Shutdown the LogRunner. |
28 remote.send(-1); | 28 remote.send(-1); |
29 break; | 29 break; |
30 case "done": | 30 case "done": |
31 local.close(); | 31 local.close(); |
32 expect(msg[1], 6); | 32 expect(msg[1], 6); |
33 done(); | 33 done(); |
34 } | 34 } |
35 }, count: 2)); | 35 }, count: 2)); |
36 }); | 36 }); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 expect(message.length, 3); | 76 expect(message.length, 3); |
77 expect(message[0], "Hello"); | 77 expect(message[0], "Hello"); |
78 expect(message[1], "World"); | 78 expect(message[1], "World"); |
79 expect(message[2], 0xffffffffff); | 79 expect(message[2], 0xffffffffff); |
80 break; | 80 break; |
81 } | 81 } |
82 count++; | 82 count++; |
83 } | 83 } |
84 }); | 84 }); |
85 } | 85 } |
OLD | NEW |