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

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

Issue 14864009: Keep track of when a socket has been destroyed (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove delete_handle marker. Created 7 years, 5 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
« no previous file with comments | « sdk/lib/io/socket.dart ('k') | tests/standalone/io/raw_socket_typed_data_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1b1b23f5e2f65a1c11c1e84344b8f153d7dfe86f..a61bccfe9114e3abb91be6f70854df8b43ae41bd 100644
--- a/tests/standalone/io/raw_socket_test.dart
+++ b/tests/standalone/io/raw_socket_test.dart
@@ -150,6 +150,7 @@ void testSimpleReadWrite({bool dropReads}) {
server.listen((client) {
int bytesRead = 0;
int bytesWritten = 0;
+ bool closedEventReceived = false;
List<int> data = new List<int>(messageSize);
client.writeEventsEnabled = false;
@@ -188,14 +189,20 @@ void testSimpleReadWrite({bool dropReads}) {
case RawSocketEvent.READ_CLOSED:
server.close();
break;
+ case RawSocketEvent.CLOSED:
+ Expect.isFalse(closedEventReceived);
+ closedEventReceived = true;
+ break;
default: throw "Unexpected event $event";
}
- });
+ },
+ onDone: () => Expect.isTrue(closedEventReceived));
});
RawSocket.connect("127.0.0.1", server.port).then((socket) {
int bytesRead = 0;
int bytesWritten = 0;
+ bool closedEventReceived = false;
List<int> data = createTestData();
socket.listen((event) {
@@ -229,10 +236,17 @@ void testSimpleReadWrite({bool dropReads}) {
verifyTestData(data);
socket.close();
break;
+ case RawSocketEvent.CLOSED:
+ Expect.isFalse(closedEventReceived);
+ closedEventReceived = true;
+ break;
default: throw "Unexpected event $event";
}
},
- onDone: () => port.close());
+ onDone: () {
+ Expect.isTrue(closedEventReceived);
+ port.close();
+ });
});
});
}
@@ -288,6 +302,7 @@ void testPauseSocket() {
RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) {
Expect.isTrue(server.port > 0);
server.listen((client) {
+ bool closedEventReceived = false;
List<int> data = new List<int>.filled(messageSize, 0);
writeSubscription = client.listen((event) {
switch (event) {
@@ -312,12 +327,18 @@ void testPauseSocket() {
client.close();
server.close();
break;
+ case RawSocketEvent.CLOSED:
+ Expect.isFalse(closedEventReceived);
+ closedEventReceived = true;
+ break;
default: throw "Unexpected event $event";
}
- });
+ },
+ onDone: () => Expect.isTrue(closedEventReceived));
});
RawSocket.connect("127.0.0.1", server.port).then((socket) {
+ bool closedEventReceived = false;
socket.writeEventsEnabled = false;
readSubscription = socket.listen((event) {
switch (event) {
@@ -343,10 +364,15 @@ void testPauseSocket() {
case RawSocketEvent.WRITE:
throw "Unexpected write event";
case RawSocketEvent.READ_CLOSED:
- throw "Unexpected close event";
+ throw "Unexpected read closed event";
+ case RawSocketEvent.CLOSED:
+ Expect.isFalse(closedEventReceived);
+ closedEventReceived = true;
+ break;
default: throw "Unexpected event $event";
}
- });
+ },
+ onDone: () => Expect.isTrue(closedEventReceived));
readSubscription.pause();
connected.complete(true);
});
« no previous file with comments | « sdk/lib/io/socket.dart ('k') | tests/standalone/io/raw_socket_typed_data_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698