| 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/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/java_engine.dart'; | 8 import 'package:analyzer/src/generated/java_engine.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 AnalysisResult lastResult = new AnalysisResult(null, 1, '', 1); | 43 AnalysisResult lastResult = new AnalysisResult(null, 1, '', 1); |
| 44 context.when(callsTo("performAnalysisTask")) | 44 context.when(callsTo("performAnalysisTask")) |
| 45 ..thenReturn(firstResult, 3) | 45 ..thenReturn(firstResult, 3) |
| 46 ..thenReturn(lastResult); | 46 ..thenReturn(lastResult); |
| 47 helper.server.schedulePerformAnalysisOperation(context); | 47 helper.server.schedulePerformAnalysisOperation(context); |
| 48 // Pump the event queue to make sure the server has finished any | 48 // Pump the event queue to make sure the server has finished any |
| 49 // analysis. | 49 // analysis. |
| 50 return pumpEventQueue().then((_) { | 50 return pumpEventQueue().then((_) { |
| 51 List<Notification> notifications = helper.channel.notificationsReceived; | 51 List<Notification> notifications = helper.channel.notificationsReceived; |
| 52 expect(notifications, isNot(isEmpty)); | 52 expect(notifications, isNot(isEmpty)); |
| 53 // expect at least one notification indicating analysis is in progress |
| 54 expect(notifications.any((Notification notification) { |
| 55 if (notification.event == SERVER_STATUS) { |
| 56 Map analysisStatus = notification.params['analysis']; |
| 57 return analysisStatus['analyzing']; |
| 58 } |
| 59 return false; |
| 60 }), isTrue); |
| 61 // the last notification should indicate that analysis is complete |
| 53 Notification notification = notifications[notifications.length - 1]; | 62 Notification notification = notifications[notifications.length - 1]; |
| 54 Map analysisStatus = notification.params['analysis']; | 63 Map analysisStatus = notification.params['analysis']; |
| 55 expect(analysisStatus['analyzing'], isFalse); | 64 expect(analysisStatus['analyzing'], isFalse); |
| 56 }); | 65 }); |
| 57 }); | 66 }); |
| 58 | 67 |
| 59 test('echo', () { | 68 test('echo', () { |
| 60 AnalysisServerTestHelper helper = new AnalysisServerTestHelper(); | 69 AnalysisServerTestHelper helper = new AnalysisServerTestHelper(); |
| 61 helper.server.handlers = [new EchoHandler()]; | 70 helper.server.handlers = [new EchoHandler()]; |
| 62 var request = new Request('my22', 'echo'); | 71 var request = new Request('my22', 'echo'); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 @override | 118 @override |
| 110 Response handleRequest(Request request) { | 119 Response handleRequest(Request request) { |
| 111 if (request.method == 'echo') { | 120 if (request.method == 'echo') { |
| 112 var response = new Response(request.id); | 121 var response = new Response(request.id); |
| 113 response.setResult('echo', true); | 122 response.setResult('echo', true); |
| 114 return response; | 123 return response; |
| 115 } | 124 } |
| 116 return null; | 125 return null; |
| 117 } | 126 } |
| 118 } | 127 } |
| OLD | NEW |