| 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.socket.server; | 5 library test.socket.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'mocks.dart'; | 9 import 'mocks.dart'; |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 }); | 23 }); |
| 24 } | 24 } |
| 25 | 25 |
| 26 class SocketServerTest { | 26 class SocketServerTest { |
| 27 static Future createAnalysisServer_successful() { | 27 static Future createAnalysisServer_successful() { |
| 28 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); | 28 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); |
| 29 MockServerChannel channel = new MockServerChannel(); | 29 MockServerChannel channel = new MockServerChannel(); |
| 30 server.createAnalysisServer(channel); | 30 server.createAnalysisServer(channel); |
| 31 channel.expectMsgCount(notificationCount: 1); | 31 channel.expectMsgCount(notificationCount: 1); |
| 32 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); | 32 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); |
| 33 expect(channel.notificationsReceived[0].params, isNull); | |
| 34 return channel.sendRequest( | 33 return channel.sendRequest( |
| 35 new Request('0', SERVER_SHUTDOWN) | 34 new ServerShutdownParams().toRequest('0') |
| 36 ).then((Response response) { | 35 ).then((Response response) { |
| 37 expect(response.id, equals('0')); | 36 expect(response.id, equals('0')); |
| 38 expect(response.error, isNull); | 37 expect(response.error, isNull); |
| 39 channel.expectMsgCount(responseCount: 1, notificationCount: 1); | 38 channel.expectMsgCount(responseCount: 1, notificationCount: 1); |
| 40 }); | 39 }); |
| 41 } | 40 } |
| 42 | 41 |
| 43 static void createAnalysisServer_alreadyStarted() { | 42 static void createAnalysisServer_alreadyStarted() { |
| 44 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); | 43 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); |
| 45 MockServerChannel channel1 = new MockServerChannel(); | 44 MockServerChannel channel1 = new MockServerChannel(); |
| 46 MockServerChannel channel2 = new MockServerChannel(); | 45 MockServerChannel channel2 = new MockServerChannel(); |
| 47 server.createAnalysisServer(channel1); | 46 server.createAnalysisServer(channel1); |
| 48 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED); | 47 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED); |
| 49 expect(channel1.notificationsReceived[0].params, isNull); | |
| 50 server.createAnalysisServer(channel2); | 48 server.createAnalysisServer(channel2); |
| 51 channel1.expectMsgCount(notificationCount: 1); | 49 channel1.expectMsgCount(notificationCount: 1); |
| 52 channel2.expectMsgCount(responseCount: 1); | 50 channel2.expectMsgCount(responseCount: 1); |
| 53 expect(channel2.responsesReceived[0].id, equals('')); | 51 expect(channel2.responsesReceived[0].id, equals('')); |
| 54 expect(channel2.responsesReceived[0].error, isNotNull); | 52 expect(channel2.responsesReceived[0].error, isNotNull); |
| 55 expect(channel2.responsesReceived[0].error.code, equals( | 53 expect(channel2.responsesReceived[0].error.code, equals( |
| 56 RequestError.CODE_SERVER_ALREADY_STARTED)); | 54 RequestError.CODE_SERVER_ALREADY_STARTED)); |
| 57 channel2.sendRequest(new Request('0', SERVER_SHUTDOWN)).then((Response respo
nse) { | 55 channel2.sendRequest(new ServerShutdownParams().toRequest('0')).then( |
| 56 (Response response) { |
| 58 expect(response.id, equals('0')); | 57 expect(response.id, equals('0')); |
| 59 expect(response.error, isNotNull); | 58 expect(response.error, isNotNull); |
| 60 expect(response.error.code, equals( | 59 expect(response.error.code, equals( |
| 61 RequestError.CODE_SERVER_ALREADY_STARTED)); | 60 RequestError.CODE_SERVER_ALREADY_STARTED)); |
| 62 channel2.expectMsgCount(responseCount: 2); | 61 channel2.expectMsgCount(responseCount: 2); |
| 63 }); | 62 }); |
| 64 } | 63 } |
| 65 } | 64 } |
| OLD | NEW |