OLD | NEW |
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.analysis_server; | 5 library test.analysis_server; |
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 Loading... |
34 main() { | 34 main() { |
35 initializeTestEnvironment(); | 35 initializeTestEnvironment(); |
36 defineReflectiveTests(AnalysisServerTest); | 36 defineReflectiveTests(AnalysisServerTest); |
37 } | 37 } |
38 | 38 |
39 @reflectiveTest | 39 @reflectiveTest |
40 class AnalysisServerTest { | 40 class AnalysisServerTest { |
41 MockServerChannel channel; | 41 MockServerChannel channel; |
42 AnalysisServer server; | 42 AnalysisServer server; |
43 MemoryResourceProvider resourceProvider; | 43 MemoryResourceProvider resourceProvider; |
44 MockPackageMapProvider packageMapProvider; | |
45 | 44 |
46 /** | 45 /** |
47 * Verify that getAnalysisContextForSource returns the correct contexts even | 46 * Verify that getAnalysisContextForSource returns the correct contexts even |
48 * for sources that are included by multiple contexts. | 47 * for sources that are included by multiple contexts. |
49 * | 48 * |
50 * See dartbug.com/21898 | 49 * See dartbug.com/21898 |
51 */ | 50 */ |
52 Future fail_getAnalysisContextForSource_crossImports() { | 51 Future fail_getAnalysisContextForSource_crossImports() { |
53 // Subscribe to STATUS so we'll know when analysis is done. | 52 // Subscribe to STATUS so we'll know when analysis is done. |
54 server.serverServices = [ServerService.STATUS].toSet(); | 53 server.serverServices = [ServerService.STATUS].toSet(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 manager.processPlugins(plugins); | 130 manager.processPlugins(plugins); |
132 } | 131 } |
133 | 132 |
134 void setUp() { | 133 void setUp() { |
135 ExtensionManager manager = new ExtensionManager(); | 134 ExtensionManager manager = new ExtensionManager(); |
136 ServerPlugin plugin = new ServerPlugin(); | 135 ServerPlugin plugin = new ServerPlugin(); |
137 manager.processPlugins([plugin]); | 136 manager.processPlugins([plugin]); |
138 channel = new MockServerChannel(); | 137 channel = new MockServerChannel(); |
139 resourceProvider = new MemoryResourceProvider(); | 138 resourceProvider = new MemoryResourceProvider(); |
140 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider); | 139 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider); |
141 packageMapProvider = new MockPackageMapProvider(); | |
142 server = new AnalysisServer( | 140 server = new AnalysisServer( |
143 channel, | 141 channel, |
144 resourceProvider, | 142 resourceProvider, |
145 packageMapProvider, | |
146 null, | 143 null, |
147 plugin, | 144 plugin, |
148 new AnalysisServerOptions(), | 145 new AnalysisServerOptions(), |
149 new DartSdkManager('/', false, (_) => sdk), | 146 new DartSdkManager('/', false, (_) => sdk), |
150 InstrumentationService.NULL_SERVICE, | 147 InstrumentationService.NULL_SERVICE, |
151 rethrowExceptions: true); | 148 rethrowExceptions: true); |
152 processRequiredPlugins(); | 149 processRequiredPlugins(); |
153 } | 150 } |
154 | 151 |
155 Future test_contextDisposed() { | 152 Future test_contextDisposed() { |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 Folder expectedFolder = resourceProvider.newFolder(expectedFolderPath); | 531 Folder expectedFolder = resourceProvider.newFolder(expectedFolderPath); |
535 ContextInfo expectedContextInfo = | 532 ContextInfo expectedContextInfo = |
536 (server.contextManager as ContextManagerImpl) | 533 (server.contextManager as ContextManagerImpl) |
537 .getContextInfoFor(expectedFolder); | 534 .getContextInfoFor(expectedFolder); |
538 expect(expectedContextInfo, isNotNull); | 535 expect(expectedContextInfo, isNotNull); |
539 expect(context, same(expectedContextInfo.context)); | 536 expect(context, same(expectedContextInfo.context)); |
540 } | 537 } |
541 | 538 |
542 void _configureSourceFactory(AnalysisContext context) { | 539 void _configureSourceFactory(AnalysisContext context) { |
543 var resourceUriResolver = new ResourceUriResolver(resourceProvider); | 540 var resourceUriResolver = new ResourceUriResolver(resourceProvider); |
544 var packageUriResolver = new PackageMapUriResolver( | 541 var packageUriResolver = |
545 resourceProvider, packageMapProvider.packageMap); | 542 new PackageMapUriResolver(resourceProvider, <String, List<Folder>>{}); |
546 context.sourceFactory = | 543 context.sourceFactory = |
547 new SourceFactory([packageUriResolver, resourceUriResolver]); | 544 new SourceFactory([packageUriResolver, resourceUriResolver]); |
548 } | 545 } |
549 } | 546 } |
550 | 547 |
551 class EchoHandler implements RequestHandler { | 548 class EchoHandler implements RequestHandler { |
552 @override | 549 @override |
553 Response handleRequest(Request request) { | 550 Response handleRequest(Request request) { |
554 if (request.method == 'echo') { | 551 if (request.method == 'echo') { |
555 return new Response(request.id, result: {'echo': true}); | 552 return new Response(request.id, result: {'echo': true}); |
(...skipping 13 matching lines...) Expand all Loading... |
569 _MockServerOperation(this.context); | 566 _MockServerOperation(this.context); |
570 | 567 |
571 @override | 568 @override |
572 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS; | 569 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS; |
573 | 570 |
574 @override | 571 @override |
575 void perform(AnalysisServer server) { | 572 void perform(AnalysisServer server) { |
576 isComplete = true; | 573 isComplete = true; |
577 } | 574 } |
578 } | 575 } |
OLD | NEW |