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