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

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

Issue 185543004: Merge all http-outgoing transfomers into _HttpOutgoing, including simpler(better) buffering. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup Created 6 years, 10 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
Index: tests/standalone/io/http_close_test.dart
diff --git a/tests/standalone/io/http_close_test.dart b/tests/standalone/io/http_close_test.dart
index 17b4e47b7c449e32f05d57877b8a67a9f2ceb2dc..bd972c1515965037ed7e2c95515781824f106021 100644
--- a/tests/standalone/io/http_close_test.dart
+++ b/tests/standalone/io/http_close_test.dart
@@ -11,6 +11,7 @@ import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:typed_data";
+import "dart:math";
void testClientAndServerCloseNoListen(int connections) {
@@ -70,6 +71,11 @@ void testClientCloseServerListen(int connections) {
void testClientCloseSendingResponse(int connections) {
+ var buffer = new Uint8List(64 * 1024);
+ var rand = new Random();
+ for (int i = 0; i < buffer.length; i++) {
+ buffer[i] = rand.nextInt(256);
+ }
HttpServer.bind("127.0.0.1", 0).then((server) {
int closed = 0;
void check() {
@@ -83,8 +89,8 @@ void testClientCloseSendingResponse(int connections) {
}
}
server.listen((request) {
- var timer = new Timer.periodic(const Duration(milliseconds: 20), (_) {
- request.response.add(new Uint8List(16 * 1024));
+ var timer = new Timer.periodic(const Duration(milliseconds: 50), (_) {
+ request.response.add(buffer);
});
request.response.done
.catchError((_) {})
@@ -101,7 +107,7 @@ void testClientCloseSendingResponse(int connections) {
// Ensure we don't accept the response until we have send the entire
// request.
var subscription = response.listen((_) {});
- new Timer(const Duration(milliseconds: 200), () {
+ new Timer(const Duration(milliseconds: 20), () {
subscription.cancel();
check();
});
@@ -115,9 +121,10 @@ void testClientCloseWhileSendingRequest(int connections) {
HttpServer.bind("127.0.0.1", 0).then((server) {
int errors = 0;
server.listen((request) {
- request.listen((_) {}, onError: (e) { errors++; });
+ request.listen((_) {});
});
var client = new HttpClient();
+ int closed = 0;
for (int i = 0; i < connections; i++) {
client.post("127.0.0.1", server.port, "/")
.then((request) {
@@ -125,14 +132,13 @@ void testClientCloseWhileSendingRequest(int connections) {
request.write("0123456789");
return request.close();
})
- .catchError((_) {});
+ .catchError((_) {
+ closed++;
+ if (closed == connections) {
+ server.close();
+ }
+ });
}
- new Timer.periodic(const Duration(milliseconds: 100), (t) {
- if (errors == connections && server.connectionsInfo().total == 0) {
- t.cancel();
- server.close();
- }
- });
});
}
« no previous file with comments | « tests/standalone/io/http_client_connect_test.dart ('k') | tests/standalone/io/http_content_length_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698