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

Side by Side Diff: tests/standalone/io/socket_exception_test.dart

Issue 14251006: Remove AsyncError with Expando. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Tests socket exceptions. 5 // Tests socket exceptions.
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import "dart:async"; 8 import "dart:async";
9 import "dart:isolate"; 9 import "dart:isolate";
10 import "dart:io"; 10 import "dart:io";
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 var completer = new Completer(); 157 var completer = new Completer();
158 server.listen((socket) { 158 server.listen((socket) {
159 completer.future.then((_) => socket.destroy()); 159 completer.future.then((_) => socket.destroy());
160 }); 160 });
161 Socket.connect("127.0.0.1", server.port).then((client) { 161 Socket.connect("127.0.0.1", server.port).then((client) {
162 const int SIZE = 1024 * 1024; 162 const int SIZE = 1024 * 1024;
163 int errors = 0; 163 int errors = 0;
164 client.listen( 164 client.listen(
165 (data) => Expect.fail("Unexpected data"), 165 (data) => Expect.fail("Unexpected data"),
166 onError: (error) { 166 onError: (error) {
167 Expect.isTrue(error.error is SocketIOException); 167 Expect.isTrue(error is SocketIOException);
168 errors++; 168 errors++;
169 }, 169 },
170 onDone: () { 170 onDone: () {
171 // We get either a close or an error followed by a close 171 // We get either a close or an error followed by a close
172 // on the socket. Whether we get both depends on 172 // on the socket. Whether we get both depends on
173 // whether the system notices the error for the read 173 // whether the system notices the error for the read
174 // event or only for the write event. 174 // event or only for the write event.
175 Expect.isTrue(errors <= 1); 175 Expect.isTrue(errors <= 1);
176 server.close(); 176 server.close();
177 }); 177 });
178 client.add(new List.filled(SIZE, 0)); 178 client.add(new List.filled(SIZE, 0));
179 // Destroy other socket now. 179 // Destroy other socket now.
180 completer.complete(null); 180 completer.complete(null);
181 var port = new ReceivePort(); 181 var port = new ReceivePort();
182 client.done.then( 182 client.done.then(
183 (_) { 183 (_) {
184 Expect.fail("Expected error"); 184 Expect.fail("Expected error");
185 }, 185 },
186 onError: (error) { 186 onError: (error) {
187 Expect.isTrue(error.error is SocketIOException); 187 Expect.isTrue(error is SocketIOException);
188 port.close(); 188 port.close();
189 }); 189 });
190 }); 190 });
191 }); 191 });
192 } 192 }
193 193
194 static void clientSocketAddCloseResultErrorTest() { 194 static void clientSocketAddCloseResultErrorTest() {
195 ServerSocket.bind().then((server) { 195 ServerSocket.bind().then((server) {
196 var completer = new Completer(); 196 var completer = new Completer();
197 server.listen((socket) { 197 server.listen((socket) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 clientSocketAddCloseErrorTest(); 233 clientSocketAddCloseErrorTest();
234 clientSocketAddCloseResultErrorTest(); 234 clientSocketAddCloseResultErrorTest();
235 unknownHostTest(); 235 unknownHostTest();
236 } 236 }
237 } 237 }
238 238
239 main() { 239 main() {
240 SocketExceptionTest.testMain(); 240 SocketExceptionTest.testMain();
241 } 241 }
242 242
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_socket_test.dart ('k') | tests/standalone/io/socket_many_connections_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698