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 import "dart:async"; | 5 import "dart:async"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 import "dart:isolate"; | 7 import "dart:isolate"; |
8 | 8 |
9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 if (msg == "Platform.script") { | 42 if (msg == "Platform.script") { |
43 reply.send(Platform.script); | 43 reply.send(Platform.script); |
44 } | 44 } |
45 if (msg == "Platform.packageRoot") { | 45 if (msg == "Platform.packageRoot") { |
46 reply.send(Platform.packageRoot); | 46 reply.send(Platform.packageRoot); |
47 } | 47 } |
48 if (msg == "Platform.executableArguments") { | 48 if (msg == "Platform.executableArguments") { |
49 reply.send(Platform.executableArguments); | 49 reply.send(Platform.executableArguments); |
50 } | 50 } |
51 if (msg == "new Options().executable") { | |
52 reply.send(new Options().executable); | |
53 } | |
54 if (msg == "new Options().script") { | |
55 reply.send(new Options().script); | |
56 } | |
57 if (msg == "close") { | 51 if (msg == "close") { |
58 reply.send("closed"); | 52 reply.send("closed"); |
59 port.close(); | 53 port.close(); |
60 } | 54 } |
61 }); | 55 }); |
62 } | 56 } |
63 | 57 |
64 testIsolate() { | 58 testIsolate() { |
65 asyncStart(); | 59 asyncStart(); |
66 var sendPort = spawnFunction(f); | 60 var sendPort = spawnFunction(f); |
67 Future.wait([sendPort.call("Platform.executable"), | 61 Future.wait([sendPort.call("Platform.executable"), |
68 sendPort.call("Platform.script"), | 62 sendPort.call("Platform.script"), |
69 sendPort.call("Platform.packageRoot"), | 63 sendPort.call("Platform.packageRoot"), |
70 sendPort.call("Platform.executableArguments"), | 64 sendPort.call("Platform.executableArguments")]) |
71 sendPort.call("new Options().executable"), | |
72 sendPort.call("new Options().script")]) | |
73 .then((results) { | 65 .then((results) { |
74 Expect.equals(Platform.executable, results[0]); | 66 Expect.equals(Platform.executable, results[0]); |
75 Expect.equals(Platform.executable, results[4]); | |
76 Uri uri = Uri.parse(results[1]); | 67 Uri uri = Uri.parse(results[1]); |
77 Expect.equals(uri, Uri.parse(results[5])); | |
78 Expect.equals("file", uri.scheme); | 68 Expect.equals("file", uri.scheme); |
79 Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart')); | 69 Expect.isTrue(uri.path.endsWith('tests/standalone/io/platform_test.dart')); |
80 Expect.equals(Platform.packageRoot, results[2]); | 70 Expect.equals(Platform.packageRoot, results[2]); |
81 Expect.listEquals(Platform.executableArguments, results[3]); | 71 Expect.listEquals(Platform.executableArguments, results[3]); |
82 sendPort.call("close").then((_) => asyncEnd()); | 72 sendPort.call("close").then((_) => asyncEnd()); |
83 }); | 73 }); |
84 } | 74 } |
85 | 75 |
86 main() { | 76 main() { |
87 test(); | 77 test(); |
88 testIsolate(); | 78 testIsolate(); |
89 } | 79 } |
OLD | NEW |