Index: tests/lib/platform/isolate_test.dart |
diff --git a/tests/lib/platform/isolate_test.dart b/tests/lib/platform/isolate_test.dart |
index b402383ae9f6e9e1a39d77d9f1f0ad6d4eed147d..b53f088a7e6cdd54e583be7fc6fc10c318fae42a 100644 |
--- a/tests/lib/platform/isolate_test.dart |
+++ b/tests/lib/platform/isolate_test.dart |
@@ -7,33 +7,49 @@ import "dart:platform" as platform; |
import "dart:isolate"; |
import "package:unittest/unittest.dart"; |
+sendReceive(SendPort port, msg) { |
+ var response = new ReceivePort(); |
+ port.send([msg, response.sendPort]); |
+ return response.first; |
+} |
+ |
main() { |
- var sendPort = spawnFunction(f); |
- expect(sendPort.call("platform.executable"), completion(platform.executable)); |
- if (platform.script != null) { |
- expect(sendPort.call("platform.script").then((s) => s.path), |
- completion(endsWith('tests/lib/platform/isolate_test.dart'))); |
- } |
- expect(sendPort.call("platform.packageRoot"), |
- completion(platform.packageRoot)); |
- expect(sendPort.call("platform.executableArguments"), |
- completion(platform.executableArguments)); |
+ test("platform in isolate", () { |
+ var response = new ReceivePort(); |
+ Isolate.spawn(f, response.sendPort); |
+ response.first.then(expectAsync1((sendPort) { |
+ expect(sendReceive(sendPort, "platform.executable"), |
+ completion(platform.executable)); |
+ if (platform.script != null) { |
+ expect(sendReceive(sendPort, "platform.script").then((s) => s.path), |
+ completion(endsWith('tests/lib/platform/isolate_test.dart'))); |
+ } |
+ expect(sendReceive(sendPort, "platform.packageRoot"), |
+ completion(platform.packageRoot)); |
+ expect(sendReceive(sendPort, "platform.executableArguments"), |
+ completion(platform.executableArguments)); |
+ })); |
+ }); |
} |
-void f() { |
+void f(initialReplyTo) { |
+ var port = new ReceivePort(); |
+ initialReplyTo.send(port.sendPort); |
int count = 0; |
- port.receive((msg, reply) { |
- if (msg == "platform.executable") { |
- reply.send(platform.executable); |
+ port.listen((msg) { |
+ var data = msg[0]; |
+ var replyTo = msg[1]; |
+ if (data == "platform.executable") { |
+ replyTo.send(platform.executable); |
} |
- if (msg == "platform.script") { |
- reply.send(platform.script); |
+ if (data == "platform.script") { |
+ replyTo.send(platform.script); |
} |
- if (msg == "platform.packageRoot") { |
- reply.send(platform.packageRoot); |
+ if (data == "platform.packageRoot") { |
+ replyTo.send(platform.packageRoot); |
} |
- if (msg == "platform.executableArguments") { |
- reply.send(platform.executableArguments); |
+ if (data == "platform.executableArguments") { |
+ replyTo.send(platform.executableArguments); |
} |
count++; |
if (count == 4) { |