| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library http_parser.web_socket_test; | 5 library http_parser.web_socket_test; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:http_parser/http_parser.dart'; | 9 import 'package:http_parser/http_parser.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 var n = 0; | 36 var n = 0; |
| 37 return webSocket.listen((message) { | 37 return webSocket.listen((message) { |
| 38 if (n == 0) { | 38 if (n == 0) { |
| 39 expect(message, equals("hello!")); | 39 expect(message, equals("hello!")); |
| 40 webSocket.add("ping"); | 40 webSocket.add("ping"); |
| 41 } else if (n == 1) { | 41 } else if (n == 1) { |
| 42 expect(message, equals("pong")); | 42 expect(message, equals("pong")); |
| 43 webSocket.close(); | 43 webSocket.close(); |
| 44 server.close(); | 44 server.close(); |
| 45 } else { | 45 } else { |
| 46 expect(false, reason: "Only expected two messages."); | 46 fail("Only expected two messages."); |
| 47 } | 47 } |
| 48 n++; | 48 n++; |
| 49 }).asFuture(); | 49 }).asFuture(); |
| 50 }); | 50 }); |
| 51 }); | 51 }); |
| 52 }); | 52 }); |
| 53 | 53 |
| 54 test("a server can communicate with a WebSocket client", () { | 54 test("a server can communicate with a WebSocket client", () { |
| 55 return HttpServer.bind("localhost", 0).then((server) { | 55 return HttpServer.bind("localhost", 0).then((server) { |
| 56 server.listen((request) { | 56 server.listen((request) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 78 var n = 0; | 78 var n = 0; |
| 79 return webSocket.listen((message) { | 79 return webSocket.listen((message) { |
| 80 if (n == 0) { | 80 if (n == 0) { |
| 81 expect(message, equals("hello!")); | 81 expect(message, equals("hello!")); |
| 82 webSocket.add("ping"); | 82 webSocket.add("ping"); |
| 83 } else if (n == 1) { | 83 } else if (n == 1) { |
| 84 expect(message, equals("pong")); | 84 expect(message, equals("pong")); |
| 85 webSocket.close(); | 85 webSocket.close(); |
| 86 server.close(); | 86 server.close(); |
| 87 } else { | 87 } else { |
| 88 expect(false, reason: "Only expected two messages."); | 88 fail("Only expected two messages."); |
| 89 } | 89 } |
| 90 n++; | 90 n++; |
| 91 }).asFuture(); | 91 }).asFuture(); |
| 92 }); | 92 }); |
| 93 }); | 93 }); |
| 94 }); | 94 }); |
| 95 } | 95 } |
| OLD | NEW |