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

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

Issue 2286923002: Convert analysis server over to use ContextBuilder (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: address comment, fix bugs, clean-up Created 4 years, 3 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 library test.domain.analysis; 5 library test.domain.analysis;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
(...skipping 23 matching lines...) Expand all
34 MemoryResourceProvider resourceProvider; 34 MemoryResourceProvider resourceProvider;
35 AnalysisServer server; 35 AnalysisServer server;
36 AnalysisDomainHandler handler; 36 AnalysisDomainHandler handler;
37 37
38 setUp(() { 38 setUp(() {
39 serverChannel = new MockServerChannel(); 39 serverChannel = new MockServerChannel();
40 resourceProvider = new MemoryResourceProvider(); 40 resourceProvider = new MemoryResourceProvider();
41 ExtensionManager manager = new ExtensionManager(); 41 ExtensionManager manager = new ExtensionManager();
42 ServerPlugin serverPlugin = new ServerPlugin(); 42 ServerPlugin serverPlugin = new ServerPlugin();
43 manager.processPlugins([serverPlugin]); 43 manager.processPlugins([serverPlugin]);
44 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
44 server = new AnalysisServer( 45 server = new AnalysisServer(
45 serverChannel, 46 serverChannel,
46 resourceProvider, 47 resourceProvider,
47 new MockPackageMapProvider(), 48 new MockPackageMapProvider(),
48 null, 49 null,
49 serverPlugin, 50 serverPlugin,
50 new AnalysisServerOptions(), 51 new AnalysisServerOptions(),
51 new DartSdkManager('', false, (_) => new MockSdk()), 52 new DartSdkManager('/', false, (_) => sdk),
52 InstrumentationService.NULL_SERVICE); 53 InstrumentationService.NULL_SERVICE);
53 handler = new AnalysisDomainHandler(server); 54 handler = new AnalysisDomainHandler(server);
54 }); 55 });
55 56
56 group('updateContent', testUpdateContent); 57 group('updateContent', testUpdateContent);
57 58
58 group('AnalysisDomainHandler', () { 59 group('AnalysisDomainHandler', () {
59 group('getReachableSources', () { 60 group('getReachableSources', () {
60 test('valid sources', () async { 61 test('valid sources', () async {
61 String fileA = '/project/a.dart'; 62 String fileA = '/project/a.dart';
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 }); 244 });
244 } 245 }
245 246
246 testUpdateContent() { 247 testUpdateContent() {
247 test('bad type', () { 248 test('bad type', () {
248 AnalysisTestHelper helper = new AnalysisTestHelper(); 249 AnalysisTestHelper helper = new AnalysisTestHelper();
249 helper.createSingleFileProject('// empty'); 250 helper.createSingleFileProject('// empty');
250 return helper.onAnalysisComplete.then((_) { 251 return helper.onAnalysisComplete.then((_) {
251 Request request = new Request('0', ANALYSIS_UPDATE_CONTENT, { 252 Request request = new Request('0', ANALYSIS_UPDATE_CONTENT, {
252 'files': { 253 'files': {
253 helper.testFile: {TYPE: 'foo',} 254 helper.testFile: {
255 TYPE: 'foo',
256 }
254 } 257 }
255 }); 258 });
256 Response response = helper.handler.handleRequest(request); 259 Response response = helper.handler.handleRequest(request);
257 expect(response, isResponseFailure('0')); 260 expect(response, isResponseFailure('0'));
258 }); 261 });
259 }); 262 });
260 263
261 test('full content', () { 264 test('full content', () {
262 AnalysisTestHelper helper = new AnalysisTestHelper(); 265 AnalysisTestHelper helper = new AnalysisTestHelper();
263 helper.createSingleFileProject('// empty'); 266 helper.createSingleFileProject('// empty');
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 421
419 test_setRoots_packages() { 422 test_setRoots_packages() {
420 // prepare package 423 // prepare package
421 String pkgFile = '/packages/pkgA/libA.dart'; 424 String pkgFile = '/packages/pkgA/libA.dart';
422 resourceProvider.newFile( 425 resourceProvider.newFile(
423 pkgFile, 426 pkgFile,
424 ''' 427 '''
425 library lib_a; 428 library lib_a;
426 class A {} 429 class A {}
427 '''); 430 ''');
428 packageMapProvider.packageMap['pkgA'] = [ 431 resourceProvider.newFile(
429 resourceProvider.getResource('/packages/pkgA') 432 '/project/.packages', 'pkgA:file:///packages/pkgA');
430 ];
431 addTestFile(''' 433 addTestFile('''
432 import 'package:pkgA/libA.dart'; 434 import 'package:pkgA/libA.dart';
433 main(A a) { 435 main(A a) {
434 } 436 }
435 '''); 437 ''');
436 // create project and wait for analysis 438 // create project and wait for analysis
437 createProject(); 439 createProject();
438 return waitForTasksFinished().then((_) { 440 return waitForTasksFinished().then((_) {
439 // if 'package:pkgA/libA.dart' was resolved, then there are no errors 441 // if 'package:pkgA/libA.dart' was resolved, then there are no errors
440 expect(filesErrors[testFile], isEmpty); 442 expect(filesErrors[testFile], isEmpty);
(...skipping 20 matching lines...) Expand all
461 463
462 String testFile = '/project/bin/test.dart'; 464 String testFile = '/project/bin/test.dart';
463 String testCode; 465 String testCode;
464 466
465 AnalysisTestHelper() { 467 AnalysisTestHelper() {
466 serverChannel = new MockServerChannel(); 468 serverChannel = new MockServerChannel();
467 resourceProvider = new MemoryResourceProvider(); 469 resourceProvider = new MemoryResourceProvider();
468 ExtensionManager manager = new ExtensionManager(); 470 ExtensionManager manager = new ExtensionManager();
469 ServerPlugin serverPlugin = new ServerPlugin(); 471 ServerPlugin serverPlugin = new ServerPlugin();
470 manager.processPlugins([serverPlugin]); 472 manager.processPlugins([serverPlugin]);
473 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
471 server = new AnalysisServer( 474 server = new AnalysisServer(
472 serverChannel, 475 serverChannel,
473 resourceProvider, 476 resourceProvider,
474 new MockPackageMapProvider(), 477 new MockPackageMapProvider(),
475 null, 478 null,
476 serverPlugin, 479 serverPlugin,
477 new AnalysisServerOptions(), 480 new AnalysisServerOptions(),
478 new DartSdkManager('', false, (_) => new MockSdk()), 481 new DartSdkManager('/', false, (_) => sdk),
479 InstrumentationService.NULL_SERVICE); 482 InstrumentationService.NULL_SERVICE);
480 handler = new AnalysisDomainHandler(server); 483 handler = new AnalysisDomainHandler(server);
481 // listen for notifications 484 // listen for notifications
482 Stream<Notification> notificationStream = 485 Stream<Notification> notificationStream =
483 serverChannel.notificationController.stream; 486 serverChannel.notificationController.stream;
484 notificationStream.listen((Notification notification) { 487 notificationStream.listen((Notification notification) {
485 if (notification.event == ANALYSIS_ERRORS) { 488 if (notification.event == ANALYSIS_ERRORS) {
486 var decoded = new AnalysisErrorsParams.fromNotification(notification); 489 var decoded = new AnalysisErrorsParams.fromNotification(notification);
487 filesErrors[decoded.file] = decoded.errors; 490 filesErrors[decoded.file] = decoded.errors;
488 } 491 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 700 }
698 701
699 test_afterAnalysis_packageFile_external() async { 702 test_afterAnalysis_packageFile_external() async {
700 String pkgFile = '/packages/pkgA/lib/libA.dart'; 703 String pkgFile = '/packages/pkgA/lib/libA.dart';
701 resourceProvider.newFile( 704 resourceProvider.newFile(
702 pkgFile, 705 pkgFile,
703 ''' 706 '''
704 library lib_a; 707 library lib_a;
705 class A {} 708 class A {}
706 '''); 709 ''');
707 packageMapProvider.packageMap = { 710 resourceProvider.newFile(
708 'pkgA': [(resourceProvider.newFolder('/packages/pkgA/lib'))] 711 '/project/.packages', 'pkgA:file:///packages/pkgA/lib');
709 };
710 // 712 //
711 addTestFile(''' 713 addTestFile('''
712 import 'package:pkgA/libA.dart'; 714 import 'package:pkgA/libA.dart';
713 main() { 715 main() {
714 new A(); 716 new A();
715 } 717 }
716 '''); 718 ''');
717 createProject(); 719 createProject();
718 // wait for analysis, no results initially 720 // wait for analysis, no results initially
719 await waitForTasksFinished(); 721 await waitForTasksFinished();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 769 }
768 770
769 test_afterAnalysis_packageFile_notUsed() async { 771 test_afterAnalysis_packageFile_notUsed() async {
770 String pkgFile = '/packages/pkgA/lib/libA.dart'; 772 String pkgFile = '/packages/pkgA/lib/libA.dart';
771 resourceProvider.newFile( 773 resourceProvider.newFile(
772 pkgFile, 774 pkgFile,
773 ''' 775 '''
774 library lib_a; 776 library lib_a;
775 class A {} 777 class A {}
776 '''); 778 ''');
777 packageMapProvider.packageMap = { 779 resourceProvider.newFile('/project/.packages', 'pkgA:/packages/pkgA/lib');
778 'pkgA': [(resourceProvider.newFolder('/packages/pkgA/lib'))]
779 };
780 // 780 //
781 addTestFile('// no "pkgA" reference'); 781 addTestFile('// no "pkgA" reference');
782 createProject(); 782 createProject();
783 // wait for analysis, no results initially 783 // wait for analysis, no results initially
784 await waitForTasksFinished(); 784 await waitForTasksFinished();
785 expect(filesHighlights[pkgFile], isNull); 785 expect(filesHighlights[pkgFile], isNull);
786 // make it a priority file, so make analyzable 786 // make it a priority file, so make analyzable
787 server.setPriorityFiles('0', [pkgFile]); 787 server.setPriorityFiles('0', [pkgFile]);
788 // subscribe 788 // subscribe
789 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, pkgFile); 789 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, pkgFile);
(...skipping 19 matching lines...) Expand all
809 test_beforeAnalysis() async { 809 test_beforeAnalysis() async {
810 addTestFile('int V = 42;'); 810 addTestFile('int V = 42;');
811 createProject(); 811 createProject();
812 // subscribe 812 // subscribe
813 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); 813 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile);
814 // wait for analysis 814 // wait for analysis
815 await waitForTasksFinished(); 815 await waitForTasksFinished();
816 expect(filesHighlights[testFile], isNotEmpty); 816 expect(filesHighlights[testFile], isNotEmpty);
817 } 817 }
818 } 818 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/context_manager_test.dart ('k') | pkg/analysis_server/test/domain_diagnostic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698