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

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

Issue 15989006: Revert until Windows crash is debugged. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:math'; 7 import 'dart:math';
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 bool dataEndClose; 197 bool dataEndClose;
198 int statusCode; 198 int statusCode;
199 String reasonPhrase; 199 String reasonPhrase;
200 HttpHeaders headers; 200 HttpHeaders headers;
201 int contentLength; 201 int contentLength;
202 int bytesReceived; 202 int bytesReceived;
203 httpParser = new _HttpParser.responseParser(); 203 httpParser = new _HttpParser.responseParser();
204 controller = new StreamController(); 204 controller = new StreamController();
205 var port = new ReceivePort(); 205 var port = new ReceivePort();
206 controller.stream.pipe(httpParser); 206 controller.stream.pipe(httpParser);
207 int doneCallCount = 0;
208 // Called when done parsing entire message and done parsing body.
209 // Only executed when both are done.
210 void whenDone() {
211 doneCallCount++;
212 if (doneCallCount < 2) return;
213 Expect.equals(expectedVersion, headers.protocolVersion);
214 Expect.equals(expectedStatusCode, statusCode);
215 Expect.equals(expectedReasonPhrase, reasonPhrase);
216 Expect.isTrue(headersCompleteCalled);
217 Expect.equals(expectedBytesReceived, bytesReceived);
218 if (!upgrade) {
219 Expect.isTrue(dataEndCalled);
220 if (close) Expect.isTrue(dataEndClose);
221 Expect.equals(dataEndClose, connectionClose);
222 }
223 };
224
225 var subscription = httpParser.listen((incoming) { 207 var subscription = httpParser.listen((incoming) {
226 port.close(); 208 port.close();
227 statusCode = incoming.statusCode; 209 statusCode = incoming.statusCode;
228 reasonPhrase = incoming.reasonPhrase; 210 reasonPhrase = incoming.reasonPhrase;
229 headers = incoming.headers; 211 headers = incoming.headers;
230 Expect.isFalse(headersCompleteCalled); 212 Expect.isFalse(headersCompleteCalled);
231 if (!chunked && !close) { 213 if (!chunked && !close) {
232 Expect.equals(expectedTransferLength, incoming.transferLength); 214 Expect.equals(expectedTransferLength, incoming.transferLength);
233 } else { 215 } else {
234 Expect.equals(-1, incoming.transferLength); 216 Expect.equals(-1, incoming.transferLength);
235 } 217 }
236 if (expectedHeaders != null) { 218 if (expectedHeaders != null) {
237 expectedHeaders.forEach((String name, String value) { 219 expectedHeaders.forEach((String name, String value) {
238 Expect.equals(value, headers[name][0]); 220 Expect.equals(value, headers[name][0]);
239 }); 221 });
240 } 222 }
241 Expect.equals(upgrade, httpParser.upgrade); 223 Expect.equals(upgrade, httpParser.upgrade);
242 headersCompleteCalled = true; 224 headersCompleteCalled = true;
243 incoming.listen( 225 incoming.listen(
244 (List<int> data) { 226 (List<int> data) {
245 Expect.isTrue(headersCompleteCalled); 227 Expect.isTrue(headersCompleteCalled);
246 bytesReceived += data.length; 228 bytesReceived += data.length;
247 }, 229 },
248 onDone: () { 230 onDone: () {
249 dataEndCalled = true; 231 dataEndCalled = true;
250 dataEndClose = close; 232 dataEndClose = close;
251 whenDone();
252 }); 233 });
253 }, onDone: whenDone); 234 });
235
236 subscription.onDone(() {
237 Expect.equals(expectedVersion, headers.protocolVersion);
238 Expect.equals(expectedStatusCode, statusCode);
239 Expect.equals(expectedReasonPhrase, reasonPhrase);
240 Expect.isTrue(headersCompleteCalled);
241 Expect.equals(expectedBytesReceived, bytesReceived);
242 if (!upgrade) {
243 Expect.isTrue(dataEndCalled);
244 if (close) Expect.isTrue(dataEndClose);
245 Expect.equals(dataEndClose, connectionClose);
246 }
247 });
254 248
255 headersCompleteCalled = false; 249 headersCompleteCalled = false;
256 dataEndCalled = false; 250 dataEndCalled = false;
257 dataEndClose = null; 251 dataEndClose = null;
258 statusCode = -1; 252 statusCode = -1;
259 reasonPhrase = null; 253 reasonPhrase = null;
260 headers = null; 254 headers = null;
261 bytesReceived = 0; 255 bytesReceived = 0;
262 } 256 }
263 257
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 0123456789012345678901234567890\r 867 0123456789012345678901234567890\r
874 0\r\n\r\n"""; 868 0\r\n\r\n""";
875 _testParseInvalidResponse(response); 869 _testParseInvalidResponse(response);
876 } 870 }
877 } 871 }
878 872
879 873
880 void main() { 874 void main() {
881 HttpParserTest.runAllTests(); 875 HttpParserTest.runAllTests();
882 } 876 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_multipart_test.dart ('k') | tests/standalone/io/http_redirect_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698