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