| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.domain.diagnostic; | 5 library test.domain.diagnostic; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.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/domain_diagnostic.dart'; | 9 import 'package:analysis_server/src/domain_diagnostic.dart'; |
| 10 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 10 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 resourceProvider, | 35 resourceProvider, |
| 36 new MockPackageMapProvider(), | 36 new MockPackageMapProvider(), |
| 37 null, | 37 null, |
| 38 serverPlugin, | 38 serverPlugin, |
| 39 new AnalysisServerOptions(), | 39 new AnalysisServerOptions(), |
| 40 new MockSdk(), | 40 new MockSdk(), |
| 41 InstrumentationService.NULL_SERVICE); | 41 InstrumentationService.NULL_SERVICE); |
| 42 handler = new DiagnosticDomainHandler(server); | 42 handler = new DiagnosticDomainHandler(server); |
| 43 }); | 43 }); |
| 44 | 44 |
| 45 tearDown(() { |
| 46 handler.sampler?.stop(); |
| 47 }); |
| 48 |
| 45 group('DiagnosticDomainHandler', () { | 49 group('DiagnosticDomainHandler', () { |
| 46 test('getDiagnostics', () async { | 50 test('getDiagnostics', () async { |
| 47 String file = '/project/bin/test.dart'; | 51 String file = '/project/bin/test.dart'; |
| 48 resourceProvider.newFile('/project/pubspec.yaml', 'name: project'); | 52 resourceProvider.newFile('/project/pubspec.yaml', 'name: project'); |
| 49 resourceProvider.newFile(file, 'main() {}'); | 53 resourceProvider.newFile(file, 'main() {}'); |
| 50 | 54 |
| 51 server.setAnalysisRoots('0', ['/project/'], [], {}); | 55 server.setAnalysisRoots('0', ['/project/'], [], {}); |
| 52 | 56 |
| 53 await server.onAnalysisComplete; | 57 await server.onAnalysisComplete; |
| 54 | 58 |
| 55 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); | 59 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); |
| 56 var response = handler.handleRequest(request); | 60 var response = handler.handleRequest(request); |
| 57 | 61 |
| 58 int fileCount = MockSdk.LIBRARIES.length + 1 /* test.dart */; | 62 int fileCount = MockSdk.LIBRARIES.length + 1 /* test.dart */; |
| 59 | 63 |
| 60 var json = response.toJson()[Response.RESULT]; | 64 var json = response.toJson()[Response.RESULT]; |
| 61 expect(json['contexts'], hasLength(1)); | 65 expect(json['contexts'], hasLength(1)); |
| 62 var context = json['contexts'][0]; | 66 var context = json['contexts'][0]; |
| 63 expect(context['name'], '/project'); | 67 expect(context['name'], '/project'); |
| 64 expect(context['explicitFileCount'], fileCount); | 68 expect(context['explicitFileCount'], fileCount); |
| 65 expect(context['implicitFileCount'], 0); | 69 expect(context['implicitFileCount'], 0); |
| 66 expect(context['workItemQueueLength'], isNotNull); | 70 expect(context['workItemQueueLength'], isNotNull); |
| 71 expect(context['workItemQueueLengthAverage'], isNotNull); |
| 67 }); | 72 }); |
| 68 | 73 |
| 69 test('getDiagnostics - (no root)', () async { | 74 test('getDiagnostics - (no root)', () async { |
| 70 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); | 75 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); |
| 71 var response = handler.handleRequest(request); | 76 var response = handler.handleRequest(request); |
| 72 var json = response.toJson()[Response.RESULT]; | 77 var json = response.toJson()[Response.RESULT]; |
| 73 expect(json['contexts'], hasLength(0)); | 78 expect(json['contexts'], hasLength(0)); |
| 74 }); | 79 }); |
| 75 }); | 80 }); |
| 76 } | 81 } |
| OLD | NEW |