OLD | NEW |
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 #import("dart:math"); | 7 #import("dart:math"); |
8 | 8 |
9 class ExpectedDataOutputStream implements OutputStream { | 9 class ExpectedDataOutputStream implements OutputStream { |
10 ExpectedDataOutputStream(List<int> this._data, | 10 ExpectedDataOutputStream(List<int> this._data, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 void set onClosed(void callback()) { | 102 void set onClosed(void callback()) { |
103 _onClosed = callback; | 103 _onClosed = callback; |
104 } | 104 } |
105 | 105 |
106 void set onError(void callback(e)) { | 106 void set onError(void callback(e)) { |
107 _onError = callback; | 107 _onError = callback; |
108 } | 108 } |
109 | 109 |
110 OutputStream get outputStream() => _outputStream; | 110 OutputStream get outputStream => _outputStream; |
111 | 111 |
112 int hashCode() => _hashCode; | 112 int hashCode() => _hashCode; |
113 | 113 |
114 List<int> _read; | 114 List<int> _read; |
115 bool _closed = false; | 115 bool _closed = false; |
116 int _hashCode; | 116 int _hashCode; |
117 Function _onData; | 117 Function _onData; |
118 Function _onClosed; | 118 Function _onClosed; |
119 Function _onError; | 119 Function _onError; |
120 Function _onClosedInternal; | 120 Function _onClosedInternal; |
(...skipping 29 matching lines...) Expand all Loading... |
150 } | 150 } |
151 | 151 |
152 void set onConnection(void callback(Socket connection)) { | 152 void set onConnection(void callback(Socket connection)) { |
153 _onConnection = callback; | 153 _onConnection = callback; |
154 } | 154 } |
155 | 155 |
156 void set onError(void callback(e)) { | 156 void set onError(void callback(e)) { |
157 _onError = callback; | 157 _onError = callback; |
158 } | 158 } |
159 | 159 |
160 int get port() => _port; | 160 int get port => _port; |
161 | 161 |
162 int _port; | 162 int _port; |
163 Function _onConnection; | 163 Function _onConnection; |
164 Function _onError; | 164 Function _onError; |
165 Set<Socket> _sockets; | 165 Set<Socket> _sockets; |
166 } | 166 } |
167 | 167 |
168 void testSocketClose() { | 168 void testSocketClose() { |
169 ServerSocketMock serverSocket = new ServerSocketMock("0.0.0.0", 5432, 5); | 169 ServerSocketMock serverSocket = new ServerSocketMock("0.0.0.0", 5432, 5); |
170 | 170 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", | 212 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", |
213 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" | 213 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" |
214 "\r\n\r\n0\r\n\r\n"); | 214 "\r\n\r\n0\r\n\r\n"); |
215 | 215 |
216 server.close(); | 216 server.close(); |
217 } | 217 } |
218 | 218 |
219 void main() { | 219 void main() { |
220 testSocketClose(); | 220 testSocketClose(); |
221 } | 221 } |
OLD | NEW |