| Index: pkg/analysis_server/test/channel/web_socket_channel_test.dart
|
| diff --git a/pkg/analysis_server/test/channel/web_socket_channel_test.dart b/pkg/analysis_server/test/channel/web_socket_channel_test.dart
|
| index f88798df6e7ff3e8c393ada992622f4f78a256c4..b7b6391fdcc0e54b8621e8d96a5d7c3e92479a71 100644
|
| --- a/pkg/analysis_server/test/channel/web_socket_channel_test.dart
|
| +++ b/pkg/analysis_server/test/channel/web_socket_channel_test.dart
|
| @@ -20,8 +20,7 @@ main() {
|
| test('invalidJsonToClient', WebSocketChannelTest.invalidJsonToClient);
|
| test('invalidJsonToServer', WebSocketChannelTest.invalidJsonToServer);
|
| test('notification', WebSocketChannelTest.notification);
|
| - test(
|
| - 'notificationAndResponse',
|
| + test('notificationAndResponse',
|
| WebSocketChannelTest.notificationAndResponse);
|
| test('request', WebSocketChannelTest.request);
|
| test('requestResponse', WebSocketChannelTest.requestResponse);
|
| @@ -45,16 +44,17 @@ class WebSocketChannelTest {
|
| return future;
|
| }
|
|
|
| - static void expectMsgCount({requestCount: 0, responseCount: 0,
|
| - notificationCount: 0}) {
|
| + static void expectMsgCount(
|
| + {requestCount: 0, responseCount: 0, notificationCount: 0}) {
|
| expect(requestsReceived, hasLength(requestCount));
|
| expect(responsesReceived, hasLength(responseCount));
|
| expect(notificationsReceived, hasLength(notificationCount));
|
| }
|
|
|
| static Future invalidJsonToClient() {
|
| - var result = client.responseStream.first.timeout(
|
| - new Duration(seconds: 1)).then((Response response) {
|
| + var result = client.responseStream.first
|
| + .timeout(new Duration(seconds: 1))
|
| + .then((Response response) {
|
| expect(response.id, equals('myId'));
|
| expectMsgCount(responseCount: 1);
|
| });
|
| @@ -64,8 +64,9 @@ class WebSocketChannelTest {
|
| }
|
|
|
| static Future invalidJsonToServer() {
|
| - var result = client.responseStream.first.timeout(
|
| - new Duration(seconds: 1)).then((Response response) {
|
| + var result = client.responseStream.first
|
| + .timeout(new Duration(seconds: 1))
|
| + .then((Response response) {
|
| expect(response.id, equals(''));
|
| expect(response.error, isNotNull);
|
| expectMsgCount(responseCount: 1);
|
| @@ -75,8 +76,9 @@ class WebSocketChannelTest {
|
| }
|
|
|
| static Future notification() {
|
| - var result = client.notificationStream.first.timeout(
|
| - new Duration(seconds: 1)).then((Notification notification) {
|
| + var result = client.notificationStream.first
|
| + .timeout(new Duration(seconds: 1))
|
| + .then((Notification notification) {
|
| expect(notification.event, equals('myEvent'));
|
| expectMsgCount(notificationCount: 1);
|
| expect(notificationsReceived.first, equals(notification));
|
| @@ -86,16 +88,13 @@ class WebSocketChannelTest {
|
| }
|
|
|
| static Future notificationAndResponse() {
|
| - var result = Future.wait(
|
| - [
|
| - client.notificationStream.first,
|
| - client.responseStream.first]).timeout(
|
| - new Duration(
|
| - seconds: 1)).then(
|
| - (_) => expectMsgCount(responseCount: 1, notificationCount: 1));
|
| + var result = Future
|
| + .wait([client.notificationStream.first, client.responseStream.first])
|
| + .timeout(new Duration(seconds: 1))
|
| + .then((_) => expectMsgCount(responseCount: 1, notificationCount: 1));
|
| server
|
| - ..sendNotification(new Notification('myEvent'))
|
| - ..sendResponse(new Response('myId'));
|
| + ..sendNotification(new Notification('myEvent'))
|
| + ..sendResponse(new Response('myId'));
|
| return result;
|
| }
|
|
|
| @@ -112,10 +111,10 @@ class WebSocketChannelTest {
|
| // Simulate server sending a response by echoing the request.
|
| server.listen(
|
| (Request request) => server.sendResponse(new Response(request.id)));
|
| - return client.sendRequest(
|
| - new Request(
|
| - 'myId',
|
| - 'myMth')).timeout(new Duration(seconds: 1)).then((Response response) {
|
| + return client
|
| + .sendRequest(new Request('myId', 'myMth'))
|
| + .timeout(new Duration(seconds: 1))
|
| + .then((Response response) {
|
| expect(response.id, equals('myId'));
|
| expectMsgCount(requestCount: 1, responseCount: 1);
|
|
|
| @@ -129,8 +128,8 @@ class WebSocketChannelTest {
|
|
|
| static Future response() {
|
| server.sendResponse(new Response('myId'));
|
| - return client.responseStream.first.timeout(
|
| - new Duration(seconds: 1)).then((Response response) {
|
| + return client.responseStream.first.timeout(new Duration(seconds: 1)).then(
|
| + (Response response) {
|
| expect(response.id, equals('myId'));
|
| expectMsgCount(responseCount: 1);
|
| });
|
| @@ -139,8 +138,8 @@ class WebSocketChannelTest {
|
| static void setUp() {
|
| socket = new MockSocket.pair();
|
| client = new WebSocketClientChannel(socket);
|
| - server =
|
| - new WebSocketServerChannel(socket.twin, InstrumentationService.NULL_SERVICE);
|
| + server = new WebSocketServerChannel(
|
| + socket.twin, InstrumentationService.NULL_SERVICE);
|
|
|
| requestsReceived = [];
|
| responsesReceived = [];
|
|
|