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

Side by Side Diff: tests/standalone/io/http_server_response_test.dart

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of review comments Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "dart:async"; 10 import "dart:async";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 Expect.equals(request.response, response); 48 Expect.equals(request.response, response);
49 server.close(); 49 server.close();
50 }); 50 });
51 }); 51 });
52 } 52 }
53 53
54 void testResponseAddStream() { 54 void testResponseAddStream() {
55 int bytes = new File(new Options().script).lengthSync(); 55 int bytes = new File(new Options().script).lengthSync();
56 56
57 testServerRequest((server, request) { 57 testServerRequest((server, request) {
58 request.response.addStream(new File(new Options().script).openRead()) 58 request.response.writeStream(new File(new Options().script).openRead())
59 .then((response) { 59 .then((response) {
60 response.close(); 60 response.close();
61 response.done.then((_) => server.close()); 61 response.done.then((_) => server.close());
62 }); 62 });
63 }, bytes: bytes); 63 }, bytes: bytes);
64 64
65 testServerRequest((server, request) { 65 testServerRequest((server, request) {
66 request.response.addStream(new File(new Options().script).openRead()) 66 request.response.writeStream(new File(new Options().script).openRead())
67 .then((response) { 67 .then((response) {
68 request.response.addStream(new File(new Options().script).openRead()) 68 request.response.writeStream(new File(new Options().script).openRead() )
69 .then((response) { 69 .then((response) {
70 response.close(); 70 response.close();
71 response.done.then((_) => server.close()); 71 response.done.then((_) => server.close());
72 }); 72 });
73 }); 73 });
74 }, bytes: bytes * 2); 74 }, bytes: bytes * 2);
75 75
76 testServerRequest((server, request) { 76 testServerRequest((server, request) {
77 var controller = new StreamController(); 77 var controller = new StreamController();
78 request.response.addStream(controller.stream) 78 request.response.writeStream(controller.stream)
79 .then((response) { 79 .then((response) {
80 response.close(); 80 response.close();
81 response.done.then((_) => server.close()); 81 response.done.then((_) => server.close());
82 }); 82 });
83 controller.close(); 83 controller.close();
84 }, bytes: 0); 84 }, bytes: 0);
85 } 85 }
86 86
87 void testBadResponseAdd() { 87 void testBadResponseAdd() {
88 testServerRequest((server, request) { 88 testServerRequest((server, request) {
89 request.response.contentLength = 0; 89 request.response.contentLength = 0;
90 request.response.add([0]); 90 request.response.writeBytes([0]);
91 request.response.done.catchError((error) { 91 request.response.done.catchError((error) {
92 server.close(); 92 server.close();
93 }, test: (e) => e is HttpException); 93 }, test: (e) => e is HttpException);
94 }); 94 });
95 95
96 testServerRequest((server, request) { 96 testServerRequest((server, request) {
97 request.response.contentLength = 5; 97 request.response.contentLength = 5;
98 request.response.add([0, 0, 0]); 98 request.response.writeBytes([0, 0, 0]);
99 request.response.add([0, 0, 0]); 99 request.response.writeBytes([0, 0, 0]);
100 request.response.done.catchError((error) { 100 request.response.done.catchError((error) {
101 server.close(); 101 server.close();
102 }, test: (e) => e is HttpException); 102 }, test: (e) => e is HttpException);
103 }); 103 });
104 104
105 testServerRequest((server, request) { 105 testServerRequest((server, request) {
106 request.response.contentLength = 0; 106 request.response.contentLength = 0;
107 request.response.add(new Uint8List(64 * 1024)); 107 request.response.writeBytes(new Uint8List(64 * 1024));
108 request.response.add(new Uint8List(64 * 1024)); 108 request.response.writeBytes(new Uint8List(64 * 1024));
109 request.response.add(new Uint8List(64 * 1024)); 109 request.response.writeBytes(new Uint8List(64 * 1024));
110 request.response.done.catchError((error) { 110 request.response.done.catchError((error) {
111 server.close(); 111 server.close();
112 }, test: (e) => e is HttpException); 112 }, test: (e) => e is HttpException);
113 }); 113 });
114 } 114 }
115 115
116 void testBadResponseClose() { 116 void testBadResponseClose() {
117 testServerRequest((server, request) { 117 testServerRequest((server, request) {
118 request.response.contentLength = 5; 118 request.response.contentLength = 5;
119 request.response.close(); 119 request.response.close();
120 request.response.done.catchError((error) { 120 request.response.done.catchError((error) {
121 server.close(); 121 server.close();
122 }, test: (e) => e is HttpException); 122 }, test: (e) => e is HttpException);
123 }); 123 });
124 124
125 testServerRequest((server, request) { 125 testServerRequest((server, request) {
126 request.response.contentLength = 5; 126 request.response.contentLength = 5;
127 request.response.add([0]); 127 request.response.writeBytes([0]);
128 request.response.close(); 128 request.response.close();
129 request.response.done.catchError((error) { 129 request.response.done.catchError((error) {
130 server.close(); 130 server.close();
131 }, test: (e) => e is HttpException); 131 }, test: (e) => e is HttpException);
132 }); 132 });
133 } 133 }
134 134
135 void main() { 135 void main() {
136 testResponseDone(); 136 testResponseDone();
137 testResponseAddStream(); 137 testResponseAddStream();
138 testBadResponseAdd(); 138 testBadResponseAdd();
139 testBadResponseClose(); 139 testBadResponseClose();
140 } 140 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_server_early_client_close_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