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

Side by Side Diff: tests/isolate/src/APIv2_unresolvedPortsBrowserTest.dart

Issue 10226008: Revert "unittest step 3 and 4: remove TestFramework.dart, make test.dart use" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months 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
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 // spawns multiple isolates and sends unresolved ports between them. 5 // spawns multiple isolates and sends unresolved ports between them.
6 #library('unresolved_ports'); 6 #library('unresolved_ports');
7 #import('dart:dom'); // import added so test.dart can treat this as a webtest.
7 #import('dart:isolate'); 8 #import('dart:isolate');
8 #import('../../../lib/unittest/unittest.dart'); 9 #import('../../../lib/unittest/unittest.dart');
10 #import('../../../lib/unittest/dom_config.dart');
9 11
10 // This test does the following: 12 // This is similar to APIv2_unresolvedPortsStandaloneTest but using
11 // - main spawns two isolates: 'tim' and 'beth' 13 // 'unittest.dart' so it can run to completion in browsers.
12 // - 'tim' spawns an isolate: 'bob'
13 // - main starts a message chain:
14 // main -> beth -> tim -> bob -> main
15 // by giving 'beth' a send-port to 'tim'.
16 14
17 bethIsolate() { 15 bethIsolate() {
18 port.receive((msg, reply) => msg[1].send( 16 port.receive((msg, reply) => msg[1].send(
19 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', reply)); 17 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', reply));
20 } 18 }
21 19
22 timIsolate() { 20 timIsolate() {
23 SendPort bob = spawnFunction(bobIsolate); 21 SendPort bob = spawnFunction(bobIsolate);
24 port.receive((msg, reply) => bob.send( 22 port.receive((msg, reply) => bob.send(
25 '$msg\nTim says: Can you tell "main" that we are all coming?', reply)); 23 '$msg\nTim says: Can you tell "main" that we are all coming?', reply));
26 } 24 }
27 25
28 bobIsolate() { 26 bobIsolate() {
29 port.receive((msg, reply) => reply.send( 27 port.receive((msg, reply) => reply.send(
30 '$msg\nBob says: we are all coming!')); 28 '$msg\nBob says: we are all coming!'));
31 } 29 }
32 30
33 main() { 31 main() {
34 test('Message chain with unresolved ports', () { 32 useDomConfiguration();
33 asyncTest('Message chain with unresolved ports', 1, () {
35 ReceivePort port = new ReceivePort(); 34 ReceivePort port = new ReceivePort();
36 port.receive(expectAsync2((msg, _) { 35 port.receive((msg, _) {
37 expect(msg).equals('main says: Beth, find out if Tim is coming.' 36 expect(msg).equals('main says: Beth, find out if Tim is coming.'
38 + '\nBeth says: Tim are you coming? And Bob?' 37 + '\nBeth says: Tim are you coming? And Bob?'
39 + '\nTim says: Can you tell "main" that we are all coming?' 38 + '\nTim says: Can you tell "main" that we are all coming?'
40 + '\nBob says: we are all coming!'); 39 + '\nBob says: we are all coming!');
41 port.close(); 40 port.close();
42 })); 41 callbackDone();
42 });
43 43
44 SendPort tim = spawnFunction(timIsolate); 44 SendPort tim = spawnFunction(timIsolate);
45 SendPort beth = spawnFunction(bethIsolate); 45 SendPort beth = spawnFunction(bethIsolate);
46 46
47 beth.send( 47 beth.send(
48 // because tim is created asynchronously, here we are sending an 48 // because tim is created asynchronously, here we are sending an
49 // unresolved port: 49 // unresolved port:
50 ['main says: Beth, find out if Tim is coming.', tim], 50 ['main says: Beth, find out if Tim is coming.', tim],
51 port.toSendPort()); 51 port.toSendPort());
52 }); 52 });
53 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698