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

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

Issue 16131003: Reapply "Active stream subscriptions". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Patch from sgjesse fixing file descriptor error. 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 756bf36be63c4c17e3cce4820000e7741b0e60cb..e6564bdc60ab7fb5c842b60f2f4038d93eab6981 100644
--- a/tests/standalone/io/http_parser_test.dart
+++ b/tests/standalone/io/http_parser_test.dart
@@ -202,6 +202,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;
@@ -228,21 +246,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