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

Unified Diff: tests/standalone/io/raw_secure_server_socket_test.dart

Issue 16858011: dart:io | Enable multithreaded secure networking encryption. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/raw_secure_server_socket_test.dart
diff --git a/tests/standalone/io/raw_secure_server_socket_test.dart b/tests/standalone/io/raw_secure_server_socket_test.dart
index a886f7d990f15ae2617638a7b386614e969f7fe8..3cd4181a07a9d64b04d5c92b27bd306b4925defb 100644
--- a/tests/standalone/io/raw_secure_server_socket_test.dart
+++ b/tests/standalone/io/raw_secure_server_socket_test.dart
@@ -155,10 +155,13 @@ void testServerListenAfterConnect() {
// server will not happen until the first TLS handshake data has been
// received from the client. This argument only takes effect when
// handshakeBeforeSecure is true.
-void testSimpleReadWrite(bool listenSecure,
- bool connectSecure,
- bool handshakeBeforeSecure,
- [bool postponeSecure = false]) {
+void testSimpleReadWrite({bool listenSecure,
+ bool connectSecure,
+ bool handshakeBeforeSecure,
+ bool postponeSecure,
+ bool dropReads}) {
+ int clientReads = 0;
+ int serverReads = 0;
if (handshakeBeforeSecure == true &&
(listenSecure == true || connectSecure == true)) {
Expect.fail("Invalid arguments to testSimpleReadWrite");
@@ -211,6 +214,14 @@ void testSimpleReadWrite(bool listenSecure,
subscription = client.listen((event) {
switch (event) {
case RawSocketEvent.READ:
+ if (dropReads) {
+ if (serverReads != 10) {
+ ++serverReads;
+ break;
+ } else {
+ serverReads = 0;
+ }
+ }
Expect.isTrue(bytesWritten == 0);
Expect.isTrue(client.available() > 0);
var buffer = client.read();
@@ -262,6 +273,14 @@ void testSimpleReadWrite(bool listenSecure,
switch (event) {
case RawSocketEvent.READ:
Expect.isTrue(socket.available() > 0);
+ if (dropReads) {
+ if (clientReads != 10) {
+ ++clientReads;
+ break;
+ } else {
+ clientReads = 0;
+ }
+ }
var buffer = socket.read();
if (buffer != null) {
dataReceived.setRange(bytesRead, bytesRead + buffer.length, buffer);
@@ -301,6 +320,14 @@ void testSimpleReadWrite(bool listenSecure,
Expect.isTrue(bytesWritten == 0);
}
Expect.isTrue(client.available() > 0);
+ if (dropReads) {
+ if (serverReads != 10) {
+ ++serverReads;
+ break;
+ } else {
+ serverReads = 0;
+ }
+ }
var buffer = client.read();
if (buffer != null) {
if (bytesRead == data.length) {
@@ -359,6 +386,14 @@ void testSimpleReadWrite(bool listenSecure,
subscription = socket.listen((event) {
switch (event) {
case RawSocketEvent.READ:
+ if (dropReads) {
+ if (clientReads != 10) {
+ ++clientReads;
+ break;
+ } else {
+ clientReads = 0;
+ }
+ }
Expect.isTrue(socket.available() > 0);
var buffer = socket.read();
if (buffer != null) {
@@ -418,7 +453,7 @@ void testSimpleReadWrite(bool listenSecure,
client,
CERTIFICATE,
subscription: secure[0],
- carryOverData: secure[1]).then((client) {
+ bufferedData: secure[1]).then((client) {
runServer(client).then((_) => server.close());
});
});
@@ -454,10 +489,44 @@ main() {
testSimpleConnectFail("not_a_nickname", true);
testSimpleConnectFail("CN=notARealDistinguishedName", true);
testServerListenAfterConnect();
- testSimpleReadWrite(true, true, false);
- testSimpleReadWrite(true, false, false);
- testSimpleReadWrite(false, true, false);
- testSimpleReadWrite(false, false, false);
- testSimpleReadWrite(false, false, true, true);
- testSimpleReadWrite(false, false, true, false);
+ testSimpleReadWrite(listenSecure: true,
+ connectSecure: true,
+ handshakeBeforeSecure: false,
+ postponeSecure: false,
+ dropReads: false);
+ testSimpleReadWrite(listenSecure: true,
+ connectSecure: false,
+ handshakeBeforeSecure: false,
+ postponeSecure: false,
+ dropReads: false);
+ testSimpleReadWrite(listenSecure: false,
+ connectSecure: true,
+ handshakeBeforeSecure: false,
+ postponeSecure: false,
+ dropReads: false);
+ testSimpleReadWrite(listenSecure: false,
+ connectSecure: false,
+ handshakeBeforeSecure: false,
+ postponeSecure: false,
+ dropReads: false);
+ testSimpleReadWrite(listenSecure: false,
+ connectSecure: false,
+ handshakeBeforeSecure: true,
+ postponeSecure: true,
+ dropReads: false);
+ testSimpleReadWrite(listenSecure: false,
+ connectSecure: false,
+ handshakeBeforeSecure: true,
+ postponeSecure: false,
+ dropReads: false);
+ testSimpleReadWrite(listenSecure: true,
+ connectSecure: true,
+ handshakeBeforeSecure: false,
+ postponeSecure: false,
+ dropReads: true);
+ testSimpleReadWrite(listenSecure: false,
+ connectSecure: false,
+ handshakeBeforeSecure: true,
+ postponeSecure: true,
+ dropReads: true);
}

Powered by Google App Engine
This is Rietveld 408576698