| OLD | NEW |
| 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:io'; | 8 import 'dart:io'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 | 10 |
| 11 void testParse(String message, | 11 void testParse(String message, |
| 12 String boundary, | 12 String boundary, |
| 13 [List<Map> expectedHeaders, | 13 [List<Map> expectedHeaders, |
| 14 List expectedParts, | 14 List expectedParts, |
| 15 bool expectError = false]) { | 15 bool expectError = false]) { |
| 16 void testWrite(List<int> data, [int chunkSize = -1]) { | 16 void testWrite(List<int> data, [int chunkSize = -1]) { |
| 17 StreamController controller = new StreamController(); | 17 StreamController controller = new StreamController(sync: true); |
| 18 | 18 |
| 19 var stream = controller.stream.transform( | 19 var stream = controller.stream.transform( |
| 20 new MimeMultipartTransformer(boundary)); | 20 new MimeMultipartTransformer(boundary)); |
| 21 int i = 0; | 21 int i = 0; |
| 22 var port = new ReceivePort(); | 22 var port = new ReceivePort(); |
| 23 stream.listen((multipart) { | 23 stream.listen((multipart) { |
| 24 int part = i++; | 24 int part = i++; |
| 25 if (expectedHeaders != null) { | 25 if (expectedHeaders != null) { |
| 26 Expect.mapEquals(expectedHeaders[part], multipart.headers); | 26 Expect.mapEquals(expectedHeaders[part], multipart.headers); |
| 27 } | 27 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 \r | 309 \r |
| 310 Body2\r | 310 Body2\r |
| 311 --xxx\r\n"""; | 311 --xxx\r\n"""; |
| 312 testParse(message, "xxx", null, [null, null], true); | 312 testParse(message, "xxx", null, [null, null], true); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void main() { | 315 void main() { |
| 316 testParseValid(); | 316 testParseValid(); |
| 317 testParseInvalid(); | 317 testParseInvalid(); |
| 318 } | 318 } |
| OLD | NEW |