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

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

Issue 14640008: Change the signature for all network bind calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by whesse@ Created 7 years, 7 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 // 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 "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:async"; 11 import "dart:async";
12 import "dart:io"; 12 import "dart:io";
13 13
14 void test1(int totalConnections) { 14 void test1(int totalConnections) {
15 // Server which just closes immediately. 15 // Server which just closes immediately.
16 HttpServer.bind().then((server) { 16 HttpServer.bind("127.0.0.1", 0).then((server) {
17 server.listen((HttpRequest request) { 17 server.listen((HttpRequest request) {
18 request.response.close(); 18 request.response.close();
19 }); 19 });
20 20
21 int count = 0; 21 int count = 0;
22 HttpClient client = new HttpClient(); 22 HttpClient client = new HttpClient();
23 for (int i = 0; i < totalConnections; i++) { 23 for (int i = 0; i < totalConnections; i++) {
24 client.get("127.0.0.1", server.port, "/") 24 client.get("127.0.0.1", server.port, "/")
25 .then((HttpClientRequest request) => request.close()) 25 .then((HttpClientRequest request) => request.close())
26 .then((HttpClientResponse response) { 26 .then((HttpClientResponse response) {
27 response.listen((_) {}, onDone: () { 27 response.listen((_) {}, onDone: () {
28 count++; 28 count++;
29 if (count == totalConnections) { 29 if (count == totalConnections) {
30 client.close(); 30 client.close();
31 server.close(); 31 server.close();
32 } 32 }
33 }); 33 });
34 }); 34 });
35 } 35 }
36 }); 36 });
37 } 37 }
38 38
39 39
40 void test2(int totalConnections, int outputStreamWrites) { 40 void test2(int totalConnections, int outputStreamWrites) {
41 // Server which responds without waiting for request body. 41 // Server which responds without waiting for request body.
42 HttpServer.bind().then((server) { 42 HttpServer.bind("127.0.0.1", 0).then((server) {
43 server.listen((HttpRequest request) { 43 server.listen((HttpRequest request) {
44 request.response.write("!dlrow ,olleH"); 44 request.response.write("!dlrow ,olleH");
45 request.response.close(); 45 request.response.close();
46 }); 46 });
47 47
48 int count = 0; 48 int count = 0;
49 HttpClient client = new HttpClient(); 49 HttpClient client = new HttpClient();
50 for (int i = 0; i < totalConnections; i++) { 50 for (int i = 0; i < totalConnections; i++) {
51 client.get("127.0.0.1", server.port, "/") 51 client.get("127.0.0.1", server.port, "/")
52 .then((HttpClientRequest request) { 52 .then((HttpClientRequest request) {
(...skipping 23 matching lines...) Expand all
76 server.close(); 76 server.close();
77 } 77 }
78 }); 78 });
79 } 79 }
80 }); 80 });
81 } 81 }
82 82
83 83
84 void test3(int totalConnections) { 84 void test3(int totalConnections) {
85 // Server which responds when request body has been received. 85 // Server which responds when request body has been received.
86 HttpServer.bind().then((server) { 86 HttpServer.bind("127.0.0.1", 0).then((server) {
87 87
88 server.listen((HttpRequest request) { 88 server.listen((HttpRequest request) {
89 request.listen((_) {}, onDone: () { 89 request.listen((_) {}, onDone: () {
90 request.response.write("!dlrow ,olleH"); 90 request.response.write("!dlrow ,olleH");
91 request.response.close(); 91 request.response.close();
92 }); 92 });
93 }); 93 });
94 94
95 int count = 0; 95 int count = 0;
96 HttpClient client = new HttpClient(); 96 HttpClient client = new HttpClient();
(...skipping 13 matching lines...) Expand all
110 } 110 }
111 }); 111 });
112 }); 112 });
113 } 113 }
114 114
115 }); 115 });
116 } 116 }
117 117
118 118
119 void test4() { 119 void test4() {
120 HttpServer.bind().then((server) { 120 HttpServer.bind("127.0.0.1", 0).then((server) {
121 121
122 server.listen((var request) { 122 server.listen((var request) {
123 request.listen((_) {}, onDone: () { 123 request.listen((_) {}, onDone: () {
124 new Timer.periodic(new Duration(milliseconds: 100), (timer) { 124 new Timer.periodic(new Duration(milliseconds: 100), (timer) {
125 if (server.connectionsInfo().total == 0) { 125 if (server.connectionsInfo().total == 0) {
126 server.close(); 126 server.close();
127 timer.cancel(); 127 timer.cancel();
128 } 128 }
129 }); 129 });
130 request.response.close(); 130 request.response.close();
131 }); 131 });
132 }); 132 });
133 133
134 var client= new HttpClient(); 134 var client= new HttpClient();
135 client.get("127.0.0.1", server.port, "/") 135 client.get("127.0.0.1", server.port, "/")
136 .then((request) => request.close()) 136 .then((request) => request.close())
137 .then((response) { 137 .then((response) {
138 response.listen((_) {}, onDone: () { 138 response.listen((_) {}, onDone: () {
139 client.close(); 139 client.close();
140 }); 140 });
141 }); 141 });
142 142
143 }); 143 });
144 } 144 }
145 145
146 146
147 void test5(int totalConnections) { 147 void test5(int totalConnections) {
148 HttpServer.bind().then((server) { 148 HttpServer.bind("127.0.0.1", 0).then((server) {
149 server.listen( 149 server.listen(
150 (request) { 150 (request) {
151 request.listen( 151 request.listen(
152 (_) { }, 152 (_) { },
153 onDone: () { 153 onDone: () {
154 request.response.close(); 154 request.response.close();
155 request.response.done.catchError((e) {}); 155 request.response.done.catchError((e) {});
156 }, 156 },
157 onError: (error) { }); 157 onError: (error) { });
158 }, 158 },
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 test1(10); 198 test1(10);
199 test2(1, 10); 199 test2(1, 10);
200 test2(10, 10); 200 test2(10, 10);
201 test2(10, 1000); 201 test2(10, 1000);
202 test3(1); 202 test3(1);
203 test3(10); 203 test3(10);
204 test4(); 204 test4();
205 test5(1); 205 test5(1);
206 test5(10); 206 test5(10);
207 } 207 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_session_test.dart ('k') | tests/standalone/io/raw_secure_server_closing_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698