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

Unified Diff: tests/standalone/io/raw_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_socket_test.dart
diff --git a/tests/standalone/io/raw_socket_test.dart b/tests/standalone/io/raw_socket_test.dart
index 381c0ed2a134911c939223256601e5e114aa91a7..a6bc078d9ceac9674df832a5454cad02f1bc6dae 100644
--- a/tests/standalone/io/raw_socket_test.dart
+++ b/tests/standalone/io/raw_socket_test.dart
@@ -128,7 +128,7 @@ void testServerListenAfterConnect() {
});
}
-void testSimpleReadWrite() {
+void testSimpleReadWrite({bool dropReads}) {
// This test creates a server and a client connects. The client then
// writes and the server echos. When the server has finished its
// echo it half-closes. When the client gets the close event is
@@ -136,6 +136,8 @@ void testSimpleReadWrite() {
ReceivePort port = new ReceivePort();
const messageSize = 1000;
+ int serverReadCount = 0;
+ int clientReadCount = 0;
List<int> createTestData() {
return new List<int>.generate(messageSize, (index) => index & 0xff);
@@ -159,9 +161,17 @@ void testSimpleReadWrite() {
client.listen((event) {
switch (event) {
case RawSocketEvent.READ:
+ if (dropReads) {
+ if (serverReadCount != 10) {
+ serverReadCount++;
+ break;
+ } else {
+ serverReadCount = 0;
+ }
+ }
Expect.isTrue(bytesWritten == 0);
Expect.isTrue(client.available() > 0);
- var buffer = client.read();
+ var buffer = client.read(200);
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
if (bytesRead == data.length) {
@@ -197,6 +207,14 @@ void testSimpleReadWrite() {
switch (event) {
case RawSocketEvent.READ:
Expect.isTrue(socket.available() > 0);
+ if (dropReads) {
+ if (clientReadCount != 10) {
+ clientReadCount++;
+ break;
+ } else {
+ clientReadCount = 0;
+ }
+ }
var buffer = socket.read();
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
@@ -348,7 +366,8 @@ main() {
testInvalidBind();
testSimpleConnect();
testServerListenAfterConnect();
- testSimpleReadWrite();
+ testSimpleReadWrite(dropReads: false);
+ testSimpleReadWrite(dropReads: true);
testPauseServerSocket();
testPauseSocket();
}

Powered by Google App Engine
This is Rietveld 408576698