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

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

Issue 517513002: Bugfix in dart:io's WebSocketTransformer implementation, correctly test async behaviour of websocke… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | « dart/sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/standalone/io/web_socket_test.dart
diff --git a/dart/tests/standalone/io/web_socket_test.dart b/dart/tests/standalone/io/web_socket_test.dart
index 564f412131a7d09f09a1dea790d8cc8b43610c48..b04e02f35d4fac5f9d1046a0cae3d22361831874 100644
--- a/dart/tests/standalone/io/web_socket_test.dart
+++ b/dart/tests/standalone/io/web_socket_test.dart
@@ -43,9 +43,14 @@ class SecurityConfiguration {
void testRequestResponseClientCloses(int totalConnections,
int closeStatus,
- String closeReason) {
+ String closeReason,
+ int numberOfMessages) {
+ assert (numberOfMessages >= 1);
+
+ asyncStart();
createServer().then((server) {
server.transform(new WebSocketTransformer()).listen((webSocket) {
+ asyncStart();
webSocket.listen(
webSocket.add,
onDone: () {
@@ -55,20 +60,24 @@ class SecurityConfiguration {
Expect.equals(
closeReason == null ? ""
: closeReason, webSocket.closeReason);
+ asyncEnd();
});
+ }, onDone: () {
+ asyncEnd();
});
int closeCount = 0;
String messageText = "Hello, world!";
for (int i = 0; i < totalConnections; i++) {
- int messageCount = 0;
+ asyncStart();
createClient(server.port).then((webSocket) {
webSocket.add(messageText);
webSocket.listen(
(message) {
- messageCount++;
- if (messageCount < 1 ) {
- Expect.equals(messageText, message);
+ numberOfMessages--;
+ Expect.equals(messageText, message);
+
+ if (numberOfMessages > 0) {
webSocket.add(message);
} else {
webSocket.close(closeStatus, closeReason);
@@ -83,6 +92,7 @@ class SecurityConfiguration {
if (closeCount == totalConnections) {
server.close();
}
+ asyncEnd();
});
});
}
@@ -423,9 +433,9 @@ class SecurityConfiguration {
}
void runTests() {
- testRequestResponseClientCloses(2, null, null);
- testRequestResponseClientCloses(2, 3001, null);
- testRequestResponseClientCloses(2, 3002, "Got tired");
+ testRequestResponseClientCloses(2, null, null, 1);
+ testRequestResponseClientCloses(2, 3001, null, 2);
+ testRequestResponseClientCloses(2, 3002, "Got tired", 3);
testRequestResponseServerCloses(2, null, null);
testRequestResponseServerCloses(2, 3001, null);
testRequestResponseServerCloses(2, 3002, "Got tired");
@@ -455,9 +465,7 @@ void initializeSSL() {
main() {
- asyncStart();
new SecurityConfiguration(secure: false).runTests();
initializeSSL();
new SecurityConfiguration(secure: true).runTests();
- asyncEnd();
}
« no previous file with comments | « dart/sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698