| 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.analysis_server; | 5 library test.analysis_server; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/physical_file_system.dart'; | 7 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 8 import 'package:analysis_server/src/analysis_server.dart'; | 8 import 'package:analysis_server/src/analysis_server.dart'; |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/domain_server.dart'; | 10 import 'package:analysis_server/src/domain_server.dart'; |
| 11 import 'package:analysis_server/src/operation/operation.dart'; | 11 import 'package:analysis_server/src/operation/operation.dart'; |
| 12 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
| 13 import 'package:analysis_server/src/protocol2.dart'; | |
| 14 import 'package:analysis_testing/mock_sdk.dart'; | 13 import 'package:analysis_testing/mock_sdk.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/java_engine.dart'; | 15 import 'package:analyzer/src/generated/java_engine.dart'; |
| 17 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 18 import 'package:mock/mock.dart'; | 17 import 'package:mock/mock.dart'; |
| 19 import 'package:unittest/unittest.dart'; | 18 import 'package:unittest/unittest.dart'; |
| 20 | 19 |
| 21 import 'mocks.dart'; | 20 import 'mocks.dart'; |
| 22 | 21 |
| 23 main() { | 22 main() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 helper.server.serverServices.add(ServerService.STATUS); | 37 helper.server.serverServices.add(ServerService.STATUS); |
| 39 helper.server.schedulePerformAnalysisOperation(context); | 38 helper.server.schedulePerformAnalysisOperation(context); |
| 40 // Pump the event queue to make sure the server has finished any | 39 // Pump the event queue to make sure the server has finished any |
| 41 // analysis. | 40 // analysis. |
| 42 return pumpEventQueue().then((_) { | 41 return pumpEventQueue().then((_) { |
| 43 List<Notification> notifications = helper.channel.notificationsReceived; | 42 List<Notification> notifications = helper.channel.notificationsReceived; |
| 44 expect(notifications, isNot(isEmpty)); | 43 expect(notifications, isNot(isEmpty)); |
| 45 // expect at least one notification indicating analysis is in progress | 44 // expect at least one notification indicating analysis is in progress |
| 46 expect(notifications.any((Notification notification) { | 45 expect(notifications.any((Notification notification) { |
| 47 if (notification.event == SERVER_STATUS) { | 46 if (notification.event == SERVER_STATUS) { |
| 48 Map analysisStatus = notification.params['analysis']; | 47 var params = new ServerStatusParams.fromNotification(notification); |
| 49 return analysisStatus['analyzing']; | 48 return params.analysis.analyzing; |
| 50 } | 49 } |
| 51 return false; | 50 return false; |
| 52 }), isTrue); | 51 }), isTrue); |
| 53 // the last notification should indicate that analysis is complete | 52 // the last notification should indicate that analysis is complete |
| 54 Notification notification = notifications[notifications.length - 1]; | 53 Notification notification = notifications[notifications.length - 1]; |
| 55 Map analysisStatus = notification.params['analysis']; | 54 var params = new ServerStatusParams.fromNotification(notification); |
| 56 expect(analysisStatus['analyzing'], isFalse); | 55 expect(params.analysis.analyzing, isFalse); |
| 57 }); | 56 }); |
| 58 }); | 57 }); |
| 59 | 58 |
| 60 test('echo', () { | 59 test('echo', () { |
| 61 AnalysisServerTestHelper helper = new AnalysisServerTestHelper(); | 60 AnalysisServerTestHelper helper = new AnalysisServerTestHelper(); |
| 62 helper.server.handlers = [new EchoHandler()]; | 61 helper.server.handlers = [new EchoHandler()]; |
| 63 var request = new Request('my22', 'echo'); | 62 var request = new Request('my22', 'echo'); |
| 64 return helper.channel.sendRequest(request) | 63 return helper.channel.sendRequest(request) |
| 65 .then((Response response) { | 64 .then((Response response) { |
| 66 expect(response.id, equals('my22')); | 65 expect(response.id, equals('my22')); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 119 |
| 121 class EchoHandler implements RequestHandler { | 120 class EchoHandler implements RequestHandler { |
| 122 @override | 121 @override |
| 123 Response handleRequest(Request request) { | 122 Response handleRequest(Request request) { |
| 124 if (request.method == 'echo') { | 123 if (request.method == 'echo') { |
| 125 return new Response(request.id, result: {'echo': true}); | 124 return new Response(request.id, result: {'echo': true}); |
| 126 } | 125 } |
| 127 return null; | 126 return null; |
| 128 } | 127 } |
| 129 } | 128 } |
| OLD | NEW |