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

Side by Side Diff: tests/isolate/message_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 // Dart test program for testing serialization of messages. 5 // Dart test program for testing serialization of messages.
6 // VMOptions=--enable_type_checks --enable_asserts 6 // VMOptions=--enable_type_checks --enable_asserts
7 7
8 library MessageTest; 8 library MessageTest;
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ReceivePort receivePort = new ReceivePort(); 92 ReceivePort receivePort = new ReceivePort();
93 port.send([message, receivePort.sendPort]); 93 port.send([message, receivePort.sendPort]);
94 return receivePort.first; 94 return receivePort.first;
95 } 95 }
96 96
97 void main([args, port]) { 97 void main([args, port]) {
98 if (testRemote(main, port)) return; 98 if (testRemote(main, port)) return;
99 test("send objects and receive them back", () { 99 test("send objects and receive them back", () {
100 ReceivePort port = new ReceivePort(); 100 ReceivePort port = new ReceivePort();
101 Isolate.spawn(pingPong, port.sendPort); 101 Isolate.spawn(pingPong, port.sendPort);
102 port.first.then(expectAsync1((remote) { 102 port.first.then(expectAsync((remote) {
103 // Send objects and receive them back. 103 // Send objects and receive them back.
104 for (int i = 0; i < MessageTest.elms.length; i++) { 104 for (int i = 0; i < MessageTest.elms.length; i++) {
105 var sentObject = MessageTest.elms[i]; 105 var sentObject = MessageTest.elms[i];
106 remoteCall(remote, sentObject).then(expectAsync1((var receivedObject) { 106 remoteCall(remote, sentObject).then(expectAsync((var receivedObject) {
107 MessageTest.VerifyObject(i, receivedObject); 107 MessageTest.VerifyObject(i, receivedObject);
108 })); 108 }));
109 } 109 }
110 110
111 // Send recursive objects and receive them back. 111 // Send recursive objects and receive them back.
112 List local_list1 = ["Hello", "World", "Hello", 0xffffffffff]; 112 List local_list1 = ["Hello", "World", "Hello", 0xffffffffff];
113 List local_list2 = [null, local_list1, local_list1 ]; 113 List local_list2 = [null, local_list1, local_list1 ];
114 List local_list3 = [local_list2, 2.0, true, false, 0xffffffffff]; 114 List local_list3 = [local_list2, 2.0, true, false, 0xffffffffff];
115 List sendObject = new List(5); 115 List sendObject = new List(5);
116 sendObject[0] = local_list1; 116 sendObject[0] = local_list1;
117 sendObject[1] = sendObject; 117 sendObject[1] = sendObject;
118 sendObject[2] = local_list2; 118 sendObject[2] = local_list2;
119 sendObject[3] = sendObject; 119 sendObject[3] = sendObject;
120 sendObject[4] = local_list3; 120 sendObject[4] = local_list3;
121 remoteCall(remote, sendObject).then((var replyObject) { 121 remoteCall(remote, sendObject).then((var replyObject) {
122 expect(sendObject, isList); 122 expect(sendObject, isList);
123 expect(replyObject, isList); 123 expect(replyObject, isList);
124 expect(sendObject.length, equals(replyObject.length)); 124 expect(sendObject.length, equals(replyObject.length));
125 expect(replyObject[1], same(replyObject)); 125 expect(replyObject[1], same(replyObject));
126 expect(replyObject[3], same(replyObject)); 126 expect(replyObject[3], same(replyObject));
127 expect(replyObject[0], same(replyObject[2][1])); 127 expect(replyObject[0], same(replyObject[2][1]));
128 expect(replyObject[0], same(replyObject[2][2])); 128 expect(replyObject[0], same(replyObject[2][2]));
129 expect(replyObject[2], same(replyObject[4][0])); 129 expect(replyObject[2], same(replyObject[4][0]));
130 expect(replyObject[0][0], same(replyObject[0][2])); 130 expect(replyObject[0][0], same(replyObject[0][2]));
131 // Bigint literals are not canonicalized so do a == check. 131 // Bigint literals are not canonicalized so do a == check.
132 expect(replyObject[0][3], equals(replyObject[4][4])); 132 expect(replyObject[0][3], equals(replyObject[4][4]));
133 }); 133 });
134 134
135 // Shutdown the MessageServer. 135 // Shutdown the MessageServer.
136 remoteCall(remote, -1).then(expectAsync1((int message) { 136 remoteCall(remote, -1).then(expectAsync((int message) {
137 expect(message, MessageTest.elms.length + 1); 137 expect(message, MessageTest.elms.length + 1);
138 })); 138 }));
139 })); 139 }));
140 }); 140 });
141 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698