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

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

Issue 2960073002: Generate constants in server as we do in plugin (Closed)
Patch Set: improve names Created 3 years, 5 months 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
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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/protocol/protocol.dart'; 7 import 'package:analysis_server/protocol/protocol.dart';
8 import 'package:analysis_server/protocol/protocol_constants.dart';
8 import 'package:analysis_server/protocol/protocol_generated.dart'; 9 import 'package:analysis_server/protocol/protocol_generated.dart';
9 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart';
11 import 'package:analysis_server/src/domain_analysis.dart'; 11 import 'package:analysis_server/src/domain_analysis.dart';
12 import 'package:analysis_server/src/plugin/server_plugin.dart'; 12 import 'package:analysis_server/src/plugin/server_plugin.dart';
13 import 'package:analyzer/file_system/memory_file_system.dart'; 13 import 'package:analyzer/file_system/memory_file_system.dart';
14 import 'package:analyzer/instrumentation/instrumentation.dart'; 14 import 'package:analyzer/instrumentation/instrumentation.dart';
15 import 'package:analyzer/src/generated/engine.dart'; 15 import 'package:analyzer/src/generated/engine.dart';
16 import 'package:analyzer/src/generated/sdk.dart'; 16 import 'package:analyzer/src/generated/sdk.dart';
17 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 17 import 'package:analyzer_plugin/protocol/protocol_common.dart';
18 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; 18 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
19 import 'package:plugin/manager.dart'; 19 import 'package:plugin/manager.dart';
20 import 'package:plugin/plugin.dart'; 20 import 'package:plugin/plugin.dart';
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 222
223 setPriorityFiles(['/p1/a.dart', '/p2/b.dart']); 223 setPriorityFiles(['/p1/a.dart', '/p2/b.dart']);
224 setPriorityFiles(['/p2/b.dart', '/p2/c.dart']); 224 setPriorityFiles(['/p2/b.dart', '/p2/c.dart']);
225 setPriorityFiles([]); 225 setPriorityFiles([]);
226 }); 226 });
227 }); 227 });
228 228
229 group('updateOptions', () { 229 group('updateOptions', () {
230 test('invalid', () { 230 test('invalid', () {
231 var request = new Request('0', ANALYSIS_UPDATE_OPTIONS, { 231 var request = new Request('0', ANALYSIS_REQUEST_UPDATE_OPTIONS, {
232 OPTIONS: {'not-an-option': true} 232 ANALYSIS_REQUEST_UPDATE_OPTIONS_OPTIONS: {'not-an-option': true}
233 }); 233 });
234 var response = handler.handleRequest(request); 234 var response = handler.handleRequest(request);
235 // Invalid options should be silently ignored. 235 // Invalid options should be silently ignored.
236 expect(response, isResponseSuccess('0')); 236 expect(response, isResponseSuccess('0'));
237 }); 237 });
238 238
239 test('null', () { 239 test('null', () {
240 // null is allowed as a synonym for {}. 240 // null is allowed as a synonym for {}.
241 var request = 241 var request = new Request('0', ANALYSIS_REQUEST_UPDATE_OPTIONS,
242 new Request('0', ANALYSIS_UPDATE_OPTIONS, {OPTIONS: null}); 242 {ANALYSIS_REQUEST_UPDATE_OPTIONS_OPTIONS: null});
243 var response = handler.handleRequest(request); 243 var response = handler.handleRequest(request);
244 expect(response, isResponseSuccess('0')); 244 expect(response, isResponseSuccess('0'));
245 }); 245 });
246 }); 246 });
247 }); 247 });
248 } 248 }
249 249
250 testUpdateContent() { 250 testUpdateContent() {
251 test('bad type', () { 251 test('bad type', () {
252 AnalysisTestHelper helper = new AnalysisTestHelper(); 252 AnalysisTestHelper helper = new AnalysisTestHelper();
253 helper.createSingleFileProject('// empty'); 253 helper.createSingleFileProject('// empty');
254 return helper.onAnalysisComplete.then((_) { 254 return helper.onAnalysisComplete.then((_) {
255 Request request = new Request('0', ANALYSIS_UPDATE_CONTENT, { 255 Request request = new Request('0', ANALYSIS_REQUEST_UPDATE_CONTENT, {
256 'files': { 256 ANALYSIS_REQUEST_UPDATE_CONTENT_FILES: {
257 helper.testFile: { 257 helper.testFile: {
258 TYPE: 'foo', 258 'type': 'foo',
259 } 259 }
260 } 260 }
261 }); 261 });
262 Response response = helper.handler.handleRequest(request); 262 Response response = helper.handler.handleRequest(request);
263 expect(response, isResponseFailure('0')); 263 expect(response, isResponseFailure('0'));
264 }); 264 });
265 }); 265 });
266 266
267 test('full content', () { 267 test('full content', () {
268 AnalysisTestHelper helper = new AnalysisTestHelper(); 268 AnalysisTestHelper helper = new AnalysisTestHelper();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 return outOfRangeTest(new SourceEdit(6, 6, 'foo')); 375 return outOfRangeTest(new SourceEdit(6, 6, 'foo'));
376 }); 376 });
377 }); 377 });
378 } 378 }
379 379
380 @reflectiveTest 380 @reflectiveTest
381 class AnalysisDomainTest extends AbstractAnalysisTest { 381 class AnalysisDomainTest extends AbstractAnalysisTest {
382 Map<String, List<AnalysisError>> filesErrors = {}; 382 Map<String, List<AnalysisError>> filesErrors = {};
383 383
384 void processNotification(Notification notification) { 384 void processNotification(Notification notification) {
385 if (notification.event == ANALYSIS_ERRORS) { 385 if (notification.event == ANALYSIS_NOTIFICATION_ERRORS) {
386 var decoded = new AnalysisErrorsParams.fromNotification(notification); 386 var decoded = new AnalysisErrorsParams.fromNotification(notification);
387 filesErrors[decoded.file] = decoded.errors; 387 filesErrors[decoded.file] = decoded.errors;
388 } 388 }
389 } 389 }
390 390
391 test_setRoots_packages() { 391 test_setRoots_packages() {
392 // prepare package 392 // prepare package
393 String pkgFile = '/packages/pkgA/libA.dart'; 393 String pkgFile = '/packages/pkgA/libA.dart';
394 resourceProvider.newFile( 394 resourceProvider.newFile(
395 pkgFile, 395 pkgFile,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 null, 447 null,
448 serverPlugin, 448 serverPlugin,
449 new AnalysisServerOptions(), 449 new AnalysisServerOptions(),
450 new DartSdkManager('/', false), 450 new DartSdkManager('/', false),
451 InstrumentationService.NULL_SERVICE); 451 InstrumentationService.NULL_SERVICE);
452 handler = new AnalysisDomainHandler(server); 452 handler = new AnalysisDomainHandler(server);
453 // listen for notifications 453 // listen for notifications
454 Stream<Notification> notificationStream = 454 Stream<Notification> notificationStream =
455 serverChannel.notificationController.stream; 455 serverChannel.notificationController.stream;
456 notificationStream.listen((Notification notification) { 456 notificationStream.listen((Notification notification) {
457 if (notification.event == ANALYSIS_ERRORS) { 457 if (notification.event == ANALYSIS_NOTIFICATION_ERRORS) {
458 var decoded = new AnalysisErrorsParams.fromNotification(notification); 458 var decoded = new AnalysisErrorsParams.fromNotification(notification);
459 filesErrors[decoded.file] = decoded.errors; 459 filesErrors[decoded.file] = decoded.errors;
460 } 460 }
461 if (notification.event == ANALYSIS_HIGHLIGHTS) { 461 if (notification.event == ANALYSIS_NOTIFICATION_HIGHLIGHTS) {
462 var params = 462 var params =
463 new AnalysisHighlightsParams.fromNotification(notification); 463 new AnalysisHighlightsParams.fromNotification(notification);
464 filesHighlights[params.file] = params.regions; 464 filesHighlights[params.file] = params.regions;
465 } 465 }
466 if (notification.event == ANALYSIS_NAVIGATION) { 466 if (notification.event == ANALYSIS_NOTIFICATION_NAVIGATION) {
467 var params = 467 var params =
468 new AnalysisNavigationParams.fromNotification(notification); 468 new AnalysisNavigationParams.fromNotification(notification);
469 filesNavigation[params.file] = params.regions; 469 filesNavigation[params.file] = params.regions;
470 } 470 }
471 }); 471 });
472 } 472 }
473 473
474 /** 474 /**
475 * Returns a [Future] that completes when the server's analysis is complete. 475 * Returns a [Future] that completes when the server's analysis is complete.
476 */ 476 */
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 639 }
640 } 640 }
641 641
642 @reflectiveTest 642 @reflectiveTest
643 class SetSubscriptionsTest extends AbstractAnalysisTest { 643 class SetSubscriptionsTest extends AbstractAnalysisTest {
644 Map<String, List<HighlightRegion>> filesHighlights = {}; 644 Map<String, List<HighlightRegion>> filesHighlights = {};
645 645
646 Completer _resultsAvailable = new Completer(); 646 Completer _resultsAvailable = new Completer();
647 647
648 void processNotification(Notification notification) { 648 void processNotification(Notification notification) {
649 if (notification.event == ANALYSIS_HIGHLIGHTS) { 649 if (notification.event == ANALYSIS_NOTIFICATION_HIGHLIGHTS) {
650 var params = new AnalysisHighlightsParams.fromNotification(notification); 650 var params = new AnalysisHighlightsParams.fromNotification(notification);
651 filesHighlights[params.file] = params.regions; 651 filesHighlights[params.file] = params.regions;
652 _resultsAvailable.complete(null); 652 _resultsAvailable.complete(null);
653 } 653 }
654 } 654 }
655 655
656 test_afterAnalysis() async { 656 test_afterAnalysis() async {
657 addTestFile('int V = 42;'); 657 addTestFile('int V = 42;');
658 createProject(); 658 createProject();
659 // wait for analysis, no results initially 659 // wait for analysis, no results initially
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 plugin.AnalysisSetSubscriptionsParams params = 807 plugin.AnalysisSetSubscriptionsParams params =
808 pluginManager.analysisSetSubscriptionsParams; 808 pluginManager.analysisSetSubscriptionsParams;
809 expect(params, isNotNull); 809 expect(params, isNotNull);
810 Map<plugin.AnalysisService, List<String>> subscriptions = 810 Map<plugin.AnalysisService, List<String>> subscriptions =
811 params.subscriptions; 811 params.subscriptions;
812 expect(subscriptions, hasLength(1)); 812 expect(subscriptions, hasLength(1));
813 List<String> files = subscriptions[plugin.AnalysisService.HIGHLIGHTS]; 813 List<String> files = subscriptions[plugin.AnalysisService.HIGHLIGHTS];
814 expect(files, [testFile]); 814 expect(files, [testFile]);
815 } 815 }
816 } 816 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | pkg/analysis_server/test/domain_completion_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698