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

Unified Diff: tests/standalone/io/http_parser_test.dart

Issue 14753009: Make StreamSubscription be the active part of a stream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/http_multipart_test.dart ('k') | tests/standalone/io/http_redirect_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_parser_test.dart
diff --git a/tests/standalone/io/http_parser_test.dart b/tests/standalone/io/http_parser_test.dart
index c0d4e1e17c32403b53b5aefa641e04e8de9f6be8..62cdcd5f997fe0253198abcfec4129fe460ab08a 100644
--- a/tests/standalone/io/http_parser_test.dart
+++ b/tests/standalone/io/http_parser_test.dart
@@ -204,6 +204,24 @@ class HttpParserTest {
controller = new StreamController();
var port = new ReceivePort();
controller.stream.pipe(httpParser);
+ int doneCallCount = 0;
+ // Called when done parsing entire message and done parsing body.
+ // Only executed when both are done.
+ void whenDone() {
+ doneCallCount++;
+ if (doneCallCount < 2) return;
+ Expect.equals(expectedVersion, headers.protocolVersion);
+ Expect.equals(expectedStatusCode, statusCode);
+ Expect.equals(expectedReasonPhrase, reasonPhrase);
+ Expect.isTrue(headersCompleteCalled);
+ Expect.equals(expectedBytesReceived, bytesReceived);
+ if (!upgrade) {
+ Expect.isTrue(dataEndCalled);
+ if (close) Expect.isTrue(dataEndClose);
+ Expect.equals(dataEndClose, connectionClose);
+ }
+ };
+
var subscription = httpParser.listen((incoming) {
port.close();
statusCode = incoming.statusCode;
@@ -230,21 +248,9 @@ class HttpParserTest {
onDone: () {
dataEndCalled = true;
dataEndClose = close;
+ whenDone();
});
- });
-
- subscription.onDone(() {
- Expect.equals(expectedVersion, headers.protocolVersion);
- Expect.equals(expectedStatusCode, statusCode);
- Expect.equals(expectedReasonPhrase, reasonPhrase);
- Expect.isTrue(headersCompleteCalled);
- Expect.equals(expectedBytesReceived, bytesReceived);
- if (!upgrade) {
- Expect.isTrue(dataEndCalled);
- if (close) Expect.isTrue(dataEndClose);
- Expect.equals(dataEndClose, connectionClose);
- }
- });
+ }, onDone: whenDone);
headersCompleteCalled = false;
dataEndCalled = false;
« no previous file with comments | « tests/standalone/io/http_multipart_test.dart ('k') | tests/standalone/io/http_redirect_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698