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 // Test RawReceivePort. | 5 // Test RawReceivePort. |
6 | 6 |
7 library raw_port_test; | 7 library raw_port_test; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'remote_unittest_helper.dart'; | 10 import 'remote_unittest_helper.dart'; |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 test("raw receive", () { | 25 test("raw receive", () { |
26 RawReceivePort port = new RawReceivePort(); | 26 RawReceivePort port = new RawReceivePort(); |
27 Isolate.spawn(remote, port.sendPort); | 27 Isolate.spawn(remote, port.sendPort); |
28 port.handler = expectAsync((v) { | 28 port.handler = expectAsync((v) { |
29 expect(v, "reply"); | 29 expect(v, "reply"); |
30 port.close(); | 30 port.close(); |
31 }); | 31 }); |
32 }); | 32 }); |
33 | 33 |
| 34 test("raw receive hashCode", () { |
| 35 RawReceivePort port = new RawReceivePort(); |
| 36 expect(port.hashCode is int, true); |
| 37 port.close(); |
| 38 }); |
| 39 |
34 test("raw receive twice - change handler", () { | 40 test("raw receive twice - change handler", () { |
35 RawReceivePort port = new RawReceivePort(); | 41 RawReceivePort port = new RawReceivePort(); |
36 Isolate.spawn(remote2, port.sendPort); | 42 Isolate.spawn(remote2, port.sendPort); |
37 port.handler = expectAsync((v) { | 43 port.handler = expectAsync((v) { |
38 expect(v, "reply 1"); | 44 expect(v, "reply 1"); |
39 port.handler = expectAsync((v) { | 45 port.handler = expectAsync((v) { |
40 expect(v, "reply 2"); | 46 expect(v, "reply 2"); |
41 port.close(); | 47 port.close(); |
42 }); | 48 }); |
43 }); | 49 }); |
(...skipping 10 matching lines...) Expand all Loading... |
54 int ctr = 2; | 60 int ctr = 2; |
55 port.listen(expectAsync((v) { | 61 port.listen(expectAsync((v) { |
56 expect(v, "reply"); | 62 expect(v, "reply"); |
57 ctr--; | 63 ctr--; |
58 if (ctr == 0) port.close(); | 64 if (ctr == 0) port.close(); |
59 }, count: 2), | 65 }, count: 2), |
60 onDone: expectAsync((){})); | 66 onDone: expectAsync((){})); |
61 }); | 67 }); |
62 }); | 68 }); |
63 } | 69 } |
OLD | NEW |