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

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

Issue 10832188: Add an OutputStream.closed getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #import("dart:io"); 5 #import("dart:io");
6 #import("dart:isolate"); 6 #import("dart:isolate");
7 7
8 class ExpectedDataOutputStream implements OutputStream { 8 class ExpectedDataOutputStream implements OutputStream {
9 ExpectedDataOutputStream(List<int> this._data, 9 ExpectedDataOutputStream(List<int> this._data,
10 int this._cutoff, 10 int this._cutoff,
(...skipping 16 matching lines...) Expand all
27 bool writeFrom(List data, [int offset = 0, int len]) { 27 bool writeFrom(List data, [int offset = 0, int len]) {
28 if (len === null) len = data.length - offset; 28 if (len === null) len = data.length - offset;
29 _onData(data.getRange(offset, len)); 29 _onData(data.getRange(offset, len));
30 return true; 30 return true;
31 } 31 }
32 32
33 void close() { 33 void close() {
34 _socket.close(true); 34 _socket.close(true);
35 } 35 }
36 36
37 bool get closed() => _socket._closed;
Søren Gjesse 2012/08/08 11:49:15 Not strictly needed here. It is never used and Exp
nweiz 2012/08/09 19:39:52 Removed.
38
37 void _onData(List<int> data) { 39 void _onData(List<int> data) {
38 // TODO(ajohnsen): To be removed, since the socket should not be written to 40 // TODO(ajohnsen): To be removed, since the socket should not be written to
39 // after close. 41 // after close.
40 if (_socket._closed) return; 42 if (_socket._closed) return;
41 Expect.isFalse(_written > _cutoff); 43 Expect.isFalse(_written > _cutoff);
42 Expect.listEquals(data, _data.getRange(0, data.length)); 44 Expect.listEquals(data, _data.getRange(0, data.length));
43 _data = _data.getRange(data.length, _data.length - data.length); 45 _data = _data.getRange(data.length, _data.length - data.length);
44 _written += data.length; 46 _written += data.length;
45 if (_written >= _cutoff) { 47 if (_written >= _cutoff) {
46 // Tell HttpServer that the socket have closed. 48 // Tell HttpServer that the socket have closed.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", 213 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n",
212 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" 214 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close"
213 "\r\n\r\n0\r\n\r\n"); 215 "\r\n\r\n0\r\n\r\n");
214 216
215 server.close(); 217 server.close();
216 } 218 }
217 219
218 void main() { 220 void main() {
219 testSocketClose(); 221 testSocketClose();
220 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698