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

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

Issue 23886004: Update dart:io tests to use asyncStart/asyncEnd (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 3 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 import 'dart:io'; 5 import 'dart:io';
6 import 'dart:isolate'; 6
7 import "package:async_helper/async_helper.dart";
7 8
8 const ANY = InternetAddressType.ANY; 9 const ANY = InternetAddressType.ANY;
9 10
10 void testIPv6toIPv6() { 11 void testIPv6toIPv6() {
12 asyncStart();
11 InternetAddress.lookup("::0", type: ANY).then((serverAddr) { 13 InternetAddress.lookup("::0", type: ANY).then((serverAddr) {
12 InternetAddress.lookup("::1", type: ANY).then((clientAddr) { 14 InternetAddress.lookup("::1", type: ANY).then((clientAddr) {
13 ServerSocket.bind(serverAddr.first, 0).then((server) { 15 ServerSocket.bind(serverAddr.first, 0).then((server) {
14 server.listen((socket) { 16 server.listen((socket) {
15 socket.destroy(); 17 socket.destroy();
16 server.close(); 18 server.close();
19 asyncEnd();
17 }); 20 });
18 Socket.connect(clientAddr.first, server.port).then((socket) { 21 Socket.connect(clientAddr.first, server.port).then((socket) {
19 socket.destroy(); 22 socket.destroy();
20 }); 23 });
21 }); 24 });
22 }); 25 });
23 }); 26 });
24 } 27 }
25 28
26 void testIPv4toIPv6() { 29 void testIPv4toIPv6() {
30 asyncStart();
27 InternetAddress.lookup("::0", type: ANY).then((serverAddr) { 31 InternetAddress.lookup("::0", type: ANY).then((serverAddr) {
28 ServerSocket.bind(serverAddr.first, 0).then((server) { 32 ServerSocket.bind(serverAddr.first, 0).then((server) {
29 server.listen((socket) { 33 server.listen((socket) {
30 socket.destroy(); 34 socket.destroy();
31 server.close(); 35 server.close();
36 asyncEnd();
32 }); 37 });
33 Socket.connect("127.0.0.1", server.port).then((socket) { 38 Socket.connect("127.0.0.1", server.port).then((socket) {
34 socket.destroy(); 39 socket.destroy();
35 }); 40 });
36 }); 41 });
37 }); 42 });
38 } 43 }
39 44
40 void testIPv6toIPv4() { 45 void testIPv6toIPv4() {
46 asyncStart();
41 InternetAddress.lookup("::1", type: ANY).then((clientAddr) { 47 InternetAddress.lookup("::1", type: ANY).then((clientAddr) {
42 ServerSocket.bind("127.0.0.1", 0).then((server) { 48 ServerSocket.bind("127.0.0.1", 0).then((server) {
43 server.listen((socket) { 49 server.listen((socket) {
44 throw "Unexpected socket"; 50 throw "Unexpected socket";
45 }); 51 });
46 Socket.connect(clientAddr.first, server.port).catchError((e) { 52 Socket.connect(clientAddr.first, server.port).catchError((e) {
47 server.close(); 53 server.close();
54 asyncEnd();
48 }); 55 });
49 }); 56 });
50 }); 57 });
51 } 58 }
52 59
53 void testIPv4toIPv4() { 60 void testIPv4toIPv4() {
61 asyncStart();
54 ServerSocket.bind("127.0.0.1", 0).then((server) { 62 ServerSocket.bind("127.0.0.1", 0).then((server) {
55 server.listen((socket) { 63 server.listen((socket) {
56 socket.destroy(); 64 socket.destroy();
57 server.close(); 65 server.close();
66 asyncEnd();
58 }); 67 });
59 Socket.connect("127.0.0.1", server.port).then((socket) { 68 Socket.connect("127.0.0.1", server.port).then((socket) {
60 socket.destroy(); 69 socket.destroy();
61 }); 70 });
62 }); 71 });
63 } 72 }
64 73
65 void testIPv6Lookup() { 74 void testIPv6Lookup() {
66 var port = new ReceivePort(); 75 asyncStart();
67 InternetAddress.lookup("::0", type: ANY).then((list) { 76 InternetAddress.lookup("::0", type: ANY).then((list) {
68 if (list.length < 0) throw "no address"; 77 if (list.length < 0) throw "no address";
69 for (var entry in list) { 78 for (var entry in list) {
70 if (entry.type != InternetAddressType.IP_V6) { 79 if (entry.type != InternetAddressType.IP_V6) {
71 throw "Wrong IP type"; 80 throw "Wrong IP type";
72 } 81 }
73 } 82 }
74 port.close(); 83 asyncEnd();
75 }); 84 });
76 } 85 }
77 86
78 void testIPv4Lookup() { 87 void testIPv4Lookup() {
79 var port = new ReceivePort(); 88 asyncStart();
80 InternetAddress.lookup("127.0.0.1").then((list) { 89 InternetAddress.lookup("127.0.0.1").then((list) {
81 if (list.length < 0) throw "no addresse"; 90 if (list.length < 0) throw "no addresse";
82 for (var entry in list) { 91 for (var entry in list) {
83 if (entry.type != InternetAddressType.IP_V4) { 92 if (entry.type != InternetAddressType.IP_V4) {
84 throw "Wrong IP type"; 93 throw "Wrong IP type";
85 } 94 }
86 } 95 }
87 port.close(); 96 asyncEnd();
88 }); 97 });
89 } 98 }
90 99
91 void testIPv4toIPv6_IPV6Only() { 100 void testIPv4toIPv6_IPV6Only() {
101 asyncStart();
92 InternetAddress.lookup("::0", type: ANY) 102 InternetAddress.lookup("::0", type: ANY)
93 .then((serverAddr) { 103 .then((serverAddr) {
94 ServerSocket.bind(serverAddr.first, 0, v6Only: true) 104 ServerSocket.bind(serverAddr.first, 0, v6Only: true)
95 .then((server) { 105 .then((server) {
96 server.listen((socket) { 106 server.listen((socket) {
97 throw "Unexpcted socket"; 107 throw "Unexpcted socket";
98 }); 108 });
99 Socket.connect("127.0.0.1", server.port).catchError((error) { 109 Socket.connect("127.0.0.1", server.port).catchError((error) {
100 server.close(); 110 server.close();
111 asyncEnd();
101 }); 112 });
102 }); 113 });
103 }); 114 });
104 } 115 }
105 116
106 void main() { 117 void main() {
107 testIPv6toIPv6(); 118 testIPv6toIPv6();
108 testIPv4toIPv6(); 119 testIPv4toIPv6();
109 testIPv6toIPv4(); 120 testIPv6toIPv4();
110 testIPv4toIPv4(); 121 testIPv4toIPv4();
111 testIPv6Lookup(); 122 testIPv6Lookup();
112 testIPv4Lookup(); 123 testIPv4Lookup();
113 124
114 testIPv4toIPv6_IPV6Only(); 125 testIPv4toIPv6_IPV6Only();
115 } 126 }
OLDNEW
« no previous file with comments | « tests/standalone/io/socket_invalid_arguments_test.dart ('k') | tests/standalone/io/socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698