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

Side by Side Diff: pkg/http/test/multipart_test.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « pkg/http/test/mock_client_test.dart ('k') | pkg/http/test/request_test.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 library multipart_test; 5 library multipart_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:utf'; 8 import 'dart:utf';
9 9
10 // TODO(nweiz): get rid of this import before packaging this 10 // TODO(nweiz): get rid of this import before packaging this
(...skipping 11 matching lines...) Expand all
22 Matcher bodyMatches(String pattern) => new _BodyMatches(pattern); 22 Matcher bodyMatches(String pattern) => new _BodyMatches(pattern);
23 23
24 class _BodyMatches extends BaseMatcher { 24 class _BodyMatches extends BaseMatcher {
25 final String _pattern; 25 final String _pattern;
26 26
27 _BodyMatches(this._pattern); 27 _BodyMatches(this._pattern);
28 28
29 bool matches(item, MatchState matchState) { 29 bool matches(item, MatchState matchState) {
30 if (item is! http.MultipartRequest) return false; 30 if (item is! http.MultipartRequest) return false;
31 31
32 var future = consumeInputStream(item.finalize()).transform((bodyBytes) { 32 var future = consumeInputStream(item.finalize()).then((bodyBytes) {
33 var body = decodeUtf8(bodyBytes); 33 var body = decodeUtf8(bodyBytes);
34 var contentType = new ContentType.fromString( 34 var contentType = new ContentType.fromString(
35 item.headers['content-type']); 35 item.headers['content-type']);
36 var boundary = contentType.parameters['boundary']; 36 var boundary = contentType.parameters['boundary'];
37 var expected = cleanUpLiteral(_pattern) 37 var expected = cleanUpLiteral(_pattern)
38 .replaceAll("\n", "\r\n") 38 .replaceAll("\n", "\r\n")
39 .replaceAll("{{boundary}}", boundary); 39 .replaceAll("{{boundary}}", boundary);
40 40
41 expect(body, equals(expected)); 41 expect(body, equals(expected));
42 expect(item.contentLength, equals(bodyBytes.length)); 42 expect(item.contentLength, equals(bodyBytes.length));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 expect(request, bodyMatches(''' 196 expect(request, bodyMatches('''
197 --{{boundary}} 197 --{{boundary}}
198 content-type: application/octet-stream 198 content-type: application/octet-stream
199 content-disposition: form-data; name="file" 199 content-disposition: form-data; name="file"
200 200
201 hello 201 hello
202 --{{boundary}}-- 202 --{{boundary}}--
203 ''')); 203 '''));
204 }); 204 });
205 } 205 }
OLDNEW
« no previous file with comments | « pkg/http/test/mock_client_test.dart ('k') | pkg/http/test/request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698