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

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

Issue 10153005: 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, 8 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 // negative test to ensure that APIv2_unresolvedPortsBrowserTest works. 5 // negative test to ensure that APIv2_unresolvedPortsTest works.
6 #library('unresolved_ports'); 6 #library('unresolved_ports');
7 #import('dart:dom'); // import added so test.dart can treat this as a webtest.
8 #import('dart:isolate'); 7 #import('dart:isolate');
9 #import('../../../lib/unittest/unittest.dart'); 8 #import('../../../lib/unittest/unittest.dart');
10 #import('../../../lib/unittest/dom_config.dart');
11
12 // This is similar to APIv2_unresolvedPortsStandaloneNegativeTest but using
13 // 'unittest.dart' so it can run to completion in browsers.
14 9
15 bethIsolate() { 10 bethIsolate() {
16 port.receive((msg, reply) => msg[1].send( 11 port.receive((msg, reply) => msg[1].send(
17 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', reply)); 12 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', reply));
18 } 13 }
19 14
20 timIsolate() { 15 timIsolate() {
21 SendPort bob = spawnFunction(bobIsolate); 16 SendPort bob = spawnFunction(bobIsolate);
22 port.receive((msg, reply) => bob.send( 17 port.receive((msg, reply) => bob.send(
23 '$msg\nTim says: Can you tell "main" that we are all coming?', reply)); 18 '$msg\nTim says: Can you tell "main" that we are all coming?', reply));
24 } 19 }
25 20
26 bobIsolate() { 21 bobIsolate() {
27 port.receive((msg, reply) => reply.send( 22 port.receive((msg, reply) => reply.send(
28 '$msg\nBob says: we are all coming!')); 23 '$msg\nBob says: we are all coming!'));
29 } 24 }
30 25
31 main() { 26 main() {
32 useDomConfiguration(); 27 test('Message chain with unresolved ports', () {
33 asyncTest('Message chain with unresolved ports', 1, () {
34 ReceivePort port = new ReceivePort(); 28 ReceivePort port = new ReceivePort();
35 port.receive((msg, _) { 29 port.receive(expectAsync2((msg, _) {
36 expect(msg).equals('main says: Beth, find out if Tim is coming.' 30 expect(msg).equals('main says: Beth, find out if Tim is coming.'
37 + '\nBeth says: Tim are you coming? And Bob?' 31 + '\nBeth says: Tim are you coming? And Bob?'
38 + '\nTim says: Can you tell "main" that we are all coming?' 32 + '\nTim says: Can you tell "main" that we are all coming?'
39 + '\nBob says: we are NOT coming!'); // should be 'all', not 'NOT' 33 + '\nBob says: we are NOT coming!'); // should be 'all', not 'NOT'
40 port.close(); 34 port.close();
41 callbackDone(); 35 }));
42 });
43 36
44 SendPort tim = spawnFunction(timIsolate); 37 SendPort tim = spawnFunction(timIsolate);
45 SendPort beth = spawnFunction(bethIsolate); 38 SendPort beth = spawnFunction(bethIsolate);
46 39
47 beth.send( 40 beth.send(
48 // because tim is created asynchronously, here we are sending an 41 // because tim is created asynchronously, here we are sending an
49 // unresolved port: 42 // unresolved port:
50 ['main says: Beth, find out if Tim is coming.', tim], 43 ['main says: Beth, find out if Tim is coming.', tim],
51 port.toSendPort()); 44 port.toSendPort());
52 }); 45 });
53 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698