| 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 28 matching lines...) Expand all Loading... |
| 39 resourceProvider, | 39 resourceProvider, |
| 40 new MockPackageMapProvider(), | 40 new MockPackageMapProvider(), |
| 41 null, | 41 null, |
| 42 serverPlugin, | 42 serverPlugin, |
| 43 new AnalysisServerOptions(), | 43 new AnalysisServerOptions(), |
| 44 new MockSdk(), | 44 new MockSdk(), |
| 45 InstrumentationService.NULL_SERVICE); | 45 InstrumentationService.NULL_SERVICE); |
| 46 handler = new DiagnosticDomainHandler(server); | 46 handler = new DiagnosticDomainHandler(server); |
| 47 }); | 47 }); |
| 48 | 48 |
| 49 tearDown(() { |
| 50 handler.sampler?.stop(); |
| 51 }); |
| 52 |
| 49 group('DiagnosticDomainHandler', () { | 53 group('DiagnosticDomainHandler', () { |
| 50 test('getDiagnostics', () async { | 54 test('getDiagnostics', () async { |
| 51 String file = '/project/bin/test.dart'; | 55 String file = '/project/bin/test.dart'; |
| 52 resourceProvider.newFile('/project/pubspec.yaml', 'name: project'); | 56 resourceProvider.newFile('/project/pubspec.yaml', 'name: project'); |
| 53 resourceProvider.newFile(file, 'main() {}'); | 57 resourceProvider.newFile(file, 'main() {}'); |
| 54 | 58 |
| 55 server.setAnalysisRoots('0', ['/project/'], [], {}); | 59 server.setAnalysisRoots('0', ['/project/'], [], {}); |
| 56 | 60 |
| 57 await server.onAnalysisComplete; | 61 await server.onAnalysisComplete; |
| 58 | 62 |
| 59 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); | 63 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); |
| 60 var response = handler.handleRequest(request); | 64 var response = handler.handleRequest(request); |
| 61 | 65 |
| 62 int fileCount = MockSdk.LIBRARIES.length + 1 /* test.dart */; | 66 int fileCount = MockSdk.LIBRARIES.length + 1 /* test.dart */; |
| 63 | 67 |
| 64 var json = response.toJson()[Response.RESULT]; | 68 var json = response.toJson()[Response.RESULT]; |
| 65 expect(json['contexts'], hasLength(1)); | 69 expect(json['contexts'], hasLength(1)); |
| 66 var context = json['contexts'][0]; | 70 var context = json['contexts'][0]; |
| 67 expect(context['name'], '/project'); | 71 expect(context['name'], '/project'); |
| 68 expect(context['explicitFileCount'], fileCount); | 72 expect(context['explicitFileCount'], fileCount); |
| 69 expect(context['implicitFileCount'], 0); | 73 expect(context['implicitFileCount'], 0); |
| 70 expect(context['workItemQueueLength'], isNotNull); | 74 expect(context['workItemQueueLength'], isNotNull); |
| 75 expect(context['workItemQueueLengthAverage'], isNotNull); |
| 71 }); | 76 }); |
| 72 | 77 |
| 73 test('getDiagnostics - (no root)', () async { | 78 test('getDiagnostics - (no root)', () async { |
| 74 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); | 79 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); |
| 75 var response = handler.handleRequest(request); | 80 var response = handler.handleRequest(request); |
| 76 var json = response.toJson()[Response.RESULT]; | 81 var json = response.toJson()[Response.RESULT]; |
| 77 expect(json['contexts'], hasLength(0)); | 82 expect(json['contexts'], hasLength(0)); |
| 78 }); | 83 }); |
| 79 }); | 84 }); |
| 80 } | 85 } |
| OLD | NEW |