Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: tests/lib/platform/isolate_test.dart

Issue 50573002: Remove dart:platform library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/platform/import_test.dart ('k') | tests/lib/platform/local_hostname_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "dart:platform" as platform;
6
7 import "dart:isolate";
8 import "package:unittest/unittest.dart";
9
10 sendReceive(SendPort port, msg) {
11 var response = new ReceivePort();
12 port.send([msg, response.sendPort]);
13 return response.first;
14 }
15
16 main() {
17 test("platform in isolate", () {
18 var response = new ReceivePort();
19 Isolate.spawn(f, response.sendPort);
20 response.first.then(expectAsync1((sendPort) {
21 expect(sendReceive(sendPort, "platform.executable"),
22 completion(platform.executable));
23 if (platform.script != null) {
24 expect(sendReceive(sendPort, "platform.script").then((s) => s.path),
25 completion(endsWith('tests/lib/platform/isolate_test.dart')));
26 }
27 expect(sendReceive(sendPort, "platform.packageRoot"),
28 completion(platform.packageRoot));
29 expect(sendReceive(sendPort, "platform.executableArguments"),
30 completion(platform.executableArguments));
31 }));
32 });
33 }
34
35 void f(initialReplyTo) {
36 var port = new ReceivePort();
37 initialReplyTo.send(port.sendPort);
38 int count = 0;
39 port.listen((msg) {
40 var data = msg[0];
41 var replyTo = msg[1];
42 if (data == "platform.executable") {
43 replyTo.send(platform.executable);
44 }
45 if (data == "platform.script") {
46 replyTo.send(platform.script);
47 }
48 if (data == "platform.packageRoot") {
49 replyTo.send(platform.packageRoot);
50 }
51 if (data == "platform.executableArguments") {
52 replyTo.send(platform.executableArguments);
53 }
54 count++;
55 if (count == 4) {
56 port.close();
57 }
58 });
59 }
OLDNEW
« no previous file with comments | « tests/lib/platform/import_test.dart ('k') | tests/lib/platform/local_hostname_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698