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

Side by Side Diff: tests/standalone/src/io/HttpParserTest.dart

Issue 9581011: Make the HttpParser and HttpUtil classes private (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
« no previous file with comments | « runtime/bin/io_sources.gypi ('k') | tests/standalone/src/io/UrlEncodingTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #source("../../../../runtime/bin/http_parser.dart");
6 6
7 class HttpParserTest { 7 class HttpParserTest {
8 static void runAllTests() { 8 static void runAllTests() {
9 testParseRequest(); 9 testParseRequest();
10 testParseResponse(); 10 testParseResponse();
11 } 11 }
12 12
13 static void _testParseRequest(String request, 13 static void _testParseRequest(String request,
14 String expectedMethod, 14 String expectedMethod,
15 String expectedUri, 15 String expectedUri,
16 [int expectedContentLength = 0, 16 [int expectedContentLength = 0,
17 int expectedBytesReceived = 0, 17 int expectedBytesReceived = 0,
18 Map expectedHeaders = null, 18 Map expectedHeaders = null,
19 bool chunked = false]) { 19 bool chunked = false]) {
20 HttpParser httpParser; 20 _HttpParser httpParser;
21 bool headersCompleteCalled; 21 bool headersCompleteCalled;
22 bool dataEndCalled; 22 bool dataEndCalled;
23 String method; 23 String method;
24 String uri; 24 String uri;
25 Map headers; 25 Map headers;
26 int contentLength; 26 int contentLength;
27 int bytesReceived; 27 int bytesReceived;
28 28
29 void reset() { 29 void reset() {
30 httpParser = new HttpParser(); 30 httpParser = new _HttpParser();
31 httpParser.requestStart = (m, u) { method = m; uri = u; }; 31 httpParser.requestStart = (m, u) { method = m; uri = u; };
32 httpParser.responseStart = (s, r) { Expect.fail("Expected request"); }; 32 httpParser.responseStart = (s, r) { Expect.fail("Expected request"); };
33 httpParser.headerReceived = (f, v) { 33 httpParser.headerReceived = (f, v) {
34 Expect.isFalse(headersCompleteCalled); 34 Expect.isFalse(headersCompleteCalled);
35 headers[f] = v; 35 headers[f] = v;
36 }; 36 };
37 httpParser.headersComplete = () { 37 httpParser.headersComplete = () {
38 Expect.isFalse(headersCompleteCalled); 38 Expect.isFalse(headersCompleteCalled);
39 if (!chunked) { 39 if (!chunked) {
40 Expect.equals(expectedContentLength, httpParser.contentLength); 40 Expect.equals(expectedContentLength, httpParser.contentLength);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 testWrite(requestData, 1); 95 testWrite(requestData, 1);
96 } 96 }
97 97
98 static void _testParseResponse(String response, 98 static void _testParseResponse(String response,
99 int expectedStatusCode, 99 int expectedStatusCode,
100 String expectedReasonPhrase, 100 String expectedReasonPhrase,
101 [int expectedContentLength = 0, 101 [int expectedContentLength = 0,
102 int expectedBytesReceived = 0, 102 int expectedBytesReceived = 0,
103 Map expectedHeaders = null, 103 Map expectedHeaders = null,
104 bool chunked = false]) { 104 bool chunked = false]) {
105 HttpParser httpParser; 105 _HttpParser httpParser;
106 bool headersCompleteCalled; 106 bool headersCompleteCalled;
107 bool dataEndCalled; 107 bool dataEndCalled;
108 int statusCode; 108 int statusCode;
109 String reasonPhrase; 109 String reasonPhrase;
110 Map headers; 110 Map headers;
111 int contentLength; 111 int contentLength;
112 int bytesReceived; 112 int bytesReceived;
113 113
114 void reset() { 114 void reset() {
115 httpParser = new HttpParser(); 115 httpParser = new _HttpParser();
116 httpParser.requestStart = (m, u) => Expect.fail("Expected response"); 116 httpParser.requestStart = (m, u) => Expect.fail("Expected response");
117 httpParser.responseStart = (s, r) { 117 httpParser.responseStart = (s, r) {
118 statusCode = s; 118 statusCode = s;
119 reasonPhrase = r; 119 reasonPhrase = r;
120 }; 120 };
121 httpParser.headerReceived = (f, v) { 121 httpParser.headerReceived = (f, v) {
122 Expect.isFalse(headersCompleteCalled); 122 Expect.isFalse(headersCompleteCalled);
123 headers[f] = v; 123 headers[f] = v;
124 }; 124 };
125 httpParser.headersComplete = () { 125 httpParser.headersComplete = () {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 0123456789012345678901234567890\r 352 0123456789012345678901234567890\r
353 0\r\n\r\n"""; 353 0\r\n\r\n""";
354 _testParseResponse(response, 200, "OK", -1, 57, null, true); 354 _testParseResponse(response, 200, "OK", -1, 57, null, true);
355 } 355 }
356 } 356 }
357 357
358 358
359 void main() { 359 void main() {
360 HttpParserTest.runAllTests(); 360 HttpParserTest.runAllTests();
361 } 361 }
OLDNEW
« no previous file with comments | « runtime/bin/io_sources.gypi ('k') | tests/standalone/src/io/UrlEncodingTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698