OLD | NEW |
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 "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 int bytesWritten = 0; | 164 int bytesWritten = 0; |
165 List<int> data = new List<int>(messageSize); | 165 List<int> data = new List<int>(messageSize); |
166 | 166 |
167 client.listen( | 167 client.listen( |
168 (buffer) { | 168 (buffer) { |
169 Expect.isTrue(bytesWritten == 0); | 169 Expect.isTrue(bytesWritten == 0); |
170 data.setRange(bytesRead, buffer.length, buffer); | 170 data.setRange(bytesRead, buffer.length, buffer); |
171 bytesRead += buffer.length; | 171 bytesRead += buffer.length; |
172 if (bytesRead == data.length) { | 172 if (bytesRead == data.length) { |
173 verifyTestData(data); | 173 verifyTestData(data); |
174 client.writeBytes(data); | 174 client.add(data); |
175 client.close(); | 175 client.close(); |
176 } | 176 } |
177 }, | 177 }, |
178 onDone: () { | 178 onDone: () { |
179 server.close(); | 179 server.close(); |
180 }); | 180 }); |
181 }); | 181 }); |
182 | 182 |
183 SecureSocket.connect(HOST_NAME, server.port).then((socket) { | 183 SecureSocket.connect(HOST_NAME, server.port).then((socket) { |
184 int bytesRead = 0; | 184 int bytesRead = 0; |
185 int bytesWritten = 0; | 185 int bytesWritten = 0; |
186 List<int> dataSent = createTestData(); | 186 List<int> dataSent = createTestData(); |
187 List<int> dataReceived = new List<int>(dataSent.length); | 187 List<int> dataReceived = new List<int>(dataSent.length); |
188 socket.writeBytes(dataSent); | 188 socket.add(dataSent); |
189 socket.close(); // Can also be delayed. | 189 socket.close(); // Can also be delayed. |
190 socket.listen( | 190 socket.listen( |
191 (List<int> buffer) { | 191 (List<int> buffer) { |
192 dataReceived.setRange(bytesRead, buffer.length, buffer); | 192 dataReceived.setRange(bytesRead, buffer.length, buffer); |
193 bytesRead += buffer.length; | 193 bytesRead += buffer.length; |
194 }, | 194 }, |
195 onDone: () { | 195 onDone: () { |
196 verifyTestData(dataReceived); | 196 verifyTestData(dataReceived); |
197 socket.close(); | 197 socket.close(); |
198 port.close(); | 198 port.close(); |
(...skipping 11 matching lines...) Expand all Loading... |
210 testArguments(); | 210 testArguments(); |
211 testSimpleBind(); | 211 testSimpleBind(); |
212 testInvalidBind(); | 212 testInvalidBind(); |
213 testSimpleConnect(CERTIFICATE); | 213 testSimpleConnect(CERTIFICATE); |
214 testSimpleConnect("CN=localhost"); | 214 testSimpleConnect("CN=localhost"); |
215 testSimpleConnectFail("not_a_nickname"); | 215 testSimpleConnectFail("not_a_nickname"); |
216 testSimpleConnectFail("CN=notARealDistinguishedName"); | 216 testSimpleConnectFail("CN=notARealDistinguishedName"); |
217 testServerListenAfterConnect(); | 217 testServerListenAfterConnect(); |
218 testSimpleReadWrite(); | 218 testSimpleReadWrite(); |
219 } | 219 } |
OLD | NEW |