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

Side by Side Diff: tests/isolate/cross_isolate_message_test.dart

Issue 11301046: Restructure pkg/unittest and pkg/webdriver to follow the pub conventions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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/isolate/count_test.dart ('k') | tests/isolate/isolate3_negative_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
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 // Dart test program for testing that isolates can communicate to isolates 5 // Dart test program for testing that isolates can communicate to isolates
6 // other than the main isolate. 6 // other than the main isolate.
7 7
8 #library('CrossIsolateMessageTest'); 8 library CrossIsolateMessageTest;
9 #import('dart:isolate'); 9 import 'dart:isolate';
10 #import('../../pkg/unittest/unittest.dart'); 10 import '../../pkg/unittest/lib/unittest.dart';
11 11
12 void crossIsolate1() { 12 void crossIsolate1() {
13 port.receive((msg, replyTo) { 13 port.receive((msg, replyTo) {
14 SendPort otherIsolate = msg; 14 SendPort otherIsolate = msg;
15 ReceivePort receivePort = new ReceivePort(); 15 ReceivePort receivePort = new ReceivePort();
16 receivePort.receive((msg, replyTo) { 16 receivePort.receive((msg, replyTo) {
17 otherIsolate.send(msg + 58, null); // 100. 17 otherIsolate.send(msg + 58, null); // 100.
18 receivePort.close(); 18 receivePort.close();
19 }); 19 });
20 replyTo.send(['ready', receivePort.toSendPort()]); 20 replyTo.send(['ready', receivePort.toSendPort()]);
(...skipping 16 matching lines...) Expand all
37 }); 37 });
38 } 38 }
39 39
40 main() { 40 main() {
41 test("share port, and send message cross isolates ", () { 41 test("share port, and send message cross isolates ", () {
42 SendPort port1 = spawnFunction(crossIsolate1); 42 SendPort port1 = spawnFunction(crossIsolate1);
43 SendPort port2 = spawnFunction(crossIsolate2); 43 SendPort port2 = spawnFunction(crossIsolate2);
44 // Create a new receive port and send it to isolate2. 44 // Create a new receive port and send it to isolate2.
45 ReceivePort myPort = new ReceivePort(); 45 ReceivePort myPort = new ReceivePort();
46 port2.call(myPort.toSendPort()).then(expectAsync1((msg) { 46 port2.call(myPort.toSendPort()).then(expectAsync1((msg) {
47 Expect.equals("ready", msg[0]); 47 expect(msg[0], "ready");
48 // Send port of isolate2 to isolate1. 48 // Send port of isolate2 to isolate1.
49 port1.call(msg[1]).then(expectAsync1((msg) { 49 port1.call(msg[1]).then(expectAsync1((msg) {
50 Expect.equals("ready", msg[0]); 50 expect(msg[0], "ready");
51 myPort.receive(expectAsync2((msg, replyTo) { 51 myPort.receive(expectAsync2((msg, replyTo) {
52 Expect.equals(499, msg); 52 expect(msg, 499);
53 myPort.close(); 53 myPort.close();
54 })); 54 }));
55 msg[1].send(42, null); 55 msg[1].send(42, null);
56 })); 56 }));
57 })); 57 }));
58 }); 58 });
59 } 59 }
OLDNEW
« no previous file with comments | « tests/isolate/count_test.dart ('k') | tests/isolate/isolate3_negative_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698