| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 401 } |
| 402 | 402 |
| 403 void testSocketZoneError() { | 403 void testSocketZoneError() { |
| 404 asyncStart(); | 404 asyncStart(); |
| 405 Expect.equals(Zone.ROOT, Zone.current); | 405 Expect.equals(Zone.ROOT, Zone.current); |
| 406 runZoned(() { | 406 runZoned(() { |
| 407 Expect.notEquals(Zone.ROOT, Zone.current); | 407 Expect.notEquals(Zone.ROOT, Zone.current); |
| 408 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { | 408 RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
| 409 Expect.notEquals(Zone.ROOT, Zone.current); | 409 Expect.notEquals(Zone.ROOT, Zone.current); |
| 410 server.listen((socket) { | 410 server.listen((socket) { |
| 411 Expect.notEquals(Zone.ROOT, Zone.current); |
| 412 var timer; |
| 413 void write() { |
| 414 socket.write(const [0]); |
| 415 timer = new Timer(const Duration(milliseconds: 5), write); |
| 416 } |
| 417 write(); |
| 411 socket.listen((_) { | 418 socket.listen((_) { |
| 412 }, onError: (error) { | 419 }, onError: (error) { |
| 420 timer.cancel(); |
| 413 Expect.notEquals(Zone.ROOT, Zone.current); | 421 Expect.notEquals(Zone.ROOT, Zone.current); |
| 414 socket.close(); | 422 socket.close(); |
| 415 server.close(); | 423 server.close(); |
| 416 throw error; | 424 throw error; |
| 417 }); | 425 }); |
| 418 Expect.notEquals(Zone.ROOT, Zone.current); | |
| 419 socket.write(const [0]); | |
| 420 }); | 426 }); |
| 421 RawSocket.connect("127.0.0.1", server.port).then((socket) { | 427 RawSocket.connect("127.0.0.1", server.port).then((socket) { |
| 422 socket.close(); | 428 socket.close(); |
| 423 }); | 429 }); |
| 424 }); | 430 }); |
| 425 }, onError: (e) { | 431 }, onError: (e) { |
| 426 asyncEnd(); | 432 asyncEnd(); |
| 427 }); | 433 }); |
| 428 } | 434 } |
| 429 | 435 |
| 430 main() { | 436 main() { |
| 431 asyncStart(); | 437 asyncStart(); |
| 432 testArguments(); | 438 testArguments(); |
| 433 testSimpleBind(); | 439 testSimpleBind(); |
| 434 testCloseOneEnd("client"); | 440 testCloseOneEnd("client"); |
| 435 testCloseOneEnd("server"); | 441 testCloseOneEnd("server"); |
| 436 testInvalidBind(); | 442 testInvalidBind(); |
| 437 testSimpleConnect(); | 443 testSimpleConnect(); |
| 438 testServerListenAfterConnect(); | 444 testServerListenAfterConnect(); |
| 439 testSimpleReadWrite(dropReads: false); | 445 testSimpleReadWrite(dropReads: false); |
| 440 testSimpleReadWrite(dropReads: true); | 446 testSimpleReadWrite(dropReads: true); |
| 441 testPauseServerSocket(); | 447 testPauseServerSocket(); |
| 442 testPauseSocket(); | 448 testPauseSocket(); |
| 443 testSocketZone(); | 449 testSocketZone(); |
| 444 testSocketZoneError(); | 450 testSocketZoneError(); |
| 445 asyncEnd(); | 451 asyncEnd(); |
| 446 } | 452 } |
| OLD | NEW |