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

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

Issue 12317147: Implement addStream for HttpClientRequest/HttpResponse and propegate all write-errors from the sock… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Extend test. Created 7 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
« no previous file with comments | « tests/standalone/io/http_request_pipeling_test.dart ('k') | tests/standalone/io/http_shutdown_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_server_response_test.dart
diff --git a/tests/standalone/io/http_server_response_test.dart b/tests/standalone/io/http_server_response_test.dart
index 674c901d54b51fe4c9bc333b61ab405d837b1096..fc948762be0a7f97b2dbbfcd37b76e5c4d7d605d 100644
--- a/tests/standalone/io/http_server_response_test.dart
+++ b/tests/standalone/io/http_server_response_test.dart
@@ -7,10 +7,11 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "dart:async";
import "dart:io";
import "dart:scalarlist";
-void testServerRequest(void handler(server, request)) {
+void testServerRequest(void handler(server, request), {int bytes}) {
HttpServer.bind().then((server) {
server.listen((request) {
handler(server, request);
@@ -23,11 +24,16 @@ void testServerRequest(void handler(server, request)) {
client.get("127.0.0.1", server.port, "/")
.then((request) => request.close())
.then((response) {
- response.listen((_) {}, onDone: () {
- client.close();
- }, onError: (error) {
- Expect.isTrue(error.error is HttpParserException);
- });
+ int received = 0;
+ response.listen(
+ (data) => received += data.length,
+ onDone: () {
+ if (bytes != null) Expect.equals(received, bytes);
+ client.close();
+ },
+ onError: (error) {
+ Expect.isTrue(error.error is HttpParserException);
+ });
})
.catchError((error) {
client.close();
@@ -45,6 +51,39 @@ void testResponseDone() {
});
}
+void testResponseAddStream() {
+ int bytes = new File(new Options().script).lengthSync();
+
+ testServerRequest((server, request) {
+ request.response.addStream(new File(new Options().script).openRead())
+ .then((response) {
+ response.close();
+ response.done.then((_) => server.close());
+ });
+ }, bytes: bytes);
+
+ testServerRequest((server, request) {
+ request.response.addStream(new File(new Options().script).openRead())
+ .then((response) {
+ request.response.addStream(new File(new Options().script).openRead())
+ .then((response) {
+ response.close();
+ response.done.then((_) => server.close());
+ });
+ });
+ }, bytes: bytes * 2);
+
+ testServerRequest((server, request) {
+ var controller = new StreamController();
+ request.response.addStream(controller.stream)
+ .then((response) {
+ response.close();
+ response.done.then((_) => server.close());
+ });
+ controller.close();
+ }, bytes: 0);
+}
+
void testBadResponseAdd() {
testServerRequest((server, request) {
request.response.contentLength = 0;
@@ -95,6 +134,7 @@ void testBadResponseClose() {
void main() {
testResponseDone();
+ testResponseAddStream();
testBadResponseAdd();
testBadResponseClose();
}
« no previous file with comments | « tests/standalone/io/http_request_pipeling_test.dart ('k') | tests/standalone/io/http_shutdown_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698