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

Side by Side Diff: tests/standalone/src/io/HttpServerSocketTest.dart

Issue 9956062: Refactor the close and error handling of HTTP connections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed additional review comments Created 8 years, 8 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,
11 bool this._closeAsError, 11 bool this._closeAsError,
12 SocketImpl this._socket); 12 SocketMock this._socket);
13 13
14 void set onNoPendingWrites(void callback()) { 14 void set onNoPendingWrites(void callback()) {
15 _onNoPendingWrites = callback; 15 _onNoPendingWrites = callback;
16 } 16 }
17 17
18 bool write(List data, [bool copyBuffer = true]) { 18 bool write(List data, [bool copyBuffer = true]) {
19 _onData(data); 19 _onData(data);
20 return true; 20 return true;
21 } 21 }
22 22
(...skipping 19 matching lines...) Expand all
42 // Tell HttpServer that the socket have closed. 42 // Tell HttpServer that the socket have closed.
43 _socket._closeInternal(_closeAsError); 43 _socket._closeInternal(_closeAsError);
44 } 44 }
45 } 45 }
46 46
47 Function _onNoPendingWrites; 47 Function _onNoPendingWrites;
48 List<int> _data; 48 List<int> _data;
49 int _written = 0; 49 int _written = 0;
50 int _cutoff; 50 int _cutoff;
51 bool _closeAsError; 51 bool _closeAsError;
52 SocketImpl _socket; 52 SocketMock _socket;
53 } 53 }
54 54
55 class SocketMock implements Socket { 55 class SocketMock implements Socket {
56 SocketMock(List<int> this._data, 56 SocketMock(List<int> this._data,
57 List<int> expected, 57 List<int> expected,
58 int cutoff, 58 int cutoff,
59 bool closeAsError) : 59 bool closeAsError) :
60 _hashCode = (Math.random() * (1 << 32)).toInt(), 60 _hashCode = (Math.random() * (1 << 32)).toInt(),
61 _read = [] { 61 _read = [] {
62 _outputStream = 62 _outputStream =
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", 204 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n",
205 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" + 205 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" +
206 "\r\n\r\n0\r\n\r\n"); 206 "\r\n\r\n0\r\n\r\n");
207 207
208 server.close(); 208 server.close();
209 } 209 }
210 210
211 void main() { 211 void main() {
212 testSocketClose(); 212 testSocketClose();
213 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698