| 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 test.channel.web_socket; | 5 library test.channel.web_socket; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/channel/web_socket_channel.dart'; | 10 import 'package:analysis_server/src/channel/web_socket_channel.dart'; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 test('requestResponse', WebSocketChannelTest.requestResponse); | 28 test('requestResponse', WebSocketChannelTest.requestResponse); |
| 29 test('response', WebSocketChannelTest.response); | 29 test('response', WebSocketChannelTest.response); |
| 30 }); | 30 }); |
| 31 } | 31 } |
| 32 | 32 |
| 33 class WebSocketChannelTest { | 33 class WebSocketChannelTest { |
| 34 static MockSocket socket; | 34 static MockSocket socket; |
| 35 static WebSocketClientChannel client; | 35 static WebSocketClientChannel client; |
| 36 static WebSocketServerChannel server; | 36 static WebSocketServerChannel server; |
| 37 | 37 |
| 38 static List requestsReceived; | 38 static List<Request> requestsReceived; |
| 39 static List responsesReceived; | 39 static List<Response> responsesReceived; |
| 40 static List notificationsReceived; | 40 static List<Notification> notificationsReceived; |
| 41 | 41 |
| 42 static Future close() { | 42 static Future close() { |
| 43 var timeout = new Duration(seconds: 1); | 43 var timeout = new Duration(seconds: 1); |
| 44 var future = client.responseStream.drain().timeout(timeout); | 44 var future = client.responseStream.drain().timeout(timeout); |
| 45 client.close(); | 45 client.close(); |
| 46 return future; | 46 return future; |
| 47 } | 47 } |
| 48 | 48 |
| 49 static void expectMsgCount( | 49 static void expectMsgCount( |
| 50 {requestCount: 0, responseCount: 0, notificationCount: 0}) { | 50 {requestCount: 0, responseCount: 0, notificationCount: 0}) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 expectMsgCount(responseCount: 1); | 137 expectMsgCount(responseCount: 1); |
| 138 }); | 138 }); |
| 139 } | 139 } |
| 140 | 140 |
| 141 static void setUp() { | 141 static void setUp() { |
| 142 socket = new MockSocket.pair(); | 142 socket = new MockSocket.pair(); |
| 143 client = new WebSocketClientChannel(socket); | 143 client = new WebSocketClientChannel(socket); |
| 144 server = new WebSocketServerChannel( | 144 server = new WebSocketServerChannel( |
| 145 socket.twin, InstrumentationService.NULL_SERVICE); | 145 socket.twin, InstrumentationService.NULL_SERVICE); |
| 146 | 146 |
| 147 requestsReceived = []; | 147 requestsReceived = <Request>[]; |
| 148 responsesReceived = []; | 148 responsesReceived = <Response>[]; |
| 149 notificationsReceived = []; | 149 notificationsReceived = <Notification>[]; |
| 150 | 150 |
| 151 // Allow multiple listeners on server side for testing. | 151 // Allow multiple listeners on server side for testing. |
| 152 socket.twin.allowMultipleListeners(); | 152 socket.twin.allowMultipleListeners(); |
| 153 | 153 |
| 154 server.listen(requestsReceived.add); | 154 server.listen(requestsReceived.add); |
| 155 client.responseStream.listen(responsesReceived.add); | 155 client.responseStream.listen(responsesReceived.add); |
| 156 client.notificationStream.listen(notificationsReceived.add); | 156 client.notificationStream.listen(notificationsReceived.add); |
| 157 } | 157 } |
| 158 } | 158 } |
| OLD | NEW |