Index: pkg/mime/test/mime_multipart_transformer_test.dart |
diff --git a/tests/standalone/io/mime_multipart_parser_test.dart b/pkg/mime/test/mime_multipart_transformer_test.dart |
similarity index 90% |
rename from tests/standalone/io/mime_multipart_parser_test.dart |
rename to pkg/mime/test/mime_multipart_transformer_test.dart |
index 49e5b6a7459e8b86b82e00bcca4b251fae202875..897c8770e52394f6301c933f8266aa24e734d7d6 100644 |
--- a/tests/standalone/io/mime_multipart_parser_test.dart |
+++ b/pkg/mime/test/mime_multipart_transformer_test.dart |
@@ -2,44 +2,44 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-import "package:expect/expect.dart"; |
+import "package:unittest/unittest.dart"; |
+import "package:mime/mime.dart"; |
import 'dart:async'; |
import 'dart:math'; |
-import 'dart:io'; |
import 'dart:isolate'; |
void testParse(String message, |
String boundary, |
[List<Map> expectedHeaders, |
- List expectedParts, |
- bool expectError = false]) { |
- void testWrite(List<int> data, [int chunkSize = -1]) { |
+ List expectedParts, |
+ bool expectError = false]) { |
+ Future testWrite(List<int> data, [int chunkSize = -1]) { |
StreamController controller = new StreamController(sync: true); |
var stream = controller.stream.transform( |
new MimeMultipartTransformer(boundary)); |
int i = 0; |
- var port = new ReceivePort(); |
+ var completer = new Completer(); |
+ var futures = []; |
stream.listen((multipart) { |
int part = i++; |
if (expectedHeaders != null) { |
- Expect.mapEquals(expectedHeaders[part], multipart.headers); |
+ expect(multipart.headers, equals(expectedHeaders[part])); |
} |
- var partPort = new ReceivePort(); |
- multipart.fold([], (buffer, data) => buffer..addAll(data)) |
+ var partCompleter = new Completer(); |
Bill Hesse
2013/07/12 11:43:33
partCompleter is unused.
Anders Johnsen
2013/07/15 08:21:32
Done.
|
+ futures.add(multipart.fold([], (buffer, data) => buffer..addAll(data)) |
.then((data) { |
if (expectedParts[part] != null) { |
Bill Hesse
2013/07/12 11:43:33
Is this really needed? I see only one test with e
Anders Johnsen
2013/07/15 08:21:32
Testing for 'null' is a way to specify in the test
|
- Expect.listEquals(expectedParts[part].codeUnits, data); |
+ expect(data, equals(expectedParts[part].codeUnits)); |
} |
- partPort.close(); |
- }); |
+ })); |
}, onError: (error) { |
if (!expectError) throw error; |
}, onDone: () { |
Bill Hesse
2013/07/12 11:43:33
expect(expectError, isFalse);
Anders Johnsen
2013/07/15 08:21:32
No, I still get close (cancelOnError is not set).
|
if (expectedParts != null) { |
- Expect.equals(expectedParts.length, i); |
+ expect(i, equals(expectedParts.length)); |
} |
- port.close(); |
+ Future.wait(futures).then(completer.complete); |
}); |
if (chunkSize == -1) chunkSize = data.length; |
@@ -52,15 +52,19 @@ void testParse(String message, |
written += writeLength; |
} |
controller.close(); |
+ |
+ return completer.future; |
} |
// Test parsing the data three times delivering the data in |
// different chunks. |
List<int> data = message.codeUnits; |
- testWrite(data); |
- testWrite(data, 10); |
- testWrite(data, 2); |
- testWrite(data, 1); |
+ expect(Future.wait([ |
+ testWrite(data), |
+ testWrite(data, 10), |
+ testWrite(data, 2), |
+ testWrite(data, 1)]), |
+ completion(anything)); |
Bill Hesse
2013/07/12 11:43:33
completes is the same as completion(anything).
Anders Johnsen
2013/07/15 08:21:32
Done.
|
} |
void testParseValid() { |