| OLD | NEW |
| 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 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import "dart:async"; | 10 import "dart:async"; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 default: throw "Unexpected event $event"; | 369 default: throw "Unexpected event $event"; |
| 370 } | 370 } |
| 371 }, | 371 }, |
| 372 onDone: () => Expect.isTrue(closedEventReceived)); | 372 onDone: () => Expect.isTrue(closedEventReceived)); |
| 373 readSubscription.pause(); | 373 readSubscription.pause(); |
| 374 connected.complete(true); | 374 connected.complete(true); |
| 375 }); | 375 }); |
| 376 }); | 376 }); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void testSocketZone() { |
| 380 asyncStart(); |
| 381 Expect.equals(Zone.ROOT, Zone.current); |
| 382 runZoned(() { |
| 383 Expect.notEquals(Zone.ROOT, Zone.current); |
| 384 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
| 385 Expect.notEquals(Zone.ROOT, Zone.current); |
| 386 server.listen((socket) { |
| 387 Expect.notEquals(Zone.ROOT, Zone.current); |
| 388 socket.close(); |
| 389 server.close(); |
| 390 }); |
| 391 RawSocket.connect("127.0.0.1", server.port).then((socket) { |
| 392 socket.listen((event) { |
| 393 if (event == RawSocketEvent.READ_CLOSED) { |
| 394 socket.close(); |
| 395 asyncEnd(); |
| 396 } |
| 397 }); |
| 398 }); |
| 399 }); |
| 400 }); |
| 401 } |
| 402 |
| 403 void testSocketZoneError() { |
| 404 asyncStart(); |
| 405 Expect.equals(Zone.ROOT, Zone.current); |
| 406 runZoned(() { |
| 407 Expect.notEquals(Zone.ROOT, Zone.current); |
| 408 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
| 409 Expect.notEquals(Zone.ROOT, Zone.current); |
| 410 server.listen((socket) { |
| 411 socket.listen((_) { |
| 412 }, onError: (error) { |
| 413 Expect.notEquals(Zone.ROOT, Zone.current); |
| 414 socket.close(); |
| 415 server.close(); |
| 416 throw error; |
| 417 }); |
| 418 Expect.notEquals(Zone.ROOT, Zone.current); |
| 419 socket.write(const [0]); |
| 420 }); |
| 421 RawSocket.connect("127.0.0.1", server.port).then((socket) { |
| 422 socket.close(); |
| 423 }); |
| 424 }); |
| 425 }, onError: (e) { |
| 426 asyncEnd(); |
| 427 }); |
| 428 } |
| 429 |
| 379 main() { | 430 main() { |
| 380 asyncStart(); | 431 asyncStart(); |
| 381 testArguments(); | 432 testArguments(); |
| 382 testSimpleBind(); | 433 testSimpleBind(); |
| 383 testCloseOneEnd("client"); | 434 testCloseOneEnd("client"); |
| 384 testCloseOneEnd("server"); | 435 testCloseOneEnd("server"); |
| 385 testInvalidBind(); | 436 testInvalidBind(); |
| 386 testSimpleConnect(); | 437 testSimpleConnect(); |
| 387 testServerListenAfterConnect(); | 438 testServerListenAfterConnect(); |
| 388 testSimpleReadWrite(dropReads: false); | 439 testSimpleReadWrite(dropReads: false); |
| 389 testSimpleReadWrite(dropReads: true); | 440 testSimpleReadWrite(dropReads: true); |
| 390 testPauseServerSocket(); | 441 testPauseServerSocket(); |
| 391 testPauseSocket(); | 442 testPauseSocket(); |
| 443 testSocketZone(); |
| 444 testSocketZoneError(); |
| 392 asyncEnd(); | 445 asyncEnd(); |
| 393 } | 446 } |
| OLD | NEW |