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

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

Issue 14914002: Change fromString constructor to parse static method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed additional tests 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 'dart:io'; 5 import 'dart:io';
6 import 'dart:utf'; 6 import 'dart:utf';
7 7
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 9
10 void testHttpClientResponseBody() { 10 void testHttpClientResponseBody() {
11 void test(String mimeType, 11 void test(String mimeType,
12 List<int> content, 12 List<int> content,
13 dynamic expectedBody, 13 dynamic expectedBody,
14 String type, 14 String type,
15 [bool shouldFail = false]) { 15 [bool shouldFail = false]) {
16 HttpServer.bind("127.0.0.1", 0).then((server) { 16 HttpServer.bind("127.0.0.1", 0).then((server) {
17 server.listen((request) { 17 server.listen((request) {
18 request.listen( 18 request.listen(
19 (_) {}, 19 (_) {},
20 onDone: () { 20 onDone: () {
21 request.response.headers.contentType = 21 request.response.headers.contentType =
22 new ContentType.fromString(mimeType); 22 ContentType.parse(mimeType);
23 request.response.add(content); 23 request.response.add(content);
24 request.response.close(); 24 request.response.close();
25 }); 25 });
26 }); 26 });
27 27
28 var client = new HttpClient(); 28 var client = new HttpClient();
29 client.get("127.0.0.1", server.port, "/") 29 client.get("127.0.0.1", server.port, "/")
30 .then((request) => request.close()) 30 .then((request) => request.close())
31 .then(HttpBodyHandler.processResponse) 31 .then(HttpBodyHandler.processResponse)
32 .then((body) { 32 .then((body) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 body.response.close(); 118 body.response.close();
119 }, onError: (error) { 119 }, onError: (error) {
120 if (!shouldFail) Expect.fail("Error unexpected"); 120 if (!shouldFail) Expect.fail("Error unexpected");
121 }); 121 });
122 122
123 var client = new HttpClient(); 123 var client = new HttpClient();
124 client.post("127.0.0.1", server.port, "/") 124 client.post("127.0.0.1", server.port, "/")
125 .then((request) { 125 .then((request) {
126 if (mimeType != null) { 126 if (mimeType != null) {
127 request.headers.contentType = 127 request.headers.contentType =
128 new ContentType.fromString(mimeType); 128 ContentType.parse(mimeType);
129 } 129 }
130 request.add(content); 130 request.add(content);
131 return request.close(); 131 return request.close();
132 }) 132 })
133 .then((response) { 133 .then((response) {
134 if (shouldFail) { 134 if (shouldFail) {
135 Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode); 135 Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode);
136 } 136 }
137 response.fold(null, (x, y) {}); 137 response.fold(null, (x, y) {});
138 client.close(); 138 client.close();
(...skipping 23 matching lines...) Expand all
162 "json", 162 "json",
163 true); 163 true);
164 164
165 test(null, "body".codeUnits, "body".codeUnits, "binary"); 165 test(null, "body".codeUnits, "body".codeUnits, "binary");
166 } 166 }
167 167
168 void main() { 168 void main() {
169 testHttpClientResponseBody(); 169 testHttpClientResponseBody();
170 testHttpServerRequestBody(); 170 testHttpServerRequestBody();
171 } 171 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_auth_digest_test.dart ('k') | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698