Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: pkg/analysis_server/test/domain_experimental_test.dart

Issue 1416093007: Experimental `getDiagnostics` request (#24480). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Review fixes. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.domain.experimental;
6
7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/analysis_server.dart';
9 import 'package:analysis_server/src/domain_experimental.dart';
10 import 'package:analysis_server/src/plugin/server_plugin.dart';
11 import 'package:analyzer/file_system/memory_file_system.dart';
12 import 'package:analyzer/instrumentation/instrumentation.dart';
13 import 'package:plugin/manager.dart';
14 import 'package:unittest/unittest.dart';
15
16 import 'mock_sdk.dart';
17 import 'mocks.dart';
18 import 'utils.dart';
19
20 main() {
21 AnalysisServer server;
22 ExperimentalDomainHandler handler;
23 MemoryResourceProvider resourceProvider;
24
25 initializeTestEnvironment();
26
27 setUp(() {
28 var serverChannel = new MockServerChannel();
29 resourceProvider = new MemoryResourceProvider();
30 ExtensionManager manager = new ExtensionManager();
31 ServerPlugin serverPlugin = new ServerPlugin();
32 manager.processPlugins([serverPlugin]);
33 server = new AnalysisServer(
34 serverChannel,
35 resourceProvider,
36 new MockPackageMapProvider(),
37 null,
38 serverPlugin,
39 new AnalysisServerOptions(),
40 new MockSdk(),
41 InstrumentationService.NULL_SERVICE);
42 handler = new ExperimentalDomainHandler(server);
43 });
44
45 group('ExperimentalDomainHandler', () {
46 test('getDiagnostics', () async {
47 String file = '/project/bin/test.dart';
48 resourceProvider.newFile('/project/pubspec.yaml', 'name: project');
49 resourceProvider.newFile(file, 'main() {}');
50
51 server.setAnalysisRoots('0', ['/project/'], [], {});
52
53 await server.onAnalysisComplete;
54
55 var request = new ExperimentalGetDiagnosticsParams().toRequest('0');
56 var response = handler.handleRequest(request);
57
58 int fileCount = MockSdk.LIBRARIES.length + 1 /* test.dart */;
59
60 var json = response.toJson()[Response.RESULT];
61 expect(json['contexts'], hasLength(1));
62 var context = json['contexts'][0];
63 expect(context['name'], '/project');
64 expect(context['explicitFileCount'], fileCount);
65 expect(context['implicitFileCount'], 0);
66 expect(context['workItemQueueLength'], isNotNull);
67 });
68
69 test('getDiagnostics - (no root)', () async {
70 var request = new ExperimentalGetDiagnosticsParams().toRequest('0');
71 var response = handler.handleRequest(request);
72 var json = response.toJson()[Response.RESULT];
73 expect(json['contexts'], hasLength(0));
74 });
75 });
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698