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

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

Issue 218273002: Upgrading tests with unittest deprecations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 // 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:async'; 7 import 'dart:async';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import "remote_unittest_helper.dart"; 10 import "remote_unittest_helper.dart";
11 11
12 // This test does the following: 12 // This test does the following:
13 // - main spawns two isolates: 'tim' and 'beth' 13 // - main spawns two isolates: 'tim' and 'beth'
14 // - 'tim' spawns an isolate: 'bob' 14 // - 'tim' spawns an isolate: 'bob'
15 // - main starts a message chain: 15 // - main starts a message chain:
16 // main -> beth -> tim -> bob -> main 16 // main -> beth -> tim -> bob -> main
17 // by giving 'beth' a send-port to 'tim'. 17 // by giving 'beth' a send-port to 'tim'.
18 18
19 bethIsolate(init) { 19 bethIsolate(init) {
20 ReceivePort port = initIsolate(init); 20 ReceivePort port = initIsolate(init);
21 // TODO(sigmund): use expectAsync2 when it is OK to use it within an isolate 21 // TODO(sigmund): use expectAsync when it is OK to use it within an isolate
22 // (issue #6856) 22 // (issue #6856)
23 port.first.then((msg) => msg[1].send([ 23 port.first.then((msg) => msg[1].send([
24 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', msg[2]])); 24 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', msg[2]]));
25 } 25 }
26 26
27 timIsolate(init) { 27 timIsolate(init) {
28 ReceivePort port = initIsolate(init); 28 ReceivePort port = initIsolate(init);
29 spawnFunction(bobIsolate).then((bob) { 29 spawnFunction(bobIsolate).then((bob) {
30 port.first.then((msg) => bob.send([ 30 port.first.then((msg) => bob.send([
31 '${msg[0]}\nTim says: Can you tell "main" that we are all coming?', 31 '${msg[0]}\nTim says: Can you tell "main" that we are all coming?',
(...skipping 15 matching lines...) Expand all
47 47
48 ReceivePort initIsolate(SendPort starter) { 48 ReceivePort initIsolate(SendPort starter) {
49 ReceivePort port = new ReceivePort(); 49 ReceivePort port = new ReceivePort();
50 starter.send(port.sendPort); 50 starter.send(port.sendPort);
51 return port; 51 return port;
52 } 52 }
53 53
54 baseTest({bool failForNegativeTest: false}) { 54 baseTest({bool failForNegativeTest: false}) {
55 test('Message chain with unresolved ports', () { 55 test('Message chain with unresolved ports', () {
56 ReceivePort port = new ReceivePort(); 56 ReceivePort port = new ReceivePort();
57 port.listen(expectAsync1((msg) { 57 port.listen(expectAsync((msg) {
58 expect(msg, equals('main says: Beth, find out if Tim is coming.' 58 expect(msg, equals('main says: Beth, find out if Tim is coming.'
59 '\nBeth says: Tim are you coming? And Bob?' 59 '\nBeth says: Tim are you coming? And Bob?'
60 '\nTim says: Can you tell "main" that we are all coming?' 60 '\nTim says: Can you tell "main" that we are all coming?'
61 '\nBob says: we are all coming!')); 61 '\nBob says: we are all coming!'));
62 expect(failForNegativeTest, isFalse); 62 expect(failForNegativeTest, isFalse);
63 port.close(); 63 port.close();
64 })); 64 }));
65 65
66 spawnFunction(timIsolate).then((tim) { 66 spawnFunction(timIsolate).then((tim) {
67 spawnFunction(bethIsolate).then((beth) { 67 spawnFunction(bethIsolate).then((beth) {
68 beth.send(['main says: Beth, find out if Tim is coming.', 68 beth.send(['main says: Beth, find out if Tim is coming.',
69 tim, port.sendPort]); 69 tim, port.sendPort]);
70 }); 70 });
71 }); 71 });
72 72
73 }); 73 });
74 } 74 }
75 75
76 void main([args, port]) { 76 void main([args, port]) {
77 if (testRemote(main, port)) return; 77 if (testRemote(main, port)) return;
78 baseTest(); 78 baseTest();
79 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698