| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // LineInfo lineInfo = new LineInfo([0]); | 75 // LineInfo lineInfo = new LineInfo([0]); |
| 76 // AnalysisError analysisError = new AnalysisError.con1(source, | 76 // AnalysisError analysisError = new AnalysisError.con1(source, |
| 77 // CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER, ['Foo']); | 77 // CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER, ['Foo']); |
| 78 // changeNoticeImpl.setErrors([analysisError], lineInfo); | 78 // changeNoticeImpl.setErrors([analysisError], lineInfo); |
| 79 // context.when(callsTo('performAnalysisTask')).thenReturn( | 79 // context.when(callsTo('performAnalysisTask')).thenReturn( |
| 80 // new AnalysisResult([changeNoticeImpl], 0, 'myClass', 0)); | 80 // new AnalysisResult([changeNoticeImpl], 0, 'myClass', 0)); |
| 81 // context.when(callsTo('performAnalysisTask')).thenReturn( | 81 // context.when(callsTo('performAnalysisTask')).thenReturn( |
| 82 // new AnalysisResult(null, 0, null, 0)); | 82 // new AnalysisResult(null, 0, null, 0)); |
| 83 // return pumpEventQueue().then((_) { | 83 // return pumpEventQueue().then((_) { |
| 84 // context.getLogs(callsTo('performAnalysisTask')).verify(happenedExactly(2
)); | 84 // context.getLogs(callsTo('performAnalysisTask')).verify(happenedExactly(2
)); |
| 85 // var notifications = channel.notificationsReceived; | 85 // List<Notification> notifications = channel.notificationsReceived; |
| 86 // expect(notifications, hasLength(2)); | 86 // expect(notifications, hasLength(4)); |
| 87 // |
| 87 // expect(notifications[0].event, equals('server.connected')); | 88 // expect(notifications[0].event, equals('server.connected')); |
| 88 // expect(notifications[1].event, equals('context.errors')); | 89 // |
| 89 // expect(notifications[1].params['source'], equals('foo.dart')); | 90 // assertStatusNotification(notifications[1], true); |
| 90 // expect(notifications[1].params['contextId'], equals('context-27')); | 91 // |
| 91 // List<AnalysisError> errors = notifications[1].params['errors']; | 92 // expect(notifications[2].event, equals('context.errors')); |
| 93 // expect(notifications[2].params['source'], equals('foo.dart')); |
| 94 // expect(notifications[2].params['contextId'], equals('context-27')); |
| 95 // List<AnalysisError> errors = notifications[2].params['errors']; |
| 92 // expect(errors, hasLength(1)); | 96 // expect(errors, hasLength(1)); |
| 93 // expect(errors[0], equals(AnalysisServer.errorToJson(analysisError))); | 97 // expect(errors[0], equals(AnalysisServer.errorToJson(analysisError))); |
| 98 // |
| 99 // assertStatusNotification(notifications[3], false); |
| 94 // }); | 100 // }); |
| 95 // } | 101 // } |
| 102 // |
| 103 // static void assertStatusNotification(Notification notification, bool expectA
nalyzing) { |
| 104 // expect(notification.event, equals('server.status')); |
| 105 // Map<String, Object> analysis = notification.params['analysis']; |
| 106 // expect(analysis['analyzing'], expectAnalyzing); |
| 107 // expect(analysis.containsKey('analysisTarget'), expectAnalyzing); |
| 108 // if (expectAnalyzing) { |
| 109 // var analysisTarget = analysis['analysisTarget']; |
| 110 // expect((analysisTarget is String), isTrue); |
| 111 // expect(analysisTarget.length > 0, isTrue); |
| 112 // } |
| 113 // } |
| 96 | 114 |
| 97 static Future addContextToWorkQueue_twice() { | 115 static Future addContextToWorkQueue_twice() { |
| 98 // TODO(scheglov) remove after implementing "setAnalysisRoots" API | 116 // TODO(scheglov) remove after implementing "setAnalysisRoots" API |
| 99 return new Future.value(); | 117 return new Future.value(); |
| 100 // // The context should only be asked to perform its analysis task once. | 118 // // The context should only be asked to perform its analysis task once. |
| 101 // MockAnalysisContext context = new MockAnalysisContext(); | 119 // MockAnalysisContext context = new MockAnalysisContext(); |
| 102 // server.addContextToWorkQueue(context); | 120 // server.addContextToWorkQueue(context); |
| 103 // server.addContextToWorkQueue(context); | 121 // server.addContextToWorkQueue(context); |
| 104 // context.when(callsTo('performAnalysisTask')).thenReturn( | 122 // context.when(callsTo('performAnalysisTask')).thenReturn( |
| 105 // new AnalysisResult(null, 0, null, 0)); | 123 // new AnalysisResult(null, 0, null, 0)); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 @override | 229 @override |
| 212 Response handleRequest(Request request) { | 230 Response handleRequest(Request request) { |
| 213 if (request.method == 'echo') { | 231 if (request.method == 'echo') { |
| 214 var response = new Response(request.id); | 232 var response = new Response(request.id); |
| 215 response.setResult('echo', true); | 233 response.setResult('echo', true); |
| 216 return response; | 234 return response; |
| 217 } | 235 } |
| 218 return null; | 236 return null; |
| 219 } | 237 } |
| 220 } | 238 } |
| OLD | NEW |