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

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

Issue 341893010: Use "pub list-package-dirs" to resolve package URIs in analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
(...skipping 14 matching lines...) Expand all
25 runReflectiveTests(AnalysisDomainTest); 25 runReflectiveTests(AnalysisDomainTest);
26 26
27 MockServerChannel serverChannel; 27 MockServerChannel serverChannel;
28 MemoryResourceProvider resourceProvider; 28 MemoryResourceProvider resourceProvider;
29 AnalysisServer server; 29 AnalysisServer server;
30 AnalysisDomainHandler handler; 30 AnalysisDomainHandler handler;
31 31
32 setUp(() { 32 setUp(() {
33 serverChannel = new MockServerChannel(); 33 serverChannel = new MockServerChannel();
34 resourceProvider = new MemoryResourceProvider(); 34 resourceProvider = new MemoryResourceProvider();
35 server = new AnalysisServer(serverChannel, resourceProvider); 35 server = new AnalysisServer(
36 serverChannel, resourceProvider, new MockPackageMapProvider());
36 server.defaultSdk = new MockSdk(); 37 server.defaultSdk = new MockSdk();
37 handler = new AnalysisDomainHandler(server); 38 handler = new AnalysisDomainHandler(server);
38 }); 39 });
39 40
40 group('notification.errors', testNotificationErrors); 41 group('notification.errors', testNotificationErrors);
41 group('updateContent', testUpdateContent); 42 group('updateContent', testUpdateContent);
42 group('setSubscriptions', test_setSubscriptions); 43 group('setSubscriptions', test_setSubscriptions);
43 44
44 group('AnalysisDomainHandler', () { 45 group('AnalysisDomainHandler', () {
45 group('setAnalysisRoots', () { 46 group('setAnalysisRoots', () {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 Map<String, List<AnalysisError>> filesErrors = {}; 203 Map<String, List<AnalysisError>> filesErrors = {};
203 Map<String, List<Map<String, Object>>> filesHighlights = {}; 204 Map<String, List<Map<String, Object>>> filesHighlights = {};
204 Map<String, List<Map<String, Object>>> filesNavigation = {}; 205 Map<String, List<Map<String, Object>>> filesNavigation = {};
205 206
206 String testFile = '/project/bin/test.dart'; 207 String testFile = '/project/bin/test.dart';
207 String testCode; 208 String testCode;
208 209
209 AnalysisTestHelper() { 210 AnalysisTestHelper() {
210 serverChannel = new MockServerChannel(); 211 serverChannel = new MockServerChannel();
211 resourceProvider = new MemoryResourceProvider(); 212 resourceProvider = new MemoryResourceProvider();
212 server = new AnalysisServer(serverChannel, resourceProvider); 213 server = new AnalysisServer(
214 serverChannel, resourceProvider, new MockPackageMapProvider());
213 server.defaultSdk = new MockSdk(); 215 server.defaultSdk = new MockSdk();
214 handler = new AnalysisDomainHandler(server); 216 handler = new AnalysisDomainHandler(server);
215 // listen for notifications 217 // listen for notifications
216 Stream<Notification> notificationStream = serverChannel.notificationControll er.stream; 218 Stream<Notification> notificationStream = serverChannel.notificationControll er.stream;
217 notificationStream.listen((Notification notification) { 219 notificationStream.listen((Notification notification) {
218 if (notification.event == ANALYSIS_ERRORS) { 220 if (notification.event == ANALYSIS_ERRORS) {
219 String file = notification.getParameter(FILE); 221 String file = notification.getParameter(FILE);
220 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS); 222 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS);
221 filesErrors[file] = errorMaps.map(jsonToAnalysisError).toList(); 223 filesErrors[file] = errorMaps.map(jsonToAnalysisError).toList();
222 } 224 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 564
563 void processNotification(Notification notification) { 565 void processNotification(Notification notification) {
564 if (notification.event == ANALYSIS_ERRORS) { 566 if (notification.event == ANALYSIS_ERRORS) {
565 String file = notification.getParameter(FILE); 567 String file = notification.getParameter(FILE);
566 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS); 568 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS);
567 filesErrors[file] = errorMaps.map(jsonToAnalysisError).toList(); 569 filesErrors[file] = errorMaps.map(jsonToAnalysisError).toList();
568 } 570 }
569 } 571 }
570 572
571 test_setRoots_packages() { 573 test_setRoots_packages() {
572 // prepare project with 'packages' folder 574 // prepare package
573 String pkgFile = '/project/packages/pkgA/libA.dart'; 575 String pkgFile = '/packages/pkgA/libA.dart';
574 resourceProvider.newFile(pkgFile, ''' 576 resourceProvider.newFile(pkgFile, '''
575 library lib_a; 577 library lib_a;
576 class A {} 578 class A {}
577 '''); 579 ''');
580 packageMapProvider.packageMap['pkgA'] =
581 resourceProvider.getResource('/packages/pkgA');
578 addTestFile(''' 582 addTestFile('''
579 import 'package:pkgA/libA.dart'; 583 import 'package:pkgA/libA.dart';
580 main(A a) { 584 main(A a) {
581 } 585 }
582 '''); 586 ''');
583 // create project and wait for analysis 587 // create project and wait for analysis
584 createProject(); 588 createProject();
585 return waitForTasksFinished().then((_) { 589 return waitForTasksFinished().then((_) {
586 // if 'package:pkgA/libA.dart' was resolved, then there are no errors 590 // if 'package:pkgA/libA.dart' was resolved, then there are no errors
587 expect(filesErrors[testFile], isEmpty); 591 expect(filesErrors[testFile], isEmpty);
588 // packages file also was resolved 592 // packages file also was resolved
589 expect(filesErrors[pkgFile], isEmpty); 593 expect(filesErrors[pkgFile], isEmpty);
590 }); 594 });
591 } 595 }
592 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698