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 serialization_test; | 5 library serialization_test; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 import 'package:serialization/serialization.dart'; | 9 import 'package:serialization/serialization.dart'; |
10 import 'package:serialization/src/serialization_helpers.dart'; | 10 import 'package:serialization/src/serialization_helpers.dart'; |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 expect(MirrorSystem.getName(input.simpleName), "Address"); | 542 expect(MirrorSystem.getName(input.simpleName), "Address"); |
543 }); | 543 }); |
544 | 544 |
545 test('round-trip, default format, pass to isolate', () { | 545 test('round-trip, default format, pass to isolate', () { |
546 Node n1 = new Node("1"), n2 = new Node("2"), n3 = new Node("3"); | 546 Node n1 = new Node("1"), n2 = new Node("2"), n3 = new Node("3"); |
547 n1.children = [n2, n3]; | 547 n1.children = [n2, n3]; |
548 n2.parent = n1; | 548 n2.parent = n1; |
549 n3.parent = n1; | 549 n3.parent = n1; |
550 var s = nodeSerializerReflective(n1); | 550 var s = nodeSerializerReflective(n1); |
551 var output = s.write(n2); | 551 var output = s.write(n2); |
552 var port = spawnFunction(echo); | 552 ReceivePort port = new ReceivePort(); |
553 return port.call(output).then(verify); | 553 var remote = Isolate.spawn(echo, [output, port.sendPort]); |
| 554 port.first.then(verify); |
554 }); | 555 }); |
555 } | 556 } |
556 | 557 |
557 /** | 558 /** |
558 * Verify serialized output that we have passed to an isolate and back. | 559 * Verify serialized output that we have passed to an isolate and back. |
559 */ | 560 */ |
560 void verify(input) { | 561 void verify(input) { |
561 var s2 = nodeSerializerReflective(new Node("a")); | 562 var s2 = nodeSerializerReflective(new Node("a")); |
562 var m2 = s2.read(input); | 563 var m2 = s2.read(input); |
563 var m1 = m2.parent; | 564 var m1 = m2.parent; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 if (value == key) return each; | 802 if (value == key) return each; |
802 } | 803 } |
803 return null; | 804 return null; |
804 } | 805 } |
805 } | 806 } |
806 | 807 |
807 /** | 808 /** |
808 * Function used in an isolate to make sure that the output passes through | 809 * Function used in an isolate to make sure that the output passes through |
809 * isolate serialization properly. | 810 * isolate serialization properly. |
810 */ | 811 */ |
811 void echo() { | 812 void echo(initialMessage) { |
812 port.receive((msg, reply) { | 813 var msg = initialMessage[0]; |
813 reply.send(msg); | 814 var reply = initialMessage[1]; |
814 }); | 815 reply.send(msg); |
815 } | 816 } |
OLD | NEW |