| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 List<int> data = new List<int>(messageSize); | 166 List<int> data = new List<int>(messageSize); |
| 167 | 167 |
| 168 client.writeEventsEnabled = false; | 168 client.writeEventsEnabled = false; |
| 169 client.listen((event) { | 169 client.listen((event) { |
| 170 switch (event) { | 170 switch (event) { |
| 171 case RawSocketEvent.READ: | 171 case RawSocketEvent.READ: |
| 172 Expect.isTrue(bytesWritten == 0); | 172 Expect.isTrue(bytesWritten == 0); |
| 173 Expect.isTrue(client.available() > 0); | 173 Expect.isTrue(client.available() > 0); |
| 174 var buffer = client.read(); | 174 var buffer = client.read(); |
| 175 if (buffer != null) { | 175 if (buffer != null) { |
| 176 data.setRange(bytesRead, buffer.length, buffer); | 176 data.setRange(bytesRead, bytesRead + buffer.length, buffer); |
| 177 bytesRead += buffer.length; | 177 bytesRead += buffer.length; |
| 178 for (var value in buffer) { | 178 for (var value in buffer) { |
| 179 Expect.isTrue(value is int); | 179 Expect.isTrue(value is int); |
| 180 Expect.isTrue(value < 256 && value >= 0); | 180 Expect.isTrue(value < 256 && value >= 0); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 if (bytesRead == data.length) { | 183 if (bytesRead == data.length) { |
| 184 verifyTestData(data); | 184 verifyTestData(data); |
| 185 client.writeEventsEnabled = true; | 185 client.writeEventsEnabled = true; |
| 186 } | 186 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 213 int bytesRead = 0; | 213 int bytesRead = 0; |
| 214 int bytesWritten = 0; | 214 int bytesWritten = 0; |
| 215 List<int> dataSent = createTestData(); | 215 List<int> dataSent = createTestData(); |
| 216 List<int> dataReceived = new List<int>(dataSent.length); | 216 List<int> dataReceived = new List<int>(dataSent.length); |
| 217 socket.listen((event) { | 217 socket.listen((event) { |
| 218 switch (event) { | 218 switch (event) { |
| 219 case RawSocketEvent.READ: | 219 case RawSocketEvent.READ: |
| 220 Expect.isTrue(socket.available() > 0); | 220 Expect.isTrue(socket.available() > 0); |
| 221 var buffer = socket.read(); | 221 var buffer = socket.read(); |
| 222 if (buffer != null) { | 222 if (buffer != null) { |
| 223 dataReceived.setRange(bytesRead, buffer.length, buffer); | 223 int endIndex = bytesRead + buffer.length; |
| 224 dataReceived.setRange(bytesRead, endIndex, buffer); |
| 224 bytesRead += buffer.length; | 225 bytesRead += buffer.length; |
| 225 } | 226 } |
| 226 break; | 227 break; |
| 227 case RawSocketEvent.WRITE: | 228 case RawSocketEvent.WRITE: |
| 228 Expect.isTrue(bytesRead == 0); | 229 Expect.isTrue(bytesRead == 0); |
| 229 Expect.isFalse(socket.writeEventsEnabled); | 230 Expect.isFalse(socket.writeEventsEnabled); |
| 230 bytesWritten += socket.write( | 231 bytesWritten += socket.write( |
| 231 dataSent, bytesWritten, dataSent.length - bytesWritten); | 232 dataSent, bytesWritten, dataSent.length - bytesWritten); |
| 232 if (bytesWritten < dataSent.length) { | 233 if (bytesWritten < dataSent.length) { |
| 233 socket.writeEventsEnabled = true; | 234 socket.writeEventsEnabled = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 254 testArguments(); | 255 testArguments(); |
| 255 testSimpleBind(); | 256 testSimpleBind(); |
| 256 testInvalidBind(); | 257 testInvalidBind(); |
| 257 testSimpleConnect(CERTIFICATE); | 258 testSimpleConnect(CERTIFICATE); |
| 258 testSimpleConnect("CN=localhost"); | 259 testSimpleConnect("CN=localhost"); |
| 259 testSimpleConnectFail("not_a_nickname"); | 260 testSimpleConnectFail("not_a_nickname"); |
| 260 testSimpleConnectFail("CN=notARealDistinguishedName"); | 261 testSimpleConnectFail("CN=notARealDistinguishedName"); |
| 261 testServerListenAfterConnect(); | 262 testServerListenAfterConnect(); |
| 262 testSimpleReadWrite(); | 263 testSimpleReadWrite(); |
| 263 } | 264 } |
| OLD | NEW |